mutation.go 675 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945
  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/agentbase"
  11. "wechat-api/ent/batchmsg"
  12. "wechat-api/ent/category"
  13. "wechat-api/ent/contact"
  14. "wechat-api/ent/custom_types"
  15. "wechat-api/ent/employee"
  16. "wechat-api/ent/employeeconfig"
  17. "wechat-api/ent/label"
  18. "wechat-api/ent/labelrelationship"
  19. "wechat-api/ent/message"
  20. "wechat-api/ent/messagerecords"
  21. "wechat-api/ent/msg"
  22. "wechat-api/ent/predicate"
  23. "wechat-api/ent/server"
  24. "wechat-api/ent/sopnode"
  25. "wechat-api/ent/sopstage"
  26. "wechat-api/ent/soptask"
  27. "wechat-api/ent/token"
  28. "wechat-api/ent/tutorial"
  29. "wechat-api/ent/workexperience"
  30. "wechat-api/ent/wx"
  31. "entgo.io/ent"
  32. "entgo.io/ent/dialect/sql"
  33. )
  34. const (
  35. // Operation types.
  36. OpCreate = ent.OpCreate
  37. OpDelete = ent.OpDelete
  38. OpDeleteOne = ent.OpDeleteOne
  39. OpUpdate = ent.OpUpdate
  40. OpUpdateOne = ent.OpUpdateOne
  41. // Node types.
  42. TypeAgent = "Agent"
  43. TypeAgentBase = "AgentBase"
  44. TypeBatchMsg = "BatchMsg"
  45. TypeCategory = "Category"
  46. TypeContact = "Contact"
  47. TypeEmployee = "Employee"
  48. TypeEmployeeConfig = "EmployeeConfig"
  49. TypeLabel = "Label"
  50. TypeLabelRelationship = "LabelRelationship"
  51. TypeMessage = "Message"
  52. TypeMessageRecords = "MessageRecords"
  53. TypeMsg = "Msg"
  54. TypeServer = "Server"
  55. TypeSopNode = "SopNode"
  56. TypeSopStage = "SopStage"
  57. TypeSopTask = "SopTask"
  58. TypeToken = "Token"
  59. TypeTutorial = "Tutorial"
  60. TypeWorkExperience = "WorkExperience"
  61. TypeWx = "Wx"
  62. )
  63. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  64. type AgentMutation struct {
  65. config
  66. op Op
  67. typ string
  68. id *uint64
  69. created_at *time.Time
  70. updated_at *time.Time
  71. deleted_at *time.Time
  72. name *string
  73. role *string
  74. status *int
  75. addstatus *int
  76. background *string
  77. examples *string
  78. organization_id *uint64
  79. addorganization_id *int64
  80. dataset_id *string
  81. collection_id *string
  82. clearedFields map[string]struct{}
  83. wx_agent map[uint64]struct{}
  84. removedwx_agent map[uint64]struct{}
  85. clearedwx_agent bool
  86. done bool
  87. oldValue func(context.Context) (*Agent, error)
  88. predicates []predicate.Agent
  89. }
  90. var _ ent.Mutation = (*AgentMutation)(nil)
  91. // agentOption allows management of the mutation configuration using functional options.
  92. type agentOption func(*AgentMutation)
  93. // newAgentMutation creates new mutation for the Agent entity.
  94. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  95. m := &AgentMutation{
  96. config: c,
  97. op: op,
  98. typ: TypeAgent,
  99. clearedFields: make(map[string]struct{}),
  100. }
  101. for _, opt := range opts {
  102. opt(m)
  103. }
  104. return m
  105. }
  106. // withAgentID sets the ID field of the mutation.
  107. func withAgentID(id uint64) agentOption {
  108. return func(m *AgentMutation) {
  109. var (
  110. err error
  111. once sync.Once
  112. value *Agent
  113. )
  114. m.oldValue = func(ctx context.Context) (*Agent, error) {
  115. once.Do(func() {
  116. if m.done {
  117. err = errors.New("querying old values post mutation is not allowed")
  118. } else {
  119. value, err = m.Client().Agent.Get(ctx, id)
  120. }
  121. })
  122. return value, err
  123. }
  124. m.id = &id
  125. }
  126. }
  127. // withAgent sets the old Agent of the mutation.
  128. func withAgent(node *Agent) agentOption {
  129. return func(m *AgentMutation) {
  130. m.oldValue = func(context.Context) (*Agent, error) {
  131. return node, nil
  132. }
  133. m.id = &node.ID
  134. }
  135. }
  136. // Client returns a new `ent.Client` from the mutation. If the mutation was
  137. // executed in a transaction (ent.Tx), a transactional client is returned.
  138. func (m AgentMutation) Client() *Client {
  139. client := &Client{config: m.config}
  140. client.init()
  141. return client
  142. }
  143. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  144. // it returns an error otherwise.
  145. func (m AgentMutation) Tx() (*Tx, error) {
  146. if _, ok := m.driver.(*txDriver); !ok {
  147. return nil, errors.New("ent: mutation is not running in a transaction")
  148. }
  149. tx := &Tx{config: m.config}
  150. tx.init()
  151. return tx, nil
  152. }
  153. // SetID sets the value of the id field. Note that this
  154. // operation is only accepted on creation of Agent entities.
  155. func (m *AgentMutation) SetID(id uint64) {
  156. m.id = &id
  157. }
  158. // ID returns the ID value in the mutation. Note that the ID is only available
  159. // if it was provided to the builder or after it was returned from the database.
  160. func (m *AgentMutation) ID() (id uint64, exists bool) {
  161. if m.id == nil {
  162. return
  163. }
  164. return *m.id, true
  165. }
  166. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  167. // That means, if the mutation is applied within a transaction with an isolation level such
  168. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  169. // or updated by the mutation.
  170. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  171. switch {
  172. case m.op.Is(OpUpdateOne | OpDeleteOne):
  173. id, exists := m.ID()
  174. if exists {
  175. return []uint64{id}, nil
  176. }
  177. fallthrough
  178. case m.op.Is(OpUpdate | OpDelete):
  179. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  180. default:
  181. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  182. }
  183. }
  184. // SetCreatedAt sets the "created_at" field.
  185. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  186. m.created_at = &t
  187. }
  188. // CreatedAt returns the value of the "created_at" field in the mutation.
  189. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  190. v := m.created_at
  191. if v == nil {
  192. return
  193. }
  194. return *v, true
  195. }
  196. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  197. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  199. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  200. if !m.op.Is(OpUpdateOne) {
  201. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  202. }
  203. if m.id == nil || m.oldValue == nil {
  204. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  205. }
  206. oldValue, err := m.oldValue(ctx)
  207. if err != nil {
  208. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  209. }
  210. return oldValue.CreatedAt, nil
  211. }
  212. // ResetCreatedAt resets all changes to the "created_at" field.
  213. func (m *AgentMutation) ResetCreatedAt() {
  214. m.created_at = nil
  215. }
  216. // SetUpdatedAt sets the "updated_at" field.
  217. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  218. m.updated_at = &t
  219. }
  220. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  221. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  222. v := m.updated_at
  223. if v == nil {
  224. return
  225. }
  226. return *v, true
  227. }
  228. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  229. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  231. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  232. if !m.op.Is(OpUpdateOne) {
  233. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  234. }
  235. if m.id == nil || m.oldValue == nil {
  236. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  237. }
  238. oldValue, err := m.oldValue(ctx)
  239. if err != nil {
  240. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  241. }
  242. return oldValue.UpdatedAt, nil
  243. }
  244. // ResetUpdatedAt resets all changes to the "updated_at" field.
  245. func (m *AgentMutation) ResetUpdatedAt() {
  246. m.updated_at = nil
  247. }
  248. // SetDeletedAt sets the "deleted_at" field.
  249. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  250. m.deleted_at = &t
  251. }
  252. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  253. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  254. v := m.deleted_at
  255. if v == nil {
  256. return
  257. }
  258. return *v, true
  259. }
  260. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  261. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  263. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  264. if !m.op.Is(OpUpdateOne) {
  265. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  266. }
  267. if m.id == nil || m.oldValue == nil {
  268. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  269. }
  270. oldValue, err := m.oldValue(ctx)
  271. if err != nil {
  272. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  273. }
  274. return oldValue.DeletedAt, nil
  275. }
  276. // ClearDeletedAt clears the value of the "deleted_at" field.
  277. func (m *AgentMutation) ClearDeletedAt() {
  278. m.deleted_at = nil
  279. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  280. }
  281. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  282. func (m *AgentMutation) DeletedAtCleared() bool {
  283. _, ok := m.clearedFields[agent.FieldDeletedAt]
  284. return ok
  285. }
  286. // ResetDeletedAt resets all changes to the "deleted_at" field.
  287. func (m *AgentMutation) ResetDeletedAt() {
  288. m.deleted_at = nil
  289. delete(m.clearedFields, agent.FieldDeletedAt)
  290. }
  291. // SetName sets the "name" field.
  292. func (m *AgentMutation) SetName(s string) {
  293. m.name = &s
  294. }
  295. // Name returns the value of the "name" field in the mutation.
  296. func (m *AgentMutation) Name() (r string, exists bool) {
  297. v := m.name
  298. if v == nil {
  299. return
  300. }
  301. return *v, true
  302. }
  303. // OldName returns the old "name" field's value of the Agent entity.
  304. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  306. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  307. if !m.op.Is(OpUpdateOne) {
  308. return v, errors.New("OldName is only allowed on UpdateOne operations")
  309. }
  310. if m.id == nil || m.oldValue == nil {
  311. return v, errors.New("OldName requires an ID field in the mutation")
  312. }
  313. oldValue, err := m.oldValue(ctx)
  314. if err != nil {
  315. return v, fmt.Errorf("querying old value for OldName: %w", err)
  316. }
  317. return oldValue.Name, nil
  318. }
  319. // ResetName resets all changes to the "name" field.
  320. func (m *AgentMutation) ResetName() {
  321. m.name = nil
  322. }
  323. // SetRole sets the "role" field.
  324. func (m *AgentMutation) SetRole(s string) {
  325. m.role = &s
  326. }
  327. // Role returns the value of the "role" field in the mutation.
  328. func (m *AgentMutation) Role() (r string, exists bool) {
  329. v := m.role
  330. if v == nil {
  331. return
  332. }
  333. return *v, true
  334. }
  335. // OldRole returns the old "role" field's value of the Agent entity.
  336. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  338. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  339. if !m.op.Is(OpUpdateOne) {
  340. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  341. }
  342. if m.id == nil || m.oldValue == nil {
  343. return v, errors.New("OldRole requires an ID field in the mutation")
  344. }
  345. oldValue, err := m.oldValue(ctx)
  346. if err != nil {
  347. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  348. }
  349. return oldValue.Role, nil
  350. }
  351. // ResetRole resets all changes to the "role" field.
  352. func (m *AgentMutation) ResetRole() {
  353. m.role = nil
  354. }
  355. // SetStatus sets the "status" field.
  356. func (m *AgentMutation) SetStatus(i int) {
  357. m.status = &i
  358. m.addstatus = nil
  359. }
  360. // Status returns the value of the "status" field in the mutation.
  361. func (m *AgentMutation) Status() (r int, exists bool) {
  362. v := m.status
  363. if v == nil {
  364. return
  365. }
  366. return *v, true
  367. }
  368. // OldStatus returns the old "status" field's value of the Agent entity.
  369. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  371. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  372. if !m.op.Is(OpUpdateOne) {
  373. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  374. }
  375. if m.id == nil || m.oldValue == nil {
  376. return v, errors.New("OldStatus requires an ID field in the mutation")
  377. }
  378. oldValue, err := m.oldValue(ctx)
  379. if err != nil {
  380. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  381. }
  382. return oldValue.Status, nil
  383. }
  384. // AddStatus adds i to the "status" field.
  385. func (m *AgentMutation) AddStatus(i int) {
  386. if m.addstatus != nil {
  387. *m.addstatus += i
  388. } else {
  389. m.addstatus = &i
  390. }
  391. }
  392. // AddedStatus returns the value that was added to the "status" field in this mutation.
  393. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  394. v := m.addstatus
  395. if v == nil {
  396. return
  397. }
  398. return *v, true
  399. }
  400. // ClearStatus clears the value of the "status" field.
  401. func (m *AgentMutation) ClearStatus() {
  402. m.status = nil
  403. m.addstatus = nil
  404. m.clearedFields[agent.FieldStatus] = struct{}{}
  405. }
  406. // StatusCleared returns if the "status" field was cleared in this mutation.
  407. func (m *AgentMutation) StatusCleared() bool {
  408. _, ok := m.clearedFields[agent.FieldStatus]
  409. return ok
  410. }
  411. // ResetStatus resets all changes to the "status" field.
  412. func (m *AgentMutation) ResetStatus() {
  413. m.status = nil
  414. m.addstatus = nil
  415. delete(m.clearedFields, agent.FieldStatus)
  416. }
  417. // SetBackground sets the "background" field.
  418. func (m *AgentMutation) SetBackground(s string) {
  419. m.background = &s
  420. }
  421. // Background returns the value of the "background" field in the mutation.
  422. func (m *AgentMutation) Background() (r string, exists bool) {
  423. v := m.background
  424. if v == nil {
  425. return
  426. }
  427. return *v, true
  428. }
  429. // OldBackground returns the old "background" field's value of the Agent entity.
  430. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  432. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  433. if !m.op.Is(OpUpdateOne) {
  434. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  435. }
  436. if m.id == nil || m.oldValue == nil {
  437. return v, errors.New("OldBackground requires an ID field in the mutation")
  438. }
  439. oldValue, err := m.oldValue(ctx)
  440. if err != nil {
  441. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  442. }
  443. return oldValue.Background, nil
  444. }
  445. // ClearBackground clears the value of the "background" field.
  446. func (m *AgentMutation) ClearBackground() {
  447. m.background = nil
  448. m.clearedFields[agent.FieldBackground] = struct{}{}
  449. }
  450. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  451. func (m *AgentMutation) BackgroundCleared() bool {
  452. _, ok := m.clearedFields[agent.FieldBackground]
  453. return ok
  454. }
  455. // ResetBackground resets all changes to the "background" field.
  456. func (m *AgentMutation) ResetBackground() {
  457. m.background = nil
  458. delete(m.clearedFields, agent.FieldBackground)
  459. }
  460. // SetExamples sets the "examples" field.
  461. func (m *AgentMutation) SetExamples(s string) {
  462. m.examples = &s
  463. }
  464. // Examples returns the value of the "examples" field in the mutation.
  465. func (m *AgentMutation) Examples() (r string, exists bool) {
  466. v := m.examples
  467. if v == nil {
  468. return
  469. }
  470. return *v, true
  471. }
  472. // OldExamples returns the old "examples" field's value of the Agent entity.
  473. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  475. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  476. if !m.op.Is(OpUpdateOne) {
  477. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  478. }
  479. if m.id == nil || m.oldValue == nil {
  480. return v, errors.New("OldExamples requires an ID field in the mutation")
  481. }
  482. oldValue, err := m.oldValue(ctx)
  483. if err != nil {
  484. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  485. }
  486. return oldValue.Examples, nil
  487. }
  488. // ClearExamples clears the value of the "examples" field.
  489. func (m *AgentMutation) ClearExamples() {
  490. m.examples = nil
  491. m.clearedFields[agent.FieldExamples] = struct{}{}
  492. }
  493. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  494. func (m *AgentMutation) ExamplesCleared() bool {
  495. _, ok := m.clearedFields[agent.FieldExamples]
  496. return ok
  497. }
  498. // ResetExamples resets all changes to the "examples" field.
  499. func (m *AgentMutation) ResetExamples() {
  500. m.examples = nil
  501. delete(m.clearedFields, agent.FieldExamples)
  502. }
  503. // SetOrganizationID sets the "organization_id" field.
  504. func (m *AgentMutation) SetOrganizationID(u uint64) {
  505. m.organization_id = &u
  506. m.addorganization_id = nil
  507. }
  508. // OrganizationID returns the value of the "organization_id" field in the mutation.
  509. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  510. v := m.organization_id
  511. if v == nil {
  512. return
  513. }
  514. return *v, true
  515. }
  516. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  517. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  519. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  520. if !m.op.Is(OpUpdateOne) {
  521. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  522. }
  523. if m.id == nil || m.oldValue == nil {
  524. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  525. }
  526. oldValue, err := m.oldValue(ctx)
  527. if err != nil {
  528. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  529. }
  530. return oldValue.OrganizationID, nil
  531. }
  532. // AddOrganizationID adds u to the "organization_id" field.
  533. func (m *AgentMutation) AddOrganizationID(u int64) {
  534. if m.addorganization_id != nil {
  535. *m.addorganization_id += u
  536. } else {
  537. m.addorganization_id = &u
  538. }
  539. }
  540. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  541. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  542. v := m.addorganization_id
  543. if v == nil {
  544. return
  545. }
  546. return *v, true
  547. }
  548. // ResetOrganizationID resets all changes to the "organization_id" field.
  549. func (m *AgentMutation) ResetOrganizationID() {
  550. m.organization_id = nil
  551. m.addorganization_id = nil
  552. }
  553. // SetDatasetID sets the "dataset_id" field.
  554. func (m *AgentMutation) SetDatasetID(s string) {
  555. m.dataset_id = &s
  556. }
  557. // DatasetID returns the value of the "dataset_id" field in the mutation.
  558. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  559. v := m.dataset_id
  560. if v == nil {
  561. return
  562. }
  563. return *v, true
  564. }
  565. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  566. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  568. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  569. if !m.op.Is(OpUpdateOne) {
  570. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  571. }
  572. if m.id == nil || m.oldValue == nil {
  573. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  574. }
  575. oldValue, err := m.oldValue(ctx)
  576. if err != nil {
  577. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  578. }
  579. return oldValue.DatasetID, nil
  580. }
  581. // ResetDatasetID resets all changes to the "dataset_id" field.
  582. func (m *AgentMutation) ResetDatasetID() {
  583. m.dataset_id = nil
  584. }
  585. // SetCollectionID sets the "collection_id" field.
  586. func (m *AgentMutation) SetCollectionID(s string) {
  587. m.collection_id = &s
  588. }
  589. // CollectionID returns the value of the "collection_id" field in the mutation.
  590. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  591. v := m.collection_id
  592. if v == nil {
  593. return
  594. }
  595. return *v, true
  596. }
  597. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  598. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  600. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  601. if !m.op.Is(OpUpdateOne) {
  602. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  603. }
  604. if m.id == nil || m.oldValue == nil {
  605. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  606. }
  607. oldValue, err := m.oldValue(ctx)
  608. if err != nil {
  609. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  610. }
  611. return oldValue.CollectionID, nil
  612. }
  613. // ResetCollectionID resets all changes to the "collection_id" field.
  614. func (m *AgentMutation) ResetCollectionID() {
  615. m.collection_id = nil
  616. }
  617. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  618. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  619. if m.wx_agent == nil {
  620. m.wx_agent = make(map[uint64]struct{})
  621. }
  622. for i := range ids {
  623. m.wx_agent[ids[i]] = struct{}{}
  624. }
  625. }
  626. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  627. func (m *AgentMutation) ClearWxAgent() {
  628. m.clearedwx_agent = true
  629. }
  630. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  631. func (m *AgentMutation) WxAgentCleared() bool {
  632. return m.clearedwx_agent
  633. }
  634. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  635. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  636. if m.removedwx_agent == nil {
  637. m.removedwx_agent = make(map[uint64]struct{})
  638. }
  639. for i := range ids {
  640. delete(m.wx_agent, ids[i])
  641. m.removedwx_agent[ids[i]] = struct{}{}
  642. }
  643. }
  644. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  645. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  646. for id := range m.removedwx_agent {
  647. ids = append(ids, id)
  648. }
  649. return
  650. }
  651. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  652. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  653. for id := range m.wx_agent {
  654. ids = append(ids, id)
  655. }
  656. return
  657. }
  658. // ResetWxAgent resets all changes to the "wx_agent" edge.
  659. func (m *AgentMutation) ResetWxAgent() {
  660. m.wx_agent = nil
  661. m.clearedwx_agent = false
  662. m.removedwx_agent = nil
  663. }
  664. // Where appends a list predicates to the AgentMutation builder.
  665. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  666. m.predicates = append(m.predicates, ps...)
  667. }
  668. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  669. // users can use type-assertion to append predicates that do not depend on any generated package.
  670. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  671. p := make([]predicate.Agent, len(ps))
  672. for i := range ps {
  673. p[i] = ps[i]
  674. }
  675. m.Where(p...)
  676. }
  677. // Op returns the operation name.
  678. func (m *AgentMutation) Op() Op {
  679. return m.op
  680. }
  681. // SetOp allows setting the mutation operation.
  682. func (m *AgentMutation) SetOp(op Op) {
  683. m.op = op
  684. }
  685. // Type returns the node type of this mutation (Agent).
  686. func (m *AgentMutation) Type() string {
  687. return m.typ
  688. }
  689. // Fields returns all fields that were changed during this mutation. Note that in
  690. // order to get all numeric fields that were incremented/decremented, call
  691. // AddedFields().
  692. func (m *AgentMutation) Fields() []string {
  693. fields := make([]string, 0, 11)
  694. if m.created_at != nil {
  695. fields = append(fields, agent.FieldCreatedAt)
  696. }
  697. if m.updated_at != nil {
  698. fields = append(fields, agent.FieldUpdatedAt)
  699. }
  700. if m.deleted_at != nil {
  701. fields = append(fields, agent.FieldDeletedAt)
  702. }
  703. if m.name != nil {
  704. fields = append(fields, agent.FieldName)
  705. }
  706. if m.role != nil {
  707. fields = append(fields, agent.FieldRole)
  708. }
  709. if m.status != nil {
  710. fields = append(fields, agent.FieldStatus)
  711. }
  712. if m.background != nil {
  713. fields = append(fields, agent.FieldBackground)
  714. }
  715. if m.examples != nil {
  716. fields = append(fields, agent.FieldExamples)
  717. }
  718. if m.organization_id != nil {
  719. fields = append(fields, agent.FieldOrganizationID)
  720. }
  721. if m.dataset_id != nil {
  722. fields = append(fields, agent.FieldDatasetID)
  723. }
  724. if m.collection_id != nil {
  725. fields = append(fields, agent.FieldCollectionID)
  726. }
  727. return fields
  728. }
  729. // Field returns the value of a field with the given name. The second boolean
  730. // return value indicates that this field was not set, or was not defined in the
  731. // schema.
  732. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  733. switch name {
  734. case agent.FieldCreatedAt:
  735. return m.CreatedAt()
  736. case agent.FieldUpdatedAt:
  737. return m.UpdatedAt()
  738. case agent.FieldDeletedAt:
  739. return m.DeletedAt()
  740. case agent.FieldName:
  741. return m.Name()
  742. case agent.FieldRole:
  743. return m.Role()
  744. case agent.FieldStatus:
  745. return m.Status()
  746. case agent.FieldBackground:
  747. return m.Background()
  748. case agent.FieldExamples:
  749. return m.Examples()
  750. case agent.FieldOrganizationID:
  751. return m.OrganizationID()
  752. case agent.FieldDatasetID:
  753. return m.DatasetID()
  754. case agent.FieldCollectionID:
  755. return m.CollectionID()
  756. }
  757. return nil, false
  758. }
  759. // OldField returns the old value of the field from the database. An error is
  760. // returned if the mutation operation is not UpdateOne, or the query to the
  761. // database failed.
  762. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  763. switch name {
  764. case agent.FieldCreatedAt:
  765. return m.OldCreatedAt(ctx)
  766. case agent.FieldUpdatedAt:
  767. return m.OldUpdatedAt(ctx)
  768. case agent.FieldDeletedAt:
  769. return m.OldDeletedAt(ctx)
  770. case agent.FieldName:
  771. return m.OldName(ctx)
  772. case agent.FieldRole:
  773. return m.OldRole(ctx)
  774. case agent.FieldStatus:
  775. return m.OldStatus(ctx)
  776. case agent.FieldBackground:
  777. return m.OldBackground(ctx)
  778. case agent.FieldExamples:
  779. return m.OldExamples(ctx)
  780. case agent.FieldOrganizationID:
  781. return m.OldOrganizationID(ctx)
  782. case agent.FieldDatasetID:
  783. return m.OldDatasetID(ctx)
  784. case agent.FieldCollectionID:
  785. return m.OldCollectionID(ctx)
  786. }
  787. return nil, fmt.Errorf("unknown Agent field %s", name)
  788. }
  789. // SetField sets the value of a field with the given name. It returns an error if
  790. // the field is not defined in the schema, or if the type mismatched the field
  791. // type.
  792. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  793. switch name {
  794. case agent.FieldCreatedAt:
  795. v, ok := value.(time.Time)
  796. if !ok {
  797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  798. }
  799. m.SetCreatedAt(v)
  800. return nil
  801. case agent.FieldUpdatedAt:
  802. v, ok := value.(time.Time)
  803. if !ok {
  804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  805. }
  806. m.SetUpdatedAt(v)
  807. return nil
  808. case agent.FieldDeletedAt:
  809. v, ok := value.(time.Time)
  810. if !ok {
  811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  812. }
  813. m.SetDeletedAt(v)
  814. return nil
  815. case agent.FieldName:
  816. v, ok := value.(string)
  817. if !ok {
  818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  819. }
  820. m.SetName(v)
  821. return nil
  822. case agent.FieldRole:
  823. v, ok := value.(string)
  824. if !ok {
  825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  826. }
  827. m.SetRole(v)
  828. return nil
  829. case agent.FieldStatus:
  830. v, ok := value.(int)
  831. if !ok {
  832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  833. }
  834. m.SetStatus(v)
  835. return nil
  836. case agent.FieldBackground:
  837. v, ok := value.(string)
  838. if !ok {
  839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  840. }
  841. m.SetBackground(v)
  842. return nil
  843. case agent.FieldExamples:
  844. v, ok := value.(string)
  845. if !ok {
  846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  847. }
  848. m.SetExamples(v)
  849. return nil
  850. case agent.FieldOrganizationID:
  851. v, ok := value.(uint64)
  852. if !ok {
  853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  854. }
  855. m.SetOrganizationID(v)
  856. return nil
  857. case agent.FieldDatasetID:
  858. v, ok := value.(string)
  859. if !ok {
  860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  861. }
  862. m.SetDatasetID(v)
  863. return nil
  864. case agent.FieldCollectionID:
  865. v, ok := value.(string)
  866. if !ok {
  867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  868. }
  869. m.SetCollectionID(v)
  870. return nil
  871. }
  872. return fmt.Errorf("unknown Agent field %s", name)
  873. }
  874. // AddedFields returns all numeric fields that were incremented/decremented during
  875. // this mutation.
  876. func (m *AgentMutation) AddedFields() []string {
  877. var fields []string
  878. if m.addstatus != nil {
  879. fields = append(fields, agent.FieldStatus)
  880. }
  881. if m.addorganization_id != nil {
  882. fields = append(fields, agent.FieldOrganizationID)
  883. }
  884. return fields
  885. }
  886. // AddedField returns the numeric value that was incremented/decremented on a field
  887. // with the given name. The second boolean return value indicates that this field
  888. // was not set, or was not defined in the schema.
  889. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  890. switch name {
  891. case agent.FieldStatus:
  892. return m.AddedStatus()
  893. case agent.FieldOrganizationID:
  894. return m.AddedOrganizationID()
  895. }
  896. return nil, false
  897. }
  898. // AddField adds the value to the field with the given name. It returns an error if
  899. // the field is not defined in the schema, or if the type mismatched the field
  900. // type.
  901. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  902. switch name {
  903. case agent.FieldStatus:
  904. v, ok := value.(int)
  905. if !ok {
  906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  907. }
  908. m.AddStatus(v)
  909. return nil
  910. case agent.FieldOrganizationID:
  911. v, ok := value.(int64)
  912. if !ok {
  913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  914. }
  915. m.AddOrganizationID(v)
  916. return nil
  917. }
  918. return fmt.Errorf("unknown Agent numeric field %s", name)
  919. }
  920. // ClearedFields returns all nullable fields that were cleared during this
  921. // mutation.
  922. func (m *AgentMutation) ClearedFields() []string {
  923. var fields []string
  924. if m.FieldCleared(agent.FieldDeletedAt) {
  925. fields = append(fields, agent.FieldDeletedAt)
  926. }
  927. if m.FieldCleared(agent.FieldStatus) {
  928. fields = append(fields, agent.FieldStatus)
  929. }
  930. if m.FieldCleared(agent.FieldBackground) {
  931. fields = append(fields, agent.FieldBackground)
  932. }
  933. if m.FieldCleared(agent.FieldExamples) {
  934. fields = append(fields, agent.FieldExamples)
  935. }
  936. return fields
  937. }
  938. // FieldCleared returns a boolean indicating if a field with the given name was
  939. // cleared in this mutation.
  940. func (m *AgentMutation) FieldCleared(name string) bool {
  941. _, ok := m.clearedFields[name]
  942. return ok
  943. }
  944. // ClearField clears the value of the field with the given name. It returns an
  945. // error if the field is not defined in the schema.
  946. func (m *AgentMutation) ClearField(name string) error {
  947. switch name {
  948. case agent.FieldDeletedAt:
  949. m.ClearDeletedAt()
  950. return nil
  951. case agent.FieldStatus:
  952. m.ClearStatus()
  953. return nil
  954. case agent.FieldBackground:
  955. m.ClearBackground()
  956. return nil
  957. case agent.FieldExamples:
  958. m.ClearExamples()
  959. return nil
  960. }
  961. return fmt.Errorf("unknown Agent nullable field %s", name)
  962. }
  963. // ResetField resets all changes in the mutation for the field with the given name.
  964. // It returns an error if the field is not defined in the schema.
  965. func (m *AgentMutation) ResetField(name string) error {
  966. switch name {
  967. case agent.FieldCreatedAt:
  968. m.ResetCreatedAt()
  969. return nil
  970. case agent.FieldUpdatedAt:
  971. m.ResetUpdatedAt()
  972. return nil
  973. case agent.FieldDeletedAt:
  974. m.ResetDeletedAt()
  975. return nil
  976. case agent.FieldName:
  977. m.ResetName()
  978. return nil
  979. case agent.FieldRole:
  980. m.ResetRole()
  981. return nil
  982. case agent.FieldStatus:
  983. m.ResetStatus()
  984. return nil
  985. case agent.FieldBackground:
  986. m.ResetBackground()
  987. return nil
  988. case agent.FieldExamples:
  989. m.ResetExamples()
  990. return nil
  991. case agent.FieldOrganizationID:
  992. m.ResetOrganizationID()
  993. return nil
  994. case agent.FieldDatasetID:
  995. m.ResetDatasetID()
  996. return nil
  997. case agent.FieldCollectionID:
  998. m.ResetCollectionID()
  999. return nil
  1000. }
  1001. return fmt.Errorf("unknown Agent field %s", name)
  1002. }
  1003. // AddedEdges returns all edge names that were set/added in this mutation.
  1004. func (m *AgentMutation) AddedEdges() []string {
  1005. edges := make([]string, 0, 1)
  1006. if m.wx_agent != nil {
  1007. edges = append(edges, agent.EdgeWxAgent)
  1008. }
  1009. return edges
  1010. }
  1011. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1012. // name in this mutation.
  1013. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1014. switch name {
  1015. case agent.EdgeWxAgent:
  1016. ids := make([]ent.Value, 0, len(m.wx_agent))
  1017. for id := range m.wx_agent {
  1018. ids = append(ids, id)
  1019. }
  1020. return ids
  1021. }
  1022. return nil
  1023. }
  1024. // RemovedEdges returns all edge names that were removed in this mutation.
  1025. func (m *AgentMutation) RemovedEdges() []string {
  1026. edges := make([]string, 0, 1)
  1027. if m.removedwx_agent != nil {
  1028. edges = append(edges, agent.EdgeWxAgent)
  1029. }
  1030. return edges
  1031. }
  1032. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1033. // the given name in this mutation.
  1034. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1035. switch name {
  1036. case agent.EdgeWxAgent:
  1037. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1038. for id := range m.removedwx_agent {
  1039. ids = append(ids, id)
  1040. }
  1041. return ids
  1042. }
  1043. return nil
  1044. }
  1045. // ClearedEdges returns all edge names that were cleared in this mutation.
  1046. func (m *AgentMutation) ClearedEdges() []string {
  1047. edges := make([]string, 0, 1)
  1048. if m.clearedwx_agent {
  1049. edges = append(edges, agent.EdgeWxAgent)
  1050. }
  1051. return edges
  1052. }
  1053. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1054. // was cleared in this mutation.
  1055. func (m *AgentMutation) EdgeCleared(name string) bool {
  1056. switch name {
  1057. case agent.EdgeWxAgent:
  1058. return m.clearedwx_agent
  1059. }
  1060. return false
  1061. }
  1062. // ClearEdge clears the value of the edge with the given name. It returns an error
  1063. // if that edge is not defined in the schema.
  1064. func (m *AgentMutation) ClearEdge(name string) error {
  1065. switch name {
  1066. }
  1067. return fmt.Errorf("unknown Agent unique edge %s", name)
  1068. }
  1069. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1070. // It returns an error if the edge is not defined in the schema.
  1071. func (m *AgentMutation) ResetEdge(name string) error {
  1072. switch name {
  1073. case agent.EdgeWxAgent:
  1074. m.ResetWxAgent()
  1075. return nil
  1076. }
  1077. return fmt.Errorf("unknown Agent edge %s", name)
  1078. }
  1079. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1080. type AgentBaseMutation struct {
  1081. config
  1082. op Op
  1083. typ string
  1084. id *string
  1085. q *string
  1086. a *string
  1087. chunk_index *uint64
  1088. addchunk_index *int64
  1089. indexes *[]string
  1090. appendindexes []string
  1091. dataset_id *string
  1092. collection_id *string
  1093. source_name *string
  1094. can_write *[]bool
  1095. appendcan_write []bool
  1096. is_owner *[]bool
  1097. appendis_owner []bool
  1098. clearedFields map[string]struct{}
  1099. wx_agent map[uint64]struct{}
  1100. removedwx_agent map[uint64]struct{}
  1101. clearedwx_agent bool
  1102. done bool
  1103. oldValue func(context.Context) (*AgentBase, error)
  1104. predicates []predicate.AgentBase
  1105. }
  1106. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1107. // agentbaseOption allows management of the mutation configuration using functional options.
  1108. type agentbaseOption func(*AgentBaseMutation)
  1109. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1110. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1111. m := &AgentBaseMutation{
  1112. config: c,
  1113. op: op,
  1114. typ: TypeAgentBase,
  1115. clearedFields: make(map[string]struct{}),
  1116. }
  1117. for _, opt := range opts {
  1118. opt(m)
  1119. }
  1120. return m
  1121. }
  1122. // withAgentBaseID sets the ID field of the mutation.
  1123. func withAgentBaseID(id string) agentbaseOption {
  1124. return func(m *AgentBaseMutation) {
  1125. var (
  1126. err error
  1127. once sync.Once
  1128. value *AgentBase
  1129. )
  1130. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1131. once.Do(func() {
  1132. if m.done {
  1133. err = errors.New("querying old values post mutation is not allowed")
  1134. } else {
  1135. value, err = m.Client().AgentBase.Get(ctx, id)
  1136. }
  1137. })
  1138. return value, err
  1139. }
  1140. m.id = &id
  1141. }
  1142. }
  1143. // withAgentBase sets the old AgentBase of the mutation.
  1144. func withAgentBase(node *AgentBase) agentbaseOption {
  1145. return func(m *AgentBaseMutation) {
  1146. m.oldValue = func(context.Context) (*AgentBase, error) {
  1147. return node, nil
  1148. }
  1149. m.id = &node.ID
  1150. }
  1151. }
  1152. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1153. // executed in a transaction (ent.Tx), a transactional client is returned.
  1154. func (m AgentBaseMutation) Client() *Client {
  1155. client := &Client{config: m.config}
  1156. client.init()
  1157. return client
  1158. }
  1159. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1160. // it returns an error otherwise.
  1161. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1162. if _, ok := m.driver.(*txDriver); !ok {
  1163. return nil, errors.New("ent: mutation is not running in a transaction")
  1164. }
  1165. tx := &Tx{config: m.config}
  1166. tx.init()
  1167. return tx, nil
  1168. }
  1169. // SetID sets the value of the id field. Note that this
  1170. // operation is only accepted on creation of AgentBase entities.
  1171. func (m *AgentBaseMutation) SetID(id string) {
  1172. m.id = &id
  1173. }
  1174. // ID returns the ID value in the mutation. Note that the ID is only available
  1175. // if it was provided to the builder or after it was returned from the database.
  1176. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1177. if m.id == nil {
  1178. return
  1179. }
  1180. return *m.id, true
  1181. }
  1182. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1183. // That means, if the mutation is applied within a transaction with an isolation level such
  1184. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1185. // or updated by the mutation.
  1186. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1187. switch {
  1188. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1189. id, exists := m.ID()
  1190. if exists {
  1191. return []string{id}, nil
  1192. }
  1193. fallthrough
  1194. case m.op.Is(OpUpdate | OpDelete):
  1195. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1196. default:
  1197. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1198. }
  1199. }
  1200. // SetQ sets the "q" field.
  1201. func (m *AgentBaseMutation) SetQ(s string) {
  1202. m.q = &s
  1203. }
  1204. // Q returns the value of the "q" field in the mutation.
  1205. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1206. v := m.q
  1207. if v == nil {
  1208. return
  1209. }
  1210. return *v, true
  1211. }
  1212. // OldQ returns the old "q" field's value of the AgentBase entity.
  1213. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1215. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1216. if !m.op.Is(OpUpdateOne) {
  1217. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1218. }
  1219. if m.id == nil || m.oldValue == nil {
  1220. return v, errors.New("OldQ requires an ID field in the mutation")
  1221. }
  1222. oldValue, err := m.oldValue(ctx)
  1223. if err != nil {
  1224. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1225. }
  1226. return oldValue.Q, nil
  1227. }
  1228. // ClearQ clears the value of the "q" field.
  1229. func (m *AgentBaseMutation) ClearQ() {
  1230. m.q = nil
  1231. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1232. }
  1233. // QCleared returns if the "q" field was cleared in this mutation.
  1234. func (m *AgentBaseMutation) QCleared() bool {
  1235. _, ok := m.clearedFields[agentbase.FieldQ]
  1236. return ok
  1237. }
  1238. // ResetQ resets all changes to the "q" field.
  1239. func (m *AgentBaseMutation) ResetQ() {
  1240. m.q = nil
  1241. delete(m.clearedFields, agentbase.FieldQ)
  1242. }
  1243. // SetA sets the "a" field.
  1244. func (m *AgentBaseMutation) SetA(s string) {
  1245. m.a = &s
  1246. }
  1247. // A returns the value of the "a" field in the mutation.
  1248. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1249. v := m.a
  1250. if v == nil {
  1251. return
  1252. }
  1253. return *v, true
  1254. }
  1255. // OldA returns the old "a" field's value of the AgentBase entity.
  1256. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1258. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1259. if !m.op.Is(OpUpdateOne) {
  1260. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1261. }
  1262. if m.id == nil || m.oldValue == nil {
  1263. return v, errors.New("OldA requires an ID field in the mutation")
  1264. }
  1265. oldValue, err := m.oldValue(ctx)
  1266. if err != nil {
  1267. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1268. }
  1269. return oldValue.A, nil
  1270. }
  1271. // ClearA clears the value of the "a" field.
  1272. func (m *AgentBaseMutation) ClearA() {
  1273. m.a = nil
  1274. m.clearedFields[agentbase.FieldA] = struct{}{}
  1275. }
  1276. // ACleared returns if the "a" field was cleared in this mutation.
  1277. func (m *AgentBaseMutation) ACleared() bool {
  1278. _, ok := m.clearedFields[agentbase.FieldA]
  1279. return ok
  1280. }
  1281. // ResetA resets all changes to the "a" field.
  1282. func (m *AgentBaseMutation) ResetA() {
  1283. m.a = nil
  1284. delete(m.clearedFields, agentbase.FieldA)
  1285. }
  1286. // SetChunkIndex sets the "chunk_index" field.
  1287. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1288. m.chunk_index = &u
  1289. m.addchunk_index = nil
  1290. }
  1291. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1292. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1293. v := m.chunk_index
  1294. if v == nil {
  1295. return
  1296. }
  1297. return *v, true
  1298. }
  1299. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1300. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1302. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1303. if !m.op.Is(OpUpdateOne) {
  1304. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1305. }
  1306. if m.id == nil || m.oldValue == nil {
  1307. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1308. }
  1309. oldValue, err := m.oldValue(ctx)
  1310. if err != nil {
  1311. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1312. }
  1313. return oldValue.ChunkIndex, nil
  1314. }
  1315. // AddChunkIndex adds u to the "chunk_index" field.
  1316. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1317. if m.addchunk_index != nil {
  1318. *m.addchunk_index += u
  1319. } else {
  1320. m.addchunk_index = &u
  1321. }
  1322. }
  1323. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1324. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1325. v := m.addchunk_index
  1326. if v == nil {
  1327. return
  1328. }
  1329. return *v, true
  1330. }
  1331. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1332. func (m *AgentBaseMutation) ResetChunkIndex() {
  1333. m.chunk_index = nil
  1334. m.addchunk_index = nil
  1335. }
  1336. // SetIndexes sets the "indexes" field.
  1337. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1338. m.indexes = &s
  1339. m.appendindexes = nil
  1340. }
  1341. // Indexes returns the value of the "indexes" field in the mutation.
  1342. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1343. v := m.indexes
  1344. if v == nil {
  1345. return
  1346. }
  1347. return *v, true
  1348. }
  1349. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1350. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1352. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1353. if !m.op.Is(OpUpdateOne) {
  1354. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1355. }
  1356. if m.id == nil || m.oldValue == nil {
  1357. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1358. }
  1359. oldValue, err := m.oldValue(ctx)
  1360. if err != nil {
  1361. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1362. }
  1363. return oldValue.Indexes, nil
  1364. }
  1365. // AppendIndexes adds s to the "indexes" field.
  1366. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1367. m.appendindexes = append(m.appendindexes, s...)
  1368. }
  1369. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1370. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1371. if len(m.appendindexes) == 0 {
  1372. return nil, false
  1373. }
  1374. return m.appendindexes, true
  1375. }
  1376. // ClearIndexes clears the value of the "indexes" field.
  1377. func (m *AgentBaseMutation) ClearIndexes() {
  1378. m.indexes = nil
  1379. m.appendindexes = nil
  1380. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1381. }
  1382. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1383. func (m *AgentBaseMutation) IndexesCleared() bool {
  1384. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1385. return ok
  1386. }
  1387. // ResetIndexes resets all changes to the "indexes" field.
  1388. func (m *AgentBaseMutation) ResetIndexes() {
  1389. m.indexes = nil
  1390. m.appendindexes = nil
  1391. delete(m.clearedFields, agentbase.FieldIndexes)
  1392. }
  1393. // SetDatasetID sets the "dataset_id" field.
  1394. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1395. m.dataset_id = &s
  1396. }
  1397. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1398. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1399. v := m.dataset_id
  1400. if v == nil {
  1401. return
  1402. }
  1403. return *v, true
  1404. }
  1405. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1406. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1408. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1409. if !m.op.Is(OpUpdateOne) {
  1410. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1411. }
  1412. if m.id == nil || m.oldValue == nil {
  1413. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1414. }
  1415. oldValue, err := m.oldValue(ctx)
  1416. if err != nil {
  1417. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1418. }
  1419. return oldValue.DatasetID, nil
  1420. }
  1421. // ClearDatasetID clears the value of the "dataset_id" field.
  1422. func (m *AgentBaseMutation) ClearDatasetID() {
  1423. m.dataset_id = nil
  1424. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1425. }
  1426. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1427. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1428. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1429. return ok
  1430. }
  1431. // ResetDatasetID resets all changes to the "dataset_id" field.
  1432. func (m *AgentBaseMutation) ResetDatasetID() {
  1433. m.dataset_id = nil
  1434. delete(m.clearedFields, agentbase.FieldDatasetID)
  1435. }
  1436. // SetCollectionID sets the "collection_id" field.
  1437. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1438. m.collection_id = &s
  1439. }
  1440. // CollectionID returns the value of the "collection_id" field in the mutation.
  1441. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1442. v := m.collection_id
  1443. if v == nil {
  1444. return
  1445. }
  1446. return *v, true
  1447. }
  1448. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1449. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1451. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1452. if !m.op.Is(OpUpdateOne) {
  1453. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1454. }
  1455. if m.id == nil || m.oldValue == nil {
  1456. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1457. }
  1458. oldValue, err := m.oldValue(ctx)
  1459. if err != nil {
  1460. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1461. }
  1462. return oldValue.CollectionID, nil
  1463. }
  1464. // ClearCollectionID clears the value of the "collection_id" field.
  1465. func (m *AgentBaseMutation) ClearCollectionID() {
  1466. m.collection_id = nil
  1467. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1468. }
  1469. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1470. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1471. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1472. return ok
  1473. }
  1474. // ResetCollectionID resets all changes to the "collection_id" field.
  1475. func (m *AgentBaseMutation) ResetCollectionID() {
  1476. m.collection_id = nil
  1477. delete(m.clearedFields, agentbase.FieldCollectionID)
  1478. }
  1479. // SetSourceName sets the "source_name" field.
  1480. func (m *AgentBaseMutation) SetSourceName(s string) {
  1481. m.source_name = &s
  1482. }
  1483. // SourceName returns the value of the "source_name" field in the mutation.
  1484. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1485. v := m.source_name
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1504. }
  1505. return oldValue.SourceName, nil
  1506. }
  1507. // ClearSourceName clears the value of the "source_name" field.
  1508. func (m *AgentBaseMutation) ClearSourceName() {
  1509. m.source_name = nil
  1510. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1511. }
  1512. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1513. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1514. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1515. return ok
  1516. }
  1517. // ResetSourceName resets all changes to the "source_name" field.
  1518. func (m *AgentBaseMutation) ResetSourceName() {
  1519. m.source_name = nil
  1520. delete(m.clearedFields, agentbase.FieldSourceName)
  1521. }
  1522. // SetCanWrite sets the "can_write" field.
  1523. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1524. m.can_write = &b
  1525. m.appendcan_write = nil
  1526. }
  1527. // CanWrite returns the value of the "can_write" field in the mutation.
  1528. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1529. v := m.can_write
  1530. if v == nil {
  1531. return
  1532. }
  1533. return *v, true
  1534. }
  1535. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1536. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1538. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1539. if !m.op.Is(OpUpdateOne) {
  1540. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1541. }
  1542. if m.id == nil || m.oldValue == nil {
  1543. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1544. }
  1545. oldValue, err := m.oldValue(ctx)
  1546. if err != nil {
  1547. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1548. }
  1549. return oldValue.CanWrite, nil
  1550. }
  1551. // AppendCanWrite adds b to the "can_write" field.
  1552. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1553. m.appendcan_write = append(m.appendcan_write, b...)
  1554. }
  1555. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1556. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1557. if len(m.appendcan_write) == 0 {
  1558. return nil, false
  1559. }
  1560. return m.appendcan_write, true
  1561. }
  1562. // ClearCanWrite clears the value of the "can_write" field.
  1563. func (m *AgentBaseMutation) ClearCanWrite() {
  1564. m.can_write = nil
  1565. m.appendcan_write = nil
  1566. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1567. }
  1568. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1569. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1570. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1571. return ok
  1572. }
  1573. // ResetCanWrite resets all changes to the "can_write" field.
  1574. func (m *AgentBaseMutation) ResetCanWrite() {
  1575. m.can_write = nil
  1576. m.appendcan_write = nil
  1577. delete(m.clearedFields, agentbase.FieldCanWrite)
  1578. }
  1579. // SetIsOwner sets the "is_owner" field.
  1580. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1581. m.is_owner = &b
  1582. m.appendis_owner = nil
  1583. }
  1584. // IsOwner returns the value of the "is_owner" field in the mutation.
  1585. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1586. v := m.is_owner
  1587. if v == nil {
  1588. return
  1589. }
  1590. return *v, true
  1591. }
  1592. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1593. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1595. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1596. if !m.op.Is(OpUpdateOne) {
  1597. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1598. }
  1599. if m.id == nil || m.oldValue == nil {
  1600. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1601. }
  1602. oldValue, err := m.oldValue(ctx)
  1603. if err != nil {
  1604. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1605. }
  1606. return oldValue.IsOwner, nil
  1607. }
  1608. // AppendIsOwner adds b to the "is_owner" field.
  1609. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1610. m.appendis_owner = append(m.appendis_owner, b...)
  1611. }
  1612. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1613. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1614. if len(m.appendis_owner) == 0 {
  1615. return nil, false
  1616. }
  1617. return m.appendis_owner, true
  1618. }
  1619. // ClearIsOwner clears the value of the "is_owner" field.
  1620. func (m *AgentBaseMutation) ClearIsOwner() {
  1621. m.is_owner = nil
  1622. m.appendis_owner = nil
  1623. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1624. }
  1625. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1626. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1627. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1628. return ok
  1629. }
  1630. // ResetIsOwner resets all changes to the "is_owner" field.
  1631. func (m *AgentBaseMutation) ResetIsOwner() {
  1632. m.is_owner = nil
  1633. m.appendis_owner = nil
  1634. delete(m.clearedFields, agentbase.FieldIsOwner)
  1635. }
  1636. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1637. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1638. if m.wx_agent == nil {
  1639. m.wx_agent = make(map[uint64]struct{})
  1640. }
  1641. for i := range ids {
  1642. m.wx_agent[ids[i]] = struct{}{}
  1643. }
  1644. }
  1645. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1646. func (m *AgentBaseMutation) ClearWxAgent() {
  1647. m.clearedwx_agent = true
  1648. }
  1649. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1650. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1651. return m.clearedwx_agent
  1652. }
  1653. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1654. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1655. if m.removedwx_agent == nil {
  1656. m.removedwx_agent = make(map[uint64]struct{})
  1657. }
  1658. for i := range ids {
  1659. delete(m.wx_agent, ids[i])
  1660. m.removedwx_agent[ids[i]] = struct{}{}
  1661. }
  1662. }
  1663. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1664. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1665. for id := range m.removedwx_agent {
  1666. ids = append(ids, id)
  1667. }
  1668. return
  1669. }
  1670. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1671. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1672. for id := range m.wx_agent {
  1673. ids = append(ids, id)
  1674. }
  1675. return
  1676. }
  1677. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1678. func (m *AgentBaseMutation) ResetWxAgent() {
  1679. m.wx_agent = nil
  1680. m.clearedwx_agent = false
  1681. m.removedwx_agent = nil
  1682. }
  1683. // Where appends a list predicates to the AgentBaseMutation builder.
  1684. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1685. m.predicates = append(m.predicates, ps...)
  1686. }
  1687. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1688. // users can use type-assertion to append predicates that do not depend on any generated package.
  1689. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1690. p := make([]predicate.AgentBase, len(ps))
  1691. for i := range ps {
  1692. p[i] = ps[i]
  1693. }
  1694. m.Where(p...)
  1695. }
  1696. // Op returns the operation name.
  1697. func (m *AgentBaseMutation) Op() Op {
  1698. return m.op
  1699. }
  1700. // SetOp allows setting the mutation operation.
  1701. func (m *AgentBaseMutation) SetOp(op Op) {
  1702. m.op = op
  1703. }
  1704. // Type returns the node type of this mutation (AgentBase).
  1705. func (m *AgentBaseMutation) Type() string {
  1706. return m.typ
  1707. }
  1708. // Fields returns all fields that were changed during this mutation. Note that in
  1709. // order to get all numeric fields that were incremented/decremented, call
  1710. // AddedFields().
  1711. func (m *AgentBaseMutation) Fields() []string {
  1712. fields := make([]string, 0, 9)
  1713. if m.q != nil {
  1714. fields = append(fields, agentbase.FieldQ)
  1715. }
  1716. if m.a != nil {
  1717. fields = append(fields, agentbase.FieldA)
  1718. }
  1719. if m.chunk_index != nil {
  1720. fields = append(fields, agentbase.FieldChunkIndex)
  1721. }
  1722. if m.indexes != nil {
  1723. fields = append(fields, agentbase.FieldIndexes)
  1724. }
  1725. if m.dataset_id != nil {
  1726. fields = append(fields, agentbase.FieldDatasetID)
  1727. }
  1728. if m.collection_id != nil {
  1729. fields = append(fields, agentbase.FieldCollectionID)
  1730. }
  1731. if m.source_name != nil {
  1732. fields = append(fields, agentbase.FieldSourceName)
  1733. }
  1734. if m.can_write != nil {
  1735. fields = append(fields, agentbase.FieldCanWrite)
  1736. }
  1737. if m.is_owner != nil {
  1738. fields = append(fields, agentbase.FieldIsOwner)
  1739. }
  1740. return fields
  1741. }
  1742. // Field returns the value of a field with the given name. The second boolean
  1743. // return value indicates that this field was not set, or was not defined in the
  1744. // schema.
  1745. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1746. switch name {
  1747. case agentbase.FieldQ:
  1748. return m.Q()
  1749. case agentbase.FieldA:
  1750. return m.A()
  1751. case agentbase.FieldChunkIndex:
  1752. return m.ChunkIndex()
  1753. case agentbase.FieldIndexes:
  1754. return m.Indexes()
  1755. case agentbase.FieldDatasetID:
  1756. return m.DatasetID()
  1757. case agentbase.FieldCollectionID:
  1758. return m.CollectionID()
  1759. case agentbase.FieldSourceName:
  1760. return m.SourceName()
  1761. case agentbase.FieldCanWrite:
  1762. return m.CanWrite()
  1763. case agentbase.FieldIsOwner:
  1764. return m.IsOwner()
  1765. }
  1766. return nil, false
  1767. }
  1768. // OldField returns the old value of the field from the database. An error is
  1769. // returned if the mutation operation is not UpdateOne, or the query to the
  1770. // database failed.
  1771. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1772. switch name {
  1773. case agentbase.FieldQ:
  1774. return m.OldQ(ctx)
  1775. case agentbase.FieldA:
  1776. return m.OldA(ctx)
  1777. case agentbase.FieldChunkIndex:
  1778. return m.OldChunkIndex(ctx)
  1779. case agentbase.FieldIndexes:
  1780. return m.OldIndexes(ctx)
  1781. case agentbase.FieldDatasetID:
  1782. return m.OldDatasetID(ctx)
  1783. case agentbase.FieldCollectionID:
  1784. return m.OldCollectionID(ctx)
  1785. case agentbase.FieldSourceName:
  1786. return m.OldSourceName(ctx)
  1787. case agentbase.FieldCanWrite:
  1788. return m.OldCanWrite(ctx)
  1789. case agentbase.FieldIsOwner:
  1790. return m.OldIsOwner(ctx)
  1791. }
  1792. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1793. }
  1794. // SetField sets the value of a field with the given name. It returns an error if
  1795. // the field is not defined in the schema, or if the type mismatched the field
  1796. // type.
  1797. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1798. switch name {
  1799. case agentbase.FieldQ:
  1800. v, ok := value.(string)
  1801. if !ok {
  1802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1803. }
  1804. m.SetQ(v)
  1805. return nil
  1806. case agentbase.FieldA:
  1807. v, ok := value.(string)
  1808. if !ok {
  1809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1810. }
  1811. m.SetA(v)
  1812. return nil
  1813. case agentbase.FieldChunkIndex:
  1814. v, ok := value.(uint64)
  1815. if !ok {
  1816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1817. }
  1818. m.SetChunkIndex(v)
  1819. return nil
  1820. case agentbase.FieldIndexes:
  1821. v, ok := value.([]string)
  1822. if !ok {
  1823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1824. }
  1825. m.SetIndexes(v)
  1826. return nil
  1827. case agentbase.FieldDatasetID:
  1828. v, ok := value.(string)
  1829. if !ok {
  1830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1831. }
  1832. m.SetDatasetID(v)
  1833. return nil
  1834. case agentbase.FieldCollectionID:
  1835. v, ok := value.(string)
  1836. if !ok {
  1837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1838. }
  1839. m.SetCollectionID(v)
  1840. return nil
  1841. case agentbase.FieldSourceName:
  1842. v, ok := value.(string)
  1843. if !ok {
  1844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1845. }
  1846. m.SetSourceName(v)
  1847. return nil
  1848. case agentbase.FieldCanWrite:
  1849. v, ok := value.([]bool)
  1850. if !ok {
  1851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1852. }
  1853. m.SetCanWrite(v)
  1854. return nil
  1855. case agentbase.FieldIsOwner:
  1856. v, ok := value.([]bool)
  1857. if !ok {
  1858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1859. }
  1860. m.SetIsOwner(v)
  1861. return nil
  1862. }
  1863. return fmt.Errorf("unknown AgentBase field %s", name)
  1864. }
  1865. // AddedFields returns all numeric fields that were incremented/decremented during
  1866. // this mutation.
  1867. func (m *AgentBaseMutation) AddedFields() []string {
  1868. var fields []string
  1869. if m.addchunk_index != nil {
  1870. fields = append(fields, agentbase.FieldChunkIndex)
  1871. }
  1872. return fields
  1873. }
  1874. // AddedField returns the numeric value that was incremented/decremented on a field
  1875. // with the given name. The second boolean return value indicates that this field
  1876. // was not set, or was not defined in the schema.
  1877. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1878. switch name {
  1879. case agentbase.FieldChunkIndex:
  1880. return m.AddedChunkIndex()
  1881. }
  1882. return nil, false
  1883. }
  1884. // AddField adds the value to the field with the given name. It returns an error if
  1885. // the field is not defined in the schema, or if the type mismatched the field
  1886. // type.
  1887. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1888. switch name {
  1889. case agentbase.FieldChunkIndex:
  1890. v, ok := value.(int64)
  1891. if !ok {
  1892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1893. }
  1894. m.AddChunkIndex(v)
  1895. return nil
  1896. }
  1897. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1898. }
  1899. // ClearedFields returns all nullable fields that were cleared during this
  1900. // mutation.
  1901. func (m *AgentBaseMutation) ClearedFields() []string {
  1902. var fields []string
  1903. if m.FieldCleared(agentbase.FieldQ) {
  1904. fields = append(fields, agentbase.FieldQ)
  1905. }
  1906. if m.FieldCleared(agentbase.FieldA) {
  1907. fields = append(fields, agentbase.FieldA)
  1908. }
  1909. if m.FieldCleared(agentbase.FieldIndexes) {
  1910. fields = append(fields, agentbase.FieldIndexes)
  1911. }
  1912. if m.FieldCleared(agentbase.FieldDatasetID) {
  1913. fields = append(fields, agentbase.FieldDatasetID)
  1914. }
  1915. if m.FieldCleared(agentbase.FieldCollectionID) {
  1916. fields = append(fields, agentbase.FieldCollectionID)
  1917. }
  1918. if m.FieldCleared(agentbase.FieldSourceName) {
  1919. fields = append(fields, agentbase.FieldSourceName)
  1920. }
  1921. if m.FieldCleared(agentbase.FieldCanWrite) {
  1922. fields = append(fields, agentbase.FieldCanWrite)
  1923. }
  1924. if m.FieldCleared(agentbase.FieldIsOwner) {
  1925. fields = append(fields, agentbase.FieldIsOwner)
  1926. }
  1927. return fields
  1928. }
  1929. // FieldCleared returns a boolean indicating if a field with the given name was
  1930. // cleared in this mutation.
  1931. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  1932. _, ok := m.clearedFields[name]
  1933. return ok
  1934. }
  1935. // ClearField clears the value of the field with the given name. It returns an
  1936. // error if the field is not defined in the schema.
  1937. func (m *AgentBaseMutation) ClearField(name string) error {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. m.ClearQ()
  1941. return nil
  1942. case agentbase.FieldA:
  1943. m.ClearA()
  1944. return nil
  1945. case agentbase.FieldIndexes:
  1946. m.ClearIndexes()
  1947. return nil
  1948. case agentbase.FieldDatasetID:
  1949. m.ClearDatasetID()
  1950. return nil
  1951. case agentbase.FieldCollectionID:
  1952. m.ClearCollectionID()
  1953. return nil
  1954. case agentbase.FieldSourceName:
  1955. m.ClearSourceName()
  1956. return nil
  1957. case agentbase.FieldCanWrite:
  1958. m.ClearCanWrite()
  1959. return nil
  1960. case agentbase.FieldIsOwner:
  1961. m.ClearIsOwner()
  1962. return nil
  1963. }
  1964. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  1965. }
  1966. // ResetField resets all changes in the mutation for the field with the given name.
  1967. // It returns an error if the field is not defined in the schema.
  1968. func (m *AgentBaseMutation) ResetField(name string) error {
  1969. switch name {
  1970. case agentbase.FieldQ:
  1971. m.ResetQ()
  1972. return nil
  1973. case agentbase.FieldA:
  1974. m.ResetA()
  1975. return nil
  1976. case agentbase.FieldChunkIndex:
  1977. m.ResetChunkIndex()
  1978. return nil
  1979. case agentbase.FieldIndexes:
  1980. m.ResetIndexes()
  1981. return nil
  1982. case agentbase.FieldDatasetID:
  1983. m.ResetDatasetID()
  1984. return nil
  1985. case agentbase.FieldCollectionID:
  1986. m.ResetCollectionID()
  1987. return nil
  1988. case agentbase.FieldSourceName:
  1989. m.ResetSourceName()
  1990. return nil
  1991. case agentbase.FieldCanWrite:
  1992. m.ResetCanWrite()
  1993. return nil
  1994. case agentbase.FieldIsOwner:
  1995. m.ResetIsOwner()
  1996. return nil
  1997. }
  1998. return fmt.Errorf("unknown AgentBase field %s", name)
  1999. }
  2000. // AddedEdges returns all edge names that were set/added in this mutation.
  2001. func (m *AgentBaseMutation) AddedEdges() []string {
  2002. edges := make([]string, 0, 1)
  2003. if m.wx_agent != nil {
  2004. edges = append(edges, agentbase.EdgeWxAgent)
  2005. }
  2006. return edges
  2007. }
  2008. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2009. // name in this mutation.
  2010. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2011. switch name {
  2012. case agentbase.EdgeWxAgent:
  2013. ids := make([]ent.Value, 0, len(m.wx_agent))
  2014. for id := range m.wx_agent {
  2015. ids = append(ids, id)
  2016. }
  2017. return ids
  2018. }
  2019. return nil
  2020. }
  2021. // RemovedEdges returns all edge names that were removed in this mutation.
  2022. func (m *AgentBaseMutation) RemovedEdges() []string {
  2023. edges := make([]string, 0, 1)
  2024. if m.removedwx_agent != nil {
  2025. edges = append(edges, agentbase.EdgeWxAgent)
  2026. }
  2027. return edges
  2028. }
  2029. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2030. // the given name in this mutation.
  2031. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2032. switch name {
  2033. case agentbase.EdgeWxAgent:
  2034. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2035. for id := range m.removedwx_agent {
  2036. ids = append(ids, id)
  2037. }
  2038. return ids
  2039. }
  2040. return nil
  2041. }
  2042. // ClearedEdges returns all edge names that were cleared in this mutation.
  2043. func (m *AgentBaseMutation) ClearedEdges() []string {
  2044. edges := make([]string, 0, 1)
  2045. if m.clearedwx_agent {
  2046. edges = append(edges, agentbase.EdgeWxAgent)
  2047. }
  2048. return edges
  2049. }
  2050. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2051. // was cleared in this mutation.
  2052. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2053. switch name {
  2054. case agentbase.EdgeWxAgent:
  2055. return m.clearedwx_agent
  2056. }
  2057. return false
  2058. }
  2059. // ClearEdge clears the value of the edge with the given name. It returns an error
  2060. // if that edge is not defined in the schema.
  2061. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2062. switch name {
  2063. }
  2064. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2065. }
  2066. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2067. // It returns an error if the edge is not defined in the schema.
  2068. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2069. switch name {
  2070. case agentbase.EdgeWxAgent:
  2071. m.ResetWxAgent()
  2072. return nil
  2073. }
  2074. return fmt.Errorf("unknown AgentBase edge %s", name)
  2075. }
  2076. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  2077. type BatchMsgMutation struct {
  2078. config
  2079. op Op
  2080. typ string
  2081. id *uint64
  2082. created_at *time.Time
  2083. updated_at *time.Time
  2084. deleted_at *time.Time
  2085. status *uint8
  2086. addstatus *int8
  2087. batch_no *string
  2088. task_name *string
  2089. fromwxid *string
  2090. msg *string
  2091. tag *string
  2092. tagids *string
  2093. total *int32
  2094. addtotal *int32
  2095. success *int32
  2096. addsuccess *int32
  2097. fail *int32
  2098. addfail *int32
  2099. start_time *time.Time
  2100. stop_time *time.Time
  2101. send_time *time.Time
  2102. _type *int32
  2103. add_type *int32
  2104. organization_id *uint64
  2105. addorganization_id *int64
  2106. clearedFields map[string]struct{}
  2107. done bool
  2108. oldValue func(context.Context) (*BatchMsg, error)
  2109. predicates []predicate.BatchMsg
  2110. }
  2111. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  2112. // batchmsgOption allows management of the mutation configuration using functional options.
  2113. type batchmsgOption func(*BatchMsgMutation)
  2114. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  2115. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  2116. m := &BatchMsgMutation{
  2117. config: c,
  2118. op: op,
  2119. typ: TypeBatchMsg,
  2120. clearedFields: make(map[string]struct{}),
  2121. }
  2122. for _, opt := range opts {
  2123. opt(m)
  2124. }
  2125. return m
  2126. }
  2127. // withBatchMsgID sets the ID field of the mutation.
  2128. func withBatchMsgID(id uint64) batchmsgOption {
  2129. return func(m *BatchMsgMutation) {
  2130. var (
  2131. err error
  2132. once sync.Once
  2133. value *BatchMsg
  2134. )
  2135. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  2136. once.Do(func() {
  2137. if m.done {
  2138. err = errors.New("querying old values post mutation is not allowed")
  2139. } else {
  2140. value, err = m.Client().BatchMsg.Get(ctx, id)
  2141. }
  2142. })
  2143. return value, err
  2144. }
  2145. m.id = &id
  2146. }
  2147. }
  2148. // withBatchMsg sets the old BatchMsg of the mutation.
  2149. func withBatchMsg(node *BatchMsg) batchmsgOption {
  2150. return func(m *BatchMsgMutation) {
  2151. m.oldValue = func(context.Context) (*BatchMsg, error) {
  2152. return node, nil
  2153. }
  2154. m.id = &node.ID
  2155. }
  2156. }
  2157. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2158. // executed in a transaction (ent.Tx), a transactional client is returned.
  2159. func (m BatchMsgMutation) Client() *Client {
  2160. client := &Client{config: m.config}
  2161. client.init()
  2162. return client
  2163. }
  2164. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2165. // it returns an error otherwise.
  2166. func (m BatchMsgMutation) Tx() (*Tx, error) {
  2167. if _, ok := m.driver.(*txDriver); !ok {
  2168. return nil, errors.New("ent: mutation is not running in a transaction")
  2169. }
  2170. tx := &Tx{config: m.config}
  2171. tx.init()
  2172. return tx, nil
  2173. }
  2174. // SetID sets the value of the id field. Note that this
  2175. // operation is only accepted on creation of BatchMsg entities.
  2176. func (m *BatchMsgMutation) SetID(id uint64) {
  2177. m.id = &id
  2178. }
  2179. // ID returns the ID value in the mutation. Note that the ID is only available
  2180. // if it was provided to the builder or after it was returned from the database.
  2181. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  2182. if m.id == nil {
  2183. return
  2184. }
  2185. return *m.id, true
  2186. }
  2187. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2188. // That means, if the mutation is applied within a transaction with an isolation level such
  2189. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2190. // or updated by the mutation.
  2191. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  2192. switch {
  2193. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2194. id, exists := m.ID()
  2195. if exists {
  2196. return []uint64{id}, nil
  2197. }
  2198. fallthrough
  2199. case m.op.Is(OpUpdate | OpDelete):
  2200. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  2201. default:
  2202. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2203. }
  2204. }
  2205. // SetCreatedAt sets the "created_at" field.
  2206. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  2207. m.created_at = &t
  2208. }
  2209. // CreatedAt returns the value of the "created_at" field in the mutation.
  2210. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  2211. v := m.created_at
  2212. if v == nil {
  2213. return
  2214. }
  2215. return *v, true
  2216. }
  2217. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  2218. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2220. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2221. if !m.op.Is(OpUpdateOne) {
  2222. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2223. }
  2224. if m.id == nil || m.oldValue == nil {
  2225. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2226. }
  2227. oldValue, err := m.oldValue(ctx)
  2228. if err != nil {
  2229. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2230. }
  2231. return oldValue.CreatedAt, nil
  2232. }
  2233. // ResetCreatedAt resets all changes to the "created_at" field.
  2234. func (m *BatchMsgMutation) ResetCreatedAt() {
  2235. m.created_at = nil
  2236. }
  2237. // SetUpdatedAt sets the "updated_at" field.
  2238. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  2239. m.updated_at = &t
  2240. }
  2241. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2242. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  2243. v := m.updated_at
  2244. if v == nil {
  2245. return
  2246. }
  2247. return *v, true
  2248. }
  2249. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  2250. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2252. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2253. if !m.op.Is(OpUpdateOne) {
  2254. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2255. }
  2256. if m.id == nil || m.oldValue == nil {
  2257. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2258. }
  2259. oldValue, err := m.oldValue(ctx)
  2260. if err != nil {
  2261. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2262. }
  2263. return oldValue.UpdatedAt, nil
  2264. }
  2265. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2266. func (m *BatchMsgMutation) ResetUpdatedAt() {
  2267. m.updated_at = nil
  2268. }
  2269. // SetDeletedAt sets the "deleted_at" field.
  2270. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  2271. m.deleted_at = &t
  2272. }
  2273. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2274. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  2275. v := m.deleted_at
  2276. if v == nil {
  2277. return
  2278. }
  2279. return *v, true
  2280. }
  2281. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  2282. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2284. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2285. if !m.op.Is(OpUpdateOne) {
  2286. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2287. }
  2288. if m.id == nil || m.oldValue == nil {
  2289. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2290. }
  2291. oldValue, err := m.oldValue(ctx)
  2292. if err != nil {
  2293. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2294. }
  2295. return oldValue.DeletedAt, nil
  2296. }
  2297. // ClearDeletedAt clears the value of the "deleted_at" field.
  2298. func (m *BatchMsgMutation) ClearDeletedAt() {
  2299. m.deleted_at = nil
  2300. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  2301. }
  2302. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2303. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  2304. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  2305. return ok
  2306. }
  2307. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2308. func (m *BatchMsgMutation) ResetDeletedAt() {
  2309. m.deleted_at = nil
  2310. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  2311. }
  2312. // SetStatus sets the "status" field.
  2313. func (m *BatchMsgMutation) SetStatus(u uint8) {
  2314. m.status = &u
  2315. m.addstatus = nil
  2316. }
  2317. // Status returns the value of the "status" field in the mutation.
  2318. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  2319. v := m.status
  2320. if v == nil {
  2321. return
  2322. }
  2323. return *v, true
  2324. }
  2325. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  2326. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2328. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2329. if !m.op.Is(OpUpdateOne) {
  2330. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2331. }
  2332. if m.id == nil || m.oldValue == nil {
  2333. return v, errors.New("OldStatus requires an ID field in the mutation")
  2334. }
  2335. oldValue, err := m.oldValue(ctx)
  2336. if err != nil {
  2337. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2338. }
  2339. return oldValue.Status, nil
  2340. }
  2341. // AddStatus adds u to the "status" field.
  2342. func (m *BatchMsgMutation) AddStatus(u int8) {
  2343. if m.addstatus != nil {
  2344. *m.addstatus += u
  2345. } else {
  2346. m.addstatus = &u
  2347. }
  2348. }
  2349. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2350. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  2351. v := m.addstatus
  2352. if v == nil {
  2353. return
  2354. }
  2355. return *v, true
  2356. }
  2357. // ClearStatus clears the value of the "status" field.
  2358. func (m *BatchMsgMutation) ClearStatus() {
  2359. m.status = nil
  2360. m.addstatus = nil
  2361. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  2362. }
  2363. // StatusCleared returns if the "status" field was cleared in this mutation.
  2364. func (m *BatchMsgMutation) StatusCleared() bool {
  2365. _, ok := m.clearedFields[batchmsg.FieldStatus]
  2366. return ok
  2367. }
  2368. // ResetStatus resets all changes to the "status" field.
  2369. func (m *BatchMsgMutation) ResetStatus() {
  2370. m.status = nil
  2371. m.addstatus = nil
  2372. delete(m.clearedFields, batchmsg.FieldStatus)
  2373. }
  2374. // SetBatchNo sets the "batch_no" field.
  2375. func (m *BatchMsgMutation) SetBatchNo(s string) {
  2376. m.batch_no = &s
  2377. }
  2378. // BatchNo returns the value of the "batch_no" field in the mutation.
  2379. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  2380. v := m.batch_no
  2381. if v == nil {
  2382. return
  2383. }
  2384. return *v, true
  2385. }
  2386. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  2387. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2389. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  2390. if !m.op.Is(OpUpdateOne) {
  2391. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  2392. }
  2393. if m.id == nil || m.oldValue == nil {
  2394. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  2395. }
  2396. oldValue, err := m.oldValue(ctx)
  2397. if err != nil {
  2398. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  2399. }
  2400. return oldValue.BatchNo, nil
  2401. }
  2402. // ClearBatchNo clears the value of the "batch_no" field.
  2403. func (m *BatchMsgMutation) ClearBatchNo() {
  2404. m.batch_no = nil
  2405. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  2406. }
  2407. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  2408. func (m *BatchMsgMutation) BatchNoCleared() bool {
  2409. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  2410. return ok
  2411. }
  2412. // ResetBatchNo resets all changes to the "batch_no" field.
  2413. func (m *BatchMsgMutation) ResetBatchNo() {
  2414. m.batch_no = nil
  2415. delete(m.clearedFields, batchmsg.FieldBatchNo)
  2416. }
  2417. // SetTaskName sets the "task_name" field.
  2418. func (m *BatchMsgMutation) SetTaskName(s string) {
  2419. m.task_name = &s
  2420. }
  2421. // TaskName returns the value of the "task_name" field in the mutation.
  2422. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  2423. v := m.task_name
  2424. if v == nil {
  2425. return
  2426. }
  2427. return *v, true
  2428. }
  2429. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  2430. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2432. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  2433. if !m.op.Is(OpUpdateOne) {
  2434. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  2435. }
  2436. if m.id == nil || m.oldValue == nil {
  2437. return v, errors.New("OldTaskName requires an ID field in the mutation")
  2438. }
  2439. oldValue, err := m.oldValue(ctx)
  2440. if err != nil {
  2441. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  2442. }
  2443. return oldValue.TaskName, nil
  2444. }
  2445. // ClearTaskName clears the value of the "task_name" field.
  2446. func (m *BatchMsgMutation) ClearTaskName() {
  2447. m.task_name = nil
  2448. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  2449. }
  2450. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  2451. func (m *BatchMsgMutation) TaskNameCleared() bool {
  2452. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  2453. return ok
  2454. }
  2455. // ResetTaskName resets all changes to the "task_name" field.
  2456. func (m *BatchMsgMutation) ResetTaskName() {
  2457. m.task_name = nil
  2458. delete(m.clearedFields, batchmsg.FieldTaskName)
  2459. }
  2460. // SetFromwxid sets the "fromwxid" field.
  2461. func (m *BatchMsgMutation) SetFromwxid(s string) {
  2462. m.fromwxid = &s
  2463. }
  2464. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  2465. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  2466. v := m.fromwxid
  2467. if v == nil {
  2468. return
  2469. }
  2470. return *v, true
  2471. }
  2472. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  2473. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2475. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  2476. if !m.op.Is(OpUpdateOne) {
  2477. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  2478. }
  2479. if m.id == nil || m.oldValue == nil {
  2480. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  2481. }
  2482. oldValue, err := m.oldValue(ctx)
  2483. if err != nil {
  2484. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  2485. }
  2486. return oldValue.Fromwxid, nil
  2487. }
  2488. // ClearFromwxid clears the value of the "fromwxid" field.
  2489. func (m *BatchMsgMutation) ClearFromwxid() {
  2490. m.fromwxid = nil
  2491. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  2492. }
  2493. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  2494. func (m *BatchMsgMutation) FromwxidCleared() bool {
  2495. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  2496. return ok
  2497. }
  2498. // ResetFromwxid resets all changes to the "fromwxid" field.
  2499. func (m *BatchMsgMutation) ResetFromwxid() {
  2500. m.fromwxid = nil
  2501. delete(m.clearedFields, batchmsg.FieldFromwxid)
  2502. }
  2503. // SetMsg sets the "msg" field.
  2504. func (m *BatchMsgMutation) SetMsg(s string) {
  2505. m.msg = &s
  2506. }
  2507. // Msg returns the value of the "msg" field in the mutation.
  2508. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  2509. v := m.msg
  2510. if v == nil {
  2511. return
  2512. }
  2513. return *v, true
  2514. }
  2515. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  2516. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2518. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  2519. if !m.op.Is(OpUpdateOne) {
  2520. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  2521. }
  2522. if m.id == nil || m.oldValue == nil {
  2523. return v, errors.New("OldMsg requires an ID field in the mutation")
  2524. }
  2525. oldValue, err := m.oldValue(ctx)
  2526. if err != nil {
  2527. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  2528. }
  2529. return oldValue.Msg, nil
  2530. }
  2531. // ClearMsg clears the value of the "msg" field.
  2532. func (m *BatchMsgMutation) ClearMsg() {
  2533. m.msg = nil
  2534. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  2535. }
  2536. // MsgCleared returns if the "msg" field was cleared in this mutation.
  2537. func (m *BatchMsgMutation) MsgCleared() bool {
  2538. _, ok := m.clearedFields[batchmsg.FieldMsg]
  2539. return ok
  2540. }
  2541. // ResetMsg resets all changes to the "msg" field.
  2542. func (m *BatchMsgMutation) ResetMsg() {
  2543. m.msg = nil
  2544. delete(m.clearedFields, batchmsg.FieldMsg)
  2545. }
  2546. // SetTag sets the "tag" field.
  2547. func (m *BatchMsgMutation) SetTag(s string) {
  2548. m.tag = &s
  2549. }
  2550. // Tag returns the value of the "tag" field in the mutation.
  2551. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  2552. v := m.tag
  2553. if v == nil {
  2554. return
  2555. }
  2556. return *v, true
  2557. }
  2558. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  2559. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2561. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  2562. if !m.op.Is(OpUpdateOne) {
  2563. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  2564. }
  2565. if m.id == nil || m.oldValue == nil {
  2566. return v, errors.New("OldTag requires an ID field in the mutation")
  2567. }
  2568. oldValue, err := m.oldValue(ctx)
  2569. if err != nil {
  2570. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  2571. }
  2572. return oldValue.Tag, nil
  2573. }
  2574. // ClearTag clears the value of the "tag" field.
  2575. func (m *BatchMsgMutation) ClearTag() {
  2576. m.tag = nil
  2577. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  2578. }
  2579. // TagCleared returns if the "tag" field was cleared in this mutation.
  2580. func (m *BatchMsgMutation) TagCleared() bool {
  2581. _, ok := m.clearedFields[batchmsg.FieldTag]
  2582. return ok
  2583. }
  2584. // ResetTag resets all changes to the "tag" field.
  2585. func (m *BatchMsgMutation) ResetTag() {
  2586. m.tag = nil
  2587. delete(m.clearedFields, batchmsg.FieldTag)
  2588. }
  2589. // SetTagids sets the "tagids" field.
  2590. func (m *BatchMsgMutation) SetTagids(s string) {
  2591. m.tagids = &s
  2592. }
  2593. // Tagids returns the value of the "tagids" field in the mutation.
  2594. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  2595. v := m.tagids
  2596. if v == nil {
  2597. return
  2598. }
  2599. return *v, true
  2600. }
  2601. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  2602. // If the BatchMsg 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 *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  2605. if !m.op.Is(OpUpdateOne) {
  2606. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  2607. }
  2608. if m.id == nil || m.oldValue == nil {
  2609. return v, errors.New("OldTagids 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 OldTagids: %w", err)
  2614. }
  2615. return oldValue.Tagids, nil
  2616. }
  2617. // ClearTagids clears the value of the "tagids" field.
  2618. func (m *BatchMsgMutation) ClearTagids() {
  2619. m.tagids = nil
  2620. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  2621. }
  2622. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  2623. func (m *BatchMsgMutation) TagidsCleared() bool {
  2624. _, ok := m.clearedFields[batchmsg.FieldTagids]
  2625. return ok
  2626. }
  2627. // ResetTagids resets all changes to the "tagids" field.
  2628. func (m *BatchMsgMutation) ResetTagids() {
  2629. m.tagids = nil
  2630. delete(m.clearedFields, batchmsg.FieldTagids)
  2631. }
  2632. // SetTotal sets the "total" field.
  2633. func (m *BatchMsgMutation) SetTotal(i int32) {
  2634. m.total = &i
  2635. m.addtotal = nil
  2636. }
  2637. // Total returns the value of the "total" field in the mutation.
  2638. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  2639. v := m.total
  2640. if v == nil {
  2641. return
  2642. }
  2643. return *v, true
  2644. }
  2645. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  2646. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2648. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  2649. if !m.op.Is(OpUpdateOne) {
  2650. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  2651. }
  2652. if m.id == nil || m.oldValue == nil {
  2653. return v, errors.New("OldTotal requires an ID field in the mutation")
  2654. }
  2655. oldValue, err := m.oldValue(ctx)
  2656. if err != nil {
  2657. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  2658. }
  2659. return oldValue.Total, nil
  2660. }
  2661. // AddTotal adds i to the "total" field.
  2662. func (m *BatchMsgMutation) AddTotal(i int32) {
  2663. if m.addtotal != nil {
  2664. *m.addtotal += i
  2665. } else {
  2666. m.addtotal = &i
  2667. }
  2668. }
  2669. // AddedTotal returns the value that was added to the "total" field in this mutation.
  2670. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  2671. v := m.addtotal
  2672. if v == nil {
  2673. return
  2674. }
  2675. return *v, true
  2676. }
  2677. // ClearTotal clears the value of the "total" field.
  2678. func (m *BatchMsgMutation) ClearTotal() {
  2679. m.total = nil
  2680. m.addtotal = nil
  2681. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  2682. }
  2683. // TotalCleared returns if the "total" field was cleared in this mutation.
  2684. func (m *BatchMsgMutation) TotalCleared() bool {
  2685. _, ok := m.clearedFields[batchmsg.FieldTotal]
  2686. return ok
  2687. }
  2688. // ResetTotal resets all changes to the "total" field.
  2689. func (m *BatchMsgMutation) ResetTotal() {
  2690. m.total = nil
  2691. m.addtotal = nil
  2692. delete(m.clearedFields, batchmsg.FieldTotal)
  2693. }
  2694. // SetSuccess sets the "success" field.
  2695. func (m *BatchMsgMutation) SetSuccess(i int32) {
  2696. m.success = &i
  2697. m.addsuccess = nil
  2698. }
  2699. // Success returns the value of the "success" field in the mutation.
  2700. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  2701. v := m.success
  2702. if v == nil {
  2703. return
  2704. }
  2705. return *v, true
  2706. }
  2707. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  2708. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2710. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  2711. if !m.op.Is(OpUpdateOne) {
  2712. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  2713. }
  2714. if m.id == nil || m.oldValue == nil {
  2715. return v, errors.New("OldSuccess requires an ID field in the mutation")
  2716. }
  2717. oldValue, err := m.oldValue(ctx)
  2718. if err != nil {
  2719. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  2720. }
  2721. return oldValue.Success, nil
  2722. }
  2723. // AddSuccess adds i to the "success" field.
  2724. func (m *BatchMsgMutation) AddSuccess(i int32) {
  2725. if m.addsuccess != nil {
  2726. *m.addsuccess += i
  2727. } else {
  2728. m.addsuccess = &i
  2729. }
  2730. }
  2731. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  2732. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  2733. v := m.addsuccess
  2734. if v == nil {
  2735. return
  2736. }
  2737. return *v, true
  2738. }
  2739. // ClearSuccess clears the value of the "success" field.
  2740. func (m *BatchMsgMutation) ClearSuccess() {
  2741. m.success = nil
  2742. m.addsuccess = nil
  2743. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  2744. }
  2745. // SuccessCleared returns if the "success" field was cleared in this mutation.
  2746. func (m *BatchMsgMutation) SuccessCleared() bool {
  2747. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  2748. return ok
  2749. }
  2750. // ResetSuccess resets all changes to the "success" field.
  2751. func (m *BatchMsgMutation) ResetSuccess() {
  2752. m.success = nil
  2753. m.addsuccess = nil
  2754. delete(m.clearedFields, batchmsg.FieldSuccess)
  2755. }
  2756. // SetFail sets the "fail" field.
  2757. func (m *BatchMsgMutation) SetFail(i int32) {
  2758. m.fail = &i
  2759. m.addfail = nil
  2760. }
  2761. // Fail returns the value of the "fail" field in the mutation.
  2762. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  2763. v := m.fail
  2764. if v == nil {
  2765. return
  2766. }
  2767. return *v, true
  2768. }
  2769. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  2770. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2772. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  2773. if !m.op.Is(OpUpdateOne) {
  2774. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  2775. }
  2776. if m.id == nil || m.oldValue == nil {
  2777. return v, errors.New("OldFail requires an ID field in the mutation")
  2778. }
  2779. oldValue, err := m.oldValue(ctx)
  2780. if err != nil {
  2781. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  2782. }
  2783. return oldValue.Fail, nil
  2784. }
  2785. // AddFail adds i to the "fail" field.
  2786. func (m *BatchMsgMutation) AddFail(i int32) {
  2787. if m.addfail != nil {
  2788. *m.addfail += i
  2789. } else {
  2790. m.addfail = &i
  2791. }
  2792. }
  2793. // AddedFail returns the value that was added to the "fail" field in this mutation.
  2794. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  2795. v := m.addfail
  2796. if v == nil {
  2797. return
  2798. }
  2799. return *v, true
  2800. }
  2801. // ClearFail clears the value of the "fail" field.
  2802. func (m *BatchMsgMutation) ClearFail() {
  2803. m.fail = nil
  2804. m.addfail = nil
  2805. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  2806. }
  2807. // FailCleared returns if the "fail" field was cleared in this mutation.
  2808. func (m *BatchMsgMutation) FailCleared() bool {
  2809. _, ok := m.clearedFields[batchmsg.FieldFail]
  2810. return ok
  2811. }
  2812. // ResetFail resets all changes to the "fail" field.
  2813. func (m *BatchMsgMutation) ResetFail() {
  2814. m.fail = nil
  2815. m.addfail = nil
  2816. delete(m.clearedFields, batchmsg.FieldFail)
  2817. }
  2818. // SetStartTime sets the "start_time" field.
  2819. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  2820. m.start_time = &t
  2821. }
  2822. // StartTime returns the value of the "start_time" field in the mutation.
  2823. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  2824. v := m.start_time
  2825. if v == nil {
  2826. return
  2827. }
  2828. return *v, true
  2829. }
  2830. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  2831. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2833. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  2834. if !m.op.Is(OpUpdateOne) {
  2835. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  2836. }
  2837. if m.id == nil || m.oldValue == nil {
  2838. return v, errors.New("OldStartTime requires an ID field in the mutation")
  2839. }
  2840. oldValue, err := m.oldValue(ctx)
  2841. if err != nil {
  2842. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  2843. }
  2844. return oldValue.StartTime, nil
  2845. }
  2846. // ClearStartTime clears the value of the "start_time" field.
  2847. func (m *BatchMsgMutation) ClearStartTime() {
  2848. m.start_time = nil
  2849. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  2850. }
  2851. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  2852. func (m *BatchMsgMutation) StartTimeCleared() bool {
  2853. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  2854. return ok
  2855. }
  2856. // ResetStartTime resets all changes to the "start_time" field.
  2857. func (m *BatchMsgMutation) ResetStartTime() {
  2858. m.start_time = nil
  2859. delete(m.clearedFields, batchmsg.FieldStartTime)
  2860. }
  2861. // SetStopTime sets the "stop_time" field.
  2862. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  2863. m.stop_time = &t
  2864. }
  2865. // StopTime returns the value of the "stop_time" field in the mutation.
  2866. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  2867. v := m.stop_time
  2868. if v == nil {
  2869. return
  2870. }
  2871. return *v, true
  2872. }
  2873. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  2874. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2876. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  2877. if !m.op.Is(OpUpdateOne) {
  2878. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  2879. }
  2880. if m.id == nil || m.oldValue == nil {
  2881. return v, errors.New("OldStopTime requires an ID field in the mutation")
  2882. }
  2883. oldValue, err := m.oldValue(ctx)
  2884. if err != nil {
  2885. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  2886. }
  2887. return oldValue.StopTime, nil
  2888. }
  2889. // ClearStopTime clears the value of the "stop_time" field.
  2890. func (m *BatchMsgMutation) ClearStopTime() {
  2891. m.stop_time = nil
  2892. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  2893. }
  2894. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  2895. func (m *BatchMsgMutation) StopTimeCleared() bool {
  2896. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  2897. return ok
  2898. }
  2899. // ResetStopTime resets all changes to the "stop_time" field.
  2900. func (m *BatchMsgMutation) ResetStopTime() {
  2901. m.stop_time = nil
  2902. delete(m.clearedFields, batchmsg.FieldStopTime)
  2903. }
  2904. // SetSendTime sets the "send_time" field.
  2905. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  2906. m.send_time = &t
  2907. }
  2908. // SendTime returns the value of the "send_time" field in the mutation.
  2909. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  2910. v := m.send_time
  2911. if v == nil {
  2912. return
  2913. }
  2914. return *v, true
  2915. }
  2916. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  2917. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2919. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  2920. if !m.op.Is(OpUpdateOne) {
  2921. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  2922. }
  2923. if m.id == nil || m.oldValue == nil {
  2924. return v, errors.New("OldSendTime requires an ID field in the mutation")
  2925. }
  2926. oldValue, err := m.oldValue(ctx)
  2927. if err != nil {
  2928. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  2929. }
  2930. return oldValue.SendTime, nil
  2931. }
  2932. // ClearSendTime clears the value of the "send_time" field.
  2933. func (m *BatchMsgMutation) ClearSendTime() {
  2934. m.send_time = nil
  2935. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  2936. }
  2937. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  2938. func (m *BatchMsgMutation) SendTimeCleared() bool {
  2939. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  2940. return ok
  2941. }
  2942. // ResetSendTime resets all changes to the "send_time" field.
  2943. func (m *BatchMsgMutation) ResetSendTime() {
  2944. m.send_time = nil
  2945. delete(m.clearedFields, batchmsg.FieldSendTime)
  2946. }
  2947. // SetType sets the "type" field.
  2948. func (m *BatchMsgMutation) SetType(i int32) {
  2949. m._type = &i
  2950. m.add_type = nil
  2951. }
  2952. // GetType returns the value of the "type" field in the mutation.
  2953. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  2954. v := m._type
  2955. if v == nil {
  2956. return
  2957. }
  2958. return *v, true
  2959. }
  2960. // OldType returns the old "type" field's value of the BatchMsg entity.
  2961. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  2962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2963. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  2964. if !m.op.Is(OpUpdateOne) {
  2965. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2966. }
  2967. if m.id == nil || m.oldValue == nil {
  2968. return v, errors.New("OldType requires an ID field in the mutation")
  2969. }
  2970. oldValue, err := m.oldValue(ctx)
  2971. if err != nil {
  2972. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2973. }
  2974. return oldValue.Type, nil
  2975. }
  2976. // AddType adds i to the "type" field.
  2977. func (m *BatchMsgMutation) AddType(i int32) {
  2978. if m.add_type != nil {
  2979. *m.add_type += i
  2980. } else {
  2981. m.add_type = &i
  2982. }
  2983. }
  2984. // AddedType returns the value that was added to the "type" field in this mutation.
  2985. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  2986. v := m.add_type
  2987. if v == nil {
  2988. return
  2989. }
  2990. return *v, true
  2991. }
  2992. // ClearType clears the value of the "type" field.
  2993. func (m *BatchMsgMutation) ClearType() {
  2994. m._type = nil
  2995. m.add_type = nil
  2996. m.clearedFields[batchmsg.FieldType] = struct{}{}
  2997. }
  2998. // TypeCleared returns if the "type" field was cleared in this mutation.
  2999. func (m *BatchMsgMutation) TypeCleared() bool {
  3000. _, ok := m.clearedFields[batchmsg.FieldType]
  3001. return ok
  3002. }
  3003. // ResetType resets all changes to the "type" field.
  3004. func (m *BatchMsgMutation) ResetType() {
  3005. m._type = nil
  3006. m.add_type = nil
  3007. delete(m.clearedFields, batchmsg.FieldType)
  3008. }
  3009. // SetOrganizationID sets the "organization_id" field.
  3010. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  3011. m.organization_id = &u
  3012. m.addorganization_id = nil
  3013. }
  3014. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3015. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  3016. v := m.organization_id
  3017. if v == nil {
  3018. return
  3019. }
  3020. return *v, true
  3021. }
  3022. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  3023. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3025. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3026. if !m.op.Is(OpUpdateOne) {
  3027. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3028. }
  3029. if m.id == nil || m.oldValue == nil {
  3030. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3031. }
  3032. oldValue, err := m.oldValue(ctx)
  3033. if err != nil {
  3034. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3035. }
  3036. return oldValue.OrganizationID, nil
  3037. }
  3038. // AddOrganizationID adds u to the "organization_id" field.
  3039. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  3040. if m.addorganization_id != nil {
  3041. *m.addorganization_id += u
  3042. } else {
  3043. m.addorganization_id = &u
  3044. }
  3045. }
  3046. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3047. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  3048. v := m.addorganization_id
  3049. if v == nil {
  3050. return
  3051. }
  3052. return *v, true
  3053. }
  3054. // ResetOrganizationID resets all changes to the "organization_id" field.
  3055. func (m *BatchMsgMutation) ResetOrganizationID() {
  3056. m.organization_id = nil
  3057. m.addorganization_id = nil
  3058. }
  3059. // Where appends a list predicates to the BatchMsgMutation builder.
  3060. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  3061. m.predicates = append(m.predicates, ps...)
  3062. }
  3063. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  3064. // users can use type-assertion to append predicates that do not depend on any generated package.
  3065. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  3066. p := make([]predicate.BatchMsg, len(ps))
  3067. for i := range ps {
  3068. p[i] = ps[i]
  3069. }
  3070. m.Where(p...)
  3071. }
  3072. // Op returns the operation name.
  3073. func (m *BatchMsgMutation) Op() Op {
  3074. return m.op
  3075. }
  3076. // SetOp allows setting the mutation operation.
  3077. func (m *BatchMsgMutation) SetOp(op Op) {
  3078. m.op = op
  3079. }
  3080. // Type returns the node type of this mutation (BatchMsg).
  3081. func (m *BatchMsgMutation) Type() string {
  3082. return m.typ
  3083. }
  3084. // Fields returns all fields that were changed during this mutation. Note that in
  3085. // order to get all numeric fields that were incremented/decremented, call
  3086. // AddedFields().
  3087. func (m *BatchMsgMutation) Fields() []string {
  3088. fields := make([]string, 0, 18)
  3089. if m.created_at != nil {
  3090. fields = append(fields, batchmsg.FieldCreatedAt)
  3091. }
  3092. if m.updated_at != nil {
  3093. fields = append(fields, batchmsg.FieldUpdatedAt)
  3094. }
  3095. if m.deleted_at != nil {
  3096. fields = append(fields, batchmsg.FieldDeletedAt)
  3097. }
  3098. if m.status != nil {
  3099. fields = append(fields, batchmsg.FieldStatus)
  3100. }
  3101. if m.batch_no != nil {
  3102. fields = append(fields, batchmsg.FieldBatchNo)
  3103. }
  3104. if m.task_name != nil {
  3105. fields = append(fields, batchmsg.FieldTaskName)
  3106. }
  3107. if m.fromwxid != nil {
  3108. fields = append(fields, batchmsg.FieldFromwxid)
  3109. }
  3110. if m.msg != nil {
  3111. fields = append(fields, batchmsg.FieldMsg)
  3112. }
  3113. if m.tag != nil {
  3114. fields = append(fields, batchmsg.FieldTag)
  3115. }
  3116. if m.tagids != nil {
  3117. fields = append(fields, batchmsg.FieldTagids)
  3118. }
  3119. if m.total != nil {
  3120. fields = append(fields, batchmsg.FieldTotal)
  3121. }
  3122. if m.success != nil {
  3123. fields = append(fields, batchmsg.FieldSuccess)
  3124. }
  3125. if m.fail != nil {
  3126. fields = append(fields, batchmsg.FieldFail)
  3127. }
  3128. if m.start_time != nil {
  3129. fields = append(fields, batchmsg.FieldStartTime)
  3130. }
  3131. if m.stop_time != nil {
  3132. fields = append(fields, batchmsg.FieldStopTime)
  3133. }
  3134. if m.send_time != nil {
  3135. fields = append(fields, batchmsg.FieldSendTime)
  3136. }
  3137. if m._type != nil {
  3138. fields = append(fields, batchmsg.FieldType)
  3139. }
  3140. if m.organization_id != nil {
  3141. fields = append(fields, batchmsg.FieldOrganizationID)
  3142. }
  3143. return fields
  3144. }
  3145. // Field returns the value of a field with the given name. The second boolean
  3146. // return value indicates that this field was not set, or was not defined in the
  3147. // schema.
  3148. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  3149. switch name {
  3150. case batchmsg.FieldCreatedAt:
  3151. return m.CreatedAt()
  3152. case batchmsg.FieldUpdatedAt:
  3153. return m.UpdatedAt()
  3154. case batchmsg.FieldDeletedAt:
  3155. return m.DeletedAt()
  3156. case batchmsg.FieldStatus:
  3157. return m.Status()
  3158. case batchmsg.FieldBatchNo:
  3159. return m.BatchNo()
  3160. case batchmsg.FieldTaskName:
  3161. return m.TaskName()
  3162. case batchmsg.FieldFromwxid:
  3163. return m.Fromwxid()
  3164. case batchmsg.FieldMsg:
  3165. return m.Msg()
  3166. case batchmsg.FieldTag:
  3167. return m.Tag()
  3168. case batchmsg.FieldTagids:
  3169. return m.Tagids()
  3170. case batchmsg.FieldTotal:
  3171. return m.Total()
  3172. case batchmsg.FieldSuccess:
  3173. return m.Success()
  3174. case batchmsg.FieldFail:
  3175. return m.Fail()
  3176. case batchmsg.FieldStartTime:
  3177. return m.StartTime()
  3178. case batchmsg.FieldStopTime:
  3179. return m.StopTime()
  3180. case batchmsg.FieldSendTime:
  3181. return m.SendTime()
  3182. case batchmsg.FieldType:
  3183. return m.GetType()
  3184. case batchmsg.FieldOrganizationID:
  3185. return m.OrganizationID()
  3186. }
  3187. return nil, false
  3188. }
  3189. // OldField returns the old value of the field from the database. An error is
  3190. // returned if the mutation operation is not UpdateOne, or the query to the
  3191. // database failed.
  3192. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3193. switch name {
  3194. case batchmsg.FieldCreatedAt:
  3195. return m.OldCreatedAt(ctx)
  3196. case batchmsg.FieldUpdatedAt:
  3197. return m.OldUpdatedAt(ctx)
  3198. case batchmsg.FieldDeletedAt:
  3199. return m.OldDeletedAt(ctx)
  3200. case batchmsg.FieldStatus:
  3201. return m.OldStatus(ctx)
  3202. case batchmsg.FieldBatchNo:
  3203. return m.OldBatchNo(ctx)
  3204. case batchmsg.FieldTaskName:
  3205. return m.OldTaskName(ctx)
  3206. case batchmsg.FieldFromwxid:
  3207. return m.OldFromwxid(ctx)
  3208. case batchmsg.FieldMsg:
  3209. return m.OldMsg(ctx)
  3210. case batchmsg.FieldTag:
  3211. return m.OldTag(ctx)
  3212. case batchmsg.FieldTagids:
  3213. return m.OldTagids(ctx)
  3214. case batchmsg.FieldTotal:
  3215. return m.OldTotal(ctx)
  3216. case batchmsg.FieldSuccess:
  3217. return m.OldSuccess(ctx)
  3218. case batchmsg.FieldFail:
  3219. return m.OldFail(ctx)
  3220. case batchmsg.FieldStartTime:
  3221. return m.OldStartTime(ctx)
  3222. case batchmsg.FieldStopTime:
  3223. return m.OldStopTime(ctx)
  3224. case batchmsg.FieldSendTime:
  3225. return m.OldSendTime(ctx)
  3226. case batchmsg.FieldType:
  3227. return m.OldType(ctx)
  3228. case batchmsg.FieldOrganizationID:
  3229. return m.OldOrganizationID(ctx)
  3230. }
  3231. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  3232. }
  3233. // SetField sets the value of a field with the given name. It returns an error if
  3234. // the field is not defined in the schema, or if the type mismatched the field
  3235. // type.
  3236. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  3237. switch name {
  3238. case batchmsg.FieldCreatedAt:
  3239. v, ok := value.(time.Time)
  3240. if !ok {
  3241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3242. }
  3243. m.SetCreatedAt(v)
  3244. return nil
  3245. case batchmsg.FieldUpdatedAt:
  3246. v, ok := value.(time.Time)
  3247. if !ok {
  3248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3249. }
  3250. m.SetUpdatedAt(v)
  3251. return nil
  3252. case batchmsg.FieldDeletedAt:
  3253. v, ok := value.(time.Time)
  3254. if !ok {
  3255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3256. }
  3257. m.SetDeletedAt(v)
  3258. return nil
  3259. case batchmsg.FieldStatus:
  3260. v, ok := value.(uint8)
  3261. if !ok {
  3262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3263. }
  3264. m.SetStatus(v)
  3265. return nil
  3266. case batchmsg.FieldBatchNo:
  3267. v, ok := value.(string)
  3268. if !ok {
  3269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3270. }
  3271. m.SetBatchNo(v)
  3272. return nil
  3273. case batchmsg.FieldTaskName:
  3274. v, ok := value.(string)
  3275. if !ok {
  3276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3277. }
  3278. m.SetTaskName(v)
  3279. return nil
  3280. case batchmsg.FieldFromwxid:
  3281. v, ok := value.(string)
  3282. if !ok {
  3283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3284. }
  3285. m.SetFromwxid(v)
  3286. return nil
  3287. case batchmsg.FieldMsg:
  3288. v, ok := value.(string)
  3289. if !ok {
  3290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3291. }
  3292. m.SetMsg(v)
  3293. return nil
  3294. case batchmsg.FieldTag:
  3295. v, ok := value.(string)
  3296. if !ok {
  3297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3298. }
  3299. m.SetTag(v)
  3300. return nil
  3301. case batchmsg.FieldTagids:
  3302. v, ok := value.(string)
  3303. if !ok {
  3304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3305. }
  3306. m.SetTagids(v)
  3307. return nil
  3308. case batchmsg.FieldTotal:
  3309. v, ok := value.(int32)
  3310. if !ok {
  3311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3312. }
  3313. m.SetTotal(v)
  3314. return nil
  3315. case batchmsg.FieldSuccess:
  3316. v, ok := value.(int32)
  3317. if !ok {
  3318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3319. }
  3320. m.SetSuccess(v)
  3321. return nil
  3322. case batchmsg.FieldFail:
  3323. v, ok := value.(int32)
  3324. if !ok {
  3325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3326. }
  3327. m.SetFail(v)
  3328. return nil
  3329. case batchmsg.FieldStartTime:
  3330. v, ok := value.(time.Time)
  3331. if !ok {
  3332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3333. }
  3334. m.SetStartTime(v)
  3335. return nil
  3336. case batchmsg.FieldStopTime:
  3337. v, ok := value.(time.Time)
  3338. if !ok {
  3339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3340. }
  3341. m.SetStopTime(v)
  3342. return nil
  3343. case batchmsg.FieldSendTime:
  3344. v, ok := value.(time.Time)
  3345. if !ok {
  3346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3347. }
  3348. m.SetSendTime(v)
  3349. return nil
  3350. case batchmsg.FieldType:
  3351. v, ok := value.(int32)
  3352. if !ok {
  3353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3354. }
  3355. m.SetType(v)
  3356. return nil
  3357. case batchmsg.FieldOrganizationID:
  3358. v, ok := value.(uint64)
  3359. if !ok {
  3360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3361. }
  3362. m.SetOrganizationID(v)
  3363. return nil
  3364. }
  3365. return fmt.Errorf("unknown BatchMsg field %s", name)
  3366. }
  3367. // AddedFields returns all numeric fields that were incremented/decremented during
  3368. // this mutation.
  3369. func (m *BatchMsgMutation) AddedFields() []string {
  3370. var fields []string
  3371. if m.addstatus != nil {
  3372. fields = append(fields, batchmsg.FieldStatus)
  3373. }
  3374. if m.addtotal != nil {
  3375. fields = append(fields, batchmsg.FieldTotal)
  3376. }
  3377. if m.addsuccess != nil {
  3378. fields = append(fields, batchmsg.FieldSuccess)
  3379. }
  3380. if m.addfail != nil {
  3381. fields = append(fields, batchmsg.FieldFail)
  3382. }
  3383. if m.add_type != nil {
  3384. fields = append(fields, batchmsg.FieldType)
  3385. }
  3386. if m.addorganization_id != nil {
  3387. fields = append(fields, batchmsg.FieldOrganizationID)
  3388. }
  3389. return fields
  3390. }
  3391. // AddedField returns the numeric value that was incremented/decremented on a field
  3392. // with the given name. The second boolean return value indicates that this field
  3393. // was not set, or was not defined in the schema.
  3394. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  3395. switch name {
  3396. case batchmsg.FieldStatus:
  3397. return m.AddedStatus()
  3398. case batchmsg.FieldTotal:
  3399. return m.AddedTotal()
  3400. case batchmsg.FieldSuccess:
  3401. return m.AddedSuccess()
  3402. case batchmsg.FieldFail:
  3403. return m.AddedFail()
  3404. case batchmsg.FieldType:
  3405. return m.AddedType()
  3406. case batchmsg.FieldOrganizationID:
  3407. return m.AddedOrganizationID()
  3408. }
  3409. return nil, false
  3410. }
  3411. // AddField adds the value to the field with the given name. It returns an error if
  3412. // the field is not defined in the schema, or if the type mismatched the field
  3413. // type.
  3414. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  3415. switch name {
  3416. case batchmsg.FieldStatus:
  3417. v, ok := value.(int8)
  3418. if !ok {
  3419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3420. }
  3421. m.AddStatus(v)
  3422. return nil
  3423. case batchmsg.FieldTotal:
  3424. v, ok := value.(int32)
  3425. if !ok {
  3426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3427. }
  3428. m.AddTotal(v)
  3429. return nil
  3430. case batchmsg.FieldSuccess:
  3431. v, ok := value.(int32)
  3432. if !ok {
  3433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3434. }
  3435. m.AddSuccess(v)
  3436. return nil
  3437. case batchmsg.FieldFail:
  3438. v, ok := value.(int32)
  3439. if !ok {
  3440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3441. }
  3442. m.AddFail(v)
  3443. return nil
  3444. case batchmsg.FieldType:
  3445. v, ok := value.(int32)
  3446. if !ok {
  3447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3448. }
  3449. m.AddType(v)
  3450. return nil
  3451. case batchmsg.FieldOrganizationID:
  3452. v, ok := value.(int64)
  3453. if !ok {
  3454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3455. }
  3456. m.AddOrganizationID(v)
  3457. return nil
  3458. }
  3459. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  3460. }
  3461. // ClearedFields returns all nullable fields that were cleared during this
  3462. // mutation.
  3463. func (m *BatchMsgMutation) ClearedFields() []string {
  3464. var fields []string
  3465. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  3466. fields = append(fields, batchmsg.FieldDeletedAt)
  3467. }
  3468. if m.FieldCleared(batchmsg.FieldStatus) {
  3469. fields = append(fields, batchmsg.FieldStatus)
  3470. }
  3471. if m.FieldCleared(batchmsg.FieldBatchNo) {
  3472. fields = append(fields, batchmsg.FieldBatchNo)
  3473. }
  3474. if m.FieldCleared(batchmsg.FieldTaskName) {
  3475. fields = append(fields, batchmsg.FieldTaskName)
  3476. }
  3477. if m.FieldCleared(batchmsg.FieldFromwxid) {
  3478. fields = append(fields, batchmsg.FieldFromwxid)
  3479. }
  3480. if m.FieldCleared(batchmsg.FieldMsg) {
  3481. fields = append(fields, batchmsg.FieldMsg)
  3482. }
  3483. if m.FieldCleared(batchmsg.FieldTag) {
  3484. fields = append(fields, batchmsg.FieldTag)
  3485. }
  3486. if m.FieldCleared(batchmsg.FieldTagids) {
  3487. fields = append(fields, batchmsg.FieldTagids)
  3488. }
  3489. if m.FieldCleared(batchmsg.FieldTotal) {
  3490. fields = append(fields, batchmsg.FieldTotal)
  3491. }
  3492. if m.FieldCleared(batchmsg.FieldSuccess) {
  3493. fields = append(fields, batchmsg.FieldSuccess)
  3494. }
  3495. if m.FieldCleared(batchmsg.FieldFail) {
  3496. fields = append(fields, batchmsg.FieldFail)
  3497. }
  3498. if m.FieldCleared(batchmsg.FieldStartTime) {
  3499. fields = append(fields, batchmsg.FieldStartTime)
  3500. }
  3501. if m.FieldCleared(batchmsg.FieldStopTime) {
  3502. fields = append(fields, batchmsg.FieldStopTime)
  3503. }
  3504. if m.FieldCleared(batchmsg.FieldSendTime) {
  3505. fields = append(fields, batchmsg.FieldSendTime)
  3506. }
  3507. if m.FieldCleared(batchmsg.FieldType) {
  3508. fields = append(fields, batchmsg.FieldType)
  3509. }
  3510. return fields
  3511. }
  3512. // FieldCleared returns a boolean indicating if a field with the given name was
  3513. // cleared in this mutation.
  3514. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  3515. _, ok := m.clearedFields[name]
  3516. return ok
  3517. }
  3518. // ClearField clears the value of the field with the given name. It returns an
  3519. // error if the field is not defined in the schema.
  3520. func (m *BatchMsgMutation) ClearField(name string) error {
  3521. switch name {
  3522. case batchmsg.FieldDeletedAt:
  3523. m.ClearDeletedAt()
  3524. return nil
  3525. case batchmsg.FieldStatus:
  3526. m.ClearStatus()
  3527. return nil
  3528. case batchmsg.FieldBatchNo:
  3529. m.ClearBatchNo()
  3530. return nil
  3531. case batchmsg.FieldTaskName:
  3532. m.ClearTaskName()
  3533. return nil
  3534. case batchmsg.FieldFromwxid:
  3535. m.ClearFromwxid()
  3536. return nil
  3537. case batchmsg.FieldMsg:
  3538. m.ClearMsg()
  3539. return nil
  3540. case batchmsg.FieldTag:
  3541. m.ClearTag()
  3542. return nil
  3543. case batchmsg.FieldTagids:
  3544. m.ClearTagids()
  3545. return nil
  3546. case batchmsg.FieldTotal:
  3547. m.ClearTotal()
  3548. return nil
  3549. case batchmsg.FieldSuccess:
  3550. m.ClearSuccess()
  3551. return nil
  3552. case batchmsg.FieldFail:
  3553. m.ClearFail()
  3554. return nil
  3555. case batchmsg.FieldStartTime:
  3556. m.ClearStartTime()
  3557. return nil
  3558. case batchmsg.FieldStopTime:
  3559. m.ClearStopTime()
  3560. return nil
  3561. case batchmsg.FieldSendTime:
  3562. m.ClearSendTime()
  3563. return nil
  3564. case batchmsg.FieldType:
  3565. m.ClearType()
  3566. return nil
  3567. }
  3568. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  3569. }
  3570. // ResetField resets all changes in the mutation for the field with the given name.
  3571. // It returns an error if the field is not defined in the schema.
  3572. func (m *BatchMsgMutation) ResetField(name string) error {
  3573. switch name {
  3574. case batchmsg.FieldCreatedAt:
  3575. m.ResetCreatedAt()
  3576. return nil
  3577. case batchmsg.FieldUpdatedAt:
  3578. m.ResetUpdatedAt()
  3579. return nil
  3580. case batchmsg.FieldDeletedAt:
  3581. m.ResetDeletedAt()
  3582. return nil
  3583. case batchmsg.FieldStatus:
  3584. m.ResetStatus()
  3585. return nil
  3586. case batchmsg.FieldBatchNo:
  3587. m.ResetBatchNo()
  3588. return nil
  3589. case batchmsg.FieldTaskName:
  3590. m.ResetTaskName()
  3591. return nil
  3592. case batchmsg.FieldFromwxid:
  3593. m.ResetFromwxid()
  3594. return nil
  3595. case batchmsg.FieldMsg:
  3596. m.ResetMsg()
  3597. return nil
  3598. case batchmsg.FieldTag:
  3599. m.ResetTag()
  3600. return nil
  3601. case batchmsg.FieldTagids:
  3602. m.ResetTagids()
  3603. return nil
  3604. case batchmsg.FieldTotal:
  3605. m.ResetTotal()
  3606. return nil
  3607. case batchmsg.FieldSuccess:
  3608. m.ResetSuccess()
  3609. return nil
  3610. case batchmsg.FieldFail:
  3611. m.ResetFail()
  3612. return nil
  3613. case batchmsg.FieldStartTime:
  3614. m.ResetStartTime()
  3615. return nil
  3616. case batchmsg.FieldStopTime:
  3617. m.ResetStopTime()
  3618. return nil
  3619. case batchmsg.FieldSendTime:
  3620. m.ResetSendTime()
  3621. return nil
  3622. case batchmsg.FieldType:
  3623. m.ResetType()
  3624. return nil
  3625. case batchmsg.FieldOrganizationID:
  3626. m.ResetOrganizationID()
  3627. return nil
  3628. }
  3629. return fmt.Errorf("unknown BatchMsg field %s", name)
  3630. }
  3631. // AddedEdges returns all edge names that were set/added in this mutation.
  3632. func (m *BatchMsgMutation) AddedEdges() []string {
  3633. edges := make([]string, 0, 0)
  3634. return edges
  3635. }
  3636. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3637. // name in this mutation.
  3638. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  3639. return nil
  3640. }
  3641. // RemovedEdges returns all edge names that were removed in this mutation.
  3642. func (m *BatchMsgMutation) RemovedEdges() []string {
  3643. edges := make([]string, 0, 0)
  3644. return edges
  3645. }
  3646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3647. // the given name in this mutation.
  3648. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  3649. return nil
  3650. }
  3651. // ClearedEdges returns all edge names that were cleared in this mutation.
  3652. func (m *BatchMsgMutation) ClearedEdges() []string {
  3653. edges := make([]string, 0, 0)
  3654. return edges
  3655. }
  3656. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3657. // was cleared in this mutation.
  3658. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  3659. return false
  3660. }
  3661. // ClearEdge clears the value of the edge with the given name. It returns an error
  3662. // if that edge is not defined in the schema.
  3663. func (m *BatchMsgMutation) ClearEdge(name string) error {
  3664. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  3665. }
  3666. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3667. // It returns an error if the edge is not defined in the schema.
  3668. func (m *BatchMsgMutation) ResetEdge(name string) error {
  3669. return fmt.Errorf("unknown BatchMsg edge %s", name)
  3670. }
  3671. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  3672. type CategoryMutation struct {
  3673. config
  3674. op Op
  3675. typ string
  3676. id *uint64
  3677. created_at *time.Time
  3678. updated_at *time.Time
  3679. deleted_at *time.Time
  3680. name *string
  3681. organization_id *uint64
  3682. addorganization_id *int64
  3683. clearedFields map[string]struct{}
  3684. done bool
  3685. oldValue func(context.Context) (*Category, error)
  3686. predicates []predicate.Category
  3687. }
  3688. var _ ent.Mutation = (*CategoryMutation)(nil)
  3689. // categoryOption allows management of the mutation configuration using functional options.
  3690. type categoryOption func(*CategoryMutation)
  3691. // newCategoryMutation creates new mutation for the Category entity.
  3692. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  3693. m := &CategoryMutation{
  3694. config: c,
  3695. op: op,
  3696. typ: TypeCategory,
  3697. clearedFields: make(map[string]struct{}),
  3698. }
  3699. for _, opt := range opts {
  3700. opt(m)
  3701. }
  3702. return m
  3703. }
  3704. // withCategoryID sets the ID field of the mutation.
  3705. func withCategoryID(id uint64) categoryOption {
  3706. return func(m *CategoryMutation) {
  3707. var (
  3708. err error
  3709. once sync.Once
  3710. value *Category
  3711. )
  3712. m.oldValue = func(ctx context.Context) (*Category, error) {
  3713. once.Do(func() {
  3714. if m.done {
  3715. err = errors.New("querying old values post mutation is not allowed")
  3716. } else {
  3717. value, err = m.Client().Category.Get(ctx, id)
  3718. }
  3719. })
  3720. return value, err
  3721. }
  3722. m.id = &id
  3723. }
  3724. }
  3725. // withCategory sets the old Category of the mutation.
  3726. func withCategory(node *Category) categoryOption {
  3727. return func(m *CategoryMutation) {
  3728. m.oldValue = func(context.Context) (*Category, error) {
  3729. return node, nil
  3730. }
  3731. m.id = &node.ID
  3732. }
  3733. }
  3734. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3735. // executed in a transaction (ent.Tx), a transactional client is returned.
  3736. func (m CategoryMutation) Client() *Client {
  3737. client := &Client{config: m.config}
  3738. client.init()
  3739. return client
  3740. }
  3741. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3742. // it returns an error otherwise.
  3743. func (m CategoryMutation) Tx() (*Tx, error) {
  3744. if _, ok := m.driver.(*txDriver); !ok {
  3745. return nil, errors.New("ent: mutation is not running in a transaction")
  3746. }
  3747. tx := &Tx{config: m.config}
  3748. tx.init()
  3749. return tx, nil
  3750. }
  3751. // SetID sets the value of the id field. Note that this
  3752. // operation is only accepted on creation of Category entities.
  3753. func (m *CategoryMutation) SetID(id uint64) {
  3754. m.id = &id
  3755. }
  3756. // ID returns the ID value in the mutation. Note that the ID is only available
  3757. // if it was provided to the builder or after it was returned from the database.
  3758. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  3759. if m.id == nil {
  3760. return
  3761. }
  3762. return *m.id, true
  3763. }
  3764. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3765. // That means, if the mutation is applied within a transaction with an isolation level such
  3766. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3767. // or updated by the mutation.
  3768. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  3769. switch {
  3770. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3771. id, exists := m.ID()
  3772. if exists {
  3773. return []uint64{id}, nil
  3774. }
  3775. fallthrough
  3776. case m.op.Is(OpUpdate | OpDelete):
  3777. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  3778. default:
  3779. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3780. }
  3781. }
  3782. // SetCreatedAt sets the "created_at" field.
  3783. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  3784. m.created_at = &t
  3785. }
  3786. // CreatedAt returns the value of the "created_at" field in the mutation.
  3787. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  3788. v := m.created_at
  3789. if v == nil {
  3790. return
  3791. }
  3792. return *v, true
  3793. }
  3794. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  3795. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3797. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3798. if !m.op.Is(OpUpdateOne) {
  3799. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3800. }
  3801. if m.id == nil || m.oldValue == nil {
  3802. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3803. }
  3804. oldValue, err := m.oldValue(ctx)
  3805. if err != nil {
  3806. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3807. }
  3808. return oldValue.CreatedAt, nil
  3809. }
  3810. // ResetCreatedAt resets all changes to the "created_at" field.
  3811. func (m *CategoryMutation) ResetCreatedAt() {
  3812. m.created_at = nil
  3813. }
  3814. // SetUpdatedAt sets the "updated_at" field.
  3815. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  3816. m.updated_at = &t
  3817. }
  3818. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3819. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  3820. v := m.updated_at
  3821. if v == nil {
  3822. return
  3823. }
  3824. return *v, true
  3825. }
  3826. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  3827. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3829. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3830. if !m.op.Is(OpUpdateOne) {
  3831. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3832. }
  3833. if m.id == nil || m.oldValue == nil {
  3834. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3835. }
  3836. oldValue, err := m.oldValue(ctx)
  3837. if err != nil {
  3838. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3839. }
  3840. return oldValue.UpdatedAt, nil
  3841. }
  3842. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3843. func (m *CategoryMutation) ResetUpdatedAt() {
  3844. m.updated_at = nil
  3845. }
  3846. // SetDeletedAt sets the "deleted_at" field.
  3847. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  3848. m.deleted_at = &t
  3849. }
  3850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3851. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  3852. v := m.deleted_at
  3853. if v == nil {
  3854. return
  3855. }
  3856. return *v, true
  3857. }
  3858. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  3859. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3861. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3862. if !m.op.Is(OpUpdateOne) {
  3863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3864. }
  3865. if m.id == nil || m.oldValue == nil {
  3866. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3867. }
  3868. oldValue, err := m.oldValue(ctx)
  3869. if err != nil {
  3870. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3871. }
  3872. return oldValue.DeletedAt, nil
  3873. }
  3874. // ClearDeletedAt clears the value of the "deleted_at" field.
  3875. func (m *CategoryMutation) ClearDeletedAt() {
  3876. m.deleted_at = nil
  3877. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  3878. }
  3879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3880. func (m *CategoryMutation) DeletedAtCleared() bool {
  3881. _, ok := m.clearedFields[category.FieldDeletedAt]
  3882. return ok
  3883. }
  3884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3885. func (m *CategoryMutation) ResetDeletedAt() {
  3886. m.deleted_at = nil
  3887. delete(m.clearedFields, category.FieldDeletedAt)
  3888. }
  3889. // SetName sets the "name" field.
  3890. func (m *CategoryMutation) SetName(s string) {
  3891. m.name = &s
  3892. }
  3893. // Name returns the value of the "name" field in the mutation.
  3894. func (m *CategoryMutation) Name() (r string, exists bool) {
  3895. v := m.name
  3896. if v == nil {
  3897. return
  3898. }
  3899. return *v, true
  3900. }
  3901. // OldName returns the old "name" field's value of the Category entity.
  3902. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3904. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  3905. if !m.op.Is(OpUpdateOne) {
  3906. return v, errors.New("OldName is only allowed on UpdateOne operations")
  3907. }
  3908. if m.id == nil || m.oldValue == nil {
  3909. return v, errors.New("OldName requires an ID field in the mutation")
  3910. }
  3911. oldValue, err := m.oldValue(ctx)
  3912. if err != nil {
  3913. return v, fmt.Errorf("querying old value for OldName: %w", err)
  3914. }
  3915. return oldValue.Name, nil
  3916. }
  3917. // ResetName resets all changes to the "name" field.
  3918. func (m *CategoryMutation) ResetName() {
  3919. m.name = nil
  3920. }
  3921. // SetOrganizationID sets the "organization_id" field.
  3922. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  3923. m.organization_id = &u
  3924. m.addorganization_id = nil
  3925. }
  3926. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3927. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  3928. v := m.organization_id
  3929. if v == nil {
  3930. return
  3931. }
  3932. return *v, true
  3933. }
  3934. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  3935. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  3936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3937. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3938. if !m.op.Is(OpUpdateOne) {
  3939. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3940. }
  3941. if m.id == nil || m.oldValue == nil {
  3942. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3943. }
  3944. oldValue, err := m.oldValue(ctx)
  3945. if err != nil {
  3946. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3947. }
  3948. return oldValue.OrganizationID, nil
  3949. }
  3950. // AddOrganizationID adds u to the "organization_id" field.
  3951. func (m *CategoryMutation) AddOrganizationID(u int64) {
  3952. if m.addorganization_id != nil {
  3953. *m.addorganization_id += u
  3954. } else {
  3955. m.addorganization_id = &u
  3956. }
  3957. }
  3958. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3959. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  3960. v := m.addorganization_id
  3961. if v == nil {
  3962. return
  3963. }
  3964. return *v, true
  3965. }
  3966. // ResetOrganizationID resets all changes to the "organization_id" field.
  3967. func (m *CategoryMutation) ResetOrganizationID() {
  3968. m.organization_id = nil
  3969. m.addorganization_id = nil
  3970. }
  3971. // Where appends a list predicates to the CategoryMutation builder.
  3972. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  3973. m.predicates = append(m.predicates, ps...)
  3974. }
  3975. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  3976. // users can use type-assertion to append predicates that do not depend on any generated package.
  3977. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  3978. p := make([]predicate.Category, len(ps))
  3979. for i := range ps {
  3980. p[i] = ps[i]
  3981. }
  3982. m.Where(p...)
  3983. }
  3984. // Op returns the operation name.
  3985. func (m *CategoryMutation) Op() Op {
  3986. return m.op
  3987. }
  3988. // SetOp allows setting the mutation operation.
  3989. func (m *CategoryMutation) SetOp(op Op) {
  3990. m.op = op
  3991. }
  3992. // Type returns the node type of this mutation (Category).
  3993. func (m *CategoryMutation) Type() string {
  3994. return m.typ
  3995. }
  3996. // Fields returns all fields that were changed during this mutation. Note that in
  3997. // order to get all numeric fields that were incremented/decremented, call
  3998. // AddedFields().
  3999. func (m *CategoryMutation) Fields() []string {
  4000. fields := make([]string, 0, 5)
  4001. if m.created_at != nil {
  4002. fields = append(fields, category.FieldCreatedAt)
  4003. }
  4004. if m.updated_at != nil {
  4005. fields = append(fields, category.FieldUpdatedAt)
  4006. }
  4007. if m.deleted_at != nil {
  4008. fields = append(fields, category.FieldDeletedAt)
  4009. }
  4010. if m.name != nil {
  4011. fields = append(fields, category.FieldName)
  4012. }
  4013. if m.organization_id != nil {
  4014. fields = append(fields, category.FieldOrganizationID)
  4015. }
  4016. return fields
  4017. }
  4018. // Field returns the value of a field with the given name. The second boolean
  4019. // return value indicates that this field was not set, or was not defined in the
  4020. // schema.
  4021. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  4022. switch name {
  4023. case category.FieldCreatedAt:
  4024. return m.CreatedAt()
  4025. case category.FieldUpdatedAt:
  4026. return m.UpdatedAt()
  4027. case category.FieldDeletedAt:
  4028. return m.DeletedAt()
  4029. case category.FieldName:
  4030. return m.Name()
  4031. case category.FieldOrganizationID:
  4032. return m.OrganizationID()
  4033. }
  4034. return nil, false
  4035. }
  4036. // OldField returns the old value of the field from the database. An error is
  4037. // returned if the mutation operation is not UpdateOne, or the query to the
  4038. // database failed.
  4039. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4040. switch name {
  4041. case category.FieldCreatedAt:
  4042. return m.OldCreatedAt(ctx)
  4043. case category.FieldUpdatedAt:
  4044. return m.OldUpdatedAt(ctx)
  4045. case category.FieldDeletedAt:
  4046. return m.OldDeletedAt(ctx)
  4047. case category.FieldName:
  4048. return m.OldName(ctx)
  4049. case category.FieldOrganizationID:
  4050. return m.OldOrganizationID(ctx)
  4051. }
  4052. return nil, fmt.Errorf("unknown Category field %s", name)
  4053. }
  4054. // SetField sets the value of a field with the given name. It returns an error if
  4055. // the field is not defined in the schema, or if the type mismatched the field
  4056. // type.
  4057. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  4058. switch name {
  4059. case category.FieldCreatedAt:
  4060. v, ok := value.(time.Time)
  4061. if !ok {
  4062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4063. }
  4064. m.SetCreatedAt(v)
  4065. return nil
  4066. case category.FieldUpdatedAt:
  4067. v, ok := value.(time.Time)
  4068. if !ok {
  4069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4070. }
  4071. m.SetUpdatedAt(v)
  4072. return nil
  4073. case category.FieldDeletedAt:
  4074. v, ok := value.(time.Time)
  4075. if !ok {
  4076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4077. }
  4078. m.SetDeletedAt(v)
  4079. return nil
  4080. case category.FieldName:
  4081. v, ok := value.(string)
  4082. if !ok {
  4083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4084. }
  4085. m.SetName(v)
  4086. return nil
  4087. case category.FieldOrganizationID:
  4088. v, ok := value.(uint64)
  4089. if !ok {
  4090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4091. }
  4092. m.SetOrganizationID(v)
  4093. return nil
  4094. }
  4095. return fmt.Errorf("unknown Category field %s", name)
  4096. }
  4097. // AddedFields returns all numeric fields that were incremented/decremented during
  4098. // this mutation.
  4099. func (m *CategoryMutation) AddedFields() []string {
  4100. var fields []string
  4101. if m.addorganization_id != nil {
  4102. fields = append(fields, category.FieldOrganizationID)
  4103. }
  4104. return fields
  4105. }
  4106. // AddedField returns the numeric value that was incremented/decremented on a field
  4107. // with the given name. The second boolean return value indicates that this field
  4108. // was not set, or was not defined in the schema.
  4109. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  4110. switch name {
  4111. case category.FieldOrganizationID:
  4112. return m.AddedOrganizationID()
  4113. }
  4114. return nil, false
  4115. }
  4116. // AddField adds the value to the field with the given name. It returns an error if
  4117. // the field is not defined in the schema, or if the type mismatched the field
  4118. // type.
  4119. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  4120. switch name {
  4121. case category.FieldOrganizationID:
  4122. v, ok := value.(int64)
  4123. if !ok {
  4124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4125. }
  4126. m.AddOrganizationID(v)
  4127. return nil
  4128. }
  4129. return fmt.Errorf("unknown Category numeric field %s", name)
  4130. }
  4131. // ClearedFields returns all nullable fields that were cleared during this
  4132. // mutation.
  4133. func (m *CategoryMutation) ClearedFields() []string {
  4134. var fields []string
  4135. if m.FieldCleared(category.FieldDeletedAt) {
  4136. fields = append(fields, category.FieldDeletedAt)
  4137. }
  4138. return fields
  4139. }
  4140. // FieldCleared returns a boolean indicating if a field with the given name was
  4141. // cleared in this mutation.
  4142. func (m *CategoryMutation) FieldCleared(name string) bool {
  4143. _, ok := m.clearedFields[name]
  4144. return ok
  4145. }
  4146. // ClearField clears the value of the field with the given name. It returns an
  4147. // error if the field is not defined in the schema.
  4148. func (m *CategoryMutation) ClearField(name string) error {
  4149. switch name {
  4150. case category.FieldDeletedAt:
  4151. m.ClearDeletedAt()
  4152. return nil
  4153. }
  4154. return fmt.Errorf("unknown Category nullable field %s", name)
  4155. }
  4156. // ResetField resets all changes in the mutation for the field with the given name.
  4157. // It returns an error if the field is not defined in the schema.
  4158. func (m *CategoryMutation) ResetField(name string) error {
  4159. switch name {
  4160. case category.FieldCreatedAt:
  4161. m.ResetCreatedAt()
  4162. return nil
  4163. case category.FieldUpdatedAt:
  4164. m.ResetUpdatedAt()
  4165. return nil
  4166. case category.FieldDeletedAt:
  4167. m.ResetDeletedAt()
  4168. return nil
  4169. case category.FieldName:
  4170. m.ResetName()
  4171. return nil
  4172. case category.FieldOrganizationID:
  4173. m.ResetOrganizationID()
  4174. return nil
  4175. }
  4176. return fmt.Errorf("unknown Category field %s", name)
  4177. }
  4178. // AddedEdges returns all edge names that were set/added in this mutation.
  4179. func (m *CategoryMutation) AddedEdges() []string {
  4180. edges := make([]string, 0, 0)
  4181. return edges
  4182. }
  4183. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4184. // name in this mutation.
  4185. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  4186. return nil
  4187. }
  4188. // RemovedEdges returns all edge names that were removed in this mutation.
  4189. func (m *CategoryMutation) RemovedEdges() []string {
  4190. edges := make([]string, 0, 0)
  4191. return edges
  4192. }
  4193. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4194. // the given name in this mutation.
  4195. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  4196. return nil
  4197. }
  4198. // ClearedEdges returns all edge names that were cleared in this mutation.
  4199. func (m *CategoryMutation) ClearedEdges() []string {
  4200. edges := make([]string, 0, 0)
  4201. return edges
  4202. }
  4203. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4204. // was cleared in this mutation.
  4205. func (m *CategoryMutation) EdgeCleared(name string) bool {
  4206. return false
  4207. }
  4208. // ClearEdge clears the value of the edge with the given name. It returns an error
  4209. // if that edge is not defined in the schema.
  4210. func (m *CategoryMutation) ClearEdge(name string) error {
  4211. return fmt.Errorf("unknown Category unique edge %s", name)
  4212. }
  4213. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4214. // It returns an error if the edge is not defined in the schema.
  4215. func (m *CategoryMutation) ResetEdge(name string) error {
  4216. return fmt.Errorf("unknown Category edge %s", name)
  4217. }
  4218. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  4219. type ContactMutation struct {
  4220. config
  4221. op Op
  4222. typ string
  4223. id *uint64
  4224. created_at *time.Time
  4225. updated_at *time.Time
  4226. status *uint8
  4227. addstatus *int8
  4228. deleted_at *time.Time
  4229. wx_wxid *string
  4230. _type *int
  4231. add_type *int
  4232. wxid *string
  4233. account *string
  4234. nickname *string
  4235. markname *string
  4236. headimg *string
  4237. sex *int
  4238. addsex *int
  4239. starrole *string
  4240. dontseeit *int
  4241. adddontseeit *int
  4242. dontseeme *int
  4243. adddontseeme *int
  4244. lag *string
  4245. gid *string
  4246. gname *string
  4247. v3 *string
  4248. organization_id *uint64
  4249. addorganization_id *int64
  4250. clearedFields map[string]struct{}
  4251. contact_relationships map[uint64]struct{}
  4252. removedcontact_relationships map[uint64]struct{}
  4253. clearedcontact_relationships bool
  4254. contact_messages map[uint64]struct{}
  4255. removedcontact_messages map[uint64]struct{}
  4256. clearedcontact_messages bool
  4257. done bool
  4258. oldValue func(context.Context) (*Contact, error)
  4259. predicates []predicate.Contact
  4260. }
  4261. var _ ent.Mutation = (*ContactMutation)(nil)
  4262. // contactOption allows management of the mutation configuration using functional options.
  4263. type contactOption func(*ContactMutation)
  4264. // newContactMutation creates new mutation for the Contact entity.
  4265. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  4266. m := &ContactMutation{
  4267. config: c,
  4268. op: op,
  4269. typ: TypeContact,
  4270. clearedFields: make(map[string]struct{}),
  4271. }
  4272. for _, opt := range opts {
  4273. opt(m)
  4274. }
  4275. return m
  4276. }
  4277. // withContactID sets the ID field of the mutation.
  4278. func withContactID(id uint64) contactOption {
  4279. return func(m *ContactMutation) {
  4280. var (
  4281. err error
  4282. once sync.Once
  4283. value *Contact
  4284. )
  4285. m.oldValue = func(ctx context.Context) (*Contact, error) {
  4286. once.Do(func() {
  4287. if m.done {
  4288. err = errors.New("querying old values post mutation is not allowed")
  4289. } else {
  4290. value, err = m.Client().Contact.Get(ctx, id)
  4291. }
  4292. })
  4293. return value, err
  4294. }
  4295. m.id = &id
  4296. }
  4297. }
  4298. // withContact sets the old Contact of the mutation.
  4299. func withContact(node *Contact) contactOption {
  4300. return func(m *ContactMutation) {
  4301. m.oldValue = func(context.Context) (*Contact, error) {
  4302. return node, nil
  4303. }
  4304. m.id = &node.ID
  4305. }
  4306. }
  4307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4308. // executed in a transaction (ent.Tx), a transactional client is returned.
  4309. func (m ContactMutation) Client() *Client {
  4310. client := &Client{config: m.config}
  4311. client.init()
  4312. return client
  4313. }
  4314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4315. // it returns an error otherwise.
  4316. func (m ContactMutation) Tx() (*Tx, error) {
  4317. if _, ok := m.driver.(*txDriver); !ok {
  4318. return nil, errors.New("ent: mutation is not running in a transaction")
  4319. }
  4320. tx := &Tx{config: m.config}
  4321. tx.init()
  4322. return tx, nil
  4323. }
  4324. // SetID sets the value of the id field. Note that this
  4325. // operation is only accepted on creation of Contact entities.
  4326. func (m *ContactMutation) SetID(id uint64) {
  4327. m.id = &id
  4328. }
  4329. // ID returns the ID value in the mutation. Note that the ID is only available
  4330. // if it was provided to the builder or after it was returned from the database.
  4331. func (m *ContactMutation) ID() (id uint64, exists bool) {
  4332. if m.id == nil {
  4333. return
  4334. }
  4335. return *m.id, true
  4336. }
  4337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4338. // That means, if the mutation is applied within a transaction with an isolation level such
  4339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4340. // or updated by the mutation.
  4341. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  4342. switch {
  4343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4344. id, exists := m.ID()
  4345. if exists {
  4346. return []uint64{id}, nil
  4347. }
  4348. fallthrough
  4349. case m.op.Is(OpUpdate | OpDelete):
  4350. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  4351. default:
  4352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4353. }
  4354. }
  4355. // SetCreatedAt sets the "created_at" field.
  4356. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  4357. m.created_at = &t
  4358. }
  4359. // CreatedAt returns the value of the "created_at" field in the mutation.
  4360. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  4361. v := m.created_at
  4362. if v == nil {
  4363. return
  4364. }
  4365. return *v, true
  4366. }
  4367. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  4368. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4370. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4371. if !m.op.Is(OpUpdateOne) {
  4372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4373. }
  4374. if m.id == nil || m.oldValue == nil {
  4375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4376. }
  4377. oldValue, err := m.oldValue(ctx)
  4378. if err != nil {
  4379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4380. }
  4381. return oldValue.CreatedAt, nil
  4382. }
  4383. // ResetCreatedAt resets all changes to the "created_at" field.
  4384. func (m *ContactMutation) ResetCreatedAt() {
  4385. m.created_at = nil
  4386. }
  4387. // SetUpdatedAt sets the "updated_at" field.
  4388. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  4389. m.updated_at = &t
  4390. }
  4391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4392. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  4393. v := m.updated_at
  4394. if v == nil {
  4395. return
  4396. }
  4397. return *v, true
  4398. }
  4399. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  4400. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4402. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4403. if !m.op.Is(OpUpdateOne) {
  4404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4405. }
  4406. if m.id == nil || m.oldValue == nil {
  4407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4408. }
  4409. oldValue, err := m.oldValue(ctx)
  4410. if err != nil {
  4411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4412. }
  4413. return oldValue.UpdatedAt, nil
  4414. }
  4415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4416. func (m *ContactMutation) ResetUpdatedAt() {
  4417. m.updated_at = nil
  4418. }
  4419. // SetStatus sets the "status" field.
  4420. func (m *ContactMutation) SetStatus(u uint8) {
  4421. m.status = &u
  4422. m.addstatus = nil
  4423. }
  4424. // Status returns the value of the "status" field in the mutation.
  4425. func (m *ContactMutation) Status() (r uint8, exists bool) {
  4426. v := m.status
  4427. if v == nil {
  4428. return
  4429. }
  4430. return *v, true
  4431. }
  4432. // OldStatus returns the old "status" field's value of the Contact entity.
  4433. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4435. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4436. if !m.op.Is(OpUpdateOne) {
  4437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4438. }
  4439. if m.id == nil || m.oldValue == nil {
  4440. return v, errors.New("OldStatus requires an ID field in the mutation")
  4441. }
  4442. oldValue, err := m.oldValue(ctx)
  4443. if err != nil {
  4444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4445. }
  4446. return oldValue.Status, nil
  4447. }
  4448. // AddStatus adds u to the "status" field.
  4449. func (m *ContactMutation) AddStatus(u int8) {
  4450. if m.addstatus != nil {
  4451. *m.addstatus += u
  4452. } else {
  4453. m.addstatus = &u
  4454. }
  4455. }
  4456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4457. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  4458. v := m.addstatus
  4459. if v == nil {
  4460. return
  4461. }
  4462. return *v, true
  4463. }
  4464. // ClearStatus clears the value of the "status" field.
  4465. func (m *ContactMutation) ClearStatus() {
  4466. m.status = nil
  4467. m.addstatus = nil
  4468. m.clearedFields[contact.FieldStatus] = struct{}{}
  4469. }
  4470. // StatusCleared returns if the "status" field was cleared in this mutation.
  4471. func (m *ContactMutation) StatusCleared() bool {
  4472. _, ok := m.clearedFields[contact.FieldStatus]
  4473. return ok
  4474. }
  4475. // ResetStatus resets all changes to the "status" field.
  4476. func (m *ContactMutation) ResetStatus() {
  4477. m.status = nil
  4478. m.addstatus = nil
  4479. delete(m.clearedFields, contact.FieldStatus)
  4480. }
  4481. // SetDeletedAt sets the "deleted_at" field.
  4482. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  4483. m.deleted_at = &t
  4484. }
  4485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4486. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  4487. v := m.deleted_at
  4488. if v == nil {
  4489. return
  4490. }
  4491. return *v, true
  4492. }
  4493. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  4494. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4496. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4497. if !m.op.Is(OpUpdateOne) {
  4498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4499. }
  4500. if m.id == nil || m.oldValue == nil {
  4501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4502. }
  4503. oldValue, err := m.oldValue(ctx)
  4504. if err != nil {
  4505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4506. }
  4507. return oldValue.DeletedAt, nil
  4508. }
  4509. // ClearDeletedAt clears the value of the "deleted_at" field.
  4510. func (m *ContactMutation) ClearDeletedAt() {
  4511. m.deleted_at = nil
  4512. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  4513. }
  4514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4515. func (m *ContactMutation) DeletedAtCleared() bool {
  4516. _, ok := m.clearedFields[contact.FieldDeletedAt]
  4517. return ok
  4518. }
  4519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4520. func (m *ContactMutation) ResetDeletedAt() {
  4521. m.deleted_at = nil
  4522. delete(m.clearedFields, contact.FieldDeletedAt)
  4523. }
  4524. // SetWxWxid sets the "wx_wxid" field.
  4525. func (m *ContactMutation) SetWxWxid(s string) {
  4526. m.wx_wxid = &s
  4527. }
  4528. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  4529. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  4530. v := m.wx_wxid
  4531. if v == nil {
  4532. return
  4533. }
  4534. return *v, true
  4535. }
  4536. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  4537. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4539. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  4540. if !m.op.Is(OpUpdateOne) {
  4541. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  4542. }
  4543. if m.id == nil || m.oldValue == nil {
  4544. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  4545. }
  4546. oldValue, err := m.oldValue(ctx)
  4547. if err != nil {
  4548. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  4549. }
  4550. return oldValue.WxWxid, nil
  4551. }
  4552. // ClearWxWxid clears the value of the "wx_wxid" field.
  4553. func (m *ContactMutation) ClearWxWxid() {
  4554. m.wx_wxid = nil
  4555. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  4556. }
  4557. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  4558. func (m *ContactMutation) WxWxidCleared() bool {
  4559. _, ok := m.clearedFields[contact.FieldWxWxid]
  4560. return ok
  4561. }
  4562. // ResetWxWxid resets all changes to the "wx_wxid" field.
  4563. func (m *ContactMutation) ResetWxWxid() {
  4564. m.wx_wxid = nil
  4565. delete(m.clearedFields, contact.FieldWxWxid)
  4566. }
  4567. // SetType sets the "type" field.
  4568. func (m *ContactMutation) SetType(i int) {
  4569. m._type = &i
  4570. m.add_type = nil
  4571. }
  4572. // GetType returns the value of the "type" field in the mutation.
  4573. func (m *ContactMutation) GetType() (r int, exists bool) {
  4574. v := m._type
  4575. if v == nil {
  4576. return
  4577. }
  4578. return *v, true
  4579. }
  4580. // OldType returns the old "type" field's value of the Contact entity.
  4581. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4583. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  4584. if !m.op.Is(OpUpdateOne) {
  4585. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4586. }
  4587. if m.id == nil || m.oldValue == nil {
  4588. return v, errors.New("OldType requires an ID field in the mutation")
  4589. }
  4590. oldValue, err := m.oldValue(ctx)
  4591. if err != nil {
  4592. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4593. }
  4594. return oldValue.Type, nil
  4595. }
  4596. // AddType adds i to the "type" field.
  4597. func (m *ContactMutation) AddType(i int) {
  4598. if m.add_type != nil {
  4599. *m.add_type += i
  4600. } else {
  4601. m.add_type = &i
  4602. }
  4603. }
  4604. // AddedType returns the value that was added to the "type" field in this mutation.
  4605. func (m *ContactMutation) AddedType() (r int, exists bool) {
  4606. v := m.add_type
  4607. if v == nil {
  4608. return
  4609. }
  4610. return *v, true
  4611. }
  4612. // ClearType clears the value of the "type" field.
  4613. func (m *ContactMutation) ClearType() {
  4614. m._type = nil
  4615. m.add_type = nil
  4616. m.clearedFields[contact.FieldType] = struct{}{}
  4617. }
  4618. // TypeCleared returns if the "type" field was cleared in this mutation.
  4619. func (m *ContactMutation) TypeCleared() bool {
  4620. _, ok := m.clearedFields[contact.FieldType]
  4621. return ok
  4622. }
  4623. // ResetType resets all changes to the "type" field.
  4624. func (m *ContactMutation) ResetType() {
  4625. m._type = nil
  4626. m.add_type = nil
  4627. delete(m.clearedFields, contact.FieldType)
  4628. }
  4629. // SetWxid sets the "wxid" field.
  4630. func (m *ContactMutation) SetWxid(s string) {
  4631. m.wxid = &s
  4632. }
  4633. // Wxid returns the value of the "wxid" field in the mutation.
  4634. func (m *ContactMutation) Wxid() (r string, exists bool) {
  4635. v := m.wxid
  4636. if v == nil {
  4637. return
  4638. }
  4639. return *v, true
  4640. }
  4641. // OldWxid returns the old "wxid" field's value of the Contact entity.
  4642. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4644. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  4645. if !m.op.Is(OpUpdateOne) {
  4646. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  4647. }
  4648. if m.id == nil || m.oldValue == nil {
  4649. return v, errors.New("OldWxid requires an ID field in the mutation")
  4650. }
  4651. oldValue, err := m.oldValue(ctx)
  4652. if err != nil {
  4653. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  4654. }
  4655. return oldValue.Wxid, nil
  4656. }
  4657. // ResetWxid resets all changes to the "wxid" field.
  4658. func (m *ContactMutation) ResetWxid() {
  4659. m.wxid = nil
  4660. }
  4661. // SetAccount sets the "account" field.
  4662. func (m *ContactMutation) SetAccount(s string) {
  4663. m.account = &s
  4664. }
  4665. // Account returns the value of the "account" field in the mutation.
  4666. func (m *ContactMutation) Account() (r string, exists bool) {
  4667. v := m.account
  4668. if v == nil {
  4669. return
  4670. }
  4671. return *v, true
  4672. }
  4673. // OldAccount returns the old "account" field's value of the Contact entity.
  4674. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4676. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  4677. if !m.op.Is(OpUpdateOne) {
  4678. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  4679. }
  4680. if m.id == nil || m.oldValue == nil {
  4681. return v, errors.New("OldAccount requires an ID field in the mutation")
  4682. }
  4683. oldValue, err := m.oldValue(ctx)
  4684. if err != nil {
  4685. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  4686. }
  4687. return oldValue.Account, nil
  4688. }
  4689. // ResetAccount resets all changes to the "account" field.
  4690. func (m *ContactMutation) ResetAccount() {
  4691. m.account = nil
  4692. }
  4693. // SetNickname sets the "nickname" field.
  4694. func (m *ContactMutation) SetNickname(s string) {
  4695. m.nickname = &s
  4696. }
  4697. // Nickname returns the value of the "nickname" field in the mutation.
  4698. func (m *ContactMutation) Nickname() (r string, exists bool) {
  4699. v := m.nickname
  4700. if v == nil {
  4701. return
  4702. }
  4703. return *v, true
  4704. }
  4705. // OldNickname returns the old "nickname" field's value of the Contact entity.
  4706. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4708. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  4709. if !m.op.Is(OpUpdateOne) {
  4710. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  4711. }
  4712. if m.id == nil || m.oldValue == nil {
  4713. return v, errors.New("OldNickname requires an ID field in the mutation")
  4714. }
  4715. oldValue, err := m.oldValue(ctx)
  4716. if err != nil {
  4717. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  4718. }
  4719. return oldValue.Nickname, nil
  4720. }
  4721. // ResetNickname resets all changes to the "nickname" field.
  4722. func (m *ContactMutation) ResetNickname() {
  4723. m.nickname = nil
  4724. }
  4725. // SetMarkname sets the "markname" field.
  4726. func (m *ContactMutation) SetMarkname(s string) {
  4727. m.markname = &s
  4728. }
  4729. // Markname returns the value of the "markname" field in the mutation.
  4730. func (m *ContactMutation) Markname() (r string, exists bool) {
  4731. v := m.markname
  4732. if v == nil {
  4733. return
  4734. }
  4735. return *v, true
  4736. }
  4737. // OldMarkname returns the old "markname" field's value of the Contact entity.
  4738. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4740. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  4741. if !m.op.Is(OpUpdateOne) {
  4742. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  4743. }
  4744. if m.id == nil || m.oldValue == nil {
  4745. return v, errors.New("OldMarkname requires an ID field in the mutation")
  4746. }
  4747. oldValue, err := m.oldValue(ctx)
  4748. if err != nil {
  4749. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  4750. }
  4751. return oldValue.Markname, nil
  4752. }
  4753. // ResetMarkname resets all changes to the "markname" field.
  4754. func (m *ContactMutation) ResetMarkname() {
  4755. m.markname = nil
  4756. }
  4757. // SetHeadimg sets the "headimg" field.
  4758. func (m *ContactMutation) SetHeadimg(s string) {
  4759. m.headimg = &s
  4760. }
  4761. // Headimg returns the value of the "headimg" field in the mutation.
  4762. func (m *ContactMutation) Headimg() (r string, exists bool) {
  4763. v := m.headimg
  4764. if v == nil {
  4765. return
  4766. }
  4767. return *v, true
  4768. }
  4769. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  4770. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4772. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  4773. if !m.op.Is(OpUpdateOne) {
  4774. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  4775. }
  4776. if m.id == nil || m.oldValue == nil {
  4777. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  4778. }
  4779. oldValue, err := m.oldValue(ctx)
  4780. if err != nil {
  4781. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  4782. }
  4783. return oldValue.Headimg, nil
  4784. }
  4785. // ResetHeadimg resets all changes to the "headimg" field.
  4786. func (m *ContactMutation) ResetHeadimg() {
  4787. m.headimg = nil
  4788. }
  4789. // SetSex sets the "sex" field.
  4790. func (m *ContactMutation) SetSex(i int) {
  4791. m.sex = &i
  4792. m.addsex = nil
  4793. }
  4794. // Sex returns the value of the "sex" field in the mutation.
  4795. func (m *ContactMutation) Sex() (r int, exists bool) {
  4796. v := m.sex
  4797. if v == nil {
  4798. return
  4799. }
  4800. return *v, true
  4801. }
  4802. // OldSex returns the old "sex" field's value of the Contact entity.
  4803. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4805. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  4806. if !m.op.Is(OpUpdateOne) {
  4807. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  4808. }
  4809. if m.id == nil || m.oldValue == nil {
  4810. return v, errors.New("OldSex requires an ID field in the mutation")
  4811. }
  4812. oldValue, err := m.oldValue(ctx)
  4813. if err != nil {
  4814. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  4815. }
  4816. return oldValue.Sex, nil
  4817. }
  4818. // AddSex adds i to the "sex" field.
  4819. func (m *ContactMutation) AddSex(i int) {
  4820. if m.addsex != nil {
  4821. *m.addsex += i
  4822. } else {
  4823. m.addsex = &i
  4824. }
  4825. }
  4826. // AddedSex returns the value that was added to the "sex" field in this mutation.
  4827. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  4828. v := m.addsex
  4829. if v == nil {
  4830. return
  4831. }
  4832. return *v, true
  4833. }
  4834. // ResetSex resets all changes to the "sex" field.
  4835. func (m *ContactMutation) ResetSex() {
  4836. m.sex = nil
  4837. m.addsex = nil
  4838. }
  4839. // SetStarrole sets the "starrole" field.
  4840. func (m *ContactMutation) SetStarrole(s string) {
  4841. m.starrole = &s
  4842. }
  4843. // Starrole returns the value of the "starrole" field in the mutation.
  4844. func (m *ContactMutation) Starrole() (r string, exists bool) {
  4845. v := m.starrole
  4846. if v == nil {
  4847. return
  4848. }
  4849. return *v, true
  4850. }
  4851. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  4852. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4854. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  4855. if !m.op.Is(OpUpdateOne) {
  4856. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  4857. }
  4858. if m.id == nil || m.oldValue == nil {
  4859. return v, errors.New("OldStarrole requires an ID field in the mutation")
  4860. }
  4861. oldValue, err := m.oldValue(ctx)
  4862. if err != nil {
  4863. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  4864. }
  4865. return oldValue.Starrole, nil
  4866. }
  4867. // ResetStarrole resets all changes to the "starrole" field.
  4868. func (m *ContactMutation) ResetStarrole() {
  4869. m.starrole = nil
  4870. }
  4871. // SetDontseeit sets the "dontseeit" field.
  4872. func (m *ContactMutation) SetDontseeit(i int) {
  4873. m.dontseeit = &i
  4874. m.adddontseeit = nil
  4875. }
  4876. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  4877. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  4878. v := m.dontseeit
  4879. if v == nil {
  4880. return
  4881. }
  4882. return *v, true
  4883. }
  4884. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  4885. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4887. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  4888. if !m.op.Is(OpUpdateOne) {
  4889. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  4890. }
  4891. if m.id == nil || m.oldValue == nil {
  4892. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  4893. }
  4894. oldValue, err := m.oldValue(ctx)
  4895. if err != nil {
  4896. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  4897. }
  4898. return oldValue.Dontseeit, nil
  4899. }
  4900. // AddDontseeit adds i to the "dontseeit" field.
  4901. func (m *ContactMutation) AddDontseeit(i int) {
  4902. if m.adddontseeit != nil {
  4903. *m.adddontseeit += i
  4904. } else {
  4905. m.adddontseeit = &i
  4906. }
  4907. }
  4908. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  4909. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  4910. v := m.adddontseeit
  4911. if v == nil {
  4912. return
  4913. }
  4914. return *v, true
  4915. }
  4916. // ResetDontseeit resets all changes to the "dontseeit" field.
  4917. func (m *ContactMutation) ResetDontseeit() {
  4918. m.dontseeit = nil
  4919. m.adddontseeit = nil
  4920. }
  4921. // SetDontseeme sets the "dontseeme" field.
  4922. func (m *ContactMutation) SetDontseeme(i int) {
  4923. m.dontseeme = &i
  4924. m.adddontseeme = nil
  4925. }
  4926. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  4927. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  4928. v := m.dontseeme
  4929. if v == nil {
  4930. return
  4931. }
  4932. return *v, true
  4933. }
  4934. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  4935. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4937. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  4938. if !m.op.Is(OpUpdateOne) {
  4939. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  4940. }
  4941. if m.id == nil || m.oldValue == nil {
  4942. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  4943. }
  4944. oldValue, err := m.oldValue(ctx)
  4945. if err != nil {
  4946. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  4947. }
  4948. return oldValue.Dontseeme, nil
  4949. }
  4950. // AddDontseeme adds i to the "dontseeme" field.
  4951. func (m *ContactMutation) AddDontseeme(i int) {
  4952. if m.adddontseeme != nil {
  4953. *m.adddontseeme += i
  4954. } else {
  4955. m.adddontseeme = &i
  4956. }
  4957. }
  4958. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  4959. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  4960. v := m.adddontseeme
  4961. if v == nil {
  4962. return
  4963. }
  4964. return *v, true
  4965. }
  4966. // ResetDontseeme resets all changes to the "dontseeme" field.
  4967. func (m *ContactMutation) ResetDontseeme() {
  4968. m.dontseeme = nil
  4969. m.adddontseeme = nil
  4970. }
  4971. // SetLag sets the "lag" field.
  4972. func (m *ContactMutation) SetLag(s string) {
  4973. m.lag = &s
  4974. }
  4975. // Lag returns the value of the "lag" field in the mutation.
  4976. func (m *ContactMutation) Lag() (r string, exists bool) {
  4977. v := m.lag
  4978. if v == nil {
  4979. return
  4980. }
  4981. return *v, true
  4982. }
  4983. // OldLag returns the old "lag" field's value of the Contact entity.
  4984. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  4985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4986. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  4987. if !m.op.Is(OpUpdateOne) {
  4988. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  4989. }
  4990. if m.id == nil || m.oldValue == nil {
  4991. return v, errors.New("OldLag requires an ID field in the mutation")
  4992. }
  4993. oldValue, err := m.oldValue(ctx)
  4994. if err != nil {
  4995. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  4996. }
  4997. return oldValue.Lag, nil
  4998. }
  4999. // ResetLag resets all changes to the "lag" field.
  5000. func (m *ContactMutation) ResetLag() {
  5001. m.lag = nil
  5002. }
  5003. // SetGid sets the "gid" field.
  5004. func (m *ContactMutation) SetGid(s string) {
  5005. m.gid = &s
  5006. }
  5007. // Gid returns the value of the "gid" field in the mutation.
  5008. func (m *ContactMutation) Gid() (r string, exists bool) {
  5009. v := m.gid
  5010. if v == nil {
  5011. return
  5012. }
  5013. return *v, true
  5014. }
  5015. // OldGid returns the old "gid" field's value of the Contact entity.
  5016. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5018. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  5019. if !m.op.Is(OpUpdateOne) {
  5020. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  5021. }
  5022. if m.id == nil || m.oldValue == nil {
  5023. return v, errors.New("OldGid requires an ID field in the mutation")
  5024. }
  5025. oldValue, err := m.oldValue(ctx)
  5026. if err != nil {
  5027. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  5028. }
  5029. return oldValue.Gid, nil
  5030. }
  5031. // ResetGid resets all changes to the "gid" field.
  5032. func (m *ContactMutation) ResetGid() {
  5033. m.gid = nil
  5034. }
  5035. // SetGname sets the "gname" field.
  5036. func (m *ContactMutation) SetGname(s string) {
  5037. m.gname = &s
  5038. }
  5039. // Gname returns the value of the "gname" field in the mutation.
  5040. func (m *ContactMutation) Gname() (r string, exists bool) {
  5041. v := m.gname
  5042. if v == nil {
  5043. return
  5044. }
  5045. return *v, true
  5046. }
  5047. // OldGname returns the old "gname" field's value of the Contact entity.
  5048. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5050. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  5051. if !m.op.Is(OpUpdateOne) {
  5052. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  5053. }
  5054. if m.id == nil || m.oldValue == nil {
  5055. return v, errors.New("OldGname requires an ID field in the mutation")
  5056. }
  5057. oldValue, err := m.oldValue(ctx)
  5058. if err != nil {
  5059. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  5060. }
  5061. return oldValue.Gname, nil
  5062. }
  5063. // ResetGname resets all changes to the "gname" field.
  5064. func (m *ContactMutation) ResetGname() {
  5065. m.gname = nil
  5066. }
  5067. // SetV3 sets the "v3" field.
  5068. func (m *ContactMutation) SetV3(s string) {
  5069. m.v3 = &s
  5070. }
  5071. // V3 returns the value of the "v3" field in the mutation.
  5072. func (m *ContactMutation) V3() (r string, exists bool) {
  5073. v := m.v3
  5074. if v == nil {
  5075. return
  5076. }
  5077. return *v, true
  5078. }
  5079. // OldV3 returns the old "v3" field's value of the Contact entity.
  5080. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5082. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  5083. if !m.op.Is(OpUpdateOne) {
  5084. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  5085. }
  5086. if m.id == nil || m.oldValue == nil {
  5087. return v, errors.New("OldV3 requires an ID field in the mutation")
  5088. }
  5089. oldValue, err := m.oldValue(ctx)
  5090. if err != nil {
  5091. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  5092. }
  5093. return oldValue.V3, nil
  5094. }
  5095. // ResetV3 resets all changes to the "v3" field.
  5096. func (m *ContactMutation) ResetV3() {
  5097. m.v3 = nil
  5098. }
  5099. // SetOrganizationID sets the "organization_id" field.
  5100. func (m *ContactMutation) SetOrganizationID(u uint64) {
  5101. m.organization_id = &u
  5102. m.addorganization_id = nil
  5103. }
  5104. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5105. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  5106. v := m.organization_id
  5107. if v == nil {
  5108. return
  5109. }
  5110. return *v, true
  5111. }
  5112. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  5113. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  5114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5115. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5116. if !m.op.Is(OpUpdateOne) {
  5117. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5118. }
  5119. if m.id == nil || m.oldValue == nil {
  5120. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5121. }
  5122. oldValue, err := m.oldValue(ctx)
  5123. if err != nil {
  5124. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5125. }
  5126. return oldValue.OrganizationID, nil
  5127. }
  5128. // AddOrganizationID adds u to the "organization_id" field.
  5129. func (m *ContactMutation) AddOrganizationID(u int64) {
  5130. if m.addorganization_id != nil {
  5131. *m.addorganization_id += u
  5132. } else {
  5133. m.addorganization_id = &u
  5134. }
  5135. }
  5136. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5137. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  5138. v := m.addorganization_id
  5139. if v == nil {
  5140. return
  5141. }
  5142. return *v, true
  5143. }
  5144. // ClearOrganizationID clears the value of the "organization_id" field.
  5145. func (m *ContactMutation) ClearOrganizationID() {
  5146. m.organization_id = nil
  5147. m.addorganization_id = nil
  5148. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  5149. }
  5150. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5151. func (m *ContactMutation) OrganizationIDCleared() bool {
  5152. _, ok := m.clearedFields[contact.FieldOrganizationID]
  5153. return ok
  5154. }
  5155. // ResetOrganizationID resets all changes to the "organization_id" field.
  5156. func (m *ContactMutation) ResetOrganizationID() {
  5157. m.organization_id = nil
  5158. m.addorganization_id = nil
  5159. delete(m.clearedFields, contact.FieldOrganizationID)
  5160. }
  5161. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  5162. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  5163. if m.contact_relationships == nil {
  5164. m.contact_relationships = make(map[uint64]struct{})
  5165. }
  5166. for i := range ids {
  5167. m.contact_relationships[ids[i]] = struct{}{}
  5168. }
  5169. }
  5170. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  5171. func (m *ContactMutation) ClearContactRelationships() {
  5172. m.clearedcontact_relationships = true
  5173. }
  5174. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  5175. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  5176. return m.clearedcontact_relationships
  5177. }
  5178. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  5179. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  5180. if m.removedcontact_relationships == nil {
  5181. m.removedcontact_relationships = make(map[uint64]struct{})
  5182. }
  5183. for i := range ids {
  5184. delete(m.contact_relationships, ids[i])
  5185. m.removedcontact_relationships[ids[i]] = struct{}{}
  5186. }
  5187. }
  5188. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  5189. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  5190. for id := range m.removedcontact_relationships {
  5191. ids = append(ids, id)
  5192. }
  5193. return
  5194. }
  5195. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  5196. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  5197. for id := range m.contact_relationships {
  5198. ids = append(ids, id)
  5199. }
  5200. return
  5201. }
  5202. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  5203. func (m *ContactMutation) ResetContactRelationships() {
  5204. m.contact_relationships = nil
  5205. m.clearedcontact_relationships = false
  5206. m.removedcontact_relationships = nil
  5207. }
  5208. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  5209. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  5210. if m.contact_messages == nil {
  5211. m.contact_messages = make(map[uint64]struct{})
  5212. }
  5213. for i := range ids {
  5214. m.contact_messages[ids[i]] = struct{}{}
  5215. }
  5216. }
  5217. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  5218. func (m *ContactMutation) ClearContactMessages() {
  5219. m.clearedcontact_messages = true
  5220. }
  5221. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  5222. func (m *ContactMutation) ContactMessagesCleared() bool {
  5223. return m.clearedcontact_messages
  5224. }
  5225. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  5226. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  5227. if m.removedcontact_messages == nil {
  5228. m.removedcontact_messages = make(map[uint64]struct{})
  5229. }
  5230. for i := range ids {
  5231. delete(m.contact_messages, ids[i])
  5232. m.removedcontact_messages[ids[i]] = struct{}{}
  5233. }
  5234. }
  5235. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  5236. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  5237. for id := range m.removedcontact_messages {
  5238. ids = append(ids, id)
  5239. }
  5240. return
  5241. }
  5242. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  5243. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  5244. for id := range m.contact_messages {
  5245. ids = append(ids, id)
  5246. }
  5247. return
  5248. }
  5249. // ResetContactMessages resets all changes to the "contact_messages" edge.
  5250. func (m *ContactMutation) ResetContactMessages() {
  5251. m.contact_messages = nil
  5252. m.clearedcontact_messages = false
  5253. m.removedcontact_messages = nil
  5254. }
  5255. // Where appends a list predicates to the ContactMutation builder.
  5256. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  5257. m.predicates = append(m.predicates, ps...)
  5258. }
  5259. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  5260. // users can use type-assertion to append predicates that do not depend on any generated package.
  5261. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  5262. p := make([]predicate.Contact, len(ps))
  5263. for i := range ps {
  5264. p[i] = ps[i]
  5265. }
  5266. m.Where(p...)
  5267. }
  5268. // Op returns the operation name.
  5269. func (m *ContactMutation) Op() Op {
  5270. return m.op
  5271. }
  5272. // SetOp allows setting the mutation operation.
  5273. func (m *ContactMutation) SetOp(op Op) {
  5274. m.op = op
  5275. }
  5276. // Type returns the node type of this mutation (Contact).
  5277. func (m *ContactMutation) Type() string {
  5278. return m.typ
  5279. }
  5280. // Fields returns all fields that were changed during this mutation. Note that in
  5281. // order to get all numeric fields that were incremented/decremented, call
  5282. // AddedFields().
  5283. func (m *ContactMutation) Fields() []string {
  5284. fields := make([]string, 0, 20)
  5285. if m.created_at != nil {
  5286. fields = append(fields, contact.FieldCreatedAt)
  5287. }
  5288. if m.updated_at != nil {
  5289. fields = append(fields, contact.FieldUpdatedAt)
  5290. }
  5291. if m.status != nil {
  5292. fields = append(fields, contact.FieldStatus)
  5293. }
  5294. if m.deleted_at != nil {
  5295. fields = append(fields, contact.FieldDeletedAt)
  5296. }
  5297. if m.wx_wxid != nil {
  5298. fields = append(fields, contact.FieldWxWxid)
  5299. }
  5300. if m._type != nil {
  5301. fields = append(fields, contact.FieldType)
  5302. }
  5303. if m.wxid != nil {
  5304. fields = append(fields, contact.FieldWxid)
  5305. }
  5306. if m.account != nil {
  5307. fields = append(fields, contact.FieldAccount)
  5308. }
  5309. if m.nickname != nil {
  5310. fields = append(fields, contact.FieldNickname)
  5311. }
  5312. if m.markname != nil {
  5313. fields = append(fields, contact.FieldMarkname)
  5314. }
  5315. if m.headimg != nil {
  5316. fields = append(fields, contact.FieldHeadimg)
  5317. }
  5318. if m.sex != nil {
  5319. fields = append(fields, contact.FieldSex)
  5320. }
  5321. if m.starrole != nil {
  5322. fields = append(fields, contact.FieldStarrole)
  5323. }
  5324. if m.dontseeit != nil {
  5325. fields = append(fields, contact.FieldDontseeit)
  5326. }
  5327. if m.dontseeme != nil {
  5328. fields = append(fields, contact.FieldDontseeme)
  5329. }
  5330. if m.lag != nil {
  5331. fields = append(fields, contact.FieldLag)
  5332. }
  5333. if m.gid != nil {
  5334. fields = append(fields, contact.FieldGid)
  5335. }
  5336. if m.gname != nil {
  5337. fields = append(fields, contact.FieldGname)
  5338. }
  5339. if m.v3 != nil {
  5340. fields = append(fields, contact.FieldV3)
  5341. }
  5342. if m.organization_id != nil {
  5343. fields = append(fields, contact.FieldOrganizationID)
  5344. }
  5345. return fields
  5346. }
  5347. // Field returns the value of a field with the given name. The second boolean
  5348. // return value indicates that this field was not set, or was not defined in the
  5349. // schema.
  5350. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  5351. switch name {
  5352. case contact.FieldCreatedAt:
  5353. return m.CreatedAt()
  5354. case contact.FieldUpdatedAt:
  5355. return m.UpdatedAt()
  5356. case contact.FieldStatus:
  5357. return m.Status()
  5358. case contact.FieldDeletedAt:
  5359. return m.DeletedAt()
  5360. case contact.FieldWxWxid:
  5361. return m.WxWxid()
  5362. case contact.FieldType:
  5363. return m.GetType()
  5364. case contact.FieldWxid:
  5365. return m.Wxid()
  5366. case contact.FieldAccount:
  5367. return m.Account()
  5368. case contact.FieldNickname:
  5369. return m.Nickname()
  5370. case contact.FieldMarkname:
  5371. return m.Markname()
  5372. case contact.FieldHeadimg:
  5373. return m.Headimg()
  5374. case contact.FieldSex:
  5375. return m.Sex()
  5376. case contact.FieldStarrole:
  5377. return m.Starrole()
  5378. case contact.FieldDontseeit:
  5379. return m.Dontseeit()
  5380. case contact.FieldDontseeme:
  5381. return m.Dontseeme()
  5382. case contact.FieldLag:
  5383. return m.Lag()
  5384. case contact.FieldGid:
  5385. return m.Gid()
  5386. case contact.FieldGname:
  5387. return m.Gname()
  5388. case contact.FieldV3:
  5389. return m.V3()
  5390. case contact.FieldOrganizationID:
  5391. return m.OrganizationID()
  5392. }
  5393. return nil, false
  5394. }
  5395. // OldField returns the old value of the field from the database. An error is
  5396. // returned if the mutation operation is not UpdateOne, or the query to the
  5397. // database failed.
  5398. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5399. switch name {
  5400. case contact.FieldCreatedAt:
  5401. return m.OldCreatedAt(ctx)
  5402. case contact.FieldUpdatedAt:
  5403. return m.OldUpdatedAt(ctx)
  5404. case contact.FieldStatus:
  5405. return m.OldStatus(ctx)
  5406. case contact.FieldDeletedAt:
  5407. return m.OldDeletedAt(ctx)
  5408. case contact.FieldWxWxid:
  5409. return m.OldWxWxid(ctx)
  5410. case contact.FieldType:
  5411. return m.OldType(ctx)
  5412. case contact.FieldWxid:
  5413. return m.OldWxid(ctx)
  5414. case contact.FieldAccount:
  5415. return m.OldAccount(ctx)
  5416. case contact.FieldNickname:
  5417. return m.OldNickname(ctx)
  5418. case contact.FieldMarkname:
  5419. return m.OldMarkname(ctx)
  5420. case contact.FieldHeadimg:
  5421. return m.OldHeadimg(ctx)
  5422. case contact.FieldSex:
  5423. return m.OldSex(ctx)
  5424. case contact.FieldStarrole:
  5425. return m.OldStarrole(ctx)
  5426. case contact.FieldDontseeit:
  5427. return m.OldDontseeit(ctx)
  5428. case contact.FieldDontseeme:
  5429. return m.OldDontseeme(ctx)
  5430. case contact.FieldLag:
  5431. return m.OldLag(ctx)
  5432. case contact.FieldGid:
  5433. return m.OldGid(ctx)
  5434. case contact.FieldGname:
  5435. return m.OldGname(ctx)
  5436. case contact.FieldV3:
  5437. return m.OldV3(ctx)
  5438. case contact.FieldOrganizationID:
  5439. return m.OldOrganizationID(ctx)
  5440. }
  5441. return nil, fmt.Errorf("unknown Contact field %s", name)
  5442. }
  5443. // SetField sets the value of a field with the given name. It returns an error if
  5444. // the field is not defined in the schema, or if the type mismatched the field
  5445. // type.
  5446. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  5447. switch name {
  5448. case contact.FieldCreatedAt:
  5449. v, ok := value.(time.Time)
  5450. if !ok {
  5451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5452. }
  5453. m.SetCreatedAt(v)
  5454. return nil
  5455. case contact.FieldUpdatedAt:
  5456. v, ok := value.(time.Time)
  5457. if !ok {
  5458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5459. }
  5460. m.SetUpdatedAt(v)
  5461. return nil
  5462. case contact.FieldStatus:
  5463. v, ok := value.(uint8)
  5464. if !ok {
  5465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5466. }
  5467. m.SetStatus(v)
  5468. return nil
  5469. case contact.FieldDeletedAt:
  5470. v, ok := value.(time.Time)
  5471. if !ok {
  5472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5473. }
  5474. m.SetDeletedAt(v)
  5475. return nil
  5476. case contact.FieldWxWxid:
  5477. v, ok := value.(string)
  5478. if !ok {
  5479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5480. }
  5481. m.SetWxWxid(v)
  5482. return nil
  5483. case contact.FieldType:
  5484. v, ok := value.(int)
  5485. if !ok {
  5486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5487. }
  5488. m.SetType(v)
  5489. return nil
  5490. case contact.FieldWxid:
  5491. v, ok := value.(string)
  5492. if !ok {
  5493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5494. }
  5495. m.SetWxid(v)
  5496. return nil
  5497. case contact.FieldAccount:
  5498. v, ok := value.(string)
  5499. if !ok {
  5500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5501. }
  5502. m.SetAccount(v)
  5503. return nil
  5504. case contact.FieldNickname:
  5505. v, ok := value.(string)
  5506. if !ok {
  5507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5508. }
  5509. m.SetNickname(v)
  5510. return nil
  5511. case contact.FieldMarkname:
  5512. v, ok := value.(string)
  5513. if !ok {
  5514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5515. }
  5516. m.SetMarkname(v)
  5517. return nil
  5518. case contact.FieldHeadimg:
  5519. v, ok := value.(string)
  5520. if !ok {
  5521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5522. }
  5523. m.SetHeadimg(v)
  5524. return nil
  5525. case contact.FieldSex:
  5526. v, ok := value.(int)
  5527. if !ok {
  5528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5529. }
  5530. m.SetSex(v)
  5531. return nil
  5532. case contact.FieldStarrole:
  5533. v, ok := value.(string)
  5534. if !ok {
  5535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5536. }
  5537. m.SetStarrole(v)
  5538. return nil
  5539. case contact.FieldDontseeit:
  5540. v, ok := value.(int)
  5541. if !ok {
  5542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5543. }
  5544. m.SetDontseeit(v)
  5545. return nil
  5546. case contact.FieldDontseeme:
  5547. v, ok := value.(int)
  5548. if !ok {
  5549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5550. }
  5551. m.SetDontseeme(v)
  5552. return nil
  5553. case contact.FieldLag:
  5554. v, ok := value.(string)
  5555. if !ok {
  5556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5557. }
  5558. m.SetLag(v)
  5559. return nil
  5560. case contact.FieldGid:
  5561. v, ok := value.(string)
  5562. if !ok {
  5563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5564. }
  5565. m.SetGid(v)
  5566. return nil
  5567. case contact.FieldGname:
  5568. v, ok := value.(string)
  5569. if !ok {
  5570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5571. }
  5572. m.SetGname(v)
  5573. return nil
  5574. case contact.FieldV3:
  5575. v, ok := value.(string)
  5576. if !ok {
  5577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5578. }
  5579. m.SetV3(v)
  5580. return nil
  5581. case contact.FieldOrganizationID:
  5582. v, ok := value.(uint64)
  5583. if !ok {
  5584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5585. }
  5586. m.SetOrganizationID(v)
  5587. return nil
  5588. }
  5589. return fmt.Errorf("unknown Contact field %s", name)
  5590. }
  5591. // AddedFields returns all numeric fields that were incremented/decremented during
  5592. // this mutation.
  5593. func (m *ContactMutation) AddedFields() []string {
  5594. var fields []string
  5595. if m.addstatus != nil {
  5596. fields = append(fields, contact.FieldStatus)
  5597. }
  5598. if m.add_type != nil {
  5599. fields = append(fields, contact.FieldType)
  5600. }
  5601. if m.addsex != nil {
  5602. fields = append(fields, contact.FieldSex)
  5603. }
  5604. if m.adddontseeit != nil {
  5605. fields = append(fields, contact.FieldDontseeit)
  5606. }
  5607. if m.adddontseeme != nil {
  5608. fields = append(fields, contact.FieldDontseeme)
  5609. }
  5610. if m.addorganization_id != nil {
  5611. fields = append(fields, contact.FieldOrganizationID)
  5612. }
  5613. return fields
  5614. }
  5615. // AddedField returns the numeric value that was incremented/decremented on a field
  5616. // with the given name. The second boolean return value indicates that this field
  5617. // was not set, or was not defined in the schema.
  5618. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  5619. switch name {
  5620. case contact.FieldStatus:
  5621. return m.AddedStatus()
  5622. case contact.FieldType:
  5623. return m.AddedType()
  5624. case contact.FieldSex:
  5625. return m.AddedSex()
  5626. case contact.FieldDontseeit:
  5627. return m.AddedDontseeit()
  5628. case contact.FieldDontseeme:
  5629. return m.AddedDontseeme()
  5630. case contact.FieldOrganizationID:
  5631. return m.AddedOrganizationID()
  5632. }
  5633. return nil, false
  5634. }
  5635. // AddField adds the value to the field with the given name. It returns an error if
  5636. // the field is not defined in the schema, or if the type mismatched the field
  5637. // type.
  5638. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  5639. switch name {
  5640. case contact.FieldStatus:
  5641. v, ok := value.(int8)
  5642. if !ok {
  5643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5644. }
  5645. m.AddStatus(v)
  5646. return nil
  5647. case contact.FieldType:
  5648. v, ok := value.(int)
  5649. if !ok {
  5650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5651. }
  5652. m.AddType(v)
  5653. return nil
  5654. case contact.FieldSex:
  5655. v, ok := value.(int)
  5656. if !ok {
  5657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5658. }
  5659. m.AddSex(v)
  5660. return nil
  5661. case contact.FieldDontseeit:
  5662. v, ok := value.(int)
  5663. if !ok {
  5664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5665. }
  5666. m.AddDontseeit(v)
  5667. return nil
  5668. case contact.FieldDontseeme:
  5669. v, ok := value.(int)
  5670. if !ok {
  5671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5672. }
  5673. m.AddDontseeme(v)
  5674. return nil
  5675. case contact.FieldOrganizationID:
  5676. v, ok := value.(int64)
  5677. if !ok {
  5678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5679. }
  5680. m.AddOrganizationID(v)
  5681. return nil
  5682. }
  5683. return fmt.Errorf("unknown Contact numeric field %s", name)
  5684. }
  5685. // ClearedFields returns all nullable fields that were cleared during this
  5686. // mutation.
  5687. func (m *ContactMutation) ClearedFields() []string {
  5688. var fields []string
  5689. if m.FieldCleared(contact.FieldStatus) {
  5690. fields = append(fields, contact.FieldStatus)
  5691. }
  5692. if m.FieldCleared(contact.FieldDeletedAt) {
  5693. fields = append(fields, contact.FieldDeletedAt)
  5694. }
  5695. if m.FieldCleared(contact.FieldWxWxid) {
  5696. fields = append(fields, contact.FieldWxWxid)
  5697. }
  5698. if m.FieldCleared(contact.FieldType) {
  5699. fields = append(fields, contact.FieldType)
  5700. }
  5701. if m.FieldCleared(contact.FieldOrganizationID) {
  5702. fields = append(fields, contact.FieldOrganizationID)
  5703. }
  5704. return fields
  5705. }
  5706. // FieldCleared returns a boolean indicating if a field with the given name was
  5707. // cleared in this mutation.
  5708. func (m *ContactMutation) FieldCleared(name string) bool {
  5709. _, ok := m.clearedFields[name]
  5710. return ok
  5711. }
  5712. // ClearField clears the value of the field with the given name. It returns an
  5713. // error if the field is not defined in the schema.
  5714. func (m *ContactMutation) ClearField(name string) error {
  5715. switch name {
  5716. case contact.FieldStatus:
  5717. m.ClearStatus()
  5718. return nil
  5719. case contact.FieldDeletedAt:
  5720. m.ClearDeletedAt()
  5721. return nil
  5722. case contact.FieldWxWxid:
  5723. m.ClearWxWxid()
  5724. return nil
  5725. case contact.FieldType:
  5726. m.ClearType()
  5727. return nil
  5728. case contact.FieldOrganizationID:
  5729. m.ClearOrganizationID()
  5730. return nil
  5731. }
  5732. return fmt.Errorf("unknown Contact nullable field %s", name)
  5733. }
  5734. // ResetField resets all changes in the mutation for the field with the given name.
  5735. // It returns an error if the field is not defined in the schema.
  5736. func (m *ContactMutation) ResetField(name string) error {
  5737. switch name {
  5738. case contact.FieldCreatedAt:
  5739. m.ResetCreatedAt()
  5740. return nil
  5741. case contact.FieldUpdatedAt:
  5742. m.ResetUpdatedAt()
  5743. return nil
  5744. case contact.FieldStatus:
  5745. m.ResetStatus()
  5746. return nil
  5747. case contact.FieldDeletedAt:
  5748. m.ResetDeletedAt()
  5749. return nil
  5750. case contact.FieldWxWxid:
  5751. m.ResetWxWxid()
  5752. return nil
  5753. case contact.FieldType:
  5754. m.ResetType()
  5755. return nil
  5756. case contact.FieldWxid:
  5757. m.ResetWxid()
  5758. return nil
  5759. case contact.FieldAccount:
  5760. m.ResetAccount()
  5761. return nil
  5762. case contact.FieldNickname:
  5763. m.ResetNickname()
  5764. return nil
  5765. case contact.FieldMarkname:
  5766. m.ResetMarkname()
  5767. return nil
  5768. case contact.FieldHeadimg:
  5769. m.ResetHeadimg()
  5770. return nil
  5771. case contact.FieldSex:
  5772. m.ResetSex()
  5773. return nil
  5774. case contact.FieldStarrole:
  5775. m.ResetStarrole()
  5776. return nil
  5777. case contact.FieldDontseeit:
  5778. m.ResetDontseeit()
  5779. return nil
  5780. case contact.FieldDontseeme:
  5781. m.ResetDontseeme()
  5782. return nil
  5783. case contact.FieldLag:
  5784. m.ResetLag()
  5785. return nil
  5786. case contact.FieldGid:
  5787. m.ResetGid()
  5788. return nil
  5789. case contact.FieldGname:
  5790. m.ResetGname()
  5791. return nil
  5792. case contact.FieldV3:
  5793. m.ResetV3()
  5794. return nil
  5795. case contact.FieldOrganizationID:
  5796. m.ResetOrganizationID()
  5797. return nil
  5798. }
  5799. return fmt.Errorf("unknown Contact field %s", name)
  5800. }
  5801. // AddedEdges returns all edge names that were set/added in this mutation.
  5802. func (m *ContactMutation) AddedEdges() []string {
  5803. edges := make([]string, 0, 2)
  5804. if m.contact_relationships != nil {
  5805. edges = append(edges, contact.EdgeContactRelationships)
  5806. }
  5807. if m.contact_messages != nil {
  5808. edges = append(edges, contact.EdgeContactMessages)
  5809. }
  5810. return edges
  5811. }
  5812. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5813. // name in this mutation.
  5814. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  5815. switch name {
  5816. case contact.EdgeContactRelationships:
  5817. ids := make([]ent.Value, 0, len(m.contact_relationships))
  5818. for id := range m.contact_relationships {
  5819. ids = append(ids, id)
  5820. }
  5821. return ids
  5822. case contact.EdgeContactMessages:
  5823. ids := make([]ent.Value, 0, len(m.contact_messages))
  5824. for id := range m.contact_messages {
  5825. ids = append(ids, id)
  5826. }
  5827. return ids
  5828. }
  5829. return nil
  5830. }
  5831. // RemovedEdges returns all edge names that were removed in this mutation.
  5832. func (m *ContactMutation) RemovedEdges() []string {
  5833. edges := make([]string, 0, 2)
  5834. if m.removedcontact_relationships != nil {
  5835. edges = append(edges, contact.EdgeContactRelationships)
  5836. }
  5837. if m.removedcontact_messages != nil {
  5838. edges = append(edges, contact.EdgeContactMessages)
  5839. }
  5840. return edges
  5841. }
  5842. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5843. // the given name in this mutation.
  5844. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  5845. switch name {
  5846. case contact.EdgeContactRelationships:
  5847. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  5848. for id := range m.removedcontact_relationships {
  5849. ids = append(ids, id)
  5850. }
  5851. return ids
  5852. case contact.EdgeContactMessages:
  5853. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  5854. for id := range m.removedcontact_messages {
  5855. ids = append(ids, id)
  5856. }
  5857. return ids
  5858. }
  5859. return nil
  5860. }
  5861. // ClearedEdges returns all edge names that were cleared in this mutation.
  5862. func (m *ContactMutation) ClearedEdges() []string {
  5863. edges := make([]string, 0, 2)
  5864. if m.clearedcontact_relationships {
  5865. edges = append(edges, contact.EdgeContactRelationships)
  5866. }
  5867. if m.clearedcontact_messages {
  5868. edges = append(edges, contact.EdgeContactMessages)
  5869. }
  5870. return edges
  5871. }
  5872. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5873. // was cleared in this mutation.
  5874. func (m *ContactMutation) EdgeCleared(name string) bool {
  5875. switch name {
  5876. case contact.EdgeContactRelationships:
  5877. return m.clearedcontact_relationships
  5878. case contact.EdgeContactMessages:
  5879. return m.clearedcontact_messages
  5880. }
  5881. return false
  5882. }
  5883. // ClearEdge clears the value of the edge with the given name. It returns an error
  5884. // if that edge is not defined in the schema.
  5885. func (m *ContactMutation) ClearEdge(name string) error {
  5886. switch name {
  5887. }
  5888. return fmt.Errorf("unknown Contact unique edge %s", name)
  5889. }
  5890. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5891. // It returns an error if the edge is not defined in the schema.
  5892. func (m *ContactMutation) ResetEdge(name string) error {
  5893. switch name {
  5894. case contact.EdgeContactRelationships:
  5895. m.ResetContactRelationships()
  5896. return nil
  5897. case contact.EdgeContactMessages:
  5898. m.ResetContactMessages()
  5899. return nil
  5900. }
  5901. return fmt.Errorf("unknown Contact edge %s", name)
  5902. }
  5903. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  5904. type EmployeeMutation struct {
  5905. config
  5906. op Op
  5907. typ string
  5908. id *uint64
  5909. created_at *time.Time
  5910. updated_at *time.Time
  5911. deleted_at *time.Time
  5912. title *string
  5913. avatar *string
  5914. tags *string
  5915. hire_count *int
  5916. addhire_count *int
  5917. service_count *int
  5918. addservice_count *int
  5919. achievement_count *int
  5920. addachievement_count *int
  5921. intro *string
  5922. estimate *string
  5923. skill *string
  5924. ability_type *string
  5925. scene *string
  5926. switch_in *string
  5927. video_url *string
  5928. organization_id *uint64
  5929. addorganization_id *int64
  5930. category_id *uint64
  5931. addcategory_id *int64
  5932. clearedFields map[string]struct{}
  5933. em_work_experiences map[uint64]struct{}
  5934. removedem_work_experiences map[uint64]struct{}
  5935. clearedem_work_experiences bool
  5936. em_tutorial map[uint64]struct{}
  5937. removedem_tutorial map[uint64]struct{}
  5938. clearedem_tutorial bool
  5939. done bool
  5940. oldValue func(context.Context) (*Employee, error)
  5941. predicates []predicate.Employee
  5942. }
  5943. var _ ent.Mutation = (*EmployeeMutation)(nil)
  5944. // employeeOption allows management of the mutation configuration using functional options.
  5945. type employeeOption func(*EmployeeMutation)
  5946. // newEmployeeMutation creates new mutation for the Employee entity.
  5947. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  5948. m := &EmployeeMutation{
  5949. config: c,
  5950. op: op,
  5951. typ: TypeEmployee,
  5952. clearedFields: make(map[string]struct{}),
  5953. }
  5954. for _, opt := range opts {
  5955. opt(m)
  5956. }
  5957. return m
  5958. }
  5959. // withEmployeeID sets the ID field of the mutation.
  5960. func withEmployeeID(id uint64) employeeOption {
  5961. return func(m *EmployeeMutation) {
  5962. var (
  5963. err error
  5964. once sync.Once
  5965. value *Employee
  5966. )
  5967. m.oldValue = func(ctx context.Context) (*Employee, error) {
  5968. once.Do(func() {
  5969. if m.done {
  5970. err = errors.New("querying old values post mutation is not allowed")
  5971. } else {
  5972. value, err = m.Client().Employee.Get(ctx, id)
  5973. }
  5974. })
  5975. return value, err
  5976. }
  5977. m.id = &id
  5978. }
  5979. }
  5980. // withEmployee sets the old Employee of the mutation.
  5981. func withEmployee(node *Employee) employeeOption {
  5982. return func(m *EmployeeMutation) {
  5983. m.oldValue = func(context.Context) (*Employee, error) {
  5984. return node, nil
  5985. }
  5986. m.id = &node.ID
  5987. }
  5988. }
  5989. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5990. // executed in a transaction (ent.Tx), a transactional client is returned.
  5991. func (m EmployeeMutation) Client() *Client {
  5992. client := &Client{config: m.config}
  5993. client.init()
  5994. return client
  5995. }
  5996. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5997. // it returns an error otherwise.
  5998. func (m EmployeeMutation) Tx() (*Tx, error) {
  5999. if _, ok := m.driver.(*txDriver); !ok {
  6000. return nil, errors.New("ent: mutation is not running in a transaction")
  6001. }
  6002. tx := &Tx{config: m.config}
  6003. tx.init()
  6004. return tx, nil
  6005. }
  6006. // SetID sets the value of the id field. Note that this
  6007. // operation is only accepted on creation of Employee entities.
  6008. func (m *EmployeeMutation) SetID(id uint64) {
  6009. m.id = &id
  6010. }
  6011. // ID returns the ID value in the mutation. Note that the ID is only available
  6012. // if it was provided to the builder or after it was returned from the database.
  6013. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  6014. if m.id == nil {
  6015. return
  6016. }
  6017. return *m.id, true
  6018. }
  6019. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6020. // That means, if the mutation is applied within a transaction with an isolation level such
  6021. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6022. // or updated by the mutation.
  6023. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  6024. switch {
  6025. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6026. id, exists := m.ID()
  6027. if exists {
  6028. return []uint64{id}, nil
  6029. }
  6030. fallthrough
  6031. case m.op.Is(OpUpdate | OpDelete):
  6032. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  6033. default:
  6034. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6035. }
  6036. }
  6037. // SetCreatedAt sets the "created_at" field.
  6038. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  6039. m.created_at = &t
  6040. }
  6041. // CreatedAt returns the value of the "created_at" field in the mutation.
  6042. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  6043. v := m.created_at
  6044. if v == nil {
  6045. return
  6046. }
  6047. return *v, true
  6048. }
  6049. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  6050. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6052. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6053. if !m.op.Is(OpUpdateOne) {
  6054. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6055. }
  6056. if m.id == nil || m.oldValue == nil {
  6057. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6058. }
  6059. oldValue, err := m.oldValue(ctx)
  6060. if err != nil {
  6061. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6062. }
  6063. return oldValue.CreatedAt, nil
  6064. }
  6065. // ResetCreatedAt resets all changes to the "created_at" field.
  6066. func (m *EmployeeMutation) ResetCreatedAt() {
  6067. m.created_at = nil
  6068. }
  6069. // SetUpdatedAt sets the "updated_at" field.
  6070. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  6071. m.updated_at = &t
  6072. }
  6073. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6074. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  6075. v := m.updated_at
  6076. if v == nil {
  6077. return
  6078. }
  6079. return *v, true
  6080. }
  6081. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  6082. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6084. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6085. if !m.op.Is(OpUpdateOne) {
  6086. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6087. }
  6088. if m.id == nil || m.oldValue == nil {
  6089. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6090. }
  6091. oldValue, err := m.oldValue(ctx)
  6092. if err != nil {
  6093. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6094. }
  6095. return oldValue.UpdatedAt, nil
  6096. }
  6097. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6098. func (m *EmployeeMutation) ResetUpdatedAt() {
  6099. m.updated_at = nil
  6100. }
  6101. // SetDeletedAt sets the "deleted_at" field.
  6102. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  6103. m.deleted_at = &t
  6104. }
  6105. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6106. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  6107. v := m.deleted_at
  6108. if v == nil {
  6109. return
  6110. }
  6111. return *v, true
  6112. }
  6113. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  6114. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6116. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6117. if !m.op.Is(OpUpdateOne) {
  6118. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6119. }
  6120. if m.id == nil || m.oldValue == nil {
  6121. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6122. }
  6123. oldValue, err := m.oldValue(ctx)
  6124. if err != nil {
  6125. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6126. }
  6127. return oldValue.DeletedAt, nil
  6128. }
  6129. // ClearDeletedAt clears the value of the "deleted_at" field.
  6130. func (m *EmployeeMutation) ClearDeletedAt() {
  6131. m.deleted_at = nil
  6132. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  6133. }
  6134. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6135. func (m *EmployeeMutation) DeletedAtCleared() bool {
  6136. _, ok := m.clearedFields[employee.FieldDeletedAt]
  6137. return ok
  6138. }
  6139. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6140. func (m *EmployeeMutation) ResetDeletedAt() {
  6141. m.deleted_at = nil
  6142. delete(m.clearedFields, employee.FieldDeletedAt)
  6143. }
  6144. // SetTitle sets the "title" field.
  6145. func (m *EmployeeMutation) SetTitle(s string) {
  6146. m.title = &s
  6147. }
  6148. // Title returns the value of the "title" field in the mutation.
  6149. func (m *EmployeeMutation) Title() (r string, exists bool) {
  6150. v := m.title
  6151. if v == nil {
  6152. return
  6153. }
  6154. return *v, true
  6155. }
  6156. // OldTitle returns the old "title" field's value of the Employee entity.
  6157. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6159. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  6160. if !m.op.Is(OpUpdateOne) {
  6161. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  6162. }
  6163. if m.id == nil || m.oldValue == nil {
  6164. return v, errors.New("OldTitle requires an ID field in the mutation")
  6165. }
  6166. oldValue, err := m.oldValue(ctx)
  6167. if err != nil {
  6168. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  6169. }
  6170. return oldValue.Title, nil
  6171. }
  6172. // ResetTitle resets all changes to the "title" field.
  6173. func (m *EmployeeMutation) ResetTitle() {
  6174. m.title = nil
  6175. }
  6176. // SetAvatar sets the "avatar" field.
  6177. func (m *EmployeeMutation) SetAvatar(s string) {
  6178. m.avatar = &s
  6179. }
  6180. // Avatar returns the value of the "avatar" field in the mutation.
  6181. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  6182. v := m.avatar
  6183. if v == nil {
  6184. return
  6185. }
  6186. return *v, true
  6187. }
  6188. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  6189. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6191. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  6192. if !m.op.Is(OpUpdateOne) {
  6193. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  6194. }
  6195. if m.id == nil || m.oldValue == nil {
  6196. return v, errors.New("OldAvatar requires an ID field in the mutation")
  6197. }
  6198. oldValue, err := m.oldValue(ctx)
  6199. if err != nil {
  6200. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  6201. }
  6202. return oldValue.Avatar, nil
  6203. }
  6204. // ResetAvatar resets all changes to the "avatar" field.
  6205. func (m *EmployeeMutation) ResetAvatar() {
  6206. m.avatar = nil
  6207. }
  6208. // SetTags sets the "tags" field.
  6209. func (m *EmployeeMutation) SetTags(s string) {
  6210. m.tags = &s
  6211. }
  6212. // Tags returns the value of the "tags" field in the mutation.
  6213. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  6214. v := m.tags
  6215. if v == nil {
  6216. return
  6217. }
  6218. return *v, true
  6219. }
  6220. // OldTags returns the old "tags" field's value of the Employee entity.
  6221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6223. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  6224. if !m.op.Is(OpUpdateOne) {
  6225. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  6226. }
  6227. if m.id == nil || m.oldValue == nil {
  6228. return v, errors.New("OldTags requires an ID field in the mutation")
  6229. }
  6230. oldValue, err := m.oldValue(ctx)
  6231. if err != nil {
  6232. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  6233. }
  6234. return oldValue.Tags, nil
  6235. }
  6236. // ResetTags resets all changes to the "tags" field.
  6237. func (m *EmployeeMutation) ResetTags() {
  6238. m.tags = nil
  6239. }
  6240. // SetHireCount sets the "hire_count" field.
  6241. func (m *EmployeeMutation) SetHireCount(i int) {
  6242. m.hire_count = &i
  6243. m.addhire_count = nil
  6244. }
  6245. // HireCount returns the value of the "hire_count" field in the mutation.
  6246. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  6247. v := m.hire_count
  6248. if v == nil {
  6249. return
  6250. }
  6251. return *v, true
  6252. }
  6253. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  6254. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6256. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  6257. if !m.op.Is(OpUpdateOne) {
  6258. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  6259. }
  6260. if m.id == nil || m.oldValue == nil {
  6261. return v, errors.New("OldHireCount requires an ID field in the mutation")
  6262. }
  6263. oldValue, err := m.oldValue(ctx)
  6264. if err != nil {
  6265. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  6266. }
  6267. return oldValue.HireCount, nil
  6268. }
  6269. // AddHireCount adds i to the "hire_count" field.
  6270. func (m *EmployeeMutation) AddHireCount(i int) {
  6271. if m.addhire_count != nil {
  6272. *m.addhire_count += i
  6273. } else {
  6274. m.addhire_count = &i
  6275. }
  6276. }
  6277. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  6278. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  6279. v := m.addhire_count
  6280. if v == nil {
  6281. return
  6282. }
  6283. return *v, true
  6284. }
  6285. // ResetHireCount resets all changes to the "hire_count" field.
  6286. func (m *EmployeeMutation) ResetHireCount() {
  6287. m.hire_count = nil
  6288. m.addhire_count = nil
  6289. }
  6290. // SetServiceCount sets the "service_count" field.
  6291. func (m *EmployeeMutation) SetServiceCount(i int) {
  6292. m.service_count = &i
  6293. m.addservice_count = nil
  6294. }
  6295. // ServiceCount returns the value of the "service_count" field in the mutation.
  6296. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  6297. v := m.service_count
  6298. if v == nil {
  6299. return
  6300. }
  6301. return *v, true
  6302. }
  6303. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  6304. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6306. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  6307. if !m.op.Is(OpUpdateOne) {
  6308. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  6309. }
  6310. if m.id == nil || m.oldValue == nil {
  6311. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  6312. }
  6313. oldValue, err := m.oldValue(ctx)
  6314. if err != nil {
  6315. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  6316. }
  6317. return oldValue.ServiceCount, nil
  6318. }
  6319. // AddServiceCount adds i to the "service_count" field.
  6320. func (m *EmployeeMutation) AddServiceCount(i int) {
  6321. if m.addservice_count != nil {
  6322. *m.addservice_count += i
  6323. } else {
  6324. m.addservice_count = &i
  6325. }
  6326. }
  6327. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  6328. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  6329. v := m.addservice_count
  6330. if v == nil {
  6331. return
  6332. }
  6333. return *v, true
  6334. }
  6335. // ResetServiceCount resets all changes to the "service_count" field.
  6336. func (m *EmployeeMutation) ResetServiceCount() {
  6337. m.service_count = nil
  6338. m.addservice_count = nil
  6339. }
  6340. // SetAchievementCount sets the "achievement_count" field.
  6341. func (m *EmployeeMutation) SetAchievementCount(i int) {
  6342. m.achievement_count = &i
  6343. m.addachievement_count = nil
  6344. }
  6345. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  6346. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  6347. v := m.achievement_count
  6348. if v == nil {
  6349. return
  6350. }
  6351. return *v, true
  6352. }
  6353. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  6354. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6356. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  6357. if !m.op.Is(OpUpdateOne) {
  6358. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  6359. }
  6360. if m.id == nil || m.oldValue == nil {
  6361. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  6362. }
  6363. oldValue, err := m.oldValue(ctx)
  6364. if err != nil {
  6365. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  6366. }
  6367. return oldValue.AchievementCount, nil
  6368. }
  6369. // AddAchievementCount adds i to the "achievement_count" field.
  6370. func (m *EmployeeMutation) AddAchievementCount(i int) {
  6371. if m.addachievement_count != nil {
  6372. *m.addachievement_count += i
  6373. } else {
  6374. m.addachievement_count = &i
  6375. }
  6376. }
  6377. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  6378. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  6379. v := m.addachievement_count
  6380. if v == nil {
  6381. return
  6382. }
  6383. return *v, true
  6384. }
  6385. // ResetAchievementCount resets all changes to the "achievement_count" field.
  6386. func (m *EmployeeMutation) ResetAchievementCount() {
  6387. m.achievement_count = nil
  6388. m.addachievement_count = nil
  6389. }
  6390. // SetIntro sets the "intro" field.
  6391. func (m *EmployeeMutation) SetIntro(s string) {
  6392. m.intro = &s
  6393. }
  6394. // Intro returns the value of the "intro" field in the mutation.
  6395. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  6396. v := m.intro
  6397. if v == nil {
  6398. return
  6399. }
  6400. return *v, true
  6401. }
  6402. // OldIntro returns the old "intro" field's value of the Employee entity.
  6403. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6405. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  6406. if !m.op.Is(OpUpdateOne) {
  6407. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  6408. }
  6409. if m.id == nil || m.oldValue == nil {
  6410. return v, errors.New("OldIntro requires an ID field in the mutation")
  6411. }
  6412. oldValue, err := m.oldValue(ctx)
  6413. if err != nil {
  6414. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  6415. }
  6416. return oldValue.Intro, nil
  6417. }
  6418. // ResetIntro resets all changes to the "intro" field.
  6419. func (m *EmployeeMutation) ResetIntro() {
  6420. m.intro = nil
  6421. }
  6422. // SetEstimate sets the "estimate" field.
  6423. func (m *EmployeeMutation) SetEstimate(s string) {
  6424. m.estimate = &s
  6425. }
  6426. // Estimate returns the value of the "estimate" field in the mutation.
  6427. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  6428. v := m.estimate
  6429. if v == nil {
  6430. return
  6431. }
  6432. return *v, true
  6433. }
  6434. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  6435. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6437. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  6438. if !m.op.Is(OpUpdateOne) {
  6439. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  6440. }
  6441. if m.id == nil || m.oldValue == nil {
  6442. return v, errors.New("OldEstimate requires an ID field in the mutation")
  6443. }
  6444. oldValue, err := m.oldValue(ctx)
  6445. if err != nil {
  6446. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  6447. }
  6448. return oldValue.Estimate, nil
  6449. }
  6450. // ResetEstimate resets all changes to the "estimate" field.
  6451. func (m *EmployeeMutation) ResetEstimate() {
  6452. m.estimate = nil
  6453. }
  6454. // SetSkill sets the "skill" field.
  6455. func (m *EmployeeMutation) SetSkill(s string) {
  6456. m.skill = &s
  6457. }
  6458. // Skill returns the value of the "skill" field in the mutation.
  6459. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  6460. v := m.skill
  6461. if v == nil {
  6462. return
  6463. }
  6464. return *v, true
  6465. }
  6466. // OldSkill returns the old "skill" field's value of the Employee entity.
  6467. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6469. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  6470. if !m.op.Is(OpUpdateOne) {
  6471. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  6472. }
  6473. if m.id == nil || m.oldValue == nil {
  6474. return v, errors.New("OldSkill requires an ID field in the mutation")
  6475. }
  6476. oldValue, err := m.oldValue(ctx)
  6477. if err != nil {
  6478. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  6479. }
  6480. return oldValue.Skill, nil
  6481. }
  6482. // ResetSkill resets all changes to the "skill" field.
  6483. func (m *EmployeeMutation) ResetSkill() {
  6484. m.skill = nil
  6485. }
  6486. // SetAbilityType sets the "ability_type" field.
  6487. func (m *EmployeeMutation) SetAbilityType(s string) {
  6488. m.ability_type = &s
  6489. }
  6490. // AbilityType returns the value of the "ability_type" field in the mutation.
  6491. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  6492. v := m.ability_type
  6493. if v == nil {
  6494. return
  6495. }
  6496. return *v, true
  6497. }
  6498. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  6499. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6501. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  6502. if !m.op.Is(OpUpdateOne) {
  6503. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  6504. }
  6505. if m.id == nil || m.oldValue == nil {
  6506. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  6507. }
  6508. oldValue, err := m.oldValue(ctx)
  6509. if err != nil {
  6510. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  6511. }
  6512. return oldValue.AbilityType, nil
  6513. }
  6514. // ResetAbilityType resets all changes to the "ability_type" field.
  6515. func (m *EmployeeMutation) ResetAbilityType() {
  6516. m.ability_type = nil
  6517. }
  6518. // SetScene sets the "scene" field.
  6519. func (m *EmployeeMutation) SetScene(s string) {
  6520. m.scene = &s
  6521. }
  6522. // Scene returns the value of the "scene" field in the mutation.
  6523. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  6524. v := m.scene
  6525. if v == nil {
  6526. return
  6527. }
  6528. return *v, true
  6529. }
  6530. // OldScene returns the old "scene" field's value of the Employee entity.
  6531. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6533. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  6534. if !m.op.Is(OpUpdateOne) {
  6535. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  6536. }
  6537. if m.id == nil || m.oldValue == nil {
  6538. return v, errors.New("OldScene requires an ID field in the mutation")
  6539. }
  6540. oldValue, err := m.oldValue(ctx)
  6541. if err != nil {
  6542. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  6543. }
  6544. return oldValue.Scene, nil
  6545. }
  6546. // ResetScene resets all changes to the "scene" field.
  6547. func (m *EmployeeMutation) ResetScene() {
  6548. m.scene = nil
  6549. }
  6550. // SetSwitchIn sets the "switch_in" field.
  6551. func (m *EmployeeMutation) SetSwitchIn(s string) {
  6552. m.switch_in = &s
  6553. }
  6554. // SwitchIn returns the value of the "switch_in" field in the mutation.
  6555. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  6556. v := m.switch_in
  6557. if v == nil {
  6558. return
  6559. }
  6560. return *v, true
  6561. }
  6562. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  6563. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6565. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  6566. if !m.op.Is(OpUpdateOne) {
  6567. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  6568. }
  6569. if m.id == nil || m.oldValue == nil {
  6570. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  6571. }
  6572. oldValue, err := m.oldValue(ctx)
  6573. if err != nil {
  6574. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  6575. }
  6576. return oldValue.SwitchIn, nil
  6577. }
  6578. // ResetSwitchIn resets all changes to the "switch_in" field.
  6579. func (m *EmployeeMutation) ResetSwitchIn() {
  6580. m.switch_in = nil
  6581. }
  6582. // SetVideoURL sets the "video_url" field.
  6583. func (m *EmployeeMutation) SetVideoURL(s string) {
  6584. m.video_url = &s
  6585. }
  6586. // VideoURL returns the value of the "video_url" field in the mutation.
  6587. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  6588. v := m.video_url
  6589. if v == nil {
  6590. return
  6591. }
  6592. return *v, true
  6593. }
  6594. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  6595. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6597. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  6598. if !m.op.Is(OpUpdateOne) {
  6599. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  6600. }
  6601. if m.id == nil || m.oldValue == nil {
  6602. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  6603. }
  6604. oldValue, err := m.oldValue(ctx)
  6605. if err != nil {
  6606. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  6607. }
  6608. return oldValue.VideoURL, nil
  6609. }
  6610. // ResetVideoURL resets all changes to the "video_url" field.
  6611. func (m *EmployeeMutation) ResetVideoURL() {
  6612. m.video_url = nil
  6613. }
  6614. // SetOrganizationID sets the "organization_id" field.
  6615. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  6616. m.organization_id = &u
  6617. m.addorganization_id = nil
  6618. }
  6619. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6620. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  6621. v := m.organization_id
  6622. if v == nil {
  6623. return
  6624. }
  6625. return *v, true
  6626. }
  6627. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  6628. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6630. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6631. if !m.op.Is(OpUpdateOne) {
  6632. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6633. }
  6634. if m.id == nil || m.oldValue == nil {
  6635. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6636. }
  6637. oldValue, err := m.oldValue(ctx)
  6638. if err != nil {
  6639. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6640. }
  6641. return oldValue.OrganizationID, nil
  6642. }
  6643. // AddOrganizationID adds u to the "organization_id" field.
  6644. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  6645. if m.addorganization_id != nil {
  6646. *m.addorganization_id += u
  6647. } else {
  6648. m.addorganization_id = &u
  6649. }
  6650. }
  6651. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6652. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  6653. v := m.addorganization_id
  6654. if v == nil {
  6655. return
  6656. }
  6657. return *v, true
  6658. }
  6659. // ResetOrganizationID resets all changes to the "organization_id" field.
  6660. func (m *EmployeeMutation) ResetOrganizationID() {
  6661. m.organization_id = nil
  6662. m.addorganization_id = nil
  6663. }
  6664. // SetCategoryID sets the "category_id" field.
  6665. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  6666. m.category_id = &u
  6667. m.addcategory_id = nil
  6668. }
  6669. // CategoryID returns the value of the "category_id" field in the mutation.
  6670. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  6671. v := m.category_id
  6672. if v == nil {
  6673. return
  6674. }
  6675. return *v, true
  6676. }
  6677. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  6678. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  6679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6680. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  6681. if !m.op.Is(OpUpdateOne) {
  6682. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  6683. }
  6684. if m.id == nil || m.oldValue == nil {
  6685. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  6686. }
  6687. oldValue, err := m.oldValue(ctx)
  6688. if err != nil {
  6689. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  6690. }
  6691. return oldValue.CategoryID, nil
  6692. }
  6693. // AddCategoryID adds u to the "category_id" field.
  6694. func (m *EmployeeMutation) AddCategoryID(u int64) {
  6695. if m.addcategory_id != nil {
  6696. *m.addcategory_id += u
  6697. } else {
  6698. m.addcategory_id = &u
  6699. }
  6700. }
  6701. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  6702. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  6703. v := m.addcategory_id
  6704. if v == nil {
  6705. return
  6706. }
  6707. return *v, true
  6708. }
  6709. // ResetCategoryID resets all changes to the "category_id" field.
  6710. func (m *EmployeeMutation) ResetCategoryID() {
  6711. m.category_id = nil
  6712. m.addcategory_id = nil
  6713. }
  6714. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  6715. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  6716. if m.em_work_experiences == nil {
  6717. m.em_work_experiences = make(map[uint64]struct{})
  6718. }
  6719. for i := range ids {
  6720. m.em_work_experiences[ids[i]] = struct{}{}
  6721. }
  6722. }
  6723. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  6724. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  6725. m.clearedem_work_experiences = true
  6726. }
  6727. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  6728. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  6729. return m.clearedem_work_experiences
  6730. }
  6731. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  6732. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  6733. if m.removedem_work_experiences == nil {
  6734. m.removedem_work_experiences = make(map[uint64]struct{})
  6735. }
  6736. for i := range ids {
  6737. delete(m.em_work_experiences, ids[i])
  6738. m.removedem_work_experiences[ids[i]] = struct{}{}
  6739. }
  6740. }
  6741. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  6742. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  6743. for id := range m.removedem_work_experiences {
  6744. ids = append(ids, id)
  6745. }
  6746. return
  6747. }
  6748. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  6749. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  6750. for id := range m.em_work_experiences {
  6751. ids = append(ids, id)
  6752. }
  6753. return
  6754. }
  6755. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  6756. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  6757. m.em_work_experiences = nil
  6758. m.clearedem_work_experiences = false
  6759. m.removedem_work_experiences = nil
  6760. }
  6761. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  6762. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  6763. if m.em_tutorial == nil {
  6764. m.em_tutorial = make(map[uint64]struct{})
  6765. }
  6766. for i := range ids {
  6767. m.em_tutorial[ids[i]] = struct{}{}
  6768. }
  6769. }
  6770. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  6771. func (m *EmployeeMutation) ClearEmTutorial() {
  6772. m.clearedem_tutorial = true
  6773. }
  6774. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  6775. func (m *EmployeeMutation) EmTutorialCleared() bool {
  6776. return m.clearedem_tutorial
  6777. }
  6778. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  6779. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  6780. if m.removedem_tutorial == nil {
  6781. m.removedem_tutorial = make(map[uint64]struct{})
  6782. }
  6783. for i := range ids {
  6784. delete(m.em_tutorial, ids[i])
  6785. m.removedem_tutorial[ids[i]] = struct{}{}
  6786. }
  6787. }
  6788. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  6789. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  6790. for id := range m.removedem_tutorial {
  6791. ids = append(ids, id)
  6792. }
  6793. return
  6794. }
  6795. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  6796. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  6797. for id := range m.em_tutorial {
  6798. ids = append(ids, id)
  6799. }
  6800. return
  6801. }
  6802. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  6803. func (m *EmployeeMutation) ResetEmTutorial() {
  6804. m.em_tutorial = nil
  6805. m.clearedem_tutorial = false
  6806. m.removedem_tutorial = nil
  6807. }
  6808. // Where appends a list predicates to the EmployeeMutation builder.
  6809. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  6810. m.predicates = append(m.predicates, ps...)
  6811. }
  6812. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  6813. // users can use type-assertion to append predicates that do not depend on any generated package.
  6814. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  6815. p := make([]predicate.Employee, len(ps))
  6816. for i := range ps {
  6817. p[i] = ps[i]
  6818. }
  6819. m.Where(p...)
  6820. }
  6821. // Op returns the operation name.
  6822. func (m *EmployeeMutation) Op() Op {
  6823. return m.op
  6824. }
  6825. // SetOp allows setting the mutation operation.
  6826. func (m *EmployeeMutation) SetOp(op Op) {
  6827. m.op = op
  6828. }
  6829. // Type returns the node type of this mutation (Employee).
  6830. func (m *EmployeeMutation) Type() string {
  6831. return m.typ
  6832. }
  6833. // Fields returns all fields that were changed during this mutation. Note that in
  6834. // order to get all numeric fields that were incremented/decremented, call
  6835. // AddedFields().
  6836. func (m *EmployeeMutation) Fields() []string {
  6837. fields := make([]string, 0, 18)
  6838. if m.created_at != nil {
  6839. fields = append(fields, employee.FieldCreatedAt)
  6840. }
  6841. if m.updated_at != nil {
  6842. fields = append(fields, employee.FieldUpdatedAt)
  6843. }
  6844. if m.deleted_at != nil {
  6845. fields = append(fields, employee.FieldDeletedAt)
  6846. }
  6847. if m.title != nil {
  6848. fields = append(fields, employee.FieldTitle)
  6849. }
  6850. if m.avatar != nil {
  6851. fields = append(fields, employee.FieldAvatar)
  6852. }
  6853. if m.tags != nil {
  6854. fields = append(fields, employee.FieldTags)
  6855. }
  6856. if m.hire_count != nil {
  6857. fields = append(fields, employee.FieldHireCount)
  6858. }
  6859. if m.service_count != nil {
  6860. fields = append(fields, employee.FieldServiceCount)
  6861. }
  6862. if m.achievement_count != nil {
  6863. fields = append(fields, employee.FieldAchievementCount)
  6864. }
  6865. if m.intro != nil {
  6866. fields = append(fields, employee.FieldIntro)
  6867. }
  6868. if m.estimate != nil {
  6869. fields = append(fields, employee.FieldEstimate)
  6870. }
  6871. if m.skill != nil {
  6872. fields = append(fields, employee.FieldSkill)
  6873. }
  6874. if m.ability_type != nil {
  6875. fields = append(fields, employee.FieldAbilityType)
  6876. }
  6877. if m.scene != nil {
  6878. fields = append(fields, employee.FieldScene)
  6879. }
  6880. if m.switch_in != nil {
  6881. fields = append(fields, employee.FieldSwitchIn)
  6882. }
  6883. if m.video_url != nil {
  6884. fields = append(fields, employee.FieldVideoURL)
  6885. }
  6886. if m.organization_id != nil {
  6887. fields = append(fields, employee.FieldOrganizationID)
  6888. }
  6889. if m.category_id != nil {
  6890. fields = append(fields, employee.FieldCategoryID)
  6891. }
  6892. return fields
  6893. }
  6894. // Field returns the value of a field with the given name. The second boolean
  6895. // return value indicates that this field was not set, or was not defined in the
  6896. // schema.
  6897. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  6898. switch name {
  6899. case employee.FieldCreatedAt:
  6900. return m.CreatedAt()
  6901. case employee.FieldUpdatedAt:
  6902. return m.UpdatedAt()
  6903. case employee.FieldDeletedAt:
  6904. return m.DeletedAt()
  6905. case employee.FieldTitle:
  6906. return m.Title()
  6907. case employee.FieldAvatar:
  6908. return m.Avatar()
  6909. case employee.FieldTags:
  6910. return m.Tags()
  6911. case employee.FieldHireCount:
  6912. return m.HireCount()
  6913. case employee.FieldServiceCount:
  6914. return m.ServiceCount()
  6915. case employee.FieldAchievementCount:
  6916. return m.AchievementCount()
  6917. case employee.FieldIntro:
  6918. return m.Intro()
  6919. case employee.FieldEstimate:
  6920. return m.Estimate()
  6921. case employee.FieldSkill:
  6922. return m.Skill()
  6923. case employee.FieldAbilityType:
  6924. return m.AbilityType()
  6925. case employee.FieldScene:
  6926. return m.Scene()
  6927. case employee.FieldSwitchIn:
  6928. return m.SwitchIn()
  6929. case employee.FieldVideoURL:
  6930. return m.VideoURL()
  6931. case employee.FieldOrganizationID:
  6932. return m.OrganizationID()
  6933. case employee.FieldCategoryID:
  6934. return m.CategoryID()
  6935. }
  6936. return nil, false
  6937. }
  6938. // OldField returns the old value of the field from the database. An error is
  6939. // returned if the mutation operation is not UpdateOne, or the query to the
  6940. // database failed.
  6941. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6942. switch name {
  6943. case employee.FieldCreatedAt:
  6944. return m.OldCreatedAt(ctx)
  6945. case employee.FieldUpdatedAt:
  6946. return m.OldUpdatedAt(ctx)
  6947. case employee.FieldDeletedAt:
  6948. return m.OldDeletedAt(ctx)
  6949. case employee.FieldTitle:
  6950. return m.OldTitle(ctx)
  6951. case employee.FieldAvatar:
  6952. return m.OldAvatar(ctx)
  6953. case employee.FieldTags:
  6954. return m.OldTags(ctx)
  6955. case employee.FieldHireCount:
  6956. return m.OldHireCount(ctx)
  6957. case employee.FieldServiceCount:
  6958. return m.OldServiceCount(ctx)
  6959. case employee.FieldAchievementCount:
  6960. return m.OldAchievementCount(ctx)
  6961. case employee.FieldIntro:
  6962. return m.OldIntro(ctx)
  6963. case employee.FieldEstimate:
  6964. return m.OldEstimate(ctx)
  6965. case employee.FieldSkill:
  6966. return m.OldSkill(ctx)
  6967. case employee.FieldAbilityType:
  6968. return m.OldAbilityType(ctx)
  6969. case employee.FieldScene:
  6970. return m.OldScene(ctx)
  6971. case employee.FieldSwitchIn:
  6972. return m.OldSwitchIn(ctx)
  6973. case employee.FieldVideoURL:
  6974. return m.OldVideoURL(ctx)
  6975. case employee.FieldOrganizationID:
  6976. return m.OldOrganizationID(ctx)
  6977. case employee.FieldCategoryID:
  6978. return m.OldCategoryID(ctx)
  6979. }
  6980. return nil, fmt.Errorf("unknown Employee field %s", name)
  6981. }
  6982. // SetField sets the value of a field with the given name. It returns an error if
  6983. // the field is not defined in the schema, or if the type mismatched the field
  6984. // type.
  6985. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  6986. switch name {
  6987. case employee.FieldCreatedAt:
  6988. v, ok := value.(time.Time)
  6989. if !ok {
  6990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6991. }
  6992. m.SetCreatedAt(v)
  6993. return nil
  6994. case employee.FieldUpdatedAt:
  6995. v, ok := value.(time.Time)
  6996. if !ok {
  6997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6998. }
  6999. m.SetUpdatedAt(v)
  7000. return nil
  7001. case employee.FieldDeletedAt:
  7002. v, ok := value.(time.Time)
  7003. if !ok {
  7004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7005. }
  7006. m.SetDeletedAt(v)
  7007. return nil
  7008. case employee.FieldTitle:
  7009. v, ok := value.(string)
  7010. if !ok {
  7011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7012. }
  7013. m.SetTitle(v)
  7014. return nil
  7015. case employee.FieldAvatar:
  7016. v, ok := value.(string)
  7017. if !ok {
  7018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7019. }
  7020. m.SetAvatar(v)
  7021. return nil
  7022. case employee.FieldTags:
  7023. v, ok := value.(string)
  7024. if !ok {
  7025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7026. }
  7027. m.SetTags(v)
  7028. return nil
  7029. case employee.FieldHireCount:
  7030. v, ok := value.(int)
  7031. if !ok {
  7032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7033. }
  7034. m.SetHireCount(v)
  7035. return nil
  7036. case employee.FieldServiceCount:
  7037. v, ok := value.(int)
  7038. if !ok {
  7039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7040. }
  7041. m.SetServiceCount(v)
  7042. return nil
  7043. case employee.FieldAchievementCount:
  7044. v, ok := value.(int)
  7045. if !ok {
  7046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7047. }
  7048. m.SetAchievementCount(v)
  7049. return nil
  7050. case employee.FieldIntro:
  7051. v, ok := value.(string)
  7052. if !ok {
  7053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7054. }
  7055. m.SetIntro(v)
  7056. return nil
  7057. case employee.FieldEstimate:
  7058. v, ok := value.(string)
  7059. if !ok {
  7060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7061. }
  7062. m.SetEstimate(v)
  7063. return nil
  7064. case employee.FieldSkill:
  7065. v, ok := value.(string)
  7066. if !ok {
  7067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7068. }
  7069. m.SetSkill(v)
  7070. return nil
  7071. case employee.FieldAbilityType:
  7072. v, ok := value.(string)
  7073. if !ok {
  7074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7075. }
  7076. m.SetAbilityType(v)
  7077. return nil
  7078. case employee.FieldScene:
  7079. v, ok := value.(string)
  7080. if !ok {
  7081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7082. }
  7083. m.SetScene(v)
  7084. return nil
  7085. case employee.FieldSwitchIn:
  7086. v, ok := value.(string)
  7087. if !ok {
  7088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7089. }
  7090. m.SetSwitchIn(v)
  7091. return nil
  7092. case employee.FieldVideoURL:
  7093. v, ok := value.(string)
  7094. if !ok {
  7095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7096. }
  7097. m.SetVideoURL(v)
  7098. return nil
  7099. case employee.FieldOrganizationID:
  7100. v, ok := value.(uint64)
  7101. if !ok {
  7102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7103. }
  7104. m.SetOrganizationID(v)
  7105. return nil
  7106. case employee.FieldCategoryID:
  7107. v, ok := value.(uint64)
  7108. if !ok {
  7109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7110. }
  7111. m.SetCategoryID(v)
  7112. return nil
  7113. }
  7114. return fmt.Errorf("unknown Employee field %s", name)
  7115. }
  7116. // AddedFields returns all numeric fields that were incremented/decremented during
  7117. // this mutation.
  7118. func (m *EmployeeMutation) AddedFields() []string {
  7119. var fields []string
  7120. if m.addhire_count != nil {
  7121. fields = append(fields, employee.FieldHireCount)
  7122. }
  7123. if m.addservice_count != nil {
  7124. fields = append(fields, employee.FieldServiceCount)
  7125. }
  7126. if m.addachievement_count != nil {
  7127. fields = append(fields, employee.FieldAchievementCount)
  7128. }
  7129. if m.addorganization_id != nil {
  7130. fields = append(fields, employee.FieldOrganizationID)
  7131. }
  7132. if m.addcategory_id != nil {
  7133. fields = append(fields, employee.FieldCategoryID)
  7134. }
  7135. return fields
  7136. }
  7137. // AddedField returns the numeric value that was incremented/decremented on a field
  7138. // with the given name. The second boolean return value indicates that this field
  7139. // was not set, or was not defined in the schema.
  7140. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  7141. switch name {
  7142. case employee.FieldHireCount:
  7143. return m.AddedHireCount()
  7144. case employee.FieldServiceCount:
  7145. return m.AddedServiceCount()
  7146. case employee.FieldAchievementCount:
  7147. return m.AddedAchievementCount()
  7148. case employee.FieldOrganizationID:
  7149. return m.AddedOrganizationID()
  7150. case employee.FieldCategoryID:
  7151. return m.AddedCategoryID()
  7152. }
  7153. return nil, false
  7154. }
  7155. // AddField adds the value to the field with the given name. It returns an error if
  7156. // the field is not defined in the schema, or if the type mismatched the field
  7157. // type.
  7158. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  7159. switch name {
  7160. case employee.FieldHireCount:
  7161. v, ok := value.(int)
  7162. if !ok {
  7163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7164. }
  7165. m.AddHireCount(v)
  7166. return nil
  7167. case employee.FieldServiceCount:
  7168. v, ok := value.(int)
  7169. if !ok {
  7170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7171. }
  7172. m.AddServiceCount(v)
  7173. return nil
  7174. case employee.FieldAchievementCount:
  7175. v, ok := value.(int)
  7176. if !ok {
  7177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7178. }
  7179. m.AddAchievementCount(v)
  7180. return nil
  7181. case employee.FieldOrganizationID:
  7182. v, ok := value.(int64)
  7183. if !ok {
  7184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7185. }
  7186. m.AddOrganizationID(v)
  7187. return nil
  7188. case employee.FieldCategoryID:
  7189. v, ok := value.(int64)
  7190. if !ok {
  7191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7192. }
  7193. m.AddCategoryID(v)
  7194. return nil
  7195. }
  7196. return fmt.Errorf("unknown Employee numeric field %s", name)
  7197. }
  7198. // ClearedFields returns all nullable fields that were cleared during this
  7199. // mutation.
  7200. func (m *EmployeeMutation) ClearedFields() []string {
  7201. var fields []string
  7202. if m.FieldCleared(employee.FieldDeletedAt) {
  7203. fields = append(fields, employee.FieldDeletedAt)
  7204. }
  7205. return fields
  7206. }
  7207. // FieldCleared returns a boolean indicating if a field with the given name was
  7208. // cleared in this mutation.
  7209. func (m *EmployeeMutation) FieldCleared(name string) bool {
  7210. _, ok := m.clearedFields[name]
  7211. return ok
  7212. }
  7213. // ClearField clears the value of the field with the given name. It returns an
  7214. // error if the field is not defined in the schema.
  7215. func (m *EmployeeMutation) ClearField(name string) error {
  7216. switch name {
  7217. case employee.FieldDeletedAt:
  7218. m.ClearDeletedAt()
  7219. return nil
  7220. }
  7221. return fmt.Errorf("unknown Employee nullable field %s", name)
  7222. }
  7223. // ResetField resets all changes in the mutation for the field with the given name.
  7224. // It returns an error if the field is not defined in the schema.
  7225. func (m *EmployeeMutation) ResetField(name string) error {
  7226. switch name {
  7227. case employee.FieldCreatedAt:
  7228. m.ResetCreatedAt()
  7229. return nil
  7230. case employee.FieldUpdatedAt:
  7231. m.ResetUpdatedAt()
  7232. return nil
  7233. case employee.FieldDeletedAt:
  7234. m.ResetDeletedAt()
  7235. return nil
  7236. case employee.FieldTitle:
  7237. m.ResetTitle()
  7238. return nil
  7239. case employee.FieldAvatar:
  7240. m.ResetAvatar()
  7241. return nil
  7242. case employee.FieldTags:
  7243. m.ResetTags()
  7244. return nil
  7245. case employee.FieldHireCount:
  7246. m.ResetHireCount()
  7247. return nil
  7248. case employee.FieldServiceCount:
  7249. m.ResetServiceCount()
  7250. return nil
  7251. case employee.FieldAchievementCount:
  7252. m.ResetAchievementCount()
  7253. return nil
  7254. case employee.FieldIntro:
  7255. m.ResetIntro()
  7256. return nil
  7257. case employee.FieldEstimate:
  7258. m.ResetEstimate()
  7259. return nil
  7260. case employee.FieldSkill:
  7261. m.ResetSkill()
  7262. return nil
  7263. case employee.FieldAbilityType:
  7264. m.ResetAbilityType()
  7265. return nil
  7266. case employee.FieldScene:
  7267. m.ResetScene()
  7268. return nil
  7269. case employee.FieldSwitchIn:
  7270. m.ResetSwitchIn()
  7271. return nil
  7272. case employee.FieldVideoURL:
  7273. m.ResetVideoURL()
  7274. return nil
  7275. case employee.FieldOrganizationID:
  7276. m.ResetOrganizationID()
  7277. return nil
  7278. case employee.FieldCategoryID:
  7279. m.ResetCategoryID()
  7280. return nil
  7281. }
  7282. return fmt.Errorf("unknown Employee field %s", name)
  7283. }
  7284. // AddedEdges returns all edge names that were set/added in this mutation.
  7285. func (m *EmployeeMutation) AddedEdges() []string {
  7286. edges := make([]string, 0, 2)
  7287. if m.em_work_experiences != nil {
  7288. edges = append(edges, employee.EdgeEmWorkExperiences)
  7289. }
  7290. if m.em_tutorial != nil {
  7291. edges = append(edges, employee.EdgeEmTutorial)
  7292. }
  7293. return edges
  7294. }
  7295. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7296. // name in this mutation.
  7297. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  7298. switch name {
  7299. case employee.EdgeEmWorkExperiences:
  7300. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  7301. for id := range m.em_work_experiences {
  7302. ids = append(ids, id)
  7303. }
  7304. return ids
  7305. case employee.EdgeEmTutorial:
  7306. ids := make([]ent.Value, 0, len(m.em_tutorial))
  7307. for id := range m.em_tutorial {
  7308. ids = append(ids, id)
  7309. }
  7310. return ids
  7311. }
  7312. return nil
  7313. }
  7314. // RemovedEdges returns all edge names that were removed in this mutation.
  7315. func (m *EmployeeMutation) RemovedEdges() []string {
  7316. edges := make([]string, 0, 2)
  7317. if m.removedem_work_experiences != nil {
  7318. edges = append(edges, employee.EdgeEmWorkExperiences)
  7319. }
  7320. if m.removedem_tutorial != nil {
  7321. edges = append(edges, employee.EdgeEmTutorial)
  7322. }
  7323. return edges
  7324. }
  7325. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7326. // the given name in this mutation.
  7327. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  7328. switch name {
  7329. case employee.EdgeEmWorkExperiences:
  7330. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  7331. for id := range m.removedem_work_experiences {
  7332. ids = append(ids, id)
  7333. }
  7334. return ids
  7335. case employee.EdgeEmTutorial:
  7336. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  7337. for id := range m.removedem_tutorial {
  7338. ids = append(ids, id)
  7339. }
  7340. return ids
  7341. }
  7342. return nil
  7343. }
  7344. // ClearedEdges returns all edge names that were cleared in this mutation.
  7345. func (m *EmployeeMutation) ClearedEdges() []string {
  7346. edges := make([]string, 0, 2)
  7347. if m.clearedem_work_experiences {
  7348. edges = append(edges, employee.EdgeEmWorkExperiences)
  7349. }
  7350. if m.clearedem_tutorial {
  7351. edges = append(edges, employee.EdgeEmTutorial)
  7352. }
  7353. return edges
  7354. }
  7355. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7356. // was cleared in this mutation.
  7357. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  7358. switch name {
  7359. case employee.EdgeEmWorkExperiences:
  7360. return m.clearedem_work_experiences
  7361. case employee.EdgeEmTutorial:
  7362. return m.clearedem_tutorial
  7363. }
  7364. return false
  7365. }
  7366. // ClearEdge clears the value of the edge with the given name. It returns an error
  7367. // if that edge is not defined in the schema.
  7368. func (m *EmployeeMutation) ClearEdge(name string) error {
  7369. switch name {
  7370. }
  7371. return fmt.Errorf("unknown Employee unique edge %s", name)
  7372. }
  7373. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7374. // It returns an error if the edge is not defined in the schema.
  7375. func (m *EmployeeMutation) ResetEdge(name string) error {
  7376. switch name {
  7377. case employee.EdgeEmWorkExperiences:
  7378. m.ResetEmWorkExperiences()
  7379. return nil
  7380. case employee.EdgeEmTutorial:
  7381. m.ResetEmTutorial()
  7382. return nil
  7383. }
  7384. return fmt.Errorf("unknown Employee edge %s", name)
  7385. }
  7386. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  7387. type EmployeeConfigMutation struct {
  7388. config
  7389. op Op
  7390. typ string
  7391. id *uint64
  7392. created_at *time.Time
  7393. updated_at *time.Time
  7394. deleted_at *time.Time
  7395. stype *string
  7396. title *string
  7397. photo *string
  7398. organization_id *uint64
  7399. addorganization_id *int64
  7400. clearedFields map[string]struct{}
  7401. done bool
  7402. oldValue func(context.Context) (*EmployeeConfig, error)
  7403. predicates []predicate.EmployeeConfig
  7404. }
  7405. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  7406. // employeeconfigOption allows management of the mutation configuration using functional options.
  7407. type employeeconfigOption func(*EmployeeConfigMutation)
  7408. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  7409. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  7410. m := &EmployeeConfigMutation{
  7411. config: c,
  7412. op: op,
  7413. typ: TypeEmployeeConfig,
  7414. clearedFields: make(map[string]struct{}),
  7415. }
  7416. for _, opt := range opts {
  7417. opt(m)
  7418. }
  7419. return m
  7420. }
  7421. // withEmployeeConfigID sets the ID field of the mutation.
  7422. func withEmployeeConfigID(id uint64) employeeconfigOption {
  7423. return func(m *EmployeeConfigMutation) {
  7424. var (
  7425. err error
  7426. once sync.Once
  7427. value *EmployeeConfig
  7428. )
  7429. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  7430. once.Do(func() {
  7431. if m.done {
  7432. err = errors.New("querying old values post mutation is not allowed")
  7433. } else {
  7434. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  7435. }
  7436. })
  7437. return value, err
  7438. }
  7439. m.id = &id
  7440. }
  7441. }
  7442. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  7443. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  7444. return func(m *EmployeeConfigMutation) {
  7445. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  7446. return node, nil
  7447. }
  7448. m.id = &node.ID
  7449. }
  7450. }
  7451. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7452. // executed in a transaction (ent.Tx), a transactional client is returned.
  7453. func (m EmployeeConfigMutation) Client() *Client {
  7454. client := &Client{config: m.config}
  7455. client.init()
  7456. return client
  7457. }
  7458. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7459. // it returns an error otherwise.
  7460. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  7461. if _, ok := m.driver.(*txDriver); !ok {
  7462. return nil, errors.New("ent: mutation is not running in a transaction")
  7463. }
  7464. tx := &Tx{config: m.config}
  7465. tx.init()
  7466. return tx, nil
  7467. }
  7468. // SetID sets the value of the id field. Note that this
  7469. // operation is only accepted on creation of EmployeeConfig entities.
  7470. func (m *EmployeeConfigMutation) SetID(id uint64) {
  7471. m.id = &id
  7472. }
  7473. // ID returns the ID value in the mutation. Note that the ID is only available
  7474. // if it was provided to the builder or after it was returned from the database.
  7475. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  7476. if m.id == nil {
  7477. return
  7478. }
  7479. return *m.id, true
  7480. }
  7481. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7482. // That means, if the mutation is applied within a transaction with an isolation level such
  7483. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7484. // or updated by the mutation.
  7485. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  7486. switch {
  7487. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7488. id, exists := m.ID()
  7489. if exists {
  7490. return []uint64{id}, nil
  7491. }
  7492. fallthrough
  7493. case m.op.Is(OpUpdate | OpDelete):
  7494. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  7495. default:
  7496. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7497. }
  7498. }
  7499. // SetCreatedAt sets the "created_at" field.
  7500. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  7501. m.created_at = &t
  7502. }
  7503. // CreatedAt returns the value of the "created_at" field in the mutation.
  7504. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  7505. v := m.created_at
  7506. if v == nil {
  7507. return
  7508. }
  7509. return *v, true
  7510. }
  7511. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  7512. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7514. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7515. if !m.op.Is(OpUpdateOne) {
  7516. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7517. }
  7518. if m.id == nil || m.oldValue == nil {
  7519. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7520. }
  7521. oldValue, err := m.oldValue(ctx)
  7522. if err != nil {
  7523. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7524. }
  7525. return oldValue.CreatedAt, nil
  7526. }
  7527. // ResetCreatedAt resets all changes to the "created_at" field.
  7528. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  7529. m.created_at = nil
  7530. }
  7531. // SetUpdatedAt sets the "updated_at" field.
  7532. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  7533. m.updated_at = &t
  7534. }
  7535. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7536. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  7537. v := m.updated_at
  7538. if v == nil {
  7539. return
  7540. }
  7541. return *v, true
  7542. }
  7543. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  7544. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7546. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7547. if !m.op.Is(OpUpdateOne) {
  7548. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7549. }
  7550. if m.id == nil || m.oldValue == nil {
  7551. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7552. }
  7553. oldValue, err := m.oldValue(ctx)
  7554. if err != nil {
  7555. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7556. }
  7557. return oldValue.UpdatedAt, nil
  7558. }
  7559. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7560. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  7561. m.updated_at = nil
  7562. }
  7563. // SetDeletedAt sets the "deleted_at" field.
  7564. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  7565. m.deleted_at = &t
  7566. }
  7567. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7568. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  7569. v := m.deleted_at
  7570. if v == nil {
  7571. return
  7572. }
  7573. return *v, true
  7574. }
  7575. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  7576. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7578. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7579. if !m.op.Is(OpUpdateOne) {
  7580. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7581. }
  7582. if m.id == nil || m.oldValue == nil {
  7583. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7584. }
  7585. oldValue, err := m.oldValue(ctx)
  7586. if err != nil {
  7587. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7588. }
  7589. return oldValue.DeletedAt, nil
  7590. }
  7591. // ClearDeletedAt clears the value of the "deleted_at" field.
  7592. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  7593. m.deleted_at = nil
  7594. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  7595. }
  7596. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7597. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  7598. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  7599. return ok
  7600. }
  7601. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7602. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  7603. m.deleted_at = nil
  7604. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  7605. }
  7606. // SetStype sets the "stype" field.
  7607. func (m *EmployeeConfigMutation) SetStype(s string) {
  7608. m.stype = &s
  7609. }
  7610. // Stype returns the value of the "stype" field in the mutation.
  7611. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  7612. v := m.stype
  7613. if v == nil {
  7614. return
  7615. }
  7616. return *v, true
  7617. }
  7618. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  7619. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7621. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  7622. if !m.op.Is(OpUpdateOne) {
  7623. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  7624. }
  7625. if m.id == nil || m.oldValue == nil {
  7626. return v, errors.New("OldStype requires an ID field in the mutation")
  7627. }
  7628. oldValue, err := m.oldValue(ctx)
  7629. if err != nil {
  7630. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  7631. }
  7632. return oldValue.Stype, nil
  7633. }
  7634. // ResetStype resets all changes to the "stype" field.
  7635. func (m *EmployeeConfigMutation) ResetStype() {
  7636. m.stype = nil
  7637. }
  7638. // SetTitle sets the "title" field.
  7639. func (m *EmployeeConfigMutation) SetTitle(s string) {
  7640. m.title = &s
  7641. }
  7642. // Title returns the value of the "title" field in the mutation.
  7643. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  7644. v := m.title
  7645. if v == nil {
  7646. return
  7647. }
  7648. return *v, true
  7649. }
  7650. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  7651. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7653. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  7654. if !m.op.Is(OpUpdateOne) {
  7655. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  7656. }
  7657. if m.id == nil || m.oldValue == nil {
  7658. return v, errors.New("OldTitle requires an ID field in the mutation")
  7659. }
  7660. oldValue, err := m.oldValue(ctx)
  7661. if err != nil {
  7662. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  7663. }
  7664. return oldValue.Title, nil
  7665. }
  7666. // ResetTitle resets all changes to the "title" field.
  7667. func (m *EmployeeConfigMutation) ResetTitle() {
  7668. m.title = nil
  7669. }
  7670. // SetPhoto sets the "photo" field.
  7671. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  7672. m.photo = &s
  7673. }
  7674. // Photo returns the value of the "photo" field in the mutation.
  7675. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  7676. v := m.photo
  7677. if v == nil {
  7678. return
  7679. }
  7680. return *v, true
  7681. }
  7682. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  7683. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7685. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  7686. if !m.op.Is(OpUpdateOne) {
  7687. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  7688. }
  7689. if m.id == nil || m.oldValue == nil {
  7690. return v, errors.New("OldPhoto requires an ID field in the mutation")
  7691. }
  7692. oldValue, err := m.oldValue(ctx)
  7693. if err != nil {
  7694. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  7695. }
  7696. return oldValue.Photo, nil
  7697. }
  7698. // ResetPhoto resets all changes to the "photo" field.
  7699. func (m *EmployeeConfigMutation) ResetPhoto() {
  7700. m.photo = nil
  7701. }
  7702. // SetOrganizationID sets the "organization_id" field.
  7703. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  7704. m.organization_id = &u
  7705. m.addorganization_id = nil
  7706. }
  7707. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7708. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  7709. v := m.organization_id
  7710. if v == nil {
  7711. return
  7712. }
  7713. return *v, true
  7714. }
  7715. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  7716. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  7717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7718. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7719. if !m.op.Is(OpUpdateOne) {
  7720. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7721. }
  7722. if m.id == nil || m.oldValue == nil {
  7723. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7724. }
  7725. oldValue, err := m.oldValue(ctx)
  7726. if err != nil {
  7727. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7728. }
  7729. return oldValue.OrganizationID, nil
  7730. }
  7731. // AddOrganizationID adds u to the "organization_id" field.
  7732. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  7733. if m.addorganization_id != nil {
  7734. *m.addorganization_id += u
  7735. } else {
  7736. m.addorganization_id = &u
  7737. }
  7738. }
  7739. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7740. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  7741. v := m.addorganization_id
  7742. if v == nil {
  7743. return
  7744. }
  7745. return *v, true
  7746. }
  7747. // ClearOrganizationID clears the value of the "organization_id" field.
  7748. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  7749. m.organization_id = nil
  7750. m.addorganization_id = nil
  7751. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  7752. }
  7753. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7754. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  7755. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  7756. return ok
  7757. }
  7758. // ResetOrganizationID resets all changes to the "organization_id" field.
  7759. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  7760. m.organization_id = nil
  7761. m.addorganization_id = nil
  7762. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  7763. }
  7764. // Where appends a list predicates to the EmployeeConfigMutation builder.
  7765. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  7766. m.predicates = append(m.predicates, ps...)
  7767. }
  7768. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  7769. // users can use type-assertion to append predicates that do not depend on any generated package.
  7770. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  7771. p := make([]predicate.EmployeeConfig, len(ps))
  7772. for i := range ps {
  7773. p[i] = ps[i]
  7774. }
  7775. m.Where(p...)
  7776. }
  7777. // Op returns the operation name.
  7778. func (m *EmployeeConfigMutation) Op() Op {
  7779. return m.op
  7780. }
  7781. // SetOp allows setting the mutation operation.
  7782. func (m *EmployeeConfigMutation) SetOp(op Op) {
  7783. m.op = op
  7784. }
  7785. // Type returns the node type of this mutation (EmployeeConfig).
  7786. func (m *EmployeeConfigMutation) Type() string {
  7787. return m.typ
  7788. }
  7789. // Fields returns all fields that were changed during this mutation. Note that in
  7790. // order to get all numeric fields that were incremented/decremented, call
  7791. // AddedFields().
  7792. func (m *EmployeeConfigMutation) Fields() []string {
  7793. fields := make([]string, 0, 7)
  7794. if m.created_at != nil {
  7795. fields = append(fields, employeeconfig.FieldCreatedAt)
  7796. }
  7797. if m.updated_at != nil {
  7798. fields = append(fields, employeeconfig.FieldUpdatedAt)
  7799. }
  7800. if m.deleted_at != nil {
  7801. fields = append(fields, employeeconfig.FieldDeletedAt)
  7802. }
  7803. if m.stype != nil {
  7804. fields = append(fields, employeeconfig.FieldStype)
  7805. }
  7806. if m.title != nil {
  7807. fields = append(fields, employeeconfig.FieldTitle)
  7808. }
  7809. if m.photo != nil {
  7810. fields = append(fields, employeeconfig.FieldPhoto)
  7811. }
  7812. if m.organization_id != nil {
  7813. fields = append(fields, employeeconfig.FieldOrganizationID)
  7814. }
  7815. return fields
  7816. }
  7817. // Field returns the value of a field with the given name. The second boolean
  7818. // return value indicates that this field was not set, or was not defined in the
  7819. // schema.
  7820. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  7821. switch name {
  7822. case employeeconfig.FieldCreatedAt:
  7823. return m.CreatedAt()
  7824. case employeeconfig.FieldUpdatedAt:
  7825. return m.UpdatedAt()
  7826. case employeeconfig.FieldDeletedAt:
  7827. return m.DeletedAt()
  7828. case employeeconfig.FieldStype:
  7829. return m.Stype()
  7830. case employeeconfig.FieldTitle:
  7831. return m.Title()
  7832. case employeeconfig.FieldPhoto:
  7833. return m.Photo()
  7834. case employeeconfig.FieldOrganizationID:
  7835. return m.OrganizationID()
  7836. }
  7837. return nil, false
  7838. }
  7839. // OldField returns the old value of the field from the database. An error is
  7840. // returned if the mutation operation is not UpdateOne, or the query to the
  7841. // database failed.
  7842. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7843. switch name {
  7844. case employeeconfig.FieldCreatedAt:
  7845. return m.OldCreatedAt(ctx)
  7846. case employeeconfig.FieldUpdatedAt:
  7847. return m.OldUpdatedAt(ctx)
  7848. case employeeconfig.FieldDeletedAt:
  7849. return m.OldDeletedAt(ctx)
  7850. case employeeconfig.FieldStype:
  7851. return m.OldStype(ctx)
  7852. case employeeconfig.FieldTitle:
  7853. return m.OldTitle(ctx)
  7854. case employeeconfig.FieldPhoto:
  7855. return m.OldPhoto(ctx)
  7856. case employeeconfig.FieldOrganizationID:
  7857. return m.OldOrganizationID(ctx)
  7858. }
  7859. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  7860. }
  7861. // SetField sets the value of a field with the given name. It returns an error if
  7862. // the field is not defined in the schema, or if the type mismatched the field
  7863. // type.
  7864. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  7865. switch name {
  7866. case employeeconfig.FieldCreatedAt:
  7867. v, ok := value.(time.Time)
  7868. if !ok {
  7869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7870. }
  7871. m.SetCreatedAt(v)
  7872. return nil
  7873. case employeeconfig.FieldUpdatedAt:
  7874. v, ok := value.(time.Time)
  7875. if !ok {
  7876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7877. }
  7878. m.SetUpdatedAt(v)
  7879. return nil
  7880. case employeeconfig.FieldDeletedAt:
  7881. v, ok := value.(time.Time)
  7882. if !ok {
  7883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7884. }
  7885. m.SetDeletedAt(v)
  7886. return nil
  7887. case employeeconfig.FieldStype:
  7888. v, ok := value.(string)
  7889. if !ok {
  7890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7891. }
  7892. m.SetStype(v)
  7893. return nil
  7894. case employeeconfig.FieldTitle:
  7895. v, ok := value.(string)
  7896. if !ok {
  7897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7898. }
  7899. m.SetTitle(v)
  7900. return nil
  7901. case employeeconfig.FieldPhoto:
  7902. v, ok := value.(string)
  7903. if !ok {
  7904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7905. }
  7906. m.SetPhoto(v)
  7907. return nil
  7908. case employeeconfig.FieldOrganizationID:
  7909. v, ok := value.(uint64)
  7910. if !ok {
  7911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7912. }
  7913. m.SetOrganizationID(v)
  7914. return nil
  7915. }
  7916. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  7917. }
  7918. // AddedFields returns all numeric fields that were incremented/decremented during
  7919. // this mutation.
  7920. func (m *EmployeeConfigMutation) AddedFields() []string {
  7921. var fields []string
  7922. if m.addorganization_id != nil {
  7923. fields = append(fields, employeeconfig.FieldOrganizationID)
  7924. }
  7925. return fields
  7926. }
  7927. // AddedField returns the numeric value that was incremented/decremented on a field
  7928. // with the given name. The second boolean return value indicates that this field
  7929. // was not set, or was not defined in the schema.
  7930. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  7931. switch name {
  7932. case employeeconfig.FieldOrganizationID:
  7933. return m.AddedOrganizationID()
  7934. }
  7935. return nil, false
  7936. }
  7937. // AddField adds the value to the field with the given name. It returns an error if
  7938. // the field is not defined in the schema, or if the type mismatched the field
  7939. // type.
  7940. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  7941. switch name {
  7942. case employeeconfig.FieldOrganizationID:
  7943. v, ok := value.(int64)
  7944. if !ok {
  7945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7946. }
  7947. m.AddOrganizationID(v)
  7948. return nil
  7949. }
  7950. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  7951. }
  7952. // ClearedFields returns all nullable fields that were cleared during this
  7953. // mutation.
  7954. func (m *EmployeeConfigMutation) ClearedFields() []string {
  7955. var fields []string
  7956. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  7957. fields = append(fields, employeeconfig.FieldDeletedAt)
  7958. }
  7959. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  7960. fields = append(fields, employeeconfig.FieldOrganizationID)
  7961. }
  7962. return fields
  7963. }
  7964. // FieldCleared returns a boolean indicating if a field with the given name was
  7965. // cleared in this mutation.
  7966. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  7967. _, ok := m.clearedFields[name]
  7968. return ok
  7969. }
  7970. // ClearField clears the value of the field with the given name. It returns an
  7971. // error if the field is not defined in the schema.
  7972. func (m *EmployeeConfigMutation) ClearField(name string) error {
  7973. switch name {
  7974. case employeeconfig.FieldDeletedAt:
  7975. m.ClearDeletedAt()
  7976. return nil
  7977. case employeeconfig.FieldOrganizationID:
  7978. m.ClearOrganizationID()
  7979. return nil
  7980. }
  7981. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  7982. }
  7983. // ResetField resets all changes in the mutation for the field with the given name.
  7984. // It returns an error if the field is not defined in the schema.
  7985. func (m *EmployeeConfigMutation) ResetField(name string) error {
  7986. switch name {
  7987. case employeeconfig.FieldCreatedAt:
  7988. m.ResetCreatedAt()
  7989. return nil
  7990. case employeeconfig.FieldUpdatedAt:
  7991. m.ResetUpdatedAt()
  7992. return nil
  7993. case employeeconfig.FieldDeletedAt:
  7994. m.ResetDeletedAt()
  7995. return nil
  7996. case employeeconfig.FieldStype:
  7997. m.ResetStype()
  7998. return nil
  7999. case employeeconfig.FieldTitle:
  8000. m.ResetTitle()
  8001. return nil
  8002. case employeeconfig.FieldPhoto:
  8003. m.ResetPhoto()
  8004. return nil
  8005. case employeeconfig.FieldOrganizationID:
  8006. m.ResetOrganizationID()
  8007. return nil
  8008. }
  8009. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  8010. }
  8011. // AddedEdges returns all edge names that were set/added in this mutation.
  8012. func (m *EmployeeConfigMutation) AddedEdges() []string {
  8013. edges := make([]string, 0, 0)
  8014. return edges
  8015. }
  8016. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8017. // name in this mutation.
  8018. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  8019. return nil
  8020. }
  8021. // RemovedEdges returns all edge names that were removed in this mutation.
  8022. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  8023. edges := make([]string, 0, 0)
  8024. return edges
  8025. }
  8026. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8027. // the given name in this mutation.
  8028. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  8029. return nil
  8030. }
  8031. // ClearedEdges returns all edge names that were cleared in this mutation.
  8032. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  8033. edges := make([]string, 0, 0)
  8034. return edges
  8035. }
  8036. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8037. // was cleared in this mutation.
  8038. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  8039. return false
  8040. }
  8041. // ClearEdge clears the value of the edge with the given name. It returns an error
  8042. // if that edge is not defined in the schema.
  8043. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  8044. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  8045. }
  8046. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8047. // It returns an error if the edge is not defined in the schema.
  8048. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  8049. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  8050. }
  8051. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  8052. type LabelMutation struct {
  8053. config
  8054. op Op
  8055. typ string
  8056. id *uint64
  8057. created_at *time.Time
  8058. updated_at *time.Time
  8059. status *uint8
  8060. addstatus *int8
  8061. _type *int
  8062. add_type *int
  8063. name *string
  8064. from *int
  8065. addfrom *int
  8066. mode *int
  8067. addmode *int
  8068. conditions *string
  8069. organization_id *uint64
  8070. addorganization_id *int64
  8071. clearedFields map[string]struct{}
  8072. label_relationships map[uint64]struct{}
  8073. removedlabel_relationships map[uint64]struct{}
  8074. clearedlabel_relationships bool
  8075. done bool
  8076. oldValue func(context.Context) (*Label, error)
  8077. predicates []predicate.Label
  8078. }
  8079. var _ ent.Mutation = (*LabelMutation)(nil)
  8080. // labelOption allows management of the mutation configuration using functional options.
  8081. type labelOption func(*LabelMutation)
  8082. // newLabelMutation creates new mutation for the Label entity.
  8083. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  8084. m := &LabelMutation{
  8085. config: c,
  8086. op: op,
  8087. typ: TypeLabel,
  8088. clearedFields: make(map[string]struct{}),
  8089. }
  8090. for _, opt := range opts {
  8091. opt(m)
  8092. }
  8093. return m
  8094. }
  8095. // withLabelID sets the ID field of the mutation.
  8096. func withLabelID(id uint64) labelOption {
  8097. return func(m *LabelMutation) {
  8098. var (
  8099. err error
  8100. once sync.Once
  8101. value *Label
  8102. )
  8103. m.oldValue = func(ctx context.Context) (*Label, error) {
  8104. once.Do(func() {
  8105. if m.done {
  8106. err = errors.New("querying old values post mutation is not allowed")
  8107. } else {
  8108. value, err = m.Client().Label.Get(ctx, id)
  8109. }
  8110. })
  8111. return value, err
  8112. }
  8113. m.id = &id
  8114. }
  8115. }
  8116. // withLabel sets the old Label of the mutation.
  8117. func withLabel(node *Label) labelOption {
  8118. return func(m *LabelMutation) {
  8119. m.oldValue = func(context.Context) (*Label, error) {
  8120. return node, nil
  8121. }
  8122. m.id = &node.ID
  8123. }
  8124. }
  8125. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8126. // executed in a transaction (ent.Tx), a transactional client is returned.
  8127. func (m LabelMutation) Client() *Client {
  8128. client := &Client{config: m.config}
  8129. client.init()
  8130. return client
  8131. }
  8132. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8133. // it returns an error otherwise.
  8134. func (m LabelMutation) Tx() (*Tx, error) {
  8135. if _, ok := m.driver.(*txDriver); !ok {
  8136. return nil, errors.New("ent: mutation is not running in a transaction")
  8137. }
  8138. tx := &Tx{config: m.config}
  8139. tx.init()
  8140. return tx, nil
  8141. }
  8142. // SetID sets the value of the id field. Note that this
  8143. // operation is only accepted on creation of Label entities.
  8144. func (m *LabelMutation) SetID(id uint64) {
  8145. m.id = &id
  8146. }
  8147. // ID returns the ID value in the mutation. Note that the ID is only available
  8148. // if it was provided to the builder or after it was returned from the database.
  8149. func (m *LabelMutation) ID() (id uint64, exists bool) {
  8150. if m.id == nil {
  8151. return
  8152. }
  8153. return *m.id, true
  8154. }
  8155. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8156. // That means, if the mutation is applied within a transaction with an isolation level such
  8157. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8158. // or updated by the mutation.
  8159. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  8160. switch {
  8161. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8162. id, exists := m.ID()
  8163. if exists {
  8164. return []uint64{id}, nil
  8165. }
  8166. fallthrough
  8167. case m.op.Is(OpUpdate | OpDelete):
  8168. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  8169. default:
  8170. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8171. }
  8172. }
  8173. // SetCreatedAt sets the "created_at" field.
  8174. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  8175. m.created_at = &t
  8176. }
  8177. // CreatedAt returns the value of the "created_at" field in the mutation.
  8178. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  8179. v := m.created_at
  8180. if v == nil {
  8181. return
  8182. }
  8183. return *v, true
  8184. }
  8185. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  8186. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8188. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8189. if !m.op.Is(OpUpdateOne) {
  8190. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8191. }
  8192. if m.id == nil || m.oldValue == nil {
  8193. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8194. }
  8195. oldValue, err := m.oldValue(ctx)
  8196. if err != nil {
  8197. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8198. }
  8199. return oldValue.CreatedAt, nil
  8200. }
  8201. // ResetCreatedAt resets all changes to the "created_at" field.
  8202. func (m *LabelMutation) ResetCreatedAt() {
  8203. m.created_at = nil
  8204. }
  8205. // SetUpdatedAt sets the "updated_at" field.
  8206. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  8207. m.updated_at = &t
  8208. }
  8209. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8210. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  8211. v := m.updated_at
  8212. if v == nil {
  8213. return
  8214. }
  8215. return *v, true
  8216. }
  8217. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  8218. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8220. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8221. if !m.op.Is(OpUpdateOne) {
  8222. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8223. }
  8224. if m.id == nil || m.oldValue == nil {
  8225. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8226. }
  8227. oldValue, err := m.oldValue(ctx)
  8228. if err != nil {
  8229. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8230. }
  8231. return oldValue.UpdatedAt, nil
  8232. }
  8233. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8234. func (m *LabelMutation) ResetUpdatedAt() {
  8235. m.updated_at = nil
  8236. }
  8237. // SetStatus sets the "status" field.
  8238. func (m *LabelMutation) SetStatus(u uint8) {
  8239. m.status = &u
  8240. m.addstatus = nil
  8241. }
  8242. // Status returns the value of the "status" field in the mutation.
  8243. func (m *LabelMutation) Status() (r uint8, exists bool) {
  8244. v := m.status
  8245. if v == nil {
  8246. return
  8247. }
  8248. return *v, true
  8249. }
  8250. // OldStatus returns the old "status" field's value of the Label entity.
  8251. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8253. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8254. if !m.op.Is(OpUpdateOne) {
  8255. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8256. }
  8257. if m.id == nil || m.oldValue == nil {
  8258. return v, errors.New("OldStatus requires an ID field in the mutation")
  8259. }
  8260. oldValue, err := m.oldValue(ctx)
  8261. if err != nil {
  8262. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8263. }
  8264. return oldValue.Status, nil
  8265. }
  8266. // AddStatus adds u to the "status" field.
  8267. func (m *LabelMutation) AddStatus(u int8) {
  8268. if m.addstatus != nil {
  8269. *m.addstatus += u
  8270. } else {
  8271. m.addstatus = &u
  8272. }
  8273. }
  8274. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8275. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  8276. v := m.addstatus
  8277. if v == nil {
  8278. return
  8279. }
  8280. return *v, true
  8281. }
  8282. // ClearStatus clears the value of the "status" field.
  8283. func (m *LabelMutation) ClearStatus() {
  8284. m.status = nil
  8285. m.addstatus = nil
  8286. m.clearedFields[label.FieldStatus] = struct{}{}
  8287. }
  8288. // StatusCleared returns if the "status" field was cleared in this mutation.
  8289. func (m *LabelMutation) StatusCleared() bool {
  8290. _, ok := m.clearedFields[label.FieldStatus]
  8291. return ok
  8292. }
  8293. // ResetStatus resets all changes to the "status" field.
  8294. func (m *LabelMutation) ResetStatus() {
  8295. m.status = nil
  8296. m.addstatus = nil
  8297. delete(m.clearedFields, label.FieldStatus)
  8298. }
  8299. // SetType sets the "type" field.
  8300. func (m *LabelMutation) SetType(i int) {
  8301. m._type = &i
  8302. m.add_type = nil
  8303. }
  8304. // GetType returns the value of the "type" field in the mutation.
  8305. func (m *LabelMutation) GetType() (r int, exists bool) {
  8306. v := m._type
  8307. if v == nil {
  8308. return
  8309. }
  8310. return *v, true
  8311. }
  8312. // OldType returns the old "type" field's value of the Label entity.
  8313. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8315. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  8316. if !m.op.Is(OpUpdateOne) {
  8317. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8318. }
  8319. if m.id == nil || m.oldValue == nil {
  8320. return v, errors.New("OldType requires an ID field in the mutation")
  8321. }
  8322. oldValue, err := m.oldValue(ctx)
  8323. if err != nil {
  8324. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8325. }
  8326. return oldValue.Type, nil
  8327. }
  8328. // AddType adds i to the "type" field.
  8329. func (m *LabelMutation) AddType(i int) {
  8330. if m.add_type != nil {
  8331. *m.add_type += i
  8332. } else {
  8333. m.add_type = &i
  8334. }
  8335. }
  8336. // AddedType returns the value that was added to the "type" field in this mutation.
  8337. func (m *LabelMutation) AddedType() (r int, exists bool) {
  8338. v := m.add_type
  8339. if v == nil {
  8340. return
  8341. }
  8342. return *v, true
  8343. }
  8344. // ResetType resets all changes to the "type" field.
  8345. func (m *LabelMutation) ResetType() {
  8346. m._type = nil
  8347. m.add_type = nil
  8348. }
  8349. // SetName sets the "name" field.
  8350. func (m *LabelMutation) SetName(s string) {
  8351. m.name = &s
  8352. }
  8353. // Name returns the value of the "name" field in the mutation.
  8354. func (m *LabelMutation) Name() (r string, exists bool) {
  8355. v := m.name
  8356. if v == nil {
  8357. return
  8358. }
  8359. return *v, true
  8360. }
  8361. // OldName returns the old "name" field's value of the Label entity.
  8362. // If the Label 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 *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  8365. if !m.op.Is(OpUpdateOne) {
  8366. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8367. }
  8368. if m.id == nil || m.oldValue == nil {
  8369. return v, errors.New("OldName 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 OldName: %w", err)
  8374. }
  8375. return oldValue.Name, nil
  8376. }
  8377. // ResetName resets all changes to the "name" field.
  8378. func (m *LabelMutation) ResetName() {
  8379. m.name = nil
  8380. }
  8381. // SetFrom sets the "from" field.
  8382. func (m *LabelMutation) SetFrom(i int) {
  8383. m.from = &i
  8384. m.addfrom = nil
  8385. }
  8386. // From returns the value of the "from" field in the mutation.
  8387. func (m *LabelMutation) From() (r int, exists bool) {
  8388. v := m.from
  8389. if v == nil {
  8390. return
  8391. }
  8392. return *v, true
  8393. }
  8394. // OldFrom returns the old "from" field's value of the Label entity.
  8395. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8397. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  8398. if !m.op.Is(OpUpdateOne) {
  8399. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  8400. }
  8401. if m.id == nil || m.oldValue == nil {
  8402. return v, errors.New("OldFrom requires an ID field in the mutation")
  8403. }
  8404. oldValue, err := m.oldValue(ctx)
  8405. if err != nil {
  8406. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  8407. }
  8408. return oldValue.From, nil
  8409. }
  8410. // AddFrom adds i to the "from" field.
  8411. func (m *LabelMutation) AddFrom(i int) {
  8412. if m.addfrom != nil {
  8413. *m.addfrom += i
  8414. } else {
  8415. m.addfrom = &i
  8416. }
  8417. }
  8418. // AddedFrom returns the value that was added to the "from" field in this mutation.
  8419. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  8420. v := m.addfrom
  8421. if v == nil {
  8422. return
  8423. }
  8424. return *v, true
  8425. }
  8426. // ResetFrom resets all changes to the "from" field.
  8427. func (m *LabelMutation) ResetFrom() {
  8428. m.from = nil
  8429. m.addfrom = nil
  8430. }
  8431. // SetMode sets the "mode" field.
  8432. func (m *LabelMutation) SetMode(i int) {
  8433. m.mode = &i
  8434. m.addmode = nil
  8435. }
  8436. // Mode returns the value of the "mode" field in the mutation.
  8437. func (m *LabelMutation) Mode() (r int, exists bool) {
  8438. v := m.mode
  8439. if v == nil {
  8440. return
  8441. }
  8442. return *v, true
  8443. }
  8444. // OldMode returns the old "mode" field's value of the Label entity.
  8445. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8447. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  8448. if !m.op.Is(OpUpdateOne) {
  8449. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  8450. }
  8451. if m.id == nil || m.oldValue == nil {
  8452. return v, errors.New("OldMode requires an ID field in the mutation")
  8453. }
  8454. oldValue, err := m.oldValue(ctx)
  8455. if err != nil {
  8456. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  8457. }
  8458. return oldValue.Mode, nil
  8459. }
  8460. // AddMode adds i to the "mode" field.
  8461. func (m *LabelMutation) AddMode(i int) {
  8462. if m.addmode != nil {
  8463. *m.addmode += i
  8464. } else {
  8465. m.addmode = &i
  8466. }
  8467. }
  8468. // AddedMode returns the value that was added to the "mode" field in this mutation.
  8469. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  8470. v := m.addmode
  8471. if v == nil {
  8472. return
  8473. }
  8474. return *v, true
  8475. }
  8476. // ResetMode resets all changes to the "mode" field.
  8477. func (m *LabelMutation) ResetMode() {
  8478. m.mode = nil
  8479. m.addmode = nil
  8480. }
  8481. // SetConditions sets the "conditions" field.
  8482. func (m *LabelMutation) SetConditions(s string) {
  8483. m.conditions = &s
  8484. }
  8485. // Conditions returns the value of the "conditions" field in the mutation.
  8486. func (m *LabelMutation) Conditions() (r string, exists bool) {
  8487. v := m.conditions
  8488. if v == nil {
  8489. return
  8490. }
  8491. return *v, true
  8492. }
  8493. // OldConditions returns the old "conditions" field's value of the Label entity.
  8494. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8496. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  8497. if !m.op.Is(OpUpdateOne) {
  8498. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  8499. }
  8500. if m.id == nil || m.oldValue == nil {
  8501. return v, errors.New("OldConditions requires an ID field in the mutation")
  8502. }
  8503. oldValue, err := m.oldValue(ctx)
  8504. if err != nil {
  8505. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  8506. }
  8507. return oldValue.Conditions, nil
  8508. }
  8509. // ClearConditions clears the value of the "conditions" field.
  8510. func (m *LabelMutation) ClearConditions() {
  8511. m.conditions = nil
  8512. m.clearedFields[label.FieldConditions] = struct{}{}
  8513. }
  8514. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  8515. func (m *LabelMutation) ConditionsCleared() bool {
  8516. _, ok := m.clearedFields[label.FieldConditions]
  8517. return ok
  8518. }
  8519. // ResetConditions resets all changes to the "conditions" field.
  8520. func (m *LabelMutation) ResetConditions() {
  8521. m.conditions = nil
  8522. delete(m.clearedFields, label.FieldConditions)
  8523. }
  8524. // SetOrganizationID sets the "organization_id" field.
  8525. func (m *LabelMutation) SetOrganizationID(u uint64) {
  8526. m.organization_id = &u
  8527. m.addorganization_id = nil
  8528. }
  8529. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8530. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  8531. v := m.organization_id
  8532. if v == nil {
  8533. return
  8534. }
  8535. return *v, true
  8536. }
  8537. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  8538. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  8539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8540. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8541. if !m.op.Is(OpUpdateOne) {
  8542. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8543. }
  8544. if m.id == nil || m.oldValue == nil {
  8545. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8546. }
  8547. oldValue, err := m.oldValue(ctx)
  8548. if err != nil {
  8549. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8550. }
  8551. return oldValue.OrganizationID, nil
  8552. }
  8553. // AddOrganizationID adds u to the "organization_id" field.
  8554. func (m *LabelMutation) AddOrganizationID(u int64) {
  8555. if m.addorganization_id != nil {
  8556. *m.addorganization_id += u
  8557. } else {
  8558. m.addorganization_id = &u
  8559. }
  8560. }
  8561. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8562. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  8563. v := m.addorganization_id
  8564. if v == nil {
  8565. return
  8566. }
  8567. return *v, true
  8568. }
  8569. // ClearOrganizationID clears the value of the "organization_id" field.
  8570. func (m *LabelMutation) ClearOrganizationID() {
  8571. m.organization_id = nil
  8572. m.addorganization_id = nil
  8573. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  8574. }
  8575. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8576. func (m *LabelMutation) OrganizationIDCleared() bool {
  8577. _, ok := m.clearedFields[label.FieldOrganizationID]
  8578. return ok
  8579. }
  8580. // ResetOrganizationID resets all changes to the "organization_id" field.
  8581. func (m *LabelMutation) ResetOrganizationID() {
  8582. m.organization_id = nil
  8583. m.addorganization_id = nil
  8584. delete(m.clearedFields, label.FieldOrganizationID)
  8585. }
  8586. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  8587. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  8588. if m.label_relationships == nil {
  8589. m.label_relationships = make(map[uint64]struct{})
  8590. }
  8591. for i := range ids {
  8592. m.label_relationships[ids[i]] = struct{}{}
  8593. }
  8594. }
  8595. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  8596. func (m *LabelMutation) ClearLabelRelationships() {
  8597. m.clearedlabel_relationships = true
  8598. }
  8599. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  8600. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  8601. return m.clearedlabel_relationships
  8602. }
  8603. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  8604. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  8605. if m.removedlabel_relationships == nil {
  8606. m.removedlabel_relationships = make(map[uint64]struct{})
  8607. }
  8608. for i := range ids {
  8609. delete(m.label_relationships, ids[i])
  8610. m.removedlabel_relationships[ids[i]] = struct{}{}
  8611. }
  8612. }
  8613. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  8614. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  8615. for id := range m.removedlabel_relationships {
  8616. ids = append(ids, id)
  8617. }
  8618. return
  8619. }
  8620. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  8621. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  8622. for id := range m.label_relationships {
  8623. ids = append(ids, id)
  8624. }
  8625. return
  8626. }
  8627. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  8628. func (m *LabelMutation) ResetLabelRelationships() {
  8629. m.label_relationships = nil
  8630. m.clearedlabel_relationships = false
  8631. m.removedlabel_relationships = nil
  8632. }
  8633. // Where appends a list predicates to the LabelMutation builder.
  8634. func (m *LabelMutation) Where(ps ...predicate.Label) {
  8635. m.predicates = append(m.predicates, ps...)
  8636. }
  8637. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  8638. // users can use type-assertion to append predicates that do not depend on any generated package.
  8639. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  8640. p := make([]predicate.Label, len(ps))
  8641. for i := range ps {
  8642. p[i] = ps[i]
  8643. }
  8644. m.Where(p...)
  8645. }
  8646. // Op returns the operation name.
  8647. func (m *LabelMutation) Op() Op {
  8648. return m.op
  8649. }
  8650. // SetOp allows setting the mutation operation.
  8651. func (m *LabelMutation) SetOp(op Op) {
  8652. m.op = op
  8653. }
  8654. // Type returns the node type of this mutation (Label).
  8655. func (m *LabelMutation) Type() string {
  8656. return m.typ
  8657. }
  8658. // Fields returns all fields that were changed during this mutation. Note that in
  8659. // order to get all numeric fields that were incremented/decremented, call
  8660. // AddedFields().
  8661. func (m *LabelMutation) Fields() []string {
  8662. fields := make([]string, 0, 9)
  8663. if m.created_at != nil {
  8664. fields = append(fields, label.FieldCreatedAt)
  8665. }
  8666. if m.updated_at != nil {
  8667. fields = append(fields, label.FieldUpdatedAt)
  8668. }
  8669. if m.status != nil {
  8670. fields = append(fields, label.FieldStatus)
  8671. }
  8672. if m._type != nil {
  8673. fields = append(fields, label.FieldType)
  8674. }
  8675. if m.name != nil {
  8676. fields = append(fields, label.FieldName)
  8677. }
  8678. if m.from != nil {
  8679. fields = append(fields, label.FieldFrom)
  8680. }
  8681. if m.mode != nil {
  8682. fields = append(fields, label.FieldMode)
  8683. }
  8684. if m.conditions != nil {
  8685. fields = append(fields, label.FieldConditions)
  8686. }
  8687. if m.organization_id != nil {
  8688. fields = append(fields, label.FieldOrganizationID)
  8689. }
  8690. return fields
  8691. }
  8692. // Field returns the value of a field with the given name. The second boolean
  8693. // return value indicates that this field was not set, or was not defined in the
  8694. // schema.
  8695. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  8696. switch name {
  8697. case label.FieldCreatedAt:
  8698. return m.CreatedAt()
  8699. case label.FieldUpdatedAt:
  8700. return m.UpdatedAt()
  8701. case label.FieldStatus:
  8702. return m.Status()
  8703. case label.FieldType:
  8704. return m.GetType()
  8705. case label.FieldName:
  8706. return m.Name()
  8707. case label.FieldFrom:
  8708. return m.From()
  8709. case label.FieldMode:
  8710. return m.Mode()
  8711. case label.FieldConditions:
  8712. return m.Conditions()
  8713. case label.FieldOrganizationID:
  8714. return m.OrganizationID()
  8715. }
  8716. return nil, false
  8717. }
  8718. // OldField returns the old value of the field from the database. An error is
  8719. // returned if the mutation operation is not UpdateOne, or the query to the
  8720. // database failed.
  8721. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8722. switch name {
  8723. case label.FieldCreatedAt:
  8724. return m.OldCreatedAt(ctx)
  8725. case label.FieldUpdatedAt:
  8726. return m.OldUpdatedAt(ctx)
  8727. case label.FieldStatus:
  8728. return m.OldStatus(ctx)
  8729. case label.FieldType:
  8730. return m.OldType(ctx)
  8731. case label.FieldName:
  8732. return m.OldName(ctx)
  8733. case label.FieldFrom:
  8734. return m.OldFrom(ctx)
  8735. case label.FieldMode:
  8736. return m.OldMode(ctx)
  8737. case label.FieldConditions:
  8738. return m.OldConditions(ctx)
  8739. case label.FieldOrganizationID:
  8740. return m.OldOrganizationID(ctx)
  8741. }
  8742. return nil, fmt.Errorf("unknown Label field %s", name)
  8743. }
  8744. // SetField sets the value of a field with the given name. It returns an error if
  8745. // the field is not defined in the schema, or if the type mismatched the field
  8746. // type.
  8747. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  8748. switch name {
  8749. case label.FieldCreatedAt:
  8750. v, ok := value.(time.Time)
  8751. if !ok {
  8752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8753. }
  8754. m.SetCreatedAt(v)
  8755. return nil
  8756. case label.FieldUpdatedAt:
  8757. v, ok := value.(time.Time)
  8758. if !ok {
  8759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8760. }
  8761. m.SetUpdatedAt(v)
  8762. return nil
  8763. case label.FieldStatus:
  8764. v, ok := value.(uint8)
  8765. if !ok {
  8766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8767. }
  8768. m.SetStatus(v)
  8769. return nil
  8770. case label.FieldType:
  8771. v, ok := value.(int)
  8772. if !ok {
  8773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8774. }
  8775. m.SetType(v)
  8776. return nil
  8777. case label.FieldName:
  8778. v, ok := value.(string)
  8779. if !ok {
  8780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8781. }
  8782. m.SetName(v)
  8783. return nil
  8784. case label.FieldFrom:
  8785. v, ok := value.(int)
  8786. if !ok {
  8787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8788. }
  8789. m.SetFrom(v)
  8790. return nil
  8791. case label.FieldMode:
  8792. v, ok := value.(int)
  8793. if !ok {
  8794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8795. }
  8796. m.SetMode(v)
  8797. return nil
  8798. case label.FieldConditions:
  8799. v, ok := value.(string)
  8800. if !ok {
  8801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8802. }
  8803. m.SetConditions(v)
  8804. return nil
  8805. case label.FieldOrganizationID:
  8806. v, ok := value.(uint64)
  8807. if !ok {
  8808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8809. }
  8810. m.SetOrganizationID(v)
  8811. return nil
  8812. }
  8813. return fmt.Errorf("unknown Label field %s", name)
  8814. }
  8815. // AddedFields returns all numeric fields that were incremented/decremented during
  8816. // this mutation.
  8817. func (m *LabelMutation) AddedFields() []string {
  8818. var fields []string
  8819. if m.addstatus != nil {
  8820. fields = append(fields, label.FieldStatus)
  8821. }
  8822. if m.add_type != nil {
  8823. fields = append(fields, label.FieldType)
  8824. }
  8825. if m.addfrom != nil {
  8826. fields = append(fields, label.FieldFrom)
  8827. }
  8828. if m.addmode != nil {
  8829. fields = append(fields, label.FieldMode)
  8830. }
  8831. if m.addorganization_id != nil {
  8832. fields = append(fields, label.FieldOrganizationID)
  8833. }
  8834. return fields
  8835. }
  8836. // AddedField returns the numeric value that was incremented/decremented on a field
  8837. // with the given name. The second boolean return value indicates that this field
  8838. // was not set, or was not defined in the schema.
  8839. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  8840. switch name {
  8841. case label.FieldStatus:
  8842. return m.AddedStatus()
  8843. case label.FieldType:
  8844. return m.AddedType()
  8845. case label.FieldFrom:
  8846. return m.AddedFrom()
  8847. case label.FieldMode:
  8848. return m.AddedMode()
  8849. case label.FieldOrganizationID:
  8850. return m.AddedOrganizationID()
  8851. }
  8852. return nil, false
  8853. }
  8854. // AddField adds the value to the field with the given name. It returns an error if
  8855. // the field is not defined in the schema, or if the type mismatched the field
  8856. // type.
  8857. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  8858. switch name {
  8859. case label.FieldStatus:
  8860. v, ok := value.(int8)
  8861. if !ok {
  8862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8863. }
  8864. m.AddStatus(v)
  8865. return nil
  8866. case label.FieldType:
  8867. v, ok := value.(int)
  8868. if !ok {
  8869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8870. }
  8871. m.AddType(v)
  8872. return nil
  8873. case label.FieldFrom:
  8874. v, ok := value.(int)
  8875. if !ok {
  8876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8877. }
  8878. m.AddFrom(v)
  8879. return nil
  8880. case label.FieldMode:
  8881. v, ok := value.(int)
  8882. if !ok {
  8883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8884. }
  8885. m.AddMode(v)
  8886. return nil
  8887. case label.FieldOrganizationID:
  8888. v, ok := value.(int64)
  8889. if !ok {
  8890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8891. }
  8892. m.AddOrganizationID(v)
  8893. return nil
  8894. }
  8895. return fmt.Errorf("unknown Label numeric field %s", name)
  8896. }
  8897. // ClearedFields returns all nullable fields that were cleared during this
  8898. // mutation.
  8899. func (m *LabelMutation) ClearedFields() []string {
  8900. var fields []string
  8901. if m.FieldCleared(label.FieldStatus) {
  8902. fields = append(fields, label.FieldStatus)
  8903. }
  8904. if m.FieldCleared(label.FieldConditions) {
  8905. fields = append(fields, label.FieldConditions)
  8906. }
  8907. if m.FieldCleared(label.FieldOrganizationID) {
  8908. fields = append(fields, label.FieldOrganizationID)
  8909. }
  8910. return fields
  8911. }
  8912. // FieldCleared returns a boolean indicating if a field with the given name was
  8913. // cleared in this mutation.
  8914. func (m *LabelMutation) FieldCleared(name string) bool {
  8915. _, ok := m.clearedFields[name]
  8916. return ok
  8917. }
  8918. // ClearField clears the value of the field with the given name. It returns an
  8919. // error if the field is not defined in the schema.
  8920. func (m *LabelMutation) ClearField(name string) error {
  8921. switch name {
  8922. case label.FieldStatus:
  8923. m.ClearStatus()
  8924. return nil
  8925. case label.FieldConditions:
  8926. m.ClearConditions()
  8927. return nil
  8928. case label.FieldOrganizationID:
  8929. m.ClearOrganizationID()
  8930. return nil
  8931. }
  8932. return fmt.Errorf("unknown Label nullable field %s", name)
  8933. }
  8934. // ResetField resets all changes in the mutation for the field with the given name.
  8935. // It returns an error if the field is not defined in the schema.
  8936. func (m *LabelMutation) ResetField(name string) error {
  8937. switch name {
  8938. case label.FieldCreatedAt:
  8939. m.ResetCreatedAt()
  8940. return nil
  8941. case label.FieldUpdatedAt:
  8942. m.ResetUpdatedAt()
  8943. return nil
  8944. case label.FieldStatus:
  8945. m.ResetStatus()
  8946. return nil
  8947. case label.FieldType:
  8948. m.ResetType()
  8949. return nil
  8950. case label.FieldName:
  8951. m.ResetName()
  8952. return nil
  8953. case label.FieldFrom:
  8954. m.ResetFrom()
  8955. return nil
  8956. case label.FieldMode:
  8957. m.ResetMode()
  8958. return nil
  8959. case label.FieldConditions:
  8960. m.ResetConditions()
  8961. return nil
  8962. case label.FieldOrganizationID:
  8963. m.ResetOrganizationID()
  8964. return nil
  8965. }
  8966. return fmt.Errorf("unknown Label field %s", name)
  8967. }
  8968. // AddedEdges returns all edge names that were set/added in this mutation.
  8969. func (m *LabelMutation) AddedEdges() []string {
  8970. edges := make([]string, 0, 1)
  8971. if m.label_relationships != nil {
  8972. edges = append(edges, label.EdgeLabelRelationships)
  8973. }
  8974. return edges
  8975. }
  8976. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8977. // name in this mutation.
  8978. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  8979. switch name {
  8980. case label.EdgeLabelRelationships:
  8981. ids := make([]ent.Value, 0, len(m.label_relationships))
  8982. for id := range m.label_relationships {
  8983. ids = append(ids, id)
  8984. }
  8985. return ids
  8986. }
  8987. return nil
  8988. }
  8989. // RemovedEdges returns all edge names that were removed in this mutation.
  8990. func (m *LabelMutation) RemovedEdges() []string {
  8991. edges := make([]string, 0, 1)
  8992. if m.removedlabel_relationships != nil {
  8993. edges = append(edges, label.EdgeLabelRelationships)
  8994. }
  8995. return edges
  8996. }
  8997. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8998. // the given name in this mutation.
  8999. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  9000. switch name {
  9001. case label.EdgeLabelRelationships:
  9002. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  9003. for id := range m.removedlabel_relationships {
  9004. ids = append(ids, id)
  9005. }
  9006. return ids
  9007. }
  9008. return nil
  9009. }
  9010. // ClearedEdges returns all edge names that were cleared in this mutation.
  9011. func (m *LabelMutation) ClearedEdges() []string {
  9012. edges := make([]string, 0, 1)
  9013. if m.clearedlabel_relationships {
  9014. edges = append(edges, label.EdgeLabelRelationships)
  9015. }
  9016. return edges
  9017. }
  9018. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9019. // was cleared in this mutation.
  9020. func (m *LabelMutation) EdgeCleared(name string) bool {
  9021. switch name {
  9022. case label.EdgeLabelRelationships:
  9023. return m.clearedlabel_relationships
  9024. }
  9025. return false
  9026. }
  9027. // ClearEdge clears the value of the edge with the given name. It returns an error
  9028. // if that edge is not defined in the schema.
  9029. func (m *LabelMutation) ClearEdge(name string) error {
  9030. switch name {
  9031. }
  9032. return fmt.Errorf("unknown Label unique edge %s", name)
  9033. }
  9034. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9035. // It returns an error if the edge is not defined in the schema.
  9036. func (m *LabelMutation) ResetEdge(name string) error {
  9037. switch name {
  9038. case label.EdgeLabelRelationships:
  9039. m.ResetLabelRelationships()
  9040. return nil
  9041. }
  9042. return fmt.Errorf("unknown Label edge %s", name)
  9043. }
  9044. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  9045. type LabelRelationshipMutation struct {
  9046. config
  9047. op Op
  9048. typ string
  9049. id *uint64
  9050. created_at *time.Time
  9051. updated_at *time.Time
  9052. status *uint8
  9053. addstatus *int8
  9054. deleted_at *time.Time
  9055. organization_id *uint64
  9056. addorganization_id *int64
  9057. clearedFields map[string]struct{}
  9058. contacts *uint64
  9059. clearedcontacts bool
  9060. labels *uint64
  9061. clearedlabels bool
  9062. done bool
  9063. oldValue func(context.Context) (*LabelRelationship, error)
  9064. predicates []predicate.LabelRelationship
  9065. }
  9066. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  9067. // labelrelationshipOption allows management of the mutation configuration using functional options.
  9068. type labelrelationshipOption func(*LabelRelationshipMutation)
  9069. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  9070. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  9071. m := &LabelRelationshipMutation{
  9072. config: c,
  9073. op: op,
  9074. typ: TypeLabelRelationship,
  9075. clearedFields: make(map[string]struct{}),
  9076. }
  9077. for _, opt := range opts {
  9078. opt(m)
  9079. }
  9080. return m
  9081. }
  9082. // withLabelRelationshipID sets the ID field of the mutation.
  9083. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  9084. return func(m *LabelRelationshipMutation) {
  9085. var (
  9086. err error
  9087. once sync.Once
  9088. value *LabelRelationship
  9089. )
  9090. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  9091. once.Do(func() {
  9092. if m.done {
  9093. err = errors.New("querying old values post mutation is not allowed")
  9094. } else {
  9095. value, err = m.Client().LabelRelationship.Get(ctx, id)
  9096. }
  9097. })
  9098. return value, err
  9099. }
  9100. m.id = &id
  9101. }
  9102. }
  9103. // withLabelRelationship sets the old LabelRelationship of the mutation.
  9104. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  9105. return func(m *LabelRelationshipMutation) {
  9106. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  9107. return node, nil
  9108. }
  9109. m.id = &node.ID
  9110. }
  9111. }
  9112. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9113. // executed in a transaction (ent.Tx), a transactional client is returned.
  9114. func (m LabelRelationshipMutation) Client() *Client {
  9115. client := &Client{config: m.config}
  9116. client.init()
  9117. return client
  9118. }
  9119. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9120. // it returns an error otherwise.
  9121. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  9122. if _, ok := m.driver.(*txDriver); !ok {
  9123. return nil, errors.New("ent: mutation is not running in a transaction")
  9124. }
  9125. tx := &Tx{config: m.config}
  9126. tx.init()
  9127. return tx, nil
  9128. }
  9129. // SetID sets the value of the id field. Note that this
  9130. // operation is only accepted on creation of LabelRelationship entities.
  9131. func (m *LabelRelationshipMutation) SetID(id uint64) {
  9132. m.id = &id
  9133. }
  9134. // ID returns the ID value in the mutation. Note that the ID is only available
  9135. // if it was provided to the builder or after it was returned from the database.
  9136. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  9137. if m.id == nil {
  9138. return
  9139. }
  9140. return *m.id, true
  9141. }
  9142. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9143. // That means, if the mutation is applied within a transaction with an isolation level such
  9144. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9145. // or updated by the mutation.
  9146. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  9147. switch {
  9148. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9149. id, exists := m.ID()
  9150. if exists {
  9151. return []uint64{id}, nil
  9152. }
  9153. fallthrough
  9154. case m.op.Is(OpUpdate | OpDelete):
  9155. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  9156. default:
  9157. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9158. }
  9159. }
  9160. // SetCreatedAt sets the "created_at" field.
  9161. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  9162. m.created_at = &t
  9163. }
  9164. // CreatedAt returns the value of the "created_at" field in the mutation.
  9165. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  9166. v := m.created_at
  9167. if v == nil {
  9168. return
  9169. }
  9170. return *v, true
  9171. }
  9172. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  9173. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9175. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9176. if !m.op.Is(OpUpdateOne) {
  9177. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9178. }
  9179. if m.id == nil || m.oldValue == nil {
  9180. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9181. }
  9182. oldValue, err := m.oldValue(ctx)
  9183. if err != nil {
  9184. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9185. }
  9186. return oldValue.CreatedAt, nil
  9187. }
  9188. // ResetCreatedAt resets all changes to the "created_at" field.
  9189. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  9190. m.created_at = nil
  9191. }
  9192. // SetUpdatedAt sets the "updated_at" field.
  9193. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  9194. m.updated_at = &t
  9195. }
  9196. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9197. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  9198. v := m.updated_at
  9199. if v == nil {
  9200. return
  9201. }
  9202. return *v, true
  9203. }
  9204. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  9205. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9207. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9208. if !m.op.Is(OpUpdateOne) {
  9209. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9210. }
  9211. if m.id == nil || m.oldValue == nil {
  9212. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9213. }
  9214. oldValue, err := m.oldValue(ctx)
  9215. if err != nil {
  9216. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9217. }
  9218. return oldValue.UpdatedAt, nil
  9219. }
  9220. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9221. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  9222. m.updated_at = nil
  9223. }
  9224. // SetStatus sets the "status" field.
  9225. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  9226. m.status = &u
  9227. m.addstatus = nil
  9228. }
  9229. // Status returns the value of the "status" field in the mutation.
  9230. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  9231. v := m.status
  9232. if v == nil {
  9233. return
  9234. }
  9235. return *v, true
  9236. }
  9237. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  9238. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9240. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9241. if !m.op.Is(OpUpdateOne) {
  9242. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9243. }
  9244. if m.id == nil || m.oldValue == nil {
  9245. return v, errors.New("OldStatus requires an ID field in the mutation")
  9246. }
  9247. oldValue, err := m.oldValue(ctx)
  9248. if err != nil {
  9249. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9250. }
  9251. return oldValue.Status, nil
  9252. }
  9253. // AddStatus adds u to the "status" field.
  9254. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  9255. if m.addstatus != nil {
  9256. *m.addstatus += u
  9257. } else {
  9258. m.addstatus = &u
  9259. }
  9260. }
  9261. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9262. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  9263. v := m.addstatus
  9264. if v == nil {
  9265. return
  9266. }
  9267. return *v, true
  9268. }
  9269. // ClearStatus clears the value of the "status" field.
  9270. func (m *LabelRelationshipMutation) ClearStatus() {
  9271. m.status = nil
  9272. m.addstatus = nil
  9273. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  9274. }
  9275. // StatusCleared returns if the "status" field was cleared in this mutation.
  9276. func (m *LabelRelationshipMutation) StatusCleared() bool {
  9277. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  9278. return ok
  9279. }
  9280. // ResetStatus resets all changes to the "status" field.
  9281. func (m *LabelRelationshipMutation) ResetStatus() {
  9282. m.status = nil
  9283. m.addstatus = nil
  9284. delete(m.clearedFields, labelrelationship.FieldStatus)
  9285. }
  9286. // SetDeletedAt sets the "deleted_at" field.
  9287. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  9288. m.deleted_at = &t
  9289. }
  9290. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9291. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  9292. v := m.deleted_at
  9293. if v == nil {
  9294. return
  9295. }
  9296. return *v, true
  9297. }
  9298. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  9299. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9301. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9302. if !m.op.Is(OpUpdateOne) {
  9303. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9304. }
  9305. if m.id == nil || m.oldValue == nil {
  9306. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9307. }
  9308. oldValue, err := m.oldValue(ctx)
  9309. if err != nil {
  9310. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9311. }
  9312. return oldValue.DeletedAt, nil
  9313. }
  9314. // ClearDeletedAt clears the value of the "deleted_at" field.
  9315. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  9316. m.deleted_at = nil
  9317. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  9318. }
  9319. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9320. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  9321. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  9322. return ok
  9323. }
  9324. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9325. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  9326. m.deleted_at = nil
  9327. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  9328. }
  9329. // SetLabelID sets the "label_id" field.
  9330. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  9331. m.labels = &u
  9332. }
  9333. // LabelID returns the value of the "label_id" field in the mutation.
  9334. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  9335. v := m.labels
  9336. if v == nil {
  9337. return
  9338. }
  9339. return *v, true
  9340. }
  9341. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  9342. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9344. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  9345. if !m.op.Is(OpUpdateOne) {
  9346. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  9347. }
  9348. if m.id == nil || m.oldValue == nil {
  9349. return v, errors.New("OldLabelID requires an ID field in the mutation")
  9350. }
  9351. oldValue, err := m.oldValue(ctx)
  9352. if err != nil {
  9353. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  9354. }
  9355. return oldValue.LabelID, nil
  9356. }
  9357. // ResetLabelID resets all changes to the "label_id" field.
  9358. func (m *LabelRelationshipMutation) ResetLabelID() {
  9359. m.labels = nil
  9360. }
  9361. // SetContactID sets the "contact_id" field.
  9362. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  9363. m.contacts = &u
  9364. }
  9365. // ContactID returns the value of the "contact_id" field in the mutation.
  9366. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  9367. v := m.contacts
  9368. if v == nil {
  9369. return
  9370. }
  9371. return *v, true
  9372. }
  9373. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  9374. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9376. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  9377. if !m.op.Is(OpUpdateOne) {
  9378. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  9379. }
  9380. if m.id == nil || m.oldValue == nil {
  9381. return v, errors.New("OldContactID requires an ID field in the mutation")
  9382. }
  9383. oldValue, err := m.oldValue(ctx)
  9384. if err != nil {
  9385. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  9386. }
  9387. return oldValue.ContactID, nil
  9388. }
  9389. // ResetContactID resets all changes to the "contact_id" field.
  9390. func (m *LabelRelationshipMutation) ResetContactID() {
  9391. m.contacts = nil
  9392. }
  9393. // SetOrganizationID sets the "organization_id" field.
  9394. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  9395. m.organization_id = &u
  9396. m.addorganization_id = nil
  9397. }
  9398. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9399. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  9400. v := m.organization_id
  9401. if v == nil {
  9402. return
  9403. }
  9404. return *v, true
  9405. }
  9406. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  9407. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  9408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9409. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9410. if !m.op.Is(OpUpdateOne) {
  9411. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9412. }
  9413. if m.id == nil || m.oldValue == nil {
  9414. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9415. }
  9416. oldValue, err := m.oldValue(ctx)
  9417. if err != nil {
  9418. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9419. }
  9420. return oldValue.OrganizationID, nil
  9421. }
  9422. // AddOrganizationID adds u to the "organization_id" field.
  9423. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  9424. if m.addorganization_id != nil {
  9425. *m.addorganization_id += u
  9426. } else {
  9427. m.addorganization_id = &u
  9428. }
  9429. }
  9430. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9431. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  9432. v := m.addorganization_id
  9433. if v == nil {
  9434. return
  9435. }
  9436. return *v, true
  9437. }
  9438. // ClearOrganizationID clears the value of the "organization_id" field.
  9439. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  9440. m.organization_id = nil
  9441. m.addorganization_id = nil
  9442. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  9443. }
  9444. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9445. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  9446. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  9447. return ok
  9448. }
  9449. // ResetOrganizationID resets all changes to the "organization_id" field.
  9450. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  9451. m.organization_id = nil
  9452. m.addorganization_id = nil
  9453. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  9454. }
  9455. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  9456. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  9457. m.contacts = &id
  9458. }
  9459. // ClearContacts clears the "contacts" edge to the Contact entity.
  9460. func (m *LabelRelationshipMutation) ClearContacts() {
  9461. m.clearedcontacts = true
  9462. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  9463. }
  9464. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  9465. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  9466. return m.clearedcontacts
  9467. }
  9468. // ContactsID returns the "contacts" edge ID in the mutation.
  9469. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  9470. if m.contacts != nil {
  9471. return *m.contacts, true
  9472. }
  9473. return
  9474. }
  9475. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  9476. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9477. // ContactsID instead. It exists only for internal usage by the builders.
  9478. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  9479. if id := m.contacts; id != nil {
  9480. ids = append(ids, *id)
  9481. }
  9482. return
  9483. }
  9484. // ResetContacts resets all changes to the "contacts" edge.
  9485. func (m *LabelRelationshipMutation) ResetContacts() {
  9486. m.contacts = nil
  9487. m.clearedcontacts = false
  9488. }
  9489. // SetLabelsID sets the "labels" edge to the Label entity by id.
  9490. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  9491. m.labels = &id
  9492. }
  9493. // ClearLabels clears the "labels" edge to the Label entity.
  9494. func (m *LabelRelationshipMutation) ClearLabels() {
  9495. m.clearedlabels = true
  9496. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  9497. }
  9498. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  9499. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  9500. return m.clearedlabels
  9501. }
  9502. // LabelsID returns the "labels" edge ID in the mutation.
  9503. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  9504. if m.labels != nil {
  9505. return *m.labels, true
  9506. }
  9507. return
  9508. }
  9509. // LabelsIDs returns the "labels" edge IDs in the mutation.
  9510. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9511. // LabelsID instead. It exists only for internal usage by the builders.
  9512. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  9513. if id := m.labels; id != nil {
  9514. ids = append(ids, *id)
  9515. }
  9516. return
  9517. }
  9518. // ResetLabels resets all changes to the "labels" edge.
  9519. func (m *LabelRelationshipMutation) ResetLabels() {
  9520. m.labels = nil
  9521. m.clearedlabels = false
  9522. }
  9523. // Where appends a list predicates to the LabelRelationshipMutation builder.
  9524. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  9525. m.predicates = append(m.predicates, ps...)
  9526. }
  9527. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  9528. // users can use type-assertion to append predicates that do not depend on any generated package.
  9529. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  9530. p := make([]predicate.LabelRelationship, len(ps))
  9531. for i := range ps {
  9532. p[i] = ps[i]
  9533. }
  9534. m.Where(p...)
  9535. }
  9536. // Op returns the operation name.
  9537. func (m *LabelRelationshipMutation) Op() Op {
  9538. return m.op
  9539. }
  9540. // SetOp allows setting the mutation operation.
  9541. func (m *LabelRelationshipMutation) SetOp(op Op) {
  9542. m.op = op
  9543. }
  9544. // Type returns the node type of this mutation (LabelRelationship).
  9545. func (m *LabelRelationshipMutation) Type() string {
  9546. return m.typ
  9547. }
  9548. // Fields returns all fields that were changed during this mutation. Note that in
  9549. // order to get all numeric fields that were incremented/decremented, call
  9550. // AddedFields().
  9551. func (m *LabelRelationshipMutation) Fields() []string {
  9552. fields := make([]string, 0, 7)
  9553. if m.created_at != nil {
  9554. fields = append(fields, labelrelationship.FieldCreatedAt)
  9555. }
  9556. if m.updated_at != nil {
  9557. fields = append(fields, labelrelationship.FieldUpdatedAt)
  9558. }
  9559. if m.status != nil {
  9560. fields = append(fields, labelrelationship.FieldStatus)
  9561. }
  9562. if m.deleted_at != nil {
  9563. fields = append(fields, labelrelationship.FieldDeletedAt)
  9564. }
  9565. if m.labels != nil {
  9566. fields = append(fields, labelrelationship.FieldLabelID)
  9567. }
  9568. if m.contacts != nil {
  9569. fields = append(fields, labelrelationship.FieldContactID)
  9570. }
  9571. if m.organization_id != nil {
  9572. fields = append(fields, labelrelationship.FieldOrganizationID)
  9573. }
  9574. return fields
  9575. }
  9576. // Field returns the value of a field with the given name. The second boolean
  9577. // return value indicates that this field was not set, or was not defined in the
  9578. // schema.
  9579. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  9580. switch name {
  9581. case labelrelationship.FieldCreatedAt:
  9582. return m.CreatedAt()
  9583. case labelrelationship.FieldUpdatedAt:
  9584. return m.UpdatedAt()
  9585. case labelrelationship.FieldStatus:
  9586. return m.Status()
  9587. case labelrelationship.FieldDeletedAt:
  9588. return m.DeletedAt()
  9589. case labelrelationship.FieldLabelID:
  9590. return m.LabelID()
  9591. case labelrelationship.FieldContactID:
  9592. return m.ContactID()
  9593. case labelrelationship.FieldOrganizationID:
  9594. return m.OrganizationID()
  9595. }
  9596. return nil, false
  9597. }
  9598. // OldField returns the old value of the field from the database. An error is
  9599. // returned if the mutation operation is not UpdateOne, or the query to the
  9600. // database failed.
  9601. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9602. switch name {
  9603. case labelrelationship.FieldCreatedAt:
  9604. return m.OldCreatedAt(ctx)
  9605. case labelrelationship.FieldUpdatedAt:
  9606. return m.OldUpdatedAt(ctx)
  9607. case labelrelationship.FieldStatus:
  9608. return m.OldStatus(ctx)
  9609. case labelrelationship.FieldDeletedAt:
  9610. return m.OldDeletedAt(ctx)
  9611. case labelrelationship.FieldLabelID:
  9612. return m.OldLabelID(ctx)
  9613. case labelrelationship.FieldContactID:
  9614. return m.OldContactID(ctx)
  9615. case labelrelationship.FieldOrganizationID:
  9616. return m.OldOrganizationID(ctx)
  9617. }
  9618. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  9619. }
  9620. // SetField sets the value of a field with the given name. It returns an error if
  9621. // the field is not defined in the schema, or if the type mismatched the field
  9622. // type.
  9623. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  9624. switch name {
  9625. case labelrelationship.FieldCreatedAt:
  9626. v, ok := value.(time.Time)
  9627. if !ok {
  9628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9629. }
  9630. m.SetCreatedAt(v)
  9631. return nil
  9632. case labelrelationship.FieldUpdatedAt:
  9633. v, ok := value.(time.Time)
  9634. if !ok {
  9635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9636. }
  9637. m.SetUpdatedAt(v)
  9638. return nil
  9639. case labelrelationship.FieldStatus:
  9640. v, ok := value.(uint8)
  9641. if !ok {
  9642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9643. }
  9644. m.SetStatus(v)
  9645. return nil
  9646. case labelrelationship.FieldDeletedAt:
  9647. v, ok := value.(time.Time)
  9648. if !ok {
  9649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9650. }
  9651. m.SetDeletedAt(v)
  9652. return nil
  9653. case labelrelationship.FieldLabelID:
  9654. v, ok := value.(uint64)
  9655. if !ok {
  9656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9657. }
  9658. m.SetLabelID(v)
  9659. return nil
  9660. case labelrelationship.FieldContactID:
  9661. v, ok := value.(uint64)
  9662. if !ok {
  9663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9664. }
  9665. m.SetContactID(v)
  9666. return nil
  9667. case labelrelationship.FieldOrganizationID:
  9668. v, ok := value.(uint64)
  9669. if !ok {
  9670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9671. }
  9672. m.SetOrganizationID(v)
  9673. return nil
  9674. }
  9675. return fmt.Errorf("unknown LabelRelationship field %s", name)
  9676. }
  9677. // AddedFields returns all numeric fields that were incremented/decremented during
  9678. // this mutation.
  9679. func (m *LabelRelationshipMutation) AddedFields() []string {
  9680. var fields []string
  9681. if m.addstatus != nil {
  9682. fields = append(fields, labelrelationship.FieldStatus)
  9683. }
  9684. if m.addorganization_id != nil {
  9685. fields = append(fields, labelrelationship.FieldOrganizationID)
  9686. }
  9687. return fields
  9688. }
  9689. // AddedField returns the numeric value that was incremented/decremented on a field
  9690. // with the given name. The second boolean return value indicates that this field
  9691. // was not set, or was not defined in the schema.
  9692. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  9693. switch name {
  9694. case labelrelationship.FieldStatus:
  9695. return m.AddedStatus()
  9696. case labelrelationship.FieldOrganizationID:
  9697. return m.AddedOrganizationID()
  9698. }
  9699. return nil, false
  9700. }
  9701. // AddField adds the value to the field with the given name. It returns an error if
  9702. // the field is not defined in the schema, or if the type mismatched the field
  9703. // type.
  9704. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  9705. switch name {
  9706. case labelrelationship.FieldStatus:
  9707. v, ok := value.(int8)
  9708. if !ok {
  9709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9710. }
  9711. m.AddStatus(v)
  9712. return nil
  9713. case labelrelationship.FieldOrganizationID:
  9714. v, ok := value.(int64)
  9715. if !ok {
  9716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9717. }
  9718. m.AddOrganizationID(v)
  9719. return nil
  9720. }
  9721. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  9722. }
  9723. // ClearedFields returns all nullable fields that were cleared during this
  9724. // mutation.
  9725. func (m *LabelRelationshipMutation) ClearedFields() []string {
  9726. var fields []string
  9727. if m.FieldCleared(labelrelationship.FieldStatus) {
  9728. fields = append(fields, labelrelationship.FieldStatus)
  9729. }
  9730. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  9731. fields = append(fields, labelrelationship.FieldDeletedAt)
  9732. }
  9733. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  9734. fields = append(fields, labelrelationship.FieldOrganizationID)
  9735. }
  9736. return fields
  9737. }
  9738. // FieldCleared returns a boolean indicating if a field with the given name was
  9739. // cleared in this mutation.
  9740. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  9741. _, ok := m.clearedFields[name]
  9742. return ok
  9743. }
  9744. // ClearField clears the value of the field with the given name. It returns an
  9745. // error if the field is not defined in the schema.
  9746. func (m *LabelRelationshipMutation) ClearField(name string) error {
  9747. switch name {
  9748. case labelrelationship.FieldStatus:
  9749. m.ClearStatus()
  9750. return nil
  9751. case labelrelationship.FieldDeletedAt:
  9752. m.ClearDeletedAt()
  9753. return nil
  9754. case labelrelationship.FieldOrganizationID:
  9755. m.ClearOrganizationID()
  9756. return nil
  9757. }
  9758. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  9759. }
  9760. // ResetField resets all changes in the mutation for the field with the given name.
  9761. // It returns an error if the field is not defined in the schema.
  9762. func (m *LabelRelationshipMutation) ResetField(name string) error {
  9763. switch name {
  9764. case labelrelationship.FieldCreatedAt:
  9765. m.ResetCreatedAt()
  9766. return nil
  9767. case labelrelationship.FieldUpdatedAt:
  9768. m.ResetUpdatedAt()
  9769. return nil
  9770. case labelrelationship.FieldStatus:
  9771. m.ResetStatus()
  9772. return nil
  9773. case labelrelationship.FieldDeletedAt:
  9774. m.ResetDeletedAt()
  9775. return nil
  9776. case labelrelationship.FieldLabelID:
  9777. m.ResetLabelID()
  9778. return nil
  9779. case labelrelationship.FieldContactID:
  9780. m.ResetContactID()
  9781. return nil
  9782. case labelrelationship.FieldOrganizationID:
  9783. m.ResetOrganizationID()
  9784. return nil
  9785. }
  9786. return fmt.Errorf("unknown LabelRelationship field %s", name)
  9787. }
  9788. // AddedEdges returns all edge names that were set/added in this mutation.
  9789. func (m *LabelRelationshipMutation) AddedEdges() []string {
  9790. edges := make([]string, 0, 2)
  9791. if m.contacts != nil {
  9792. edges = append(edges, labelrelationship.EdgeContacts)
  9793. }
  9794. if m.labels != nil {
  9795. edges = append(edges, labelrelationship.EdgeLabels)
  9796. }
  9797. return edges
  9798. }
  9799. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9800. // name in this mutation.
  9801. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  9802. switch name {
  9803. case labelrelationship.EdgeContacts:
  9804. if id := m.contacts; id != nil {
  9805. return []ent.Value{*id}
  9806. }
  9807. case labelrelationship.EdgeLabels:
  9808. if id := m.labels; id != nil {
  9809. return []ent.Value{*id}
  9810. }
  9811. }
  9812. return nil
  9813. }
  9814. // RemovedEdges returns all edge names that were removed in this mutation.
  9815. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  9816. edges := make([]string, 0, 2)
  9817. return edges
  9818. }
  9819. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9820. // the given name in this mutation.
  9821. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  9822. return nil
  9823. }
  9824. // ClearedEdges returns all edge names that were cleared in this mutation.
  9825. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  9826. edges := make([]string, 0, 2)
  9827. if m.clearedcontacts {
  9828. edges = append(edges, labelrelationship.EdgeContacts)
  9829. }
  9830. if m.clearedlabels {
  9831. edges = append(edges, labelrelationship.EdgeLabels)
  9832. }
  9833. return edges
  9834. }
  9835. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9836. // was cleared in this mutation.
  9837. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  9838. switch name {
  9839. case labelrelationship.EdgeContacts:
  9840. return m.clearedcontacts
  9841. case labelrelationship.EdgeLabels:
  9842. return m.clearedlabels
  9843. }
  9844. return false
  9845. }
  9846. // ClearEdge clears the value of the edge with the given name. It returns an error
  9847. // if that edge is not defined in the schema.
  9848. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  9849. switch name {
  9850. case labelrelationship.EdgeContacts:
  9851. m.ClearContacts()
  9852. return nil
  9853. case labelrelationship.EdgeLabels:
  9854. m.ClearLabels()
  9855. return nil
  9856. }
  9857. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  9858. }
  9859. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9860. // It returns an error if the edge is not defined in the schema.
  9861. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  9862. switch name {
  9863. case labelrelationship.EdgeContacts:
  9864. m.ResetContacts()
  9865. return nil
  9866. case labelrelationship.EdgeLabels:
  9867. m.ResetLabels()
  9868. return nil
  9869. }
  9870. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  9871. }
  9872. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  9873. type MessageMutation struct {
  9874. config
  9875. op Op
  9876. typ string
  9877. id *int
  9878. wx_wxid *string
  9879. wxid *string
  9880. content *string
  9881. clearedFields map[string]struct{}
  9882. done bool
  9883. oldValue func(context.Context) (*Message, error)
  9884. predicates []predicate.Message
  9885. }
  9886. var _ ent.Mutation = (*MessageMutation)(nil)
  9887. // messageOption allows management of the mutation configuration using functional options.
  9888. type messageOption func(*MessageMutation)
  9889. // newMessageMutation creates new mutation for the Message entity.
  9890. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  9891. m := &MessageMutation{
  9892. config: c,
  9893. op: op,
  9894. typ: TypeMessage,
  9895. clearedFields: make(map[string]struct{}),
  9896. }
  9897. for _, opt := range opts {
  9898. opt(m)
  9899. }
  9900. return m
  9901. }
  9902. // withMessageID sets the ID field of the mutation.
  9903. func withMessageID(id int) messageOption {
  9904. return func(m *MessageMutation) {
  9905. var (
  9906. err error
  9907. once sync.Once
  9908. value *Message
  9909. )
  9910. m.oldValue = func(ctx context.Context) (*Message, error) {
  9911. once.Do(func() {
  9912. if m.done {
  9913. err = errors.New("querying old values post mutation is not allowed")
  9914. } else {
  9915. value, err = m.Client().Message.Get(ctx, id)
  9916. }
  9917. })
  9918. return value, err
  9919. }
  9920. m.id = &id
  9921. }
  9922. }
  9923. // withMessage sets the old Message of the mutation.
  9924. func withMessage(node *Message) messageOption {
  9925. return func(m *MessageMutation) {
  9926. m.oldValue = func(context.Context) (*Message, error) {
  9927. return node, nil
  9928. }
  9929. m.id = &node.ID
  9930. }
  9931. }
  9932. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9933. // executed in a transaction (ent.Tx), a transactional client is returned.
  9934. func (m MessageMutation) Client() *Client {
  9935. client := &Client{config: m.config}
  9936. client.init()
  9937. return client
  9938. }
  9939. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9940. // it returns an error otherwise.
  9941. func (m MessageMutation) Tx() (*Tx, error) {
  9942. if _, ok := m.driver.(*txDriver); !ok {
  9943. return nil, errors.New("ent: mutation is not running in a transaction")
  9944. }
  9945. tx := &Tx{config: m.config}
  9946. tx.init()
  9947. return tx, nil
  9948. }
  9949. // ID returns the ID value in the mutation. Note that the ID is only available
  9950. // if it was provided to the builder or after it was returned from the database.
  9951. func (m *MessageMutation) ID() (id int, exists bool) {
  9952. if m.id == nil {
  9953. return
  9954. }
  9955. return *m.id, true
  9956. }
  9957. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9958. // That means, if the mutation is applied within a transaction with an isolation level such
  9959. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9960. // or updated by the mutation.
  9961. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  9962. switch {
  9963. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9964. id, exists := m.ID()
  9965. if exists {
  9966. return []int{id}, nil
  9967. }
  9968. fallthrough
  9969. case m.op.Is(OpUpdate | OpDelete):
  9970. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  9971. default:
  9972. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9973. }
  9974. }
  9975. // SetWxWxid sets the "wx_wxid" field.
  9976. func (m *MessageMutation) SetWxWxid(s string) {
  9977. m.wx_wxid = &s
  9978. }
  9979. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9980. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  9981. v := m.wx_wxid
  9982. if v == nil {
  9983. return
  9984. }
  9985. return *v, true
  9986. }
  9987. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  9988. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  9989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9990. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9991. if !m.op.Is(OpUpdateOne) {
  9992. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9993. }
  9994. if m.id == nil || m.oldValue == nil {
  9995. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9996. }
  9997. oldValue, err := m.oldValue(ctx)
  9998. if err != nil {
  9999. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  10000. }
  10001. return oldValue.WxWxid, nil
  10002. }
  10003. // ClearWxWxid clears the value of the "wx_wxid" field.
  10004. func (m *MessageMutation) ClearWxWxid() {
  10005. m.wx_wxid = nil
  10006. m.clearedFields[message.FieldWxWxid] = struct{}{}
  10007. }
  10008. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  10009. func (m *MessageMutation) WxWxidCleared() bool {
  10010. _, ok := m.clearedFields[message.FieldWxWxid]
  10011. return ok
  10012. }
  10013. // ResetWxWxid resets all changes to the "wx_wxid" field.
  10014. func (m *MessageMutation) ResetWxWxid() {
  10015. m.wx_wxid = nil
  10016. delete(m.clearedFields, message.FieldWxWxid)
  10017. }
  10018. // SetWxid sets the "wxid" field.
  10019. func (m *MessageMutation) SetWxid(s string) {
  10020. m.wxid = &s
  10021. }
  10022. // Wxid returns the value of the "wxid" field in the mutation.
  10023. func (m *MessageMutation) Wxid() (r string, exists bool) {
  10024. v := m.wxid
  10025. if v == nil {
  10026. return
  10027. }
  10028. return *v, true
  10029. }
  10030. // OldWxid returns the old "wxid" field's value of the Message entity.
  10031. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  10032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10033. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  10034. if !m.op.Is(OpUpdateOne) {
  10035. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  10036. }
  10037. if m.id == nil || m.oldValue == nil {
  10038. return v, errors.New("OldWxid requires an ID field in the mutation")
  10039. }
  10040. oldValue, err := m.oldValue(ctx)
  10041. if err != nil {
  10042. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  10043. }
  10044. return oldValue.Wxid, nil
  10045. }
  10046. // ResetWxid resets all changes to the "wxid" field.
  10047. func (m *MessageMutation) ResetWxid() {
  10048. m.wxid = nil
  10049. }
  10050. // SetContent sets the "content" field.
  10051. func (m *MessageMutation) SetContent(s string) {
  10052. m.content = &s
  10053. }
  10054. // Content returns the value of the "content" field in the mutation.
  10055. func (m *MessageMutation) Content() (r string, exists bool) {
  10056. v := m.content
  10057. if v == nil {
  10058. return
  10059. }
  10060. return *v, true
  10061. }
  10062. // OldContent returns the old "content" field's value of the Message entity.
  10063. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  10064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10065. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  10066. if !m.op.Is(OpUpdateOne) {
  10067. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  10068. }
  10069. if m.id == nil || m.oldValue == nil {
  10070. return v, errors.New("OldContent requires an ID field in the mutation")
  10071. }
  10072. oldValue, err := m.oldValue(ctx)
  10073. if err != nil {
  10074. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  10075. }
  10076. return oldValue.Content, nil
  10077. }
  10078. // ResetContent resets all changes to the "content" field.
  10079. func (m *MessageMutation) ResetContent() {
  10080. m.content = nil
  10081. }
  10082. // Where appends a list predicates to the MessageMutation builder.
  10083. func (m *MessageMutation) Where(ps ...predicate.Message) {
  10084. m.predicates = append(m.predicates, ps...)
  10085. }
  10086. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  10087. // users can use type-assertion to append predicates that do not depend on any generated package.
  10088. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  10089. p := make([]predicate.Message, len(ps))
  10090. for i := range ps {
  10091. p[i] = ps[i]
  10092. }
  10093. m.Where(p...)
  10094. }
  10095. // Op returns the operation name.
  10096. func (m *MessageMutation) Op() Op {
  10097. return m.op
  10098. }
  10099. // SetOp allows setting the mutation operation.
  10100. func (m *MessageMutation) SetOp(op Op) {
  10101. m.op = op
  10102. }
  10103. // Type returns the node type of this mutation (Message).
  10104. func (m *MessageMutation) Type() string {
  10105. return m.typ
  10106. }
  10107. // Fields returns all fields that were changed during this mutation. Note that in
  10108. // order to get all numeric fields that were incremented/decremented, call
  10109. // AddedFields().
  10110. func (m *MessageMutation) Fields() []string {
  10111. fields := make([]string, 0, 3)
  10112. if m.wx_wxid != nil {
  10113. fields = append(fields, message.FieldWxWxid)
  10114. }
  10115. if m.wxid != nil {
  10116. fields = append(fields, message.FieldWxid)
  10117. }
  10118. if m.content != nil {
  10119. fields = append(fields, message.FieldContent)
  10120. }
  10121. return fields
  10122. }
  10123. // Field returns the value of a field with the given name. The second boolean
  10124. // return value indicates that this field was not set, or was not defined in the
  10125. // schema.
  10126. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  10127. switch name {
  10128. case message.FieldWxWxid:
  10129. return m.WxWxid()
  10130. case message.FieldWxid:
  10131. return m.Wxid()
  10132. case message.FieldContent:
  10133. return m.Content()
  10134. }
  10135. return nil, false
  10136. }
  10137. // OldField returns the old value of the field from the database. An error is
  10138. // returned if the mutation operation is not UpdateOne, or the query to the
  10139. // database failed.
  10140. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10141. switch name {
  10142. case message.FieldWxWxid:
  10143. return m.OldWxWxid(ctx)
  10144. case message.FieldWxid:
  10145. return m.OldWxid(ctx)
  10146. case message.FieldContent:
  10147. return m.OldContent(ctx)
  10148. }
  10149. return nil, fmt.Errorf("unknown Message field %s", name)
  10150. }
  10151. // SetField sets the value of a field with the given name. It returns an error if
  10152. // the field is not defined in the schema, or if the type mismatched the field
  10153. // type.
  10154. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  10155. switch name {
  10156. case message.FieldWxWxid:
  10157. v, ok := value.(string)
  10158. if !ok {
  10159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10160. }
  10161. m.SetWxWxid(v)
  10162. return nil
  10163. case message.FieldWxid:
  10164. v, ok := value.(string)
  10165. if !ok {
  10166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10167. }
  10168. m.SetWxid(v)
  10169. return nil
  10170. case message.FieldContent:
  10171. v, ok := value.(string)
  10172. if !ok {
  10173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10174. }
  10175. m.SetContent(v)
  10176. return nil
  10177. }
  10178. return fmt.Errorf("unknown Message field %s", name)
  10179. }
  10180. // AddedFields returns all numeric fields that were incremented/decremented during
  10181. // this mutation.
  10182. func (m *MessageMutation) AddedFields() []string {
  10183. return nil
  10184. }
  10185. // AddedField returns the numeric value that was incremented/decremented on a field
  10186. // with the given name. The second boolean return value indicates that this field
  10187. // was not set, or was not defined in the schema.
  10188. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  10189. return nil, false
  10190. }
  10191. // AddField adds the value to the field with the given name. It returns an error if
  10192. // the field is not defined in the schema, or if the type mismatched the field
  10193. // type.
  10194. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  10195. switch name {
  10196. }
  10197. return fmt.Errorf("unknown Message numeric field %s", name)
  10198. }
  10199. // ClearedFields returns all nullable fields that were cleared during this
  10200. // mutation.
  10201. func (m *MessageMutation) ClearedFields() []string {
  10202. var fields []string
  10203. if m.FieldCleared(message.FieldWxWxid) {
  10204. fields = append(fields, message.FieldWxWxid)
  10205. }
  10206. return fields
  10207. }
  10208. // FieldCleared returns a boolean indicating if a field with the given name was
  10209. // cleared in this mutation.
  10210. func (m *MessageMutation) FieldCleared(name string) bool {
  10211. _, ok := m.clearedFields[name]
  10212. return ok
  10213. }
  10214. // ClearField clears the value of the field with the given name. It returns an
  10215. // error if the field is not defined in the schema.
  10216. func (m *MessageMutation) ClearField(name string) error {
  10217. switch name {
  10218. case message.FieldWxWxid:
  10219. m.ClearWxWxid()
  10220. return nil
  10221. }
  10222. return fmt.Errorf("unknown Message nullable field %s", name)
  10223. }
  10224. // ResetField resets all changes in the mutation for the field with the given name.
  10225. // It returns an error if the field is not defined in the schema.
  10226. func (m *MessageMutation) ResetField(name string) error {
  10227. switch name {
  10228. case message.FieldWxWxid:
  10229. m.ResetWxWxid()
  10230. return nil
  10231. case message.FieldWxid:
  10232. m.ResetWxid()
  10233. return nil
  10234. case message.FieldContent:
  10235. m.ResetContent()
  10236. return nil
  10237. }
  10238. return fmt.Errorf("unknown Message field %s", name)
  10239. }
  10240. // AddedEdges returns all edge names that were set/added in this mutation.
  10241. func (m *MessageMutation) AddedEdges() []string {
  10242. edges := make([]string, 0, 0)
  10243. return edges
  10244. }
  10245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10246. // name in this mutation.
  10247. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  10248. return nil
  10249. }
  10250. // RemovedEdges returns all edge names that were removed in this mutation.
  10251. func (m *MessageMutation) RemovedEdges() []string {
  10252. edges := make([]string, 0, 0)
  10253. return edges
  10254. }
  10255. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10256. // the given name in this mutation.
  10257. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  10258. return nil
  10259. }
  10260. // ClearedEdges returns all edge names that were cleared in this mutation.
  10261. func (m *MessageMutation) ClearedEdges() []string {
  10262. edges := make([]string, 0, 0)
  10263. return edges
  10264. }
  10265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10266. // was cleared in this mutation.
  10267. func (m *MessageMutation) EdgeCleared(name string) bool {
  10268. return false
  10269. }
  10270. // ClearEdge clears the value of the edge with the given name. It returns an error
  10271. // if that edge is not defined in the schema.
  10272. func (m *MessageMutation) ClearEdge(name string) error {
  10273. return fmt.Errorf("unknown Message unique edge %s", name)
  10274. }
  10275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10276. // It returns an error if the edge is not defined in the schema.
  10277. func (m *MessageMutation) ResetEdge(name string) error {
  10278. return fmt.Errorf("unknown Message edge %s", name)
  10279. }
  10280. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  10281. type MessageRecordsMutation struct {
  10282. config
  10283. op Op
  10284. typ string
  10285. id *uint64
  10286. created_at *time.Time
  10287. updated_at *time.Time
  10288. status *uint8
  10289. addstatus *int8
  10290. bot_wxid *string
  10291. contact_type *int
  10292. addcontact_type *int
  10293. contact_wxid *string
  10294. content_type *int
  10295. addcontent_type *int
  10296. content *string
  10297. meta *custom_types.Meta
  10298. error_detail *string
  10299. send_time *time.Time
  10300. source_type *int
  10301. addsource_type *int
  10302. organization_id *uint64
  10303. addorganization_id *int64
  10304. clearedFields map[string]struct{}
  10305. sop_stage *uint64
  10306. clearedsop_stage bool
  10307. sop_node *uint64
  10308. clearedsop_node bool
  10309. message_contact *uint64
  10310. clearedmessage_contact bool
  10311. done bool
  10312. oldValue func(context.Context) (*MessageRecords, error)
  10313. predicates []predicate.MessageRecords
  10314. }
  10315. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  10316. // messagerecordsOption allows management of the mutation configuration using functional options.
  10317. type messagerecordsOption func(*MessageRecordsMutation)
  10318. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  10319. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  10320. m := &MessageRecordsMutation{
  10321. config: c,
  10322. op: op,
  10323. typ: TypeMessageRecords,
  10324. clearedFields: make(map[string]struct{}),
  10325. }
  10326. for _, opt := range opts {
  10327. opt(m)
  10328. }
  10329. return m
  10330. }
  10331. // withMessageRecordsID sets the ID field of the mutation.
  10332. func withMessageRecordsID(id uint64) messagerecordsOption {
  10333. return func(m *MessageRecordsMutation) {
  10334. var (
  10335. err error
  10336. once sync.Once
  10337. value *MessageRecords
  10338. )
  10339. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  10340. once.Do(func() {
  10341. if m.done {
  10342. err = errors.New("querying old values post mutation is not allowed")
  10343. } else {
  10344. value, err = m.Client().MessageRecords.Get(ctx, id)
  10345. }
  10346. })
  10347. return value, err
  10348. }
  10349. m.id = &id
  10350. }
  10351. }
  10352. // withMessageRecords sets the old MessageRecords of the mutation.
  10353. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  10354. return func(m *MessageRecordsMutation) {
  10355. m.oldValue = func(context.Context) (*MessageRecords, error) {
  10356. return node, nil
  10357. }
  10358. m.id = &node.ID
  10359. }
  10360. }
  10361. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10362. // executed in a transaction (ent.Tx), a transactional client is returned.
  10363. func (m MessageRecordsMutation) Client() *Client {
  10364. client := &Client{config: m.config}
  10365. client.init()
  10366. return client
  10367. }
  10368. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10369. // it returns an error otherwise.
  10370. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  10371. if _, ok := m.driver.(*txDriver); !ok {
  10372. return nil, errors.New("ent: mutation is not running in a transaction")
  10373. }
  10374. tx := &Tx{config: m.config}
  10375. tx.init()
  10376. return tx, nil
  10377. }
  10378. // SetID sets the value of the id field. Note that this
  10379. // operation is only accepted on creation of MessageRecords entities.
  10380. func (m *MessageRecordsMutation) SetID(id uint64) {
  10381. m.id = &id
  10382. }
  10383. // ID returns the ID value in the mutation. Note that the ID is only available
  10384. // if it was provided to the builder or after it was returned from the database.
  10385. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  10386. if m.id == nil {
  10387. return
  10388. }
  10389. return *m.id, true
  10390. }
  10391. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10392. // That means, if the mutation is applied within a transaction with an isolation level such
  10393. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10394. // or updated by the mutation.
  10395. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  10396. switch {
  10397. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10398. id, exists := m.ID()
  10399. if exists {
  10400. return []uint64{id}, nil
  10401. }
  10402. fallthrough
  10403. case m.op.Is(OpUpdate | OpDelete):
  10404. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  10405. default:
  10406. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10407. }
  10408. }
  10409. // SetCreatedAt sets the "created_at" field.
  10410. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  10411. m.created_at = &t
  10412. }
  10413. // CreatedAt returns the value of the "created_at" field in the mutation.
  10414. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  10415. v := m.created_at
  10416. if v == nil {
  10417. return
  10418. }
  10419. return *v, true
  10420. }
  10421. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  10422. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10424. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10425. if !m.op.Is(OpUpdateOne) {
  10426. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10427. }
  10428. if m.id == nil || m.oldValue == nil {
  10429. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10430. }
  10431. oldValue, err := m.oldValue(ctx)
  10432. if err != nil {
  10433. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10434. }
  10435. return oldValue.CreatedAt, nil
  10436. }
  10437. // ResetCreatedAt resets all changes to the "created_at" field.
  10438. func (m *MessageRecordsMutation) ResetCreatedAt() {
  10439. m.created_at = nil
  10440. }
  10441. // SetUpdatedAt sets the "updated_at" field.
  10442. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  10443. m.updated_at = &t
  10444. }
  10445. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10446. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  10447. v := m.updated_at
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  10454. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10456. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10462. }
  10463. oldValue, err := m.oldValue(ctx)
  10464. if err != nil {
  10465. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10466. }
  10467. return oldValue.UpdatedAt, nil
  10468. }
  10469. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10470. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  10471. m.updated_at = nil
  10472. }
  10473. // SetStatus sets the "status" field.
  10474. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  10475. m.status = &u
  10476. m.addstatus = nil
  10477. }
  10478. // Status returns the value of the "status" field in the mutation.
  10479. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  10480. v := m.status
  10481. if v == nil {
  10482. return
  10483. }
  10484. return *v, true
  10485. }
  10486. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  10487. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10489. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10490. if !m.op.Is(OpUpdateOne) {
  10491. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10492. }
  10493. if m.id == nil || m.oldValue == nil {
  10494. return v, errors.New("OldStatus requires an ID field in the mutation")
  10495. }
  10496. oldValue, err := m.oldValue(ctx)
  10497. if err != nil {
  10498. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10499. }
  10500. return oldValue.Status, nil
  10501. }
  10502. // AddStatus adds u to the "status" field.
  10503. func (m *MessageRecordsMutation) AddStatus(u int8) {
  10504. if m.addstatus != nil {
  10505. *m.addstatus += u
  10506. } else {
  10507. m.addstatus = &u
  10508. }
  10509. }
  10510. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10511. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  10512. v := m.addstatus
  10513. if v == nil {
  10514. return
  10515. }
  10516. return *v, true
  10517. }
  10518. // ClearStatus clears the value of the "status" field.
  10519. func (m *MessageRecordsMutation) ClearStatus() {
  10520. m.status = nil
  10521. m.addstatus = nil
  10522. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  10523. }
  10524. // StatusCleared returns if the "status" field was cleared in this mutation.
  10525. func (m *MessageRecordsMutation) StatusCleared() bool {
  10526. _, ok := m.clearedFields[messagerecords.FieldStatus]
  10527. return ok
  10528. }
  10529. // ResetStatus resets all changes to the "status" field.
  10530. func (m *MessageRecordsMutation) ResetStatus() {
  10531. m.status = nil
  10532. m.addstatus = nil
  10533. delete(m.clearedFields, messagerecords.FieldStatus)
  10534. }
  10535. // SetBotWxid sets the "bot_wxid" field.
  10536. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  10537. m.bot_wxid = &s
  10538. }
  10539. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  10540. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  10541. v := m.bot_wxid
  10542. if v == nil {
  10543. return
  10544. }
  10545. return *v, true
  10546. }
  10547. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  10548. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10550. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  10551. if !m.op.Is(OpUpdateOne) {
  10552. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  10553. }
  10554. if m.id == nil || m.oldValue == nil {
  10555. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  10556. }
  10557. oldValue, err := m.oldValue(ctx)
  10558. if err != nil {
  10559. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  10560. }
  10561. return oldValue.BotWxid, nil
  10562. }
  10563. // ResetBotWxid resets all changes to the "bot_wxid" field.
  10564. func (m *MessageRecordsMutation) ResetBotWxid() {
  10565. m.bot_wxid = nil
  10566. }
  10567. // SetContactID sets the "contact_id" field.
  10568. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  10569. m.message_contact = &u
  10570. }
  10571. // ContactID returns the value of the "contact_id" field in the mutation.
  10572. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  10573. v := m.message_contact
  10574. if v == nil {
  10575. return
  10576. }
  10577. return *v, true
  10578. }
  10579. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  10580. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10582. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  10583. if !m.op.Is(OpUpdateOne) {
  10584. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  10585. }
  10586. if m.id == nil || m.oldValue == nil {
  10587. return v, errors.New("OldContactID requires an ID field in the mutation")
  10588. }
  10589. oldValue, err := m.oldValue(ctx)
  10590. if err != nil {
  10591. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  10592. }
  10593. return oldValue.ContactID, nil
  10594. }
  10595. // ClearContactID clears the value of the "contact_id" field.
  10596. func (m *MessageRecordsMutation) ClearContactID() {
  10597. m.message_contact = nil
  10598. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  10599. }
  10600. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  10601. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  10602. _, ok := m.clearedFields[messagerecords.FieldContactID]
  10603. return ok
  10604. }
  10605. // ResetContactID resets all changes to the "contact_id" field.
  10606. func (m *MessageRecordsMutation) ResetContactID() {
  10607. m.message_contact = nil
  10608. delete(m.clearedFields, messagerecords.FieldContactID)
  10609. }
  10610. // SetContactType sets the "contact_type" field.
  10611. func (m *MessageRecordsMutation) SetContactType(i int) {
  10612. m.contact_type = &i
  10613. m.addcontact_type = nil
  10614. }
  10615. // ContactType returns the value of the "contact_type" field in the mutation.
  10616. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  10617. v := m.contact_type
  10618. if v == nil {
  10619. return
  10620. }
  10621. return *v, true
  10622. }
  10623. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  10624. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10626. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  10627. if !m.op.Is(OpUpdateOne) {
  10628. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  10629. }
  10630. if m.id == nil || m.oldValue == nil {
  10631. return v, errors.New("OldContactType requires an ID field in the mutation")
  10632. }
  10633. oldValue, err := m.oldValue(ctx)
  10634. if err != nil {
  10635. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  10636. }
  10637. return oldValue.ContactType, nil
  10638. }
  10639. // AddContactType adds i to the "contact_type" field.
  10640. func (m *MessageRecordsMutation) AddContactType(i int) {
  10641. if m.addcontact_type != nil {
  10642. *m.addcontact_type += i
  10643. } else {
  10644. m.addcontact_type = &i
  10645. }
  10646. }
  10647. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  10648. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  10649. v := m.addcontact_type
  10650. if v == nil {
  10651. return
  10652. }
  10653. return *v, true
  10654. }
  10655. // ResetContactType resets all changes to the "contact_type" field.
  10656. func (m *MessageRecordsMutation) ResetContactType() {
  10657. m.contact_type = nil
  10658. m.addcontact_type = nil
  10659. }
  10660. // SetContactWxid sets the "contact_wxid" field.
  10661. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  10662. m.contact_wxid = &s
  10663. }
  10664. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  10665. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  10666. v := m.contact_wxid
  10667. if v == nil {
  10668. return
  10669. }
  10670. return *v, true
  10671. }
  10672. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  10673. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10675. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  10676. if !m.op.Is(OpUpdateOne) {
  10677. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  10678. }
  10679. if m.id == nil || m.oldValue == nil {
  10680. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  10681. }
  10682. oldValue, err := m.oldValue(ctx)
  10683. if err != nil {
  10684. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  10685. }
  10686. return oldValue.ContactWxid, nil
  10687. }
  10688. // ResetContactWxid resets all changes to the "contact_wxid" field.
  10689. func (m *MessageRecordsMutation) ResetContactWxid() {
  10690. m.contact_wxid = nil
  10691. }
  10692. // SetContentType sets the "content_type" field.
  10693. func (m *MessageRecordsMutation) SetContentType(i int) {
  10694. m.content_type = &i
  10695. m.addcontent_type = nil
  10696. }
  10697. // ContentType returns the value of the "content_type" field in the mutation.
  10698. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  10699. v := m.content_type
  10700. if v == nil {
  10701. return
  10702. }
  10703. return *v, true
  10704. }
  10705. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  10706. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10708. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  10709. if !m.op.Is(OpUpdateOne) {
  10710. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  10711. }
  10712. if m.id == nil || m.oldValue == nil {
  10713. return v, errors.New("OldContentType requires an ID field in the mutation")
  10714. }
  10715. oldValue, err := m.oldValue(ctx)
  10716. if err != nil {
  10717. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  10718. }
  10719. return oldValue.ContentType, nil
  10720. }
  10721. // AddContentType adds i to the "content_type" field.
  10722. func (m *MessageRecordsMutation) AddContentType(i int) {
  10723. if m.addcontent_type != nil {
  10724. *m.addcontent_type += i
  10725. } else {
  10726. m.addcontent_type = &i
  10727. }
  10728. }
  10729. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  10730. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  10731. v := m.addcontent_type
  10732. if v == nil {
  10733. return
  10734. }
  10735. return *v, true
  10736. }
  10737. // ResetContentType resets all changes to the "content_type" field.
  10738. func (m *MessageRecordsMutation) ResetContentType() {
  10739. m.content_type = nil
  10740. m.addcontent_type = nil
  10741. }
  10742. // SetContent sets the "content" field.
  10743. func (m *MessageRecordsMutation) SetContent(s string) {
  10744. m.content = &s
  10745. }
  10746. // Content returns the value of the "content" field in the mutation.
  10747. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  10748. v := m.content
  10749. if v == nil {
  10750. return
  10751. }
  10752. return *v, true
  10753. }
  10754. // OldContent returns the old "content" field's value of the MessageRecords entity.
  10755. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10757. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  10758. if !m.op.Is(OpUpdateOne) {
  10759. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  10760. }
  10761. if m.id == nil || m.oldValue == nil {
  10762. return v, errors.New("OldContent requires an ID field in the mutation")
  10763. }
  10764. oldValue, err := m.oldValue(ctx)
  10765. if err != nil {
  10766. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  10767. }
  10768. return oldValue.Content, nil
  10769. }
  10770. // ResetContent resets all changes to the "content" field.
  10771. func (m *MessageRecordsMutation) ResetContent() {
  10772. m.content = nil
  10773. }
  10774. // SetMeta sets the "meta" field.
  10775. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  10776. m.meta = &ct
  10777. }
  10778. // Meta returns the value of the "meta" field in the mutation.
  10779. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  10780. v := m.meta
  10781. if v == nil {
  10782. return
  10783. }
  10784. return *v, true
  10785. }
  10786. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  10787. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10789. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  10790. if !m.op.Is(OpUpdateOne) {
  10791. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  10792. }
  10793. if m.id == nil || m.oldValue == nil {
  10794. return v, errors.New("OldMeta requires an ID field in the mutation")
  10795. }
  10796. oldValue, err := m.oldValue(ctx)
  10797. if err != nil {
  10798. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  10799. }
  10800. return oldValue.Meta, nil
  10801. }
  10802. // ClearMeta clears the value of the "meta" field.
  10803. func (m *MessageRecordsMutation) ClearMeta() {
  10804. m.meta = nil
  10805. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  10806. }
  10807. // MetaCleared returns if the "meta" field was cleared in this mutation.
  10808. func (m *MessageRecordsMutation) MetaCleared() bool {
  10809. _, ok := m.clearedFields[messagerecords.FieldMeta]
  10810. return ok
  10811. }
  10812. // ResetMeta resets all changes to the "meta" field.
  10813. func (m *MessageRecordsMutation) ResetMeta() {
  10814. m.meta = nil
  10815. delete(m.clearedFields, messagerecords.FieldMeta)
  10816. }
  10817. // SetErrorDetail sets the "error_detail" field.
  10818. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  10819. m.error_detail = &s
  10820. }
  10821. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  10822. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  10823. v := m.error_detail
  10824. if v == nil {
  10825. return
  10826. }
  10827. return *v, true
  10828. }
  10829. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  10830. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10832. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  10833. if !m.op.Is(OpUpdateOne) {
  10834. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  10835. }
  10836. if m.id == nil || m.oldValue == nil {
  10837. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  10838. }
  10839. oldValue, err := m.oldValue(ctx)
  10840. if err != nil {
  10841. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  10842. }
  10843. return oldValue.ErrorDetail, nil
  10844. }
  10845. // ResetErrorDetail resets all changes to the "error_detail" field.
  10846. func (m *MessageRecordsMutation) ResetErrorDetail() {
  10847. m.error_detail = nil
  10848. }
  10849. // SetSendTime sets the "send_time" field.
  10850. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  10851. m.send_time = &t
  10852. }
  10853. // SendTime returns the value of the "send_time" field in the mutation.
  10854. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  10855. v := m.send_time
  10856. if v == nil {
  10857. return
  10858. }
  10859. return *v, true
  10860. }
  10861. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  10862. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10864. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  10865. if !m.op.Is(OpUpdateOne) {
  10866. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  10867. }
  10868. if m.id == nil || m.oldValue == nil {
  10869. return v, errors.New("OldSendTime requires an ID field in the mutation")
  10870. }
  10871. oldValue, err := m.oldValue(ctx)
  10872. if err != nil {
  10873. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  10874. }
  10875. return oldValue.SendTime, nil
  10876. }
  10877. // ClearSendTime clears the value of the "send_time" field.
  10878. func (m *MessageRecordsMutation) ClearSendTime() {
  10879. m.send_time = nil
  10880. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  10881. }
  10882. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  10883. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  10884. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  10885. return ok
  10886. }
  10887. // ResetSendTime resets all changes to the "send_time" field.
  10888. func (m *MessageRecordsMutation) ResetSendTime() {
  10889. m.send_time = nil
  10890. delete(m.clearedFields, messagerecords.FieldSendTime)
  10891. }
  10892. // SetSourceType sets the "source_type" field.
  10893. func (m *MessageRecordsMutation) SetSourceType(i int) {
  10894. m.source_type = &i
  10895. m.addsource_type = nil
  10896. }
  10897. // SourceType returns the value of the "source_type" field in the mutation.
  10898. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  10899. v := m.source_type
  10900. if v == nil {
  10901. return
  10902. }
  10903. return *v, true
  10904. }
  10905. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  10906. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10908. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  10909. if !m.op.Is(OpUpdateOne) {
  10910. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  10911. }
  10912. if m.id == nil || m.oldValue == nil {
  10913. return v, errors.New("OldSourceType requires an ID field in the mutation")
  10914. }
  10915. oldValue, err := m.oldValue(ctx)
  10916. if err != nil {
  10917. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  10918. }
  10919. return oldValue.SourceType, nil
  10920. }
  10921. // AddSourceType adds i to the "source_type" field.
  10922. func (m *MessageRecordsMutation) AddSourceType(i int) {
  10923. if m.addsource_type != nil {
  10924. *m.addsource_type += i
  10925. } else {
  10926. m.addsource_type = &i
  10927. }
  10928. }
  10929. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  10930. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  10931. v := m.addsource_type
  10932. if v == nil {
  10933. return
  10934. }
  10935. return *v, true
  10936. }
  10937. // ResetSourceType resets all changes to the "source_type" field.
  10938. func (m *MessageRecordsMutation) ResetSourceType() {
  10939. m.source_type = nil
  10940. m.addsource_type = nil
  10941. }
  10942. // SetSourceID sets the "source_id" field.
  10943. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  10944. m.sop_stage = &u
  10945. }
  10946. // SourceID returns the value of the "source_id" field in the mutation.
  10947. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  10948. v := m.sop_stage
  10949. if v == nil {
  10950. return
  10951. }
  10952. return *v, true
  10953. }
  10954. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  10955. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10957. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  10958. if !m.op.Is(OpUpdateOne) {
  10959. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  10960. }
  10961. if m.id == nil || m.oldValue == nil {
  10962. return v, errors.New("OldSourceID requires an ID field in the mutation")
  10963. }
  10964. oldValue, err := m.oldValue(ctx)
  10965. if err != nil {
  10966. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  10967. }
  10968. return oldValue.SourceID, nil
  10969. }
  10970. // ClearSourceID clears the value of the "source_id" field.
  10971. func (m *MessageRecordsMutation) ClearSourceID() {
  10972. m.sop_stage = nil
  10973. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  10974. }
  10975. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  10976. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  10977. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  10978. return ok
  10979. }
  10980. // ResetSourceID resets all changes to the "source_id" field.
  10981. func (m *MessageRecordsMutation) ResetSourceID() {
  10982. m.sop_stage = nil
  10983. delete(m.clearedFields, messagerecords.FieldSourceID)
  10984. }
  10985. // SetSubSourceID sets the "sub_source_id" field.
  10986. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  10987. m.sop_node = &u
  10988. }
  10989. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  10990. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  10991. v := m.sop_node
  10992. if v == nil {
  10993. return
  10994. }
  10995. return *v, true
  10996. }
  10997. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  10998. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  10999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11000. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  11001. if !m.op.Is(OpUpdateOne) {
  11002. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  11003. }
  11004. if m.id == nil || m.oldValue == nil {
  11005. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  11006. }
  11007. oldValue, err := m.oldValue(ctx)
  11008. if err != nil {
  11009. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  11010. }
  11011. return oldValue.SubSourceID, nil
  11012. }
  11013. // ClearSubSourceID clears the value of the "sub_source_id" field.
  11014. func (m *MessageRecordsMutation) ClearSubSourceID() {
  11015. m.sop_node = nil
  11016. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  11017. }
  11018. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  11019. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  11020. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  11021. return ok
  11022. }
  11023. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  11024. func (m *MessageRecordsMutation) ResetSubSourceID() {
  11025. m.sop_node = nil
  11026. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  11027. }
  11028. // SetOrganizationID sets the "organization_id" field.
  11029. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  11030. m.organization_id = &u
  11031. m.addorganization_id = nil
  11032. }
  11033. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11034. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  11035. v := m.organization_id
  11036. if v == nil {
  11037. return
  11038. }
  11039. return *v, true
  11040. }
  11041. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  11042. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  11043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11044. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11045. if !m.op.Is(OpUpdateOne) {
  11046. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11047. }
  11048. if m.id == nil || m.oldValue == nil {
  11049. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11050. }
  11051. oldValue, err := m.oldValue(ctx)
  11052. if err != nil {
  11053. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11054. }
  11055. return oldValue.OrganizationID, nil
  11056. }
  11057. // AddOrganizationID adds u to the "organization_id" field.
  11058. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  11059. if m.addorganization_id != nil {
  11060. *m.addorganization_id += u
  11061. } else {
  11062. m.addorganization_id = &u
  11063. }
  11064. }
  11065. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11066. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  11067. v := m.addorganization_id
  11068. if v == nil {
  11069. return
  11070. }
  11071. return *v, true
  11072. }
  11073. // ClearOrganizationID clears the value of the "organization_id" field.
  11074. func (m *MessageRecordsMutation) ClearOrganizationID() {
  11075. m.organization_id = nil
  11076. m.addorganization_id = nil
  11077. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  11078. }
  11079. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11080. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  11081. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  11082. return ok
  11083. }
  11084. // ResetOrganizationID resets all changes to the "organization_id" field.
  11085. func (m *MessageRecordsMutation) ResetOrganizationID() {
  11086. m.organization_id = nil
  11087. m.addorganization_id = nil
  11088. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  11089. }
  11090. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  11091. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  11092. m.sop_stage = &id
  11093. }
  11094. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  11095. func (m *MessageRecordsMutation) ClearSopStage() {
  11096. m.clearedsop_stage = true
  11097. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  11098. }
  11099. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  11100. func (m *MessageRecordsMutation) SopStageCleared() bool {
  11101. return m.SourceIDCleared() || m.clearedsop_stage
  11102. }
  11103. // SopStageID returns the "sop_stage" edge ID in the mutation.
  11104. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  11105. if m.sop_stage != nil {
  11106. return *m.sop_stage, true
  11107. }
  11108. return
  11109. }
  11110. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  11111. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11112. // SopStageID instead. It exists only for internal usage by the builders.
  11113. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  11114. if id := m.sop_stage; id != nil {
  11115. ids = append(ids, *id)
  11116. }
  11117. return
  11118. }
  11119. // ResetSopStage resets all changes to the "sop_stage" edge.
  11120. func (m *MessageRecordsMutation) ResetSopStage() {
  11121. m.sop_stage = nil
  11122. m.clearedsop_stage = false
  11123. }
  11124. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  11125. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  11126. m.sop_node = &id
  11127. }
  11128. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  11129. func (m *MessageRecordsMutation) ClearSopNode() {
  11130. m.clearedsop_node = true
  11131. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  11132. }
  11133. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  11134. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  11135. return m.SubSourceIDCleared() || m.clearedsop_node
  11136. }
  11137. // SopNodeID returns the "sop_node" edge ID in the mutation.
  11138. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  11139. if m.sop_node != nil {
  11140. return *m.sop_node, true
  11141. }
  11142. return
  11143. }
  11144. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  11145. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11146. // SopNodeID instead. It exists only for internal usage by the builders.
  11147. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  11148. if id := m.sop_node; id != nil {
  11149. ids = append(ids, *id)
  11150. }
  11151. return
  11152. }
  11153. // ResetSopNode resets all changes to the "sop_node" edge.
  11154. func (m *MessageRecordsMutation) ResetSopNode() {
  11155. m.sop_node = nil
  11156. m.clearedsop_node = false
  11157. }
  11158. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  11159. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  11160. m.message_contact = &id
  11161. }
  11162. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  11163. func (m *MessageRecordsMutation) ClearMessageContact() {
  11164. m.clearedmessage_contact = true
  11165. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  11166. }
  11167. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  11168. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  11169. return m.ContactIDCleared() || m.clearedmessage_contact
  11170. }
  11171. // MessageContactID returns the "message_contact" edge ID in the mutation.
  11172. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  11173. if m.message_contact != nil {
  11174. return *m.message_contact, true
  11175. }
  11176. return
  11177. }
  11178. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  11179. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11180. // MessageContactID instead. It exists only for internal usage by the builders.
  11181. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  11182. if id := m.message_contact; id != nil {
  11183. ids = append(ids, *id)
  11184. }
  11185. return
  11186. }
  11187. // ResetMessageContact resets all changes to the "message_contact" edge.
  11188. func (m *MessageRecordsMutation) ResetMessageContact() {
  11189. m.message_contact = nil
  11190. m.clearedmessage_contact = false
  11191. }
  11192. // Where appends a list predicates to the MessageRecordsMutation builder.
  11193. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  11194. m.predicates = append(m.predicates, ps...)
  11195. }
  11196. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  11197. // users can use type-assertion to append predicates that do not depend on any generated package.
  11198. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  11199. p := make([]predicate.MessageRecords, len(ps))
  11200. for i := range ps {
  11201. p[i] = ps[i]
  11202. }
  11203. m.Where(p...)
  11204. }
  11205. // Op returns the operation name.
  11206. func (m *MessageRecordsMutation) Op() Op {
  11207. return m.op
  11208. }
  11209. // SetOp allows setting the mutation operation.
  11210. func (m *MessageRecordsMutation) SetOp(op Op) {
  11211. m.op = op
  11212. }
  11213. // Type returns the node type of this mutation (MessageRecords).
  11214. func (m *MessageRecordsMutation) Type() string {
  11215. return m.typ
  11216. }
  11217. // Fields returns all fields that were changed during this mutation. Note that in
  11218. // order to get all numeric fields that were incremented/decremented, call
  11219. // AddedFields().
  11220. func (m *MessageRecordsMutation) Fields() []string {
  11221. fields := make([]string, 0, 16)
  11222. if m.created_at != nil {
  11223. fields = append(fields, messagerecords.FieldCreatedAt)
  11224. }
  11225. if m.updated_at != nil {
  11226. fields = append(fields, messagerecords.FieldUpdatedAt)
  11227. }
  11228. if m.status != nil {
  11229. fields = append(fields, messagerecords.FieldStatus)
  11230. }
  11231. if m.bot_wxid != nil {
  11232. fields = append(fields, messagerecords.FieldBotWxid)
  11233. }
  11234. if m.message_contact != nil {
  11235. fields = append(fields, messagerecords.FieldContactID)
  11236. }
  11237. if m.contact_type != nil {
  11238. fields = append(fields, messagerecords.FieldContactType)
  11239. }
  11240. if m.contact_wxid != nil {
  11241. fields = append(fields, messagerecords.FieldContactWxid)
  11242. }
  11243. if m.content_type != nil {
  11244. fields = append(fields, messagerecords.FieldContentType)
  11245. }
  11246. if m.content != nil {
  11247. fields = append(fields, messagerecords.FieldContent)
  11248. }
  11249. if m.meta != nil {
  11250. fields = append(fields, messagerecords.FieldMeta)
  11251. }
  11252. if m.error_detail != nil {
  11253. fields = append(fields, messagerecords.FieldErrorDetail)
  11254. }
  11255. if m.send_time != nil {
  11256. fields = append(fields, messagerecords.FieldSendTime)
  11257. }
  11258. if m.source_type != nil {
  11259. fields = append(fields, messagerecords.FieldSourceType)
  11260. }
  11261. if m.sop_stage != nil {
  11262. fields = append(fields, messagerecords.FieldSourceID)
  11263. }
  11264. if m.sop_node != nil {
  11265. fields = append(fields, messagerecords.FieldSubSourceID)
  11266. }
  11267. if m.organization_id != nil {
  11268. fields = append(fields, messagerecords.FieldOrganizationID)
  11269. }
  11270. return fields
  11271. }
  11272. // Field returns the value of a field with the given name. The second boolean
  11273. // return value indicates that this field was not set, or was not defined in the
  11274. // schema.
  11275. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  11276. switch name {
  11277. case messagerecords.FieldCreatedAt:
  11278. return m.CreatedAt()
  11279. case messagerecords.FieldUpdatedAt:
  11280. return m.UpdatedAt()
  11281. case messagerecords.FieldStatus:
  11282. return m.Status()
  11283. case messagerecords.FieldBotWxid:
  11284. return m.BotWxid()
  11285. case messagerecords.FieldContactID:
  11286. return m.ContactID()
  11287. case messagerecords.FieldContactType:
  11288. return m.ContactType()
  11289. case messagerecords.FieldContactWxid:
  11290. return m.ContactWxid()
  11291. case messagerecords.FieldContentType:
  11292. return m.ContentType()
  11293. case messagerecords.FieldContent:
  11294. return m.Content()
  11295. case messagerecords.FieldMeta:
  11296. return m.Meta()
  11297. case messagerecords.FieldErrorDetail:
  11298. return m.ErrorDetail()
  11299. case messagerecords.FieldSendTime:
  11300. return m.SendTime()
  11301. case messagerecords.FieldSourceType:
  11302. return m.SourceType()
  11303. case messagerecords.FieldSourceID:
  11304. return m.SourceID()
  11305. case messagerecords.FieldSubSourceID:
  11306. return m.SubSourceID()
  11307. case messagerecords.FieldOrganizationID:
  11308. return m.OrganizationID()
  11309. }
  11310. return nil, false
  11311. }
  11312. // OldField returns the old value of the field from the database. An error is
  11313. // returned if the mutation operation is not UpdateOne, or the query to the
  11314. // database failed.
  11315. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11316. switch name {
  11317. case messagerecords.FieldCreatedAt:
  11318. return m.OldCreatedAt(ctx)
  11319. case messagerecords.FieldUpdatedAt:
  11320. return m.OldUpdatedAt(ctx)
  11321. case messagerecords.FieldStatus:
  11322. return m.OldStatus(ctx)
  11323. case messagerecords.FieldBotWxid:
  11324. return m.OldBotWxid(ctx)
  11325. case messagerecords.FieldContactID:
  11326. return m.OldContactID(ctx)
  11327. case messagerecords.FieldContactType:
  11328. return m.OldContactType(ctx)
  11329. case messagerecords.FieldContactWxid:
  11330. return m.OldContactWxid(ctx)
  11331. case messagerecords.FieldContentType:
  11332. return m.OldContentType(ctx)
  11333. case messagerecords.FieldContent:
  11334. return m.OldContent(ctx)
  11335. case messagerecords.FieldMeta:
  11336. return m.OldMeta(ctx)
  11337. case messagerecords.FieldErrorDetail:
  11338. return m.OldErrorDetail(ctx)
  11339. case messagerecords.FieldSendTime:
  11340. return m.OldSendTime(ctx)
  11341. case messagerecords.FieldSourceType:
  11342. return m.OldSourceType(ctx)
  11343. case messagerecords.FieldSourceID:
  11344. return m.OldSourceID(ctx)
  11345. case messagerecords.FieldSubSourceID:
  11346. return m.OldSubSourceID(ctx)
  11347. case messagerecords.FieldOrganizationID:
  11348. return m.OldOrganizationID(ctx)
  11349. }
  11350. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  11351. }
  11352. // SetField sets the value of a field with the given name. It returns an error if
  11353. // the field is not defined in the schema, or if the type mismatched the field
  11354. // type.
  11355. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  11356. switch name {
  11357. case messagerecords.FieldCreatedAt:
  11358. v, ok := value.(time.Time)
  11359. if !ok {
  11360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11361. }
  11362. m.SetCreatedAt(v)
  11363. return nil
  11364. case messagerecords.FieldUpdatedAt:
  11365. v, ok := value.(time.Time)
  11366. if !ok {
  11367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11368. }
  11369. m.SetUpdatedAt(v)
  11370. return nil
  11371. case messagerecords.FieldStatus:
  11372. v, ok := value.(uint8)
  11373. if !ok {
  11374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11375. }
  11376. m.SetStatus(v)
  11377. return nil
  11378. case messagerecords.FieldBotWxid:
  11379. v, ok := value.(string)
  11380. if !ok {
  11381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11382. }
  11383. m.SetBotWxid(v)
  11384. return nil
  11385. case messagerecords.FieldContactID:
  11386. v, ok := value.(uint64)
  11387. if !ok {
  11388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11389. }
  11390. m.SetContactID(v)
  11391. return nil
  11392. case messagerecords.FieldContactType:
  11393. v, ok := value.(int)
  11394. if !ok {
  11395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11396. }
  11397. m.SetContactType(v)
  11398. return nil
  11399. case messagerecords.FieldContactWxid:
  11400. v, ok := value.(string)
  11401. if !ok {
  11402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11403. }
  11404. m.SetContactWxid(v)
  11405. return nil
  11406. case messagerecords.FieldContentType:
  11407. v, ok := value.(int)
  11408. if !ok {
  11409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11410. }
  11411. m.SetContentType(v)
  11412. return nil
  11413. case messagerecords.FieldContent:
  11414. v, ok := value.(string)
  11415. if !ok {
  11416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11417. }
  11418. m.SetContent(v)
  11419. return nil
  11420. case messagerecords.FieldMeta:
  11421. v, ok := value.(custom_types.Meta)
  11422. if !ok {
  11423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11424. }
  11425. m.SetMeta(v)
  11426. return nil
  11427. case messagerecords.FieldErrorDetail:
  11428. v, ok := value.(string)
  11429. if !ok {
  11430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11431. }
  11432. m.SetErrorDetail(v)
  11433. return nil
  11434. case messagerecords.FieldSendTime:
  11435. v, ok := value.(time.Time)
  11436. if !ok {
  11437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11438. }
  11439. m.SetSendTime(v)
  11440. return nil
  11441. case messagerecords.FieldSourceType:
  11442. v, ok := value.(int)
  11443. if !ok {
  11444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11445. }
  11446. m.SetSourceType(v)
  11447. return nil
  11448. case messagerecords.FieldSourceID:
  11449. v, ok := value.(uint64)
  11450. if !ok {
  11451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11452. }
  11453. m.SetSourceID(v)
  11454. return nil
  11455. case messagerecords.FieldSubSourceID:
  11456. v, ok := value.(uint64)
  11457. if !ok {
  11458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11459. }
  11460. m.SetSubSourceID(v)
  11461. return nil
  11462. case messagerecords.FieldOrganizationID:
  11463. v, ok := value.(uint64)
  11464. if !ok {
  11465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11466. }
  11467. m.SetOrganizationID(v)
  11468. return nil
  11469. }
  11470. return fmt.Errorf("unknown MessageRecords field %s", name)
  11471. }
  11472. // AddedFields returns all numeric fields that were incremented/decremented during
  11473. // this mutation.
  11474. func (m *MessageRecordsMutation) AddedFields() []string {
  11475. var fields []string
  11476. if m.addstatus != nil {
  11477. fields = append(fields, messagerecords.FieldStatus)
  11478. }
  11479. if m.addcontact_type != nil {
  11480. fields = append(fields, messagerecords.FieldContactType)
  11481. }
  11482. if m.addcontent_type != nil {
  11483. fields = append(fields, messagerecords.FieldContentType)
  11484. }
  11485. if m.addsource_type != nil {
  11486. fields = append(fields, messagerecords.FieldSourceType)
  11487. }
  11488. if m.addorganization_id != nil {
  11489. fields = append(fields, messagerecords.FieldOrganizationID)
  11490. }
  11491. return fields
  11492. }
  11493. // AddedField returns the numeric value that was incremented/decremented on a field
  11494. // with the given name. The second boolean return value indicates that this field
  11495. // was not set, or was not defined in the schema.
  11496. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  11497. switch name {
  11498. case messagerecords.FieldStatus:
  11499. return m.AddedStatus()
  11500. case messagerecords.FieldContactType:
  11501. return m.AddedContactType()
  11502. case messagerecords.FieldContentType:
  11503. return m.AddedContentType()
  11504. case messagerecords.FieldSourceType:
  11505. return m.AddedSourceType()
  11506. case messagerecords.FieldOrganizationID:
  11507. return m.AddedOrganizationID()
  11508. }
  11509. return nil, false
  11510. }
  11511. // AddField adds the value to the field with the given name. It returns an error if
  11512. // the field is not defined in the schema, or if the type mismatched the field
  11513. // type.
  11514. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  11515. switch name {
  11516. case messagerecords.FieldStatus:
  11517. v, ok := value.(int8)
  11518. if !ok {
  11519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11520. }
  11521. m.AddStatus(v)
  11522. return nil
  11523. case messagerecords.FieldContactType:
  11524. v, ok := value.(int)
  11525. if !ok {
  11526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11527. }
  11528. m.AddContactType(v)
  11529. return nil
  11530. case messagerecords.FieldContentType:
  11531. v, ok := value.(int)
  11532. if !ok {
  11533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11534. }
  11535. m.AddContentType(v)
  11536. return nil
  11537. case messagerecords.FieldSourceType:
  11538. v, ok := value.(int)
  11539. if !ok {
  11540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11541. }
  11542. m.AddSourceType(v)
  11543. return nil
  11544. case messagerecords.FieldOrganizationID:
  11545. v, ok := value.(int64)
  11546. if !ok {
  11547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11548. }
  11549. m.AddOrganizationID(v)
  11550. return nil
  11551. }
  11552. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  11553. }
  11554. // ClearedFields returns all nullable fields that were cleared during this
  11555. // mutation.
  11556. func (m *MessageRecordsMutation) ClearedFields() []string {
  11557. var fields []string
  11558. if m.FieldCleared(messagerecords.FieldStatus) {
  11559. fields = append(fields, messagerecords.FieldStatus)
  11560. }
  11561. if m.FieldCleared(messagerecords.FieldContactID) {
  11562. fields = append(fields, messagerecords.FieldContactID)
  11563. }
  11564. if m.FieldCleared(messagerecords.FieldMeta) {
  11565. fields = append(fields, messagerecords.FieldMeta)
  11566. }
  11567. if m.FieldCleared(messagerecords.FieldSendTime) {
  11568. fields = append(fields, messagerecords.FieldSendTime)
  11569. }
  11570. if m.FieldCleared(messagerecords.FieldSourceID) {
  11571. fields = append(fields, messagerecords.FieldSourceID)
  11572. }
  11573. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  11574. fields = append(fields, messagerecords.FieldSubSourceID)
  11575. }
  11576. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  11577. fields = append(fields, messagerecords.FieldOrganizationID)
  11578. }
  11579. return fields
  11580. }
  11581. // FieldCleared returns a boolean indicating if a field with the given name was
  11582. // cleared in this mutation.
  11583. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  11584. _, ok := m.clearedFields[name]
  11585. return ok
  11586. }
  11587. // ClearField clears the value of the field with the given name. It returns an
  11588. // error if the field is not defined in the schema.
  11589. func (m *MessageRecordsMutation) ClearField(name string) error {
  11590. switch name {
  11591. case messagerecords.FieldStatus:
  11592. m.ClearStatus()
  11593. return nil
  11594. case messagerecords.FieldContactID:
  11595. m.ClearContactID()
  11596. return nil
  11597. case messagerecords.FieldMeta:
  11598. m.ClearMeta()
  11599. return nil
  11600. case messagerecords.FieldSendTime:
  11601. m.ClearSendTime()
  11602. return nil
  11603. case messagerecords.FieldSourceID:
  11604. m.ClearSourceID()
  11605. return nil
  11606. case messagerecords.FieldSubSourceID:
  11607. m.ClearSubSourceID()
  11608. return nil
  11609. case messagerecords.FieldOrganizationID:
  11610. m.ClearOrganizationID()
  11611. return nil
  11612. }
  11613. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  11614. }
  11615. // ResetField resets all changes in the mutation for the field with the given name.
  11616. // It returns an error if the field is not defined in the schema.
  11617. func (m *MessageRecordsMutation) ResetField(name string) error {
  11618. switch name {
  11619. case messagerecords.FieldCreatedAt:
  11620. m.ResetCreatedAt()
  11621. return nil
  11622. case messagerecords.FieldUpdatedAt:
  11623. m.ResetUpdatedAt()
  11624. return nil
  11625. case messagerecords.FieldStatus:
  11626. m.ResetStatus()
  11627. return nil
  11628. case messagerecords.FieldBotWxid:
  11629. m.ResetBotWxid()
  11630. return nil
  11631. case messagerecords.FieldContactID:
  11632. m.ResetContactID()
  11633. return nil
  11634. case messagerecords.FieldContactType:
  11635. m.ResetContactType()
  11636. return nil
  11637. case messagerecords.FieldContactWxid:
  11638. m.ResetContactWxid()
  11639. return nil
  11640. case messagerecords.FieldContentType:
  11641. m.ResetContentType()
  11642. return nil
  11643. case messagerecords.FieldContent:
  11644. m.ResetContent()
  11645. return nil
  11646. case messagerecords.FieldMeta:
  11647. m.ResetMeta()
  11648. return nil
  11649. case messagerecords.FieldErrorDetail:
  11650. m.ResetErrorDetail()
  11651. return nil
  11652. case messagerecords.FieldSendTime:
  11653. m.ResetSendTime()
  11654. return nil
  11655. case messagerecords.FieldSourceType:
  11656. m.ResetSourceType()
  11657. return nil
  11658. case messagerecords.FieldSourceID:
  11659. m.ResetSourceID()
  11660. return nil
  11661. case messagerecords.FieldSubSourceID:
  11662. m.ResetSubSourceID()
  11663. return nil
  11664. case messagerecords.FieldOrganizationID:
  11665. m.ResetOrganizationID()
  11666. return nil
  11667. }
  11668. return fmt.Errorf("unknown MessageRecords field %s", name)
  11669. }
  11670. // AddedEdges returns all edge names that were set/added in this mutation.
  11671. func (m *MessageRecordsMutation) AddedEdges() []string {
  11672. edges := make([]string, 0, 3)
  11673. if m.sop_stage != nil {
  11674. edges = append(edges, messagerecords.EdgeSopStage)
  11675. }
  11676. if m.sop_node != nil {
  11677. edges = append(edges, messagerecords.EdgeSopNode)
  11678. }
  11679. if m.message_contact != nil {
  11680. edges = append(edges, messagerecords.EdgeMessageContact)
  11681. }
  11682. return edges
  11683. }
  11684. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11685. // name in this mutation.
  11686. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  11687. switch name {
  11688. case messagerecords.EdgeSopStage:
  11689. if id := m.sop_stage; id != nil {
  11690. return []ent.Value{*id}
  11691. }
  11692. case messagerecords.EdgeSopNode:
  11693. if id := m.sop_node; id != nil {
  11694. return []ent.Value{*id}
  11695. }
  11696. case messagerecords.EdgeMessageContact:
  11697. if id := m.message_contact; id != nil {
  11698. return []ent.Value{*id}
  11699. }
  11700. }
  11701. return nil
  11702. }
  11703. // RemovedEdges returns all edge names that were removed in this mutation.
  11704. func (m *MessageRecordsMutation) RemovedEdges() []string {
  11705. edges := make([]string, 0, 3)
  11706. return edges
  11707. }
  11708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11709. // the given name in this mutation.
  11710. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  11711. return nil
  11712. }
  11713. // ClearedEdges returns all edge names that were cleared in this mutation.
  11714. func (m *MessageRecordsMutation) ClearedEdges() []string {
  11715. edges := make([]string, 0, 3)
  11716. if m.clearedsop_stage {
  11717. edges = append(edges, messagerecords.EdgeSopStage)
  11718. }
  11719. if m.clearedsop_node {
  11720. edges = append(edges, messagerecords.EdgeSopNode)
  11721. }
  11722. if m.clearedmessage_contact {
  11723. edges = append(edges, messagerecords.EdgeMessageContact)
  11724. }
  11725. return edges
  11726. }
  11727. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11728. // was cleared in this mutation.
  11729. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  11730. switch name {
  11731. case messagerecords.EdgeSopStage:
  11732. return m.clearedsop_stage
  11733. case messagerecords.EdgeSopNode:
  11734. return m.clearedsop_node
  11735. case messagerecords.EdgeMessageContact:
  11736. return m.clearedmessage_contact
  11737. }
  11738. return false
  11739. }
  11740. // ClearEdge clears the value of the edge with the given name. It returns an error
  11741. // if that edge is not defined in the schema.
  11742. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  11743. switch name {
  11744. case messagerecords.EdgeSopStage:
  11745. m.ClearSopStage()
  11746. return nil
  11747. case messagerecords.EdgeSopNode:
  11748. m.ClearSopNode()
  11749. return nil
  11750. case messagerecords.EdgeMessageContact:
  11751. m.ClearMessageContact()
  11752. return nil
  11753. }
  11754. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  11755. }
  11756. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11757. // It returns an error if the edge is not defined in the schema.
  11758. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  11759. switch name {
  11760. case messagerecords.EdgeSopStage:
  11761. m.ResetSopStage()
  11762. return nil
  11763. case messagerecords.EdgeSopNode:
  11764. m.ResetSopNode()
  11765. return nil
  11766. case messagerecords.EdgeMessageContact:
  11767. m.ResetMessageContact()
  11768. return nil
  11769. }
  11770. return fmt.Errorf("unknown MessageRecords edge %s", name)
  11771. }
  11772. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  11773. type MsgMutation struct {
  11774. config
  11775. op Op
  11776. typ string
  11777. id *uint64
  11778. created_at *time.Time
  11779. updated_at *time.Time
  11780. deleted_at *time.Time
  11781. status *uint8
  11782. addstatus *int8
  11783. fromwxid *string
  11784. toid *string
  11785. msgtype *int32
  11786. addmsgtype *int32
  11787. msg *string
  11788. batch_no *string
  11789. clearedFields map[string]struct{}
  11790. done bool
  11791. oldValue func(context.Context) (*Msg, error)
  11792. predicates []predicate.Msg
  11793. }
  11794. var _ ent.Mutation = (*MsgMutation)(nil)
  11795. // msgOption allows management of the mutation configuration using functional options.
  11796. type msgOption func(*MsgMutation)
  11797. // newMsgMutation creates new mutation for the Msg entity.
  11798. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  11799. m := &MsgMutation{
  11800. config: c,
  11801. op: op,
  11802. typ: TypeMsg,
  11803. clearedFields: make(map[string]struct{}),
  11804. }
  11805. for _, opt := range opts {
  11806. opt(m)
  11807. }
  11808. return m
  11809. }
  11810. // withMsgID sets the ID field of the mutation.
  11811. func withMsgID(id uint64) msgOption {
  11812. return func(m *MsgMutation) {
  11813. var (
  11814. err error
  11815. once sync.Once
  11816. value *Msg
  11817. )
  11818. m.oldValue = func(ctx context.Context) (*Msg, error) {
  11819. once.Do(func() {
  11820. if m.done {
  11821. err = errors.New("querying old values post mutation is not allowed")
  11822. } else {
  11823. value, err = m.Client().Msg.Get(ctx, id)
  11824. }
  11825. })
  11826. return value, err
  11827. }
  11828. m.id = &id
  11829. }
  11830. }
  11831. // withMsg sets the old Msg of the mutation.
  11832. func withMsg(node *Msg) msgOption {
  11833. return func(m *MsgMutation) {
  11834. m.oldValue = func(context.Context) (*Msg, error) {
  11835. return node, nil
  11836. }
  11837. m.id = &node.ID
  11838. }
  11839. }
  11840. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11841. // executed in a transaction (ent.Tx), a transactional client is returned.
  11842. func (m MsgMutation) Client() *Client {
  11843. client := &Client{config: m.config}
  11844. client.init()
  11845. return client
  11846. }
  11847. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11848. // it returns an error otherwise.
  11849. func (m MsgMutation) Tx() (*Tx, error) {
  11850. if _, ok := m.driver.(*txDriver); !ok {
  11851. return nil, errors.New("ent: mutation is not running in a transaction")
  11852. }
  11853. tx := &Tx{config: m.config}
  11854. tx.init()
  11855. return tx, nil
  11856. }
  11857. // SetID sets the value of the id field. Note that this
  11858. // operation is only accepted on creation of Msg entities.
  11859. func (m *MsgMutation) SetID(id uint64) {
  11860. m.id = &id
  11861. }
  11862. // ID returns the ID value in the mutation. Note that the ID is only available
  11863. // if it was provided to the builder or after it was returned from the database.
  11864. func (m *MsgMutation) ID() (id uint64, exists bool) {
  11865. if m.id == nil {
  11866. return
  11867. }
  11868. return *m.id, true
  11869. }
  11870. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11871. // That means, if the mutation is applied within a transaction with an isolation level such
  11872. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11873. // or updated by the mutation.
  11874. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  11875. switch {
  11876. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11877. id, exists := m.ID()
  11878. if exists {
  11879. return []uint64{id}, nil
  11880. }
  11881. fallthrough
  11882. case m.op.Is(OpUpdate | OpDelete):
  11883. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  11884. default:
  11885. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11886. }
  11887. }
  11888. // SetCreatedAt sets the "created_at" field.
  11889. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  11890. m.created_at = &t
  11891. }
  11892. // CreatedAt returns the value of the "created_at" field in the mutation.
  11893. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  11894. v := m.created_at
  11895. if v == nil {
  11896. return
  11897. }
  11898. return *v, true
  11899. }
  11900. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  11901. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11903. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11904. if !m.op.Is(OpUpdateOne) {
  11905. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11906. }
  11907. if m.id == nil || m.oldValue == nil {
  11908. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11909. }
  11910. oldValue, err := m.oldValue(ctx)
  11911. if err != nil {
  11912. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11913. }
  11914. return oldValue.CreatedAt, nil
  11915. }
  11916. // ResetCreatedAt resets all changes to the "created_at" field.
  11917. func (m *MsgMutation) ResetCreatedAt() {
  11918. m.created_at = nil
  11919. }
  11920. // SetUpdatedAt sets the "updated_at" field.
  11921. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  11922. m.updated_at = &t
  11923. }
  11924. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11925. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  11926. v := m.updated_at
  11927. if v == nil {
  11928. return
  11929. }
  11930. return *v, true
  11931. }
  11932. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  11933. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11935. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11936. if !m.op.Is(OpUpdateOne) {
  11937. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11938. }
  11939. if m.id == nil || m.oldValue == nil {
  11940. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11941. }
  11942. oldValue, err := m.oldValue(ctx)
  11943. if err != nil {
  11944. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11945. }
  11946. return oldValue.UpdatedAt, nil
  11947. }
  11948. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11949. func (m *MsgMutation) ResetUpdatedAt() {
  11950. m.updated_at = nil
  11951. }
  11952. // SetDeletedAt sets the "deleted_at" field.
  11953. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  11954. m.deleted_at = &t
  11955. }
  11956. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11957. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  11958. v := m.deleted_at
  11959. if v == nil {
  11960. return
  11961. }
  11962. return *v, true
  11963. }
  11964. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  11965. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  11966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11967. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11968. if !m.op.Is(OpUpdateOne) {
  11969. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11970. }
  11971. if m.id == nil || m.oldValue == nil {
  11972. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11973. }
  11974. oldValue, err := m.oldValue(ctx)
  11975. if err != nil {
  11976. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11977. }
  11978. return oldValue.DeletedAt, nil
  11979. }
  11980. // ClearDeletedAt clears the value of the "deleted_at" field.
  11981. func (m *MsgMutation) ClearDeletedAt() {
  11982. m.deleted_at = nil
  11983. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  11984. }
  11985. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11986. func (m *MsgMutation) DeletedAtCleared() bool {
  11987. _, ok := m.clearedFields[msg.FieldDeletedAt]
  11988. return ok
  11989. }
  11990. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11991. func (m *MsgMutation) ResetDeletedAt() {
  11992. m.deleted_at = nil
  11993. delete(m.clearedFields, msg.FieldDeletedAt)
  11994. }
  11995. // SetStatus sets the "status" field.
  11996. func (m *MsgMutation) SetStatus(u uint8) {
  11997. m.status = &u
  11998. m.addstatus = nil
  11999. }
  12000. // Status returns the value of the "status" field in the mutation.
  12001. func (m *MsgMutation) Status() (r uint8, exists bool) {
  12002. v := m.status
  12003. if v == nil {
  12004. return
  12005. }
  12006. return *v, true
  12007. }
  12008. // OldStatus returns the old "status" field's value of the Msg entity.
  12009. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  12010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12011. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12012. if !m.op.Is(OpUpdateOne) {
  12013. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12014. }
  12015. if m.id == nil || m.oldValue == nil {
  12016. return v, errors.New("OldStatus requires an ID field in the mutation")
  12017. }
  12018. oldValue, err := m.oldValue(ctx)
  12019. if err != nil {
  12020. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12021. }
  12022. return oldValue.Status, nil
  12023. }
  12024. // AddStatus adds u to the "status" field.
  12025. func (m *MsgMutation) AddStatus(u int8) {
  12026. if m.addstatus != nil {
  12027. *m.addstatus += u
  12028. } else {
  12029. m.addstatus = &u
  12030. }
  12031. }
  12032. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12033. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  12034. v := m.addstatus
  12035. if v == nil {
  12036. return
  12037. }
  12038. return *v, true
  12039. }
  12040. // ClearStatus clears the value of the "status" field.
  12041. func (m *MsgMutation) ClearStatus() {
  12042. m.status = nil
  12043. m.addstatus = nil
  12044. m.clearedFields[msg.FieldStatus] = struct{}{}
  12045. }
  12046. // StatusCleared returns if the "status" field was cleared in this mutation.
  12047. func (m *MsgMutation) StatusCleared() bool {
  12048. _, ok := m.clearedFields[msg.FieldStatus]
  12049. return ok
  12050. }
  12051. // ResetStatus resets all changes to the "status" field.
  12052. func (m *MsgMutation) ResetStatus() {
  12053. m.status = nil
  12054. m.addstatus = nil
  12055. delete(m.clearedFields, msg.FieldStatus)
  12056. }
  12057. // SetFromwxid sets the "fromwxid" field.
  12058. func (m *MsgMutation) SetFromwxid(s string) {
  12059. m.fromwxid = &s
  12060. }
  12061. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  12062. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  12063. v := m.fromwxid
  12064. if v == nil {
  12065. return
  12066. }
  12067. return *v, true
  12068. }
  12069. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  12070. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  12071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12072. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  12073. if !m.op.Is(OpUpdateOne) {
  12074. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  12075. }
  12076. if m.id == nil || m.oldValue == nil {
  12077. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  12078. }
  12079. oldValue, err := m.oldValue(ctx)
  12080. if err != nil {
  12081. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  12082. }
  12083. return oldValue.Fromwxid, nil
  12084. }
  12085. // ClearFromwxid clears the value of the "fromwxid" field.
  12086. func (m *MsgMutation) ClearFromwxid() {
  12087. m.fromwxid = nil
  12088. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  12089. }
  12090. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  12091. func (m *MsgMutation) FromwxidCleared() bool {
  12092. _, ok := m.clearedFields[msg.FieldFromwxid]
  12093. return ok
  12094. }
  12095. // ResetFromwxid resets all changes to the "fromwxid" field.
  12096. func (m *MsgMutation) ResetFromwxid() {
  12097. m.fromwxid = nil
  12098. delete(m.clearedFields, msg.FieldFromwxid)
  12099. }
  12100. // SetToid sets the "toid" field.
  12101. func (m *MsgMutation) SetToid(s string) {
  12102. m.toid = &s
  12103. }
  12104. // Toid returns the value of the "toid" field in the mutation.
  12105. func (m *MsgMutation) Toid() (r string, exists bool) {
  12106. v := m.toid
  12107. if v == nil {
  12108. return
  12109. }
  12110. return *v, true
  12111. }
  12112. // OldToid returns the old "toid" field's value of the Msg entity.
  12113. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  12114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12115. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  12116. if !m.op.Is(OpUpdateOne) {
  12117. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  12118. }
  12119. if m.id == nil || m.oldValue == nil {
  12120. return v, errors.New("OldToid requires an ID field in the mutation")
  12121. }
  12122. oldValue, err := m.oldValue(ctx)
  12123. if err != nil {
  12124. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  12125. }
  12126. return oldValue.Toid, nil
  12127. }
  12128. // ClearToid clears the value of the "toid" field.
  12129. func (m *MsgMutation) ClearToid() {
  12130. m.toid = nil
  12131. m.clearedFields[msg.FieldToid] = struct{}{}
  12132. }
  12133. // ToidCleared returns if the "toid" field was cleared in this mutation.
  12134. func (m *MsgMutation) ToidCleared() bool {
  12135. _, ok := m.clearedFields[msg.FieldToid]
  12136. return ok
  12137. }
  12138. // ResetToid resets all changes to the "toid" field.
  12139. func (m *MsgMutation) ResetToid() {
  12140. m.toid = nil
  12141. delete(m.clearedFields, msg.FieldToid)
  12142. }
  12143. // SetMsgtype sets the "msgtype" field.
  12144. func (m *MsgMutation) SetMsgtype(i int32) {
  12145. m.msgtype = &i
  12146. m.addmsgtype = nil
  12147. }
  12148. // Msgtype returns the value of the "msgtype" field in the mutation.
  12149. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  12150. v := m.msgtype
  12151. if v == nil {
  12152. return
  12153. }
  12154. return *v, true
  12155. }
  12156. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  12157. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  12158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12159. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  12160. if !m.op.Is(OpUpdateOne) {
  12161. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  12162. }
  12163. if m.id == nil || m.oldValue == nil {
  12164. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  12165. }
  12166. oldValue, err := m.oldValue(ctx)
  12167. if err != nil {
  12168. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  12169. }
  12170. return oldValue.Msgtype, nil
  12171. }
  12172. // AddMsgtype adds i to the "msgtype" field.
  12173. func (m *MsgMutation) AddMsgtype(i int32) {
  12174. if m.addmsgtype != nil {
  12175. *m.addmsgtype += i
  12176. } else {
  12177. m.addmsgtype = &i
  12178. }
  12179. }
  12180. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  12181. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  12182. v := m.addmsgtype
  12183. if v == nil {
  12184. return
  12185. }
  12186. return *v, true
  12187. }
  12188. // ClearMsgtype clears the value of the "msgtype" field.
  12189. func (m *MsgMutation) ClearMsgtype() {
  12190. m.msgtype = nil
  12191. m.addmsgtype = nil
  12192. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  12193. }
  12194. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  12195. func (m *MsgMutation) MsgtypeCleared() bool {
  12196. _, ok := m.clearedFields[msg.FieldMsgtype]
  12197. return ok
  12198. }
  12199. // ResetMsgtype resets all changes to the "msgtype" field.
  12200. func (m *MsgMutation) ResetMsgtype() {
  12201. m.msgtype = nil
  12202. m.addmsgtype = nil
  12203. delete(m.clearedFields, msg.FieldMsgtype)
  12204. }
  12205. // SetMsg sets the "msg" field.
  12206. func (m *MsgMutation) SetMsg(s string) {
  12207. m.msg = &s
  12208. }
  12209. // Msg returns the value of the "msg" field in the mutation.
  12210. func (m *MsgMutation) Msg() (r string, exists bool) {
  12211. v := m.msg
  12212. if v == nil {
  12213. return
  12214. }
  12215. return *v, true
  12216. }
  12217. // OldMsg returns the old "msg" field's value of the Msg entity.
  12218. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  12219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12220. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  12221. if !m.op.Is(OpUpdateOne) {
  12222. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  12223. }
  12224. if m.id == nil || m.oldValue == nil {
  12225. return v, errors.New("OldMsg requires an ID field in the mutation")
  12226. }
  12227. oldValue, err := m.oldValue(ctx)
  12228. if err != nil {
  12229. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  12230. }
  12231. return oldValue.Msg, nil
  12232. }
  12233. // ClearMsg clears the value of the "msg" field.
  12234. func (m *MsgMutation) ClearMsg() {
  12235. m.msg = nil
  12236. m.clearedFields[msg.FieldMsg] = struct{}{}
  12237. }
  12238. // MsgCleared returns if the "msg" field was cleared in this mutation.
  12239. func (m *MsgMutation) MsgCleared() bool {
  12240. _, ok := m.clearedFields[msg.FieldMsg]
  12241. return ok
  12242. }
  12243. // ResetMsg resets all changes to the "msg" field.
  12244. func (m *MsgMutation) ResetMsg() {
  12245. m.msg = nil
  12246. delete(m.clearedFields, msg.FieldMsg)
  12247. }
  12248. // SetBatchNo sets the "batch_no" field.
  12249. func (m *MsgMutation) SetBatchNo(s string) {
  12250. m.batch_no = &s
  12251. }
  12252. // BatchNo returns the value of the "batch_no" field in the mutation.
  12253. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  12254. v := m.batch_no
  12255. if v == nil {
  12256. return
  12257. }
  12258. return *v, true
  12259. }
  12260. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  12261. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  12262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12263. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  12264. if !m.op.Is(OpUpdateOne) {
  12265. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  12266. }
  12267. if m.id == nil || m.oldValue == nil {
  12268. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  12269. }
  12270. oldValue, err := m.oldValue(ctx)
  12271. if err != nil {
  12272. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  12273. }
  12274. return oldValue.BatchNo, nil
  12275. }
  12276. // ClearBatchNo clears the value of the "batch_no" field.
  12277. func (m *MsgMutation) ClearBatchNo() {
  12278. m.batch_no = nil
  12279. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  12280. }
  12281. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  12282. func (m *MsgMutation) BatchNoCleared() bool {
  12283. _, ok := m.clearedFields[msg.FieldBatchNo]
  12284. return ok
  12285. }
  12286. // ResetBatchNo resets all changes to the "batch_no" field.
  12287. func (m *MsgMutation) ResetBatchNo() {
  12288. m.batch_no = nil
  12289. delete(m.clearedFields, msg.FieldBatchNo)
  12290. }
  12291. // Where appends a list predicates to the MsgMutation builder.
  12292. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  12293. m.predicates = append(m.predicates, ps...)
  12294. }
  12295. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  12296. // users can use type-assertion to append predicates that do not depend on any generated package.
  12297. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  12298. p := make([]predicate.Msg, len(ps))
  12299. for i := range ps {
  12300. p[i] = ps[i]
  12301. }
  12302. m.Where(p...)
  12303. }
  12304. // Op returns the operation name.
  12305. func (m *MsgMutation) Op() Op {
  12306. return m.op
  12307. }
  12308. // SetOp allows setting the mutation operation.
  12309. func (m *MsgMutation) SetOp(op Op) {
  12310. m.op = op
  12311. }
  12312. // Type returns the node type of this mutation (Msg).
  12313. func (m *MsgMutation) Type() string {
  12314. return m.typ
  12315. }
  12316. // Fields returns all fields that were changed during this mutation. Note that in
  12317. // order to get all numeric fields that were incremented/decremented, call
  12318. // AddedFields().
  12319. func (m *MsgMutation) Fields() []string {
  12320. fields := make([]string, 0, 9)
  12321. if m.created_at != nil {
  12322. fields = append(fields, msg.FieldCreatedAt)
  12323. }
  12324. if m.updated_at != nil {
  12325. fields = append(fields, msg.FieldUpdatedAt)
  12326. }
  12327. if m.deleted_at != nil {
  12328. fields = append(fields, msg.FieldDeletedAt)
  12329. }
  12330. if m.status != nil {
  12331. fields = append(fields, msg.FieldStatus)
  12332. }
  12333. if m.fromwxid != nil {
  12334. fields = append(fields, msg.FieldFromwxid)
  12335. }
  12336. if m.toid != nil {
  12337. fields = append(fields, msg.FieldToid)
  12338. }
  12339. if m.msgtype != nil {
  12340. fields = append(fields, msg.FieldMsgtype)
  12341. }
  12342. if m.msg != nil {
  12343. fields = append(fields, msg.FieldMsg)
  12344. }
  12345. if m.batch_no != nil {
  12346. fields = append(fields, msg.FieldBatchNo)
  12347. }
  12348. return fields
  12349. }
  12350. // Field returns the value of a field with the given name. The second boolean
  12351. // return value indicates that this field was not set, or was not defined in the
  12352. // schema.
  12353. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  12354. switch name {
  12355. case msg.FieldCreatedAt:
  12356. return m.CreatedAt()
  12357. case msg.FieldUpdatedAt:
  12358. return m.UpdatedAt()
  12359. case msg.FieldDeletedAt:
  12360. return m.DeletedAt()
  12361. case msg.FieldStatus:
  12362. return m.Status()
  12363. case msg.FieldFromwxid:
  12364. return m.Fromwxid()
  12365. case msg.FieldToid:
  12366. return m.Toid()
  12367. case msg.FieldMsgtype:
  12368. return m.Msgtype()
  12369. case msg.FieldMsg:
  12370. return m.Msg()
  12371. case msg.FieldBatchNo:
  12372. return m.BatchNo()
  12373. }
  12374. return nil, false
  12375. }
  12376. // OldField returns the old value of the field from the database. An error is
  12377. // returned if the mutation operation is not UpdateOne, or the query to the
  12378. // database failed.
  12379. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12380. switch name {
  12381. case msg.FieldCreatedAt:
  12382. return m.OldCreatedAt(ctx)
  12383. case msg.FieldUpdatedAt:
  12384. return m.OldUpdatedAt(ctx)
  12385. case msg.FieldDeletedAt:
  12386. return m.OldDeletedAt(ctx)
  12387. case msg.FieldStatus:
  12388. return m.OldStatus(ctx)
  12389. case msg.FieldFromwxid:
  12390. return m.OldFromwxid(ctx)
  12391. case msg.FieldToid:
  12392. return m.OldToid(ctx)
  12393. case msg.FieldMsgtype:
  12394. return m.OldMsgtype(ctx)
  12395. case msg.FieldMsg:
  12396. return m.OldMsg(ctx)
  12397. case msg.FieldBatchNo:
  12398. return m.OldBatchNo(ctx)
  12399. }
  12400. return nil, fmt.Errorf("unknown Msg field %s", name)
  12401. }
  12402. // SetField sets the value of a field with the given name. It returns an error if
  12403. // the field is not defined in the schema, or if the type mismatched the field
  12404. // type.
  12405. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  12406. switch name {
  12407. case msg.FieldCreatedAt:
  12408. v, ok := value.(time.Time)
  12409. if !ok {
  12410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12411. }
  12412. m.SetCreatedAt(v)
  12413. return nil
  12414. case msg.FieldUpdatedAt:
  12415. v, ok := value.(time.Time)
  12416. if !ok {
  12417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12418. }
  12419. m.SetUpdatedAt(v)
  12420. return nil
  12421. case msg.FieldDeletedAt:
  12422. v, ok := value.(time.Time)
  12423. if !ok {
  12424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12425. }
  12426. m.SetDeletedAt(v)
  12427. return nil
  12428. case msg.FieldStatus:
  12429. v, ok := value.(uint8)
  12430. if !ok {
  12431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12432. }
  12433. m.SetStatus(v)
  12434. return nil
  12435. case msg.FieldFromwxid:
  12436. v, ok := value.(string)
  12437. if !ok {
  12438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12439. }
  12440. m.SetFromwxid(v)
  12441. return nil
  12442. case msg.FieldToid:
  12443. v, ok := value.(string)
  12444. if !ok {
  12445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12446. }
  12447. m.SetToid(v)
  12448. return nil
  12449. case msg.FieldMsgtype:
  12450. v, ok := value.(int32)
  12451. if !ok {
  12452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12453. }
  12454. m.SetMsgtype(v)
  12455. return nil
  12456. case msg.FieldMsg:
  12457. v, ok := value.(string)
  12458. if !ok {
  12459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12460. }
  12461. m.SetMsg(v)
  12462. return nil
  12463. case msg.FieldBatchNo:
  12464. v, ok := value.(string)
  12465. if !ok {
  12466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12467. }
  12468. m.SetBatchNo(v)
  12469. return nil
  12470. }
  12471. return fmt.Errorf("unknown Msg field %s", name)
  12472. }
  12473. // AddedFields returns all numeric fields that were incremented/decremented during
  12474. // this mutation.
  12475. func (m *MsgMutation) AddedFields() []string {
  12476. var fields []string
  12477. if m.addstatus != nil {
  12478. fields = append(fields, msg.FieldStatus)
  12479. }
  12480. if m.addmsgtype != nil {
  12481. fields = append(fields, msg.FieldMsgtype)
  12482. }
  12483. return fields
  12484. }
  12485. // AddedField returns the numeric value that was incremented/decremented on a field
  12486. // with the given name. The second boolean return value indicates that this field
  12487. // was not set, or was not defined in the schema.
  12488. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  12489. switch name {
  12490. case msg.FieldStatus:
  12491. return m.AddedStatus()
  12492. case msg.FieldMsgtype:
  12493. return m.AddedMsgtype()
  12494. }
  12495. return nil, false
  12496. }
  12497. // AddField adds the value to the field with the given name. It returns an error if
  12498. // the field is not defined in the schema, or if the type mismatched the field
  12499. // type.
  12500. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  12501. switch name {
  12502. case msg.FieldStatus:
  12503. v, ok := value.(int8)
  12504. if !ok {
  12505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12506. }
  12507. m.AddStatus(v)
  12508. return nil
  12509. case msg.FieldMsgtype:
  12510. v, ok := value.(int32)
  12511. if !ok {
  12512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12513. }
  12514. m.AddMsgtype(v)
  12515. return nil
  12516. }
  12517. return fmt.Errorf("unknown Msg numeric field %s", name)
  12518. }
  12519. // ClearedFields returns all nullable fields that were cleared during this
  12520. // mutation.
  12521. func (m *MsgMutation) ClearedFields() []string {
  12522. var fields []string
  12523. if m.FieldCleared(msg.FieldDeletedAt) {
  12524. fields = append(fields, msg.FieldDeletedAt)
  12525. }
  12526. if m.FieldCleared(msg.FieldStatus) {
  12527. fields = append(fields, msg.FieldStatus)
  12528. }
  12529. if m.FieldCleared(msg.FieldFromwxid) {
  12530. fields = append(fields, msg.FieldFromwxid)
  12531. }
  12532. if m.FieldCleared(msg.FieldToid) {
  12533. fields = append(fields, msg.FieldToid)
  12534. }
  12535. if m.FieldCleared(msg.FieldMsgtype) {
  12536. fields = append(fields, msg.FieldMsgtype)
  12537. }
  12538. if m.FieldCleared(msg.FieldMsg) {
  12539. fields = append(fields, msg.FieldMsg)
  12540. }
  12541. if m.FieldCleared(msg.FieldBatchNo) {
  12542. fields = append(fields, msg.FieldBatchNo)
  12543. }
  12544. return fields
  12545. }
  12546. // FieldCleared returns a boolean indicating if a field with the given name was
  12547. // cleared in this mutation.
  12548. func (m *MsgMutation) FieldCleared(name string) bool {
  12549. _, ok := m.clearedFields[name]
  12550. return ok
  12551. }
  12552. // ClearField clears the value of the field with the given name. It returns an
  12553. // error if the field is not defined in the schema.
  12554. func (m *MsgMutation) ClearField(name string) error {
  12555. switch name {
  12556. case msg.FieldDeletedAt:
  12557. m.ClearDeletedAt()
  12558. return nil
  12559. case msg.FieldStatus:
  12560. m.ClearStatus()
  12561. return nil
  12562. case msg.FieldFromwxid:
  12563. m.ClearFromwxid()
  12564. return nil
  12565. case msg.FieldToid:
  12566. m.ClearToid()
  12567. return nil
  12568. case msg.FieldMsgtype:
  12569. m.ClearMsgtype()
  12570. return nil
  12571. case msg.FieldMsg:
  12572. m.ClearMsg()
  12573. return nil
  12574. case msg.FieldBatchNo:
  12575. m.ClearBatchNo()
  12576. return nil
  12577. }
  12578. return fmt.Errorf("unknown Msg nullable field %s", name)
  12579. }
  12580. // ResetField resets all changes in the mutation for the field with the given name.
  12581. // It returns an error if the field is not defined in the schema.
  12582. func (m *MsgMutation) ResetField(name string) error {
  12583. switch name {
  12584. case msg.FieldCreatedAt:
  12585. m.ResetCreatedAt()
  12586. return nil
  12587. case msg.FieldUpdatedAt:
  12588. m.ResetUpdatedAt()
  12589. return nil
  12590. case msg.FieldDeletedAt:
  12591. m.ResetDeletedAt()
  12592. return nil
  12593. case msg.FieldStatus:
  12594. m.ResetStatus()
  12595. return nil
  12596. case msg.FieldFromwxid:
  12597. m.ResetFromwxid()
  12598. return nil
  12599. case msg.FieldToid:
  12600. m.ResetToid()
  12601. return nil
  12602. case msg.FieldMsgtype:
  12603. m.ResetMsgtype()
  12604. return nil
  12605. case msg.FieldMsg:
  12606. m.ResetMsg()
  12607. return nil
  12608. case msg.FieldBatchNo:
  12609. m.ResetBatchNo()
  12610. return nil
  12611. }
  12612. return fmt.Errorf("unknown Msg field %s", name)
  12613. }
  12614. // AddedEdges returns all edge names that were set/added in this mutation.
  12615. func (m *MsgMutation) AddedEdges() []string {
  12616. edges := make([]string, 0, 0)
  12617. return edges
  12618. }
  12619. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12620. // name in this mutation.
  12621. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  12622. return nil
  12623. }
  12624. // RemovedEdges returns all edge names that were removed in this mutation.
  12625. func (m *MsgMutation) RemovedEdges() []string {
  12626. edges := make([]string, 0, 0)
  12627. return edges
  12628. }
  12629. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12630. // the given name in this mutation.
  12631. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  12632. return nil
  12633. }
  12634. // ClearedEdges returns all edge names that were cleared in this mutation.
  12635. func (m *MsgMutation) ClearedEdges() []string {
  12636. edges := make([]string, 0, 0)
  12637. return edges
  12638. }
  12639. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12640. // was cleared in this mutation.
  12641. func (m *MsgMutation) EdgeCleared(name string) bool {
  12642. return false
  12643. }
  12644. // ClearEdge clears the value of the edge with the given name. It returns an error
  12645. // if that edge is not defined in the schema.
  12646. func (m *MsgMutation) ClearEdge(name string) error {
  12647. return fmt.Errorf("unknown Msg unique edge %s", name)
  12648. }
  12649. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12650. // It returns an error if the edge is not defined in the schema.
  12651. func (m *MsgMutation) ResetEdge(name string) error {
  12652. return fmt.Errorf("unknown Msg edge %s", name)
  12653. }
  12654. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  12655. type ServerMutation struct {
  12656. config
  12657. op Op
  12658. typ string
  12659. id *uint64
  12660. created_at *time.Time
  12661. updated_at *time.Time
  12662. status *uint8
  12663. addstatus *int8
  12664. deleted_at *time.Time
  12665. name *string
  12666. public_ip *string
  12667. private_ip *string
  12668. admin_port *string
  12669. clearedFields map[string]struct{}
  12670. wxs map[uint64]struct{}
  12671. removedwxs map[uint64]struct{}
  12672. clearedwxs bool
  12673. done bool
  12674. oldValue func(context.Context) (*Server, error)
  12675. predicates []predicate.Server
  12676. }
  12677. var _ ent.Mutation = (*ServerMutation)(nil)
  12678. // serverOption allows management of the mutation configuration using functional options.
  12679. type serverOption func(*ServerMutation)
  12680. // newServerMutation creates new mutation for the Server entity.
  12681. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  12682. m := &ServerMutation{
  12683. config: c,
  12684. op: op,
  12685. typ: TypeServer,
  12686. clearedFields: make(map[string]struct{}),
  12687. }
  12688. for _, opt := range opts {
  12689. opt(m)
  12690. }
  12691. return m
  12692. }
  12693. // withServerID sets the ID field of the mutation.
  12694. func withServerID(id uint64) serverOption {
  12695. return func(m *ServerMutation) {
  12696. var (
  12697. err error
  12698. once sync.Once
  12699. value *Server
  12700. )
  12701. m.oldValue = func(ctx context.Context) (*Server, error) {
  12702. once.Do(func() {
  12703. if m.done {
  12704. err = errors.New("querying old values post mutation is not allowed")
  12705. } else {
  12706. value, err = m.Client().Server.Get(ctx, id)
  12707. }
  12708. })
  12709. return value, err
  12710. }
  12711. m.id = &id
  12712. }
  12713. }
  12714. // withServer sets the old Server of the mutation.
  12715. func withServer(node *Server) serverOption {
  12716. return func(m *ServerMutation) {
  12717. m.oldValue = func(context.Context) (*Server, error) {
  12718. return node, nil
  12719. }
  12720. m.id = &node.ID
  12721. }
  12722. }
  12723. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12724. // executed in a transaction (ent.Tx), a transactional client is returned.
  12725. func (m ServerMutation) Client() *Client {
  12726. client := &Client{config: m.config}
  12727. client.init()
  12728. return client
  12729. }
  12730. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12731. // it returns an error otherwise.
  12732. func (m ServerMutation) Tx() (*Tx, error) {
  12733. if _, ok := m.driver.(*txDriver); !ok {
  12734. return nil, errors.New("ent: mutation is not running in a transaction")
  12735. }
  12736. tx := &Tx{config: m.config}
  12737. tx.init()
  12738. return tx, nil
  12739. }
  12740. // SetID sets the value of the id field. Note that this
  12741. // operation is only accepted on creation of Server entities.
  12742. func (m *ServerMutation) SetID(id uint64) {
  12743. m.id = &id
  12744. }
  12745. // ID returns the ID value in the mutation. Note that the ID is only available
  12746. // if it was provided to the builder or after it was returned from the database.
  12747. func (m *ServerMutation) ID() (id uint64, exists bool) {
  12748. if m.id == nil {
  12749. return
  12750. }
  12751. return *m.id, true
  12752. }
  12753. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12754. // That means, if the mutation is applied within a transaction with an isolation level such
  12755. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12756. // or updated by the mutation.
  12757. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  12758. switch {
  12759. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12760. id, exists := m.ID()
  12761. if exists {
  12762. return []uint64{id}, nil
  12763. }
  12764. fallthrough
  12765. case m.op.Is(OpUpdate | OpDelete):
  12766. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  12767. default:
  12768. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12769. }
  12770. }
  12771. // SetCreatedAt sets the "created_at" field.
  12772. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  12773. m.created_at = &t
  12774. }
  12775. // CreatedAt returns the value of the "created_at" field in the mutation.
  12776. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  12777. v := m.created_at
  12778. if v == nil {
  12779. return
  12780. }
  12781. return *v, true
  12782. }
  12783. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  12784. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12786. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12787. if !m.op.Is(OpUpdateOne) {
  12788. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12789. }
  12790. if m.id == nil || m.oldValue == nil {
  12791. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12792. }
  12793. oldValue, err := m.oldValue(ctx)
  12794. if err != nil {
  12795. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12796. }
  12797. return oldValue.CreatedAt, nil
  12798. }
  12799. // ResetCreatedAt resets all changes to the "created_at" field.
  12800. func (m *ServerMutation) ResetCreatedAt() {
  12801. m.created_at = nil
  12802. }
  12803. // SetUpdatedAt sets the "updated_at" field.
  12804. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  12805. m.updated_at = &t
  12806. }
  12807. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12808. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  12809. v := m.updated_at
  12810. if v == nil {
  12811. return
  12812. }
  12813. return *v, true
  12814. }
  12815. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  12816. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12818. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12819. if !m.op.Is(OpUpdateOne) {
  12820. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12821. }
  12822. if m.id == nil || m.oldValue == nil {
  12823. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12824. }
  12825. oldValue, err := m.oldValue(ctx)
  12826. if err != nil {
  12827. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12828. }
  12829. return oldValue.UpdatedAt, nil
  12830. }
  12831. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12832. func (m *ServerMutation) ResetUpdatedAt() {
  12833. m.updated_at = nil
  12834. }
  12835. // SetStatus sets the "status" field.
  12836. func (m *ServerMutation) SetStatus(u uint8) {
  12837. m.status = &u
  12838. m.addstatus = nil
  12839. }
  12840. // Status returns the value of the "status" field in the mutation.
  12841. func (m *ServerMutation) Status() (r uint8, exists bool) {
  12842. v := m.status
  12843. if v == nil {
  12844. return
  12845. }
  12846. return *v, true
  12847. }
  12848. // OldStatus returns the old "status" field's value of the Server entity.
  12849. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12851. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12852. if !m.op.Is(OpUpdateOne) {
  12853. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12854. }
  12855. if m.id == nil || m.oldValue == nil {
  12856. return v, errors.New("OldStatus requires an ID field in the mutation")
  12857. }
  12858. oldValue, err := m.oldValue(ctx)
  12859. if err != nil {
  12860. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12861. }
  12862. return oldValue.Status, nil
  12863. }
  12864. // AddStatus adds u to the "status" field.
  12865. func (m *ServerMutation) AddStatus(u int8) {
  12866. if m.addstatus != nil {
  12867. *m.addstatus += u
  12868. } else {
  12869. m.addstatus = &u
  12870. }
  12871. }
  12872. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12873. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  12874. v := m.addstatus
  12875. if v == nil {
  12876. return
  12877. }
  12878. return *v, true
  12879. }
  12880. // ClearStatus clears the value of the "status" field.
  12881. func (m *ServerMutation) ClearStatus() {
  12882. m.status = nil
  12883. m.addstatus = nil
  12884. m.clearedFields[server.FieldStatus] = struct{}{}
  12885. }
  12886. // StatusCleared returns if the "status" field was cleared in this mutation.
  12887. func (m *ServerMutation) StatusCleared() bool {
  12888. _, ok := m.clearedFields[server.FieldStatus]
  12889. return ok
  12890. }
  12891. // ResetStatus resets all changes to the "status" field.
  12892. func (m *ServerMutation) ResetStatus() {
  12893. m.status = nil
  12894. m.addstatus = nil
  12895. delete(m.clearedFields, server.FieldStatus)
  12896. }
  12897. // SetDeletedAt sets the "deleted_at" field.
  12898. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  12899. m.deleted_at = &t
  12900. }
  12901. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12902. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  12903. v := m.deleted_at
  12904. if v == nil {
  12905. return
  12906. }
  12907. return *v, true
  12908. }
  12909. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  12910. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12912. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12913. if !m.op.Is(OpUpdateOne) {
  12914. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12915. }
  12916. if m.id == nil || m.oldValue == nil {
  12917. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12918. }
  12919. oldValue, err := m.oldValue(ctx)
  12920. if err != nil {
  12921. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12922. }
  12923. return oldValue.DeletedAt, nil
  12924. }
  12925. // ClearDeletedAt clears the value of the "deleted_at" field.
  12926. func (m *ServerMutation) ClearDeletedAt() {
  12927. m.deleted_at = nil
  12928. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  12929. }
  12930. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12931. func (m *ServerMutation) DeletedAtCleared() bool {
  12932. _, ok := m.clearedFields[server.FieldDeletedAt]
  12933. return ok
  12934. }
  12935. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12936. func (m *ServerMutation) ResetDeletedAt() {
  12937. m.deleted_at = nil
  12938. delete(m.clearedFields, server.FieldDeletedAt)
  12939. }
  12940. // SetName sets the "name" field.
  12941. func (m *ServerMutation) SetName(s string) {
  12942. m.name = &s
  12943. }
  12944. // Name returns the value of the "name" field in the mutation.
  12945. func (m *ServerMutation) Name() (r string, exists bool) {
  12946. v := m.name
  12947. if v == nil {
  12948. return
  12949. }
  12950. return *v, true
  12951. }
  12952. // OldName returns the old "name" field's value of the Server entity.
  12953. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12955. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  12956. if !m.op.Is(OpUpdateOne) {
  12957. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12958. }
  12959. if m.id == nil || m.oldValue == nil {
  12960. return v, errors.New("OldName requires an ID field in the mutation")
  12961. }
  12962. oldValue, err := m.oldValue(ctx)
  12963. if err != nil {
  12964. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12965. }
  12966. return oldValue.Name, nil
  12967. }
  12968. // ResetName resets all changes to the "name" field.
  12969. func (m *ServerMutation) ResetName() {
  12970. m.name = nil
  12971. }
  12972. // SetPublicIP sets the "public_ip" field.
  12973. func (m *ServerMutation) SetPublicIP(s string) {
  12974. m.public_ip = &s
  12975. }
  12976. // PublicIP returns the value of the "public_ip" field in the mutation.
  12977. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  12978. v := m.public_ip
  12979. if v == nil {
  12980. return
  12981. }
  12982. return *v, true
  12983. }
  12984. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  12985. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  12986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12987. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  12988. if !m.op.Is(OpUpdateOne) {
  12989. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  12990. }
  12991. if m.id == nil || m.oldValue == nil {
  12992. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  12993. }
  12994. oldValue, err := m.oldValue(ctx)
  12995. if err != nil {
  12996. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  12997. }
  12998. return oldValue.PublicIP, nil
  12999. }
  13000. // ResetPublicIP resets all changes to the "public_ip" field.
  13001. func (m *ServerMutation) ResetPublicIP() {
  13002. m.public_ip = nil
  13003. }
  13004. // SetPrivateIP sets the "private_ip" field.
  13005. func (m *ServerMutation) SetPrivateIP(s string) {
  13006. m.private_ip = &s
  13007. }
  13008. // PrivateIP returns the value of the "private_ip" field in the mutation.
  13009. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  13010. v := m.private_ip
  13011. if v == nil {
  13012. return
  13013. }
  13014. return *v, true
  13015. }
  13016. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  13017. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  13018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13019. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  13020. if !m.op.Is(OpUpdateOne) {
  13021. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  13022. }
  13023. if m.id == nil || m.oldValue == nil {
  13024. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  13025. }
  13026. oldValue, err := m.oldValue(ctx)
  13027. if err != nil {
  13028. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  13029. }
  13030. return oldValue.PrivateIP, nil
  13031. }
  13032. // ResetPrivateIP resets all changes to the "private_ip" field.
  13033. func (m *ServerMutation) ResetPrivateIP() {
  13034. m.private_ip = nil
  13035. }
  13036. // SetAdminPort sets the "admin_port" field.
  13037. func (m *ServerMutation) SetAdminPort(s string) {
  13038. m.admin_port = &s
  13039. }
  13040. // AdminPort returns the value of the "admin_port" field in the mutation.
  13041. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  13042. v := m.admin_port
  13043. if v == nil {
  13044. return
  13045. }
  13046. return *v, true
  13047. }
  13048. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  13049. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  13050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13051. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  13052. if !m.op.Is(OpUpdateOne) {
  13053. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  13054. }
  13055. if m.id == nil || m.oldValue == nil {
  13056. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  13057. }
  13058. oldValue, err := m.oldValue(ctx)
  13059. if err != nil {
  13060. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  13061. }
  13062. return oldValue.AdminPort, nil
  13063. }
  13064. // ResetAdminPort resets all changes to the "admin_port" field.
  13065. func (m *ServerMutation) ResetAdminPort() {
  13066. m.admin_port = nil
  13067. }
  13068. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  13069. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  13070. if m.wxs == nil {
  13071. m.wxs = make(map[uint64]struct{})
  13072. }
  13073. for i := range ids {
  13074. m.wxs[ids[i]] = struct{}{}
  13075. }
  13076. }
  13077. // ClearWxs clears the "wxs" edge to the Wx entity.
  13078. func (m *ServerMutation) ClearWxs() {
  13079. m.clearedwxs = true
  13080. }
  13081. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  13082. func (m *ServerMutation) WxsCleared() bool {
  13083. return m.clearedwxs
  13084. }
  13085. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  13086. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  13087. if m.removedwxs == nil {
  13088. m.removedwxs = make(map[uint64]struct{})
  13089. }
  13090. for i := range ids {
  13091. delete(m.wxs, ids[i])
  13092. m.removedwxs[ids[i]] = struct{}{}
  13093. }
  13094. }
  13095. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  13096. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  13097. for id := range m.removedwxs {
  13098. ids = append(ids, id)
  13099. }
  13100. return
  13101. }
  13102. // WxsIDs returns the "wxs" edge IDs in the mutation.
  13103. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  13104. for id := range m.wxs {
  13105. ids = append(ids, id)
  13106. }
  13107. return
  13108. }
  13109. // ResetWxs resets all changes to the "wxs" edge.
  13110. func (m *ServerMutation) ResetWxs() {
  13111. m.wxs = nil
  13112. m.clearedwxs = false
  13113. m.removedwxs = nil
  13114. }
  13115. // Where appends a list predicates to the ServerMutation builder.
  13116. func (m *ServerMutation) Where(ps ...predicate.Server) {
  13117. m.predicates = append(m.predicates, ps...)
  13118. }
  13119. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  13120. // users can use type-assertion to append predicates that do not depend on any generated package.
  13121. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  13122. p := make([]predicate.Server, len(ps))
  13123. for i := range ps {
  13124. p[i] = ps[i]
  13125. }
  13126. m.Where(p...)
  13127. }
  13128. // Op returns the operation name.
  13129. func (m *ServerMutation) Op() Op {
  13130. return m.op
  13131. }
  13132. // SetOp allows setting the mutation operation.
  13133. func (m *ServerMutation) SetOp(op Op) {
  13134. m.op = op
  13135. }
  13136. // Type returns the node type of this mutation (Server).
  13137. func (m *ServerMutation) Type() string {
  13138. return m.typ
  13139. }
  13140. // Fields returns all fields that were changed during this mutation. Note that in
  13141. // order to get all numeric fields that were incremented/decremented, call
  13142. // AddedFields().
  13143. func (m *ServerMutation) Fields() []string {
  13144. fields := make([]string, 0, 8)
  13145. if m.created_at != nil {
  13146. fields = append(fields, server.FieldCreatedAt)
  13147. }
  13148. if m.updated_at != nil {
  13149. fields = append(fields, server.FieldUpdatedAt)
  13150. }
  13151. if m.status != nil {
  13152. fields = append(fields, server.FieldStatus)
  13153. }
  13154. if m.deleted_at != nil {
  13155. fields = append(fields, server.FieldDeletedAt)
  13156. }
  13157. if m.name != nil {
  13158. fields = append(fields, server.FieldName)
  13159. }
  13160. if m.public_ip != nil {
  13161. fields = append(fields, server.FieldPublicIP)
  13162. }
  13163. if m.private_ip != nil {
  13164. fields = append(fields, server.FieldPrivateIP)
  13165. }
  13166. if m.admin_port != nil {
  13167. fields = append(fields, server.FieldAdminPort)
  13168. }
  13169. return fields
  13170. }
  13171. // Field returns the value of a field with the given name. The second boolean
  13172. // return value indicates that this field was not set, or was not defined in the
  13173. // schema.
  13174. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  13175. switch name {
  13176. case server.FieldCreatedAt:
  13177. return m.CreatedAt()
  13178. case server.FieldUpdatedAt:
  13179. return m.UpdatedAt()
  13180. case server.FieldStatus:
  13181. return m.Status()
  13182. case server.FieldDeletedAt:
  13183. return m.DeletedAt()
  13184. case server.FieldName:
  13185. return m.Name()
  13186. case server.FieldPublicIP:
  13187. return m.PublicIP()
  13188. case server.FieldPrivateIP:
  13189. return m.PrivateIP()
  13190. case server.FieldAdminPort:
  13191. return m.AdminPort()
  13192. }
  13193. return nil, false
  13194. }
  13195. // OldField returns the old value of the field from the database. An error is
  13196. // returned if the mutation operation is not UpdateOne, or the query to the
  13197. // database failed.
  13198. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13199. switch name {
  13200. case server.FieldCreatedAt:
  13201. return m.OldCreatedAt(ctx)
  13202. case server.FieldUpdatedAt:
  13203. return m.OldUpdatedAt(ctx)
  13204. case server.FieldStatus:
  13205. return m.OldStatus(ctx)
  13206. case server.FieldDeletedAt:
  13207. return m.OldDeletedAt(ctx)
  13208. case server.FieldName:
  13209. return m.OldName(ctx)
  13210. case server.FieldPublicIP:
  13211. return m.OldPublicIP(ctx)
  13212. case server.FieldPrivateIP:
  13213. return m.OldPrivateIP(ctx)
  13214. case server.FieldAdminPort:
  13215. return m.OldAdminPort(ctx)
  13216. }
  13217. return nil, fmt.Errorf("unknown Server field %s", name)
  13218. }
  13219. // SetField sets the value of a field with the given name. It returns an error if
  13220. // the field is not defined in the schema, or if the type mismatched the field
  13221. // type.
  13222. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  13223. switch name {
  13224. case server.FieldCreatedAt:
  13225. v, ok := value.(time.Time)
  13226. if !ok {
  13227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13228. }
  13229. m.SetCreatedAt(v)
  13230. return nil
  13231. case server.FieldUpdatedAt:
  13232. v, ok := value.(time.Time)
  13233. if !ok {
  13234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13235. }
  13236. m.SetUpdatedAt(v)
  13237. return nil
  13238. case server.FieldStatus:
  13239. v, ok := value.(uint8)
  13240. if !ok {
  13241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13242. }
  13243. m.SetStatus(v)
  13244. return nil
  13245. case server.FieldDeletedAt:
  13246. v, ok := value.(time.Time)
  13247. if !ok {
  13248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13249. }
  13250. m.SetDeletedAt(v)
  13251. return nil
  13252. case server.FieldName:
  13253. v, ok := value.(string)
  13254. if !ok {
  13255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13256. }
  13257. m.SetName(v)
  13258. return nil
  13259. case server.FieldPublicIP:
  13260. v, ok := value.(string)
  13261. if !ok {
  13262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13263. }
  13264. m.SetPublicIP(v)
  13265. return nil
  13266. case server.FieldPrivateIP:
  13267. v, ok := value.(string)
  13268. if !ok {
  13269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13270. }
  13271. m.SetPrivateIP(v)
  13272. return nil
  13273. case server.FieldAdminPort:
  13274. v, ok := value.(string)
  13275. if !ok {
  13276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13277. }
  13278. m.SetAdminPort(v)
  13279. return nil
  13280. }
  13281. return fmt.Errorf("unknown Server field %s", name)
  13282. }
  13283. // AddedFields returns all numeric fields that were incremented/decremented during
  13284. // this mutation.
  13285. func (m *ServerMutation) AddedFields() []string {
  13286. var fields []string
  13287. if m.addstatus != nil {
  13288. fields = append(fields, server.FieldStatus)
  13289. }
  13290. return fields
  13291. }
  13292. // AddedField returns the numeric value that was incremented/decremented on a field
  13293. // with the given name. The second boolean return value indicates that this field
  13294. // was not set, or was not defined in the schema.
  13295. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  13296. switch name {
  13297. case server.FieldStatus:
  13298. return m.AddedStatus()
  13299. }
  13300. return nil, false
  13301. }
  13302. // AddField adds the value to the field with the given name. It returns an error if
  13303. // the field is not defined in the schema, or if the type mismatched the field
  13304. // type.
  13305. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  13306. switch name {
  13307. case server.FieldStatus:
  13308. v, ok := value.(int8)
  13309. if !ok {
  13310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13311. }
  13312. m.AddStatus(v)
  13313. return nil
  13314. }
  13315. return fmt.Errorf("unknown Server numeric field %s", name)
  13316. }
  13317. // ClearedFields returns all nullable fields that were cleared during this
  13318. // mutation.
  13319. func (m *ServerMutation) ClearedFields() []string {
  13320. var fields []string
  13321. if m.FieldCleared(server.FieldStatus) {
  13322. fields = append(fields, server.FieldStatus)
  13323. }
  13324. if m.FieldCleared(server.FieldDeletedAt) {
  13325. fields = append(fields, server.FieldDeletedAt)
  13326. }
  13327. return fields
  13328. }
  13329. // FieldCleared returns a boolean indicating if a field with the given name was
  13330. // cleared in this mutation.
  13331. func (m *ServerMutation) FieldCleared(name string) bool {
  13332. _, ok := m.clearedFields[name]
  13333. return ok
  13334. }
  13335. // ClearField clears the value of the field with the given name. It returns an
  13336. // error if the field is not defined in the schema.
  13337. func (m *ServerMutation) ClearField(name string) error {
  13338. switch name {
  13339. case server.FieldStatus:
  13340. m.ClearStatus()
  13341. return nil
  13342. case server.FieldDeletedAt:
  13343. m.ClearDeletedAt()
  13344. return nil
  13345. }
  13346. return fmt.Errorf("unknown Server nullable field %s", name)
  13347. }
  13348. // ResetField resets all changes in the mutation for the field with the given name.
  13349. // It returns an error if the field is not defined in the schema.
  13350. func (m *ServerMutation) ResetField(name string) error {
  13351. switch name {
  13352. case server.FieldCreatedAt:
  13353. m.ResetCreatedAt()
  13354. return nil
  13355. case server.FieldUpdatedAt:
  13356. m.ResetUpdatedAt()
  13357. return nil
  13358. case server.FieldStatus:
  13359. m.ResetStatus()
  13360. return nil
  13361. case server.FieldDeletedAt:
  13362. m.ResetDeletedAt()
  13363. return nil
  13364. case server.FieldName:
  13365. m.ResetName()
  13366. return nil
  13367. case server.FieldPublicIP:
  13368. m.ResetPublicIP()
  13369. return nil
  13370. case server.FieldPrivateIP:
  13371. m.ResetPrivateIP()
  13372. return nil
  13373. case server.FieldAdminPort:
  13374. m.ResetAdminPort()
  13375. return nil
  13376. }
  13377. return fmt.Errorf("unknown Server field %s", name)
  13378. }
  13379. // AddedEdges returns all edge names that were set/added in this mutation.
  13380. func (m *ServerMutation) AddedEdges() []string {
  13381. edges := make([]string, 0, 1)
  13382. if m.wxs != nil {
  13383. edges = append(edges, server.EdgeWxs)
  13384. }
  13385. return edges
  13386. }
  13387. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13388. // name in this mutation.
  13389. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  13390. switch name {
  13391. case server.EdgeWxs:
  13392. ids := make([]ent.Value, 0, len(m.wxs))
  13393. for id := range m.wxs {
  13394. ids = append(ids, id)
  13395. }
  13396. return ids
  13397. }
  13398. return nil
  13399. }
  13400. // RemovedEdges returns all edge names that were removed in this mutation.
  13401. func (m *ServerMutation) RemovedEdges() []string {
  13402. edges := make([]string, 0, 1)
  13403. if m.removedwxs != nil {
  13404. edges = append(edges, server.EdgeWxs)
  13405. }
  13406. return edges
  13407. }
  13408. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13409. // the given name in this mutation.
  13410. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  13411. switch name {
  13412. case server.EdgeWxs:
  13413. ids := make([]ent.Value, 0, len(m.removedwxs))
  13414. for id := range m.removedwxs {
  13415. ids = append(ids, id)
  13416. }
  13417. return ids
  13418. }
  13419. return nil
  13420. }
  13421. // ClearedEdges returns all edge names that were cleared in this mutation.
  13422. func (m *ServerMutation) ClearedEdges() []string {
  13423. edges := make([]string, 0, 1)
  13424. if m.clearedwxs {
  13425. edges = append(edges, server.EdgeWxs)
  13426. }
  13427. return edges
  13428. }
  13429. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13430. // was cleared in this mutation.
  13431. func (m *ServerMutation) EdgeCleared(name string) bool {
  13432. switch name {
  13433. case server.EdgeWxs:
  13434. return m.clearedwxs
  13435. }
  13436. return false
  13437. }
  13438. // ClearEdge clears the value of the edge with the given name. It returns an error
  13439. // if that edge is not defined in the schema.
  13440. func (m *ServerMutation) ClearEdge(name string) error {
  13441. switch name {
  13442. }
  13443. return fmt.Errorf("unknown Server unique edge %s", name)
  13444. }
  13445. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13446. // It returns an error if the edge is not defined in the schema.
  13447. func (m *ServerMutation) ResetEdge(name string) error {
  13448. switch name {
  13449. case server.EdgeWxs:
  13450. m.ResetWxs()
  13451. return nil
  13452. }
  13453. return fmt.Errorf("unknown Server edge %s", name)
  13454. }
  13455. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  13456. type SopNodeMutation struct {
  13457. config
  13458. op Op
  13459. typ string
  13460. id *uint64
  13461. created_at *time.Time
  13462. updated_at *time.Time
  13463. status *uint8
  13464. addstatus *int8
  13465. deleted_at *time.Time
  13466. parent_id *uint64
  13467. addparent_id *int64
  13468. name *string
  13469. condition_type *int
  13470. addcondition_type *int
  13471. condition_list *[]string
  13472. appendcondition_list []string
  13473. no_reply_condition *uint64
  13474. addno_reply_condition *int64
  13475. action_message *[]custom_types.Action
  13476. appendaction_message []custom_types.Action
  13477. action_label *[]uint64
  13478. appendaction_label []uint64
  13479. clearedFields map[string]struct{}
  13480. sop_stage *uint64
  13481. clearedsop_stage bool
  13482. node_messages map[uint64]struct{}
  13483. removednode_messages map[uint64]struct{}
  13484. clearednode_messages bool
  13485. done bool
  13486. oldValue func(context.Context) (*SopNode, error)
  13487. predicates []predicate.SopNode
  13488. }
  13489. var _ ent.Mutation = (*SopNodeMutation)(nil)
  13490. // sopnodeOption allows management of the mutation configuration using functional options.
  13491. type sopnodeOption func(*SopNodeMutation)
  13492. // newSopNodeMutation creates new mutation for the SopNode entity.
  13493. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  13494. m := &SopNodeMutation{
  13495. config: c,
  13496. op: op,
  13497. typ: TypeSopNode,
  13498. clearedFields: make(map[string]struct{}),
  13499. }
  13500. for _, opt := range opts {
  13501. opt(m)
  13502. }
  13503. return m
  13504. }
  13505. // withSopNodeID sets the ID field of the mutation.
  13506. func withSopNodeID(id uint64) sopnodeOption {
  13507. return func(m *SopNodeMutation) {
  13508. var (
  13509. err error
  13510. once sync.Once
  13511. value *SopNode
  13512. )
  13513. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  13514. once.Do(func() {
  13515. if m.done {
  13516. err = errors.New("querying old values post mutation is not allowed")
  13517. } else {
  13518. value, err = m.Client().SopNode.Get(ctx, id)
  13519. }
  13520. })
  13521. return value, err
  13522. }
  13523. m.id = &id
  13524. }
  13525. }
  13526. // withSopNode sets the old SopNode of the mutation.
  13527. func withSopNode(node *SopNode) sopnodeOption {
  13528. return func(m *SopNodeMutation) {
  13529. m.oldValue = func(context.Context) (*SopNode, error) {
  13530. return node, nil
  13531. }
  13532. m.id = &node.ID
  13533. }
  13534. }
  13535. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13536. // executed in a transaction (ent.Tx), a transactional client is returned.
  13537. func (m SopNodeMutation) Client() *Client {
  13538. client := &Client{config: m.config}
  13539. client.init()
  13540. return client
  13541. }
  13542. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13543. // it returns an error otherwise.
  13544. func (m SopNodeMutation) Tx() (*Tx, error) {
  13545. if _, ok := m.driver.(*txDriver); !ok {
  13546. return nil, errors.New("ent: mutation is not running in a transaction")
  13547. }
  13548. tx := &Tx{config: m.config}
  13549. tx.init()
  13550. return tx, nil
  13551. }
  13552. // SetID sets the value of the id field. Note that this
  13553. // operation is only accepted on creation of SopNode entities.
  13554. func (m *SopNodeMutation) SetID(id uint64) {
  13555. m.id = &id
  13556. }
  13557. // ID returns the ID value in the mutation. Note that the ID is only available
  13558. // if it was provided to the builder or after it was returned from the database.
  13559. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  13560. if m.id == nil {
  13561. return
  13562. }
  13563. return *m.id, true
  13564. }
  13565. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13566. // That means, if the mutation is applied within a transaction with an isolation level such
  13567. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13568. // or updated by the mutation.
  13569. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13570. switch {
  13571. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13572. id, exists := m.ID()
  13573. if exists {
  13574. return []uint64{id}, nil
  13575. }
  13576. fallthrough
  13577. case m.op.Is(OpUpdate | OpDelete):
  13578. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  13579. default:
  13580. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13581. }
  13582. }
  13583. // SetCreatedAt sets the "created_at" field.
  13584. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  13585. m.created_at = &t
  13586. }
  13587. // CreatedAt returns the value of the "created_at" field in the mutation.
  13588. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  13589. v := m.created_at
  13590. if v == nil {
  13591. return
  13592. }
  13593. return *v, true
  13594. }
  13595. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  13596. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13598. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13599. if !m.op.Is(OpUpdateOne) {
  13600. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13601. }
  13602. if m.id == nil || m.oldValue == nil {
  13603. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13604. }
  13605. oldValue, err := m.oldValue(ctx)
  13606. if err != nil {
  13607. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13608. }
  13609. return oldValue.CreatedAt, nil
  13610. }
  13611. // ResetCreatedAt resets all changes to the "created_at" field.
  13612. func (m *SopNodeMutation) ResetCreatedAt() {
  13613. m.created_at = nil
  13614. }
  13615. // SetUpdatedAt sets the "updated_at" field.
  13616. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  13617. m.updated_at = &t
  13618. }
  13619. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13620. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  13621. v := m.updated_at
  13622. if v == nil {
  13623. return
  13624. }
  13625. return *v, true
  13626. }
  13627. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  13628. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13630. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13631. if !m.op.Is(OpUpdateOne) {
  13632. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13633. }
  13634. if m.id == nil || m.oldValue == nil {
  13635. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13636. }
  13637. oldValue, err := m.oldValue(ctx)
  13638. if err != nil {
  13639. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13640. }
  13641. return oldValue.UpdatedAt, nil
  13642. }
  13643. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13644. func (m *SopNodeMutation) ResetUpdatedAt() {
  13645. m.updated_at = nil
  13646. }
  13647. // SetStatus sets the "status" field.
  13648. func (m *SopNodeMutation) SetStatus(u uint8) {
  13649. m.status = &u
  13650. m.addstatus = nil
  13651. }
  13652. // Status returns the value of the "status" field in the mutation.
  13653. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  13654. v := m.status
  13655. if v == nil {
  13656. return
  13657. }
  13658. return *v, true
  13659. }
  13660. // OldStatus returns the old "status" field's value of the SopNode entity.
  13661. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13663. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13664. if !m.op.Is(OpUpdateOne) {
  13665. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13666. }
  13667. if m.id == nil || m.oldValue == nil {
  13668. return v, errors.New("OldStatus requires an ID field in the mutation")
  13669. }
  13670. oldValue, err := m.oldValue(ctx)
  13671. if err != nil {
  13672. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13673. }
  13674. return oldValue.Status, nil
  13675. }
  13676. // AddStatus adds u to the "status" field.
  13677. func (m *SopNodeMutation) AddStatus(u int8) {
  13678. if m.addstatus != nil {
  13679. *m.addstatus += u
  13680. } else {
  13681. m.addstatus = &u
  13682. }
  13683. }
  13684. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13685. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  13686. v := m.addstatus
  13687. if v == nil {
  13688. return
  13689. }
  13690. return *v, true
  13691. }
  13692. // ClearStatus clears the value of the "status" field.
  13693. func (m *SopNodeMutation) ClearStatus() {
  13694. m.status = nil
  13695. m.addstatus = nil
  13696. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  13697. }
  13698. // StatusCleared returns if the "status" field was cleared in this mutation.
  13699. func (m *SopNodeMutation) StatusCleared() bool {
  13700. _, ok := m.clearedFields[sopnode.FieldStatus]
  13701. return ok
  13702. }
  13703. // ResetStatus resets all changes to the "status" field.
  13704. func (m *SopNodeMutation) ResetStatus() {
  13705. m.status = nil
  13706. m.addstatus = nil
  13707. delete(m.clearedFields, sopnode.FieldStatus)
  13708. }
  13709. // SetDeletedAt sets the "deleted_at" field.
  13710. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  13711. m.deleted_at = &t
  13712. }
  13713. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13714. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  13715. v := m.deleted_at
  13716. if v == nil {
  13717. return
  13718. }
  13719. return *v, true
  13720. }
  13721. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  13722. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13724. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13725. if !m.op.Is(OpUpdateOne) {
  13726. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13727. }
  13728. if m.id == nil || m.oldValue == nil {
  13729. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13730. }
  13731. oldValue, err := m.oldValue(ctx)
  13732. if err != nil {
  13733. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13734. }
  13735. return oldValue.DeletedAt, nil
  13736. }
  13737. // ClearDeletedAt clears the value of the "deleted_at" field.
  13738. func (m *SopNodeMutation) ClearDeletedAt() {
  13739. m.deleted_at = nil
  13740. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  13741. }
  13742. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13743. func (m *SopNodeMutation) DeletedAtCleared() bool {
  13744. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  13745. return ok
  13746. }
  13747. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13748. func (m *SopNodeMutation) ResetDeletedAt() {
  13749. m.deleted_at = nil
  13750. delete(m.clearedFields, sopnode.FieldDeletedAt)
  13751. }
  13752. // SetStageID sets the "stage_id" field.
  13753. func (m *SopNodeMutation) SetStageID(u uint64) {
  13754. m.sop_stage = &u
  13755. }
  13756. // StageID returns the value of the "stage_id" field in the mutation.
  13757. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  13758. v := m.sop_stage
  13759. if v == nil {
  13760. return
  13761. }
  13762. return *v, true
  13763. }
  13764. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  13765. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13767. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  13768. if !m.op.Is(OpUpdateOne) {
  13769. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  13770. }
  13771. if m.id == nil || m.oldValue == nil {
  13772. return v, errors.New("OldStageID requires an ID field in the mutation")
  13773. }
  13774. oldValue, err := m.oldValue(ctx)
  13775. if err != nil {
  13776. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  13777. }
  13778. return oldValue.StageID, nil
  13779. }
  13780. // ResetStageID resets all changes to the "stage_id" field.
  13781. func (m *SopNodeMutation) ResetStageID() {
  13782. m.sop_stage = nil
  13783. }
  13784. // SetParentID sets the "parent_id" field.
  13785. func (m *SopNodeMutation) SetParentID(u uint64) {
  13786. m.parent_id = &u
  13787. m.addparent_id = nil
  13788. }
  13789. // ParentID returns the value of the "parent_id" field in the mutation.
  13790. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  13791. v := m.parent_id
  13792. if v == nil {
  13793. return
  13794. }
  13795. return *v, true
  13796. }
  13797. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  13798. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13800. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  13801. if !m.op.Is(OpUpdateOne) {
  13802. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  13803. }
  13804. if m.id == nil || m.oldValue == nil {
  13805. return v, errors.New("OldParentID requires an ID field in the mutation")
  13806. }
  13807. oldValue, err := m.oldValue(ctx)
  13808. if err != nil {
  13809. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  13810. }
  13811. return oldValue.ParentID, nil
  13812. }
  13813. // AddParentID adds u to the "parent_id" field.
  13814. func (m *SopNodeMutation) AddParentID(u int64) {
  13815. if m.addparent_id != nil {
  13816. *m.addparent_id += u
  13817. } else {
  13818. m.addparent_id = &u
  13819. }
  13820. }
  13821. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  13822. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  13823. v := m.addparent_id
  13824. if v == nil {
  13825. return
  13826. }
  13827. return *v, true
  13828. }
  13829. // ResetParentID resets all changes to the "parent_id" field.
  13830. func (m *SopNodeMutation) ResetParentID() {
  13831. m.parent_id = nil
  13832. m.addparent_id = nil
  13833. }
  13834. // SetName sets the "name" field.
  13835. func (m *SopNodeMutation) SetName(s string) {
  13836. m.name = &s
  13837. }
  13838. // Name returns the value of the "name" field in the mutation.
  13839. func (m *SopNodeMutation) Name() (r string, exists bool) {
  13840. v := m.name
  13841. if v == nil {
  13842. return
  13843. }
  13844. return *v, true
  13845. }
  13846. // OldName returns the old "name" field's value of the SopNode entity.
  13847. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13849. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  13850. if !m.op.Is(OpUpdateOne) {
  13851. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13852. }
  13853. if m.id == nil || m.oldValue == nil {
  13854. return v, errors.New("OldName requires an ID field in the mutation")
  13855. }
  13856. oldValue, err := m.oldValue(ctx)
  13857. if err != nil {
  13858. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13859. }
  13860. return oldValue.Name, nil
  13861. }
  13862. // ResetName resets all changes to the "name" field.
  13863. func (m *SopNodeMutation) ResetName() {
  13864. m.name = nil
  13865. }
  13866. // SetConditionType sets the "condition_type" field.
  13867. func (m *SopNodeMutation) SetConditionType(i int) {
  13868. m.condition_type = &i
  13869. m.addcondition_type = nil
  13870. }
  13871. // ConditionType returns the value of the "condition_type" field in the mutation.
  13872. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  13873. v := m.condition_type
  13874. if v == nil {
  13875. return
  13876. }
  13877. return *v, true
  13878. }
  13879. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  13880. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13882. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  13883. if !m.op.Is(OpUpdateOne) {
  13884. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  13885. }
  13886. if m.id == nil || m.oldValue == nil {
  13887. return v, errors.New("OldConditionType requires an ID field in the mutation")
  13888. }
  13889. oldValue, err := m.oldValue(ctx)
  13890. if err != nil {
  13891. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  13892. }
  13893. return oldValue.ConditionType, nil
  13894. }
  13895. // AddConditionType adds i to the "condition_type" field.
  13896. func (m *SopNodeMutation) AddConditionType(i int) {
  13897. if m.addcondition_type != nil {
  13898. *m.addcondition_type += i
  13899. } else {
  13900. m.addcondition_type = &i
  13901. }
  13902. }
  13903. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  13904. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  13905. v := m.addcondition_type
  13906. if v == nil {
  13907. return
  13908. }
  13909. return *v, true
  13910. }
  13911. // ResetConditionType resets all changes to the "condition_type" field.
  13912. func (m *SopNodeMutation) ResetConditionType() {
  13913. m.condition_type = nil
  13914. m.addcondition_type = nil
  13915. }
  13916. // SetConditionList sets the "condition_list" field.
  13917. func (m *SopNodeMutation) SetConditionList(s []string) {
  13918. m.condition_list = &s
  13919. m.appendcondition_list = nil
  13920. }
  13921. // ConditionList returns the value of the "condition_list" field in the mutation.
  13922. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  13923. v := m.condition_list
  13924. if v == nil {
  13925. return
  13926. }
  13927. return *v, true
  13928. }
  13929. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  13930. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13932. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  13933. if !m.op.Is(OpUpdateOne) {
  13934. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  13935. }
  13936. if m.id == nil || m.oldValue == nil {
  13937. return v, errors.New("OldConditionList requires an ID field in the mutation")
  13938. }
  13939. oldValue, err := m.oldValue(ctx)
  13940. if err != nil {
  13941. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  13942. }
  13943. return oldValue.ConditionList, nil
  13944. }
  13945. // AppendConditionList adds s to the "condition_list" field.
  13946. func (m *SopNodeMutation) AppendConditionList(s []string) {
  13947. m.appendcondition_list = append(m.appendcondition_list, s...)
  13948. }
  13949. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  13950. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  13951. if len(m.appendcondition_list) == 0 {
  13952. return nil, false
  13953. }
  13954. return m.appendcondition_list, true
  13955. }
  13956. // ClearConditionList clears the value of the "condition_list" field.
  13957. func (m *SopNodeMutation) ClearConditionList() {
  13958. m.condition_list = nil
  13959. m.appendcondition_list = nil
  13960. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  13961. }
  13962. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  13963. func (m *SopNodeMutation) ConditionListCleared() bool {
  13964. _, ok := m.clearedFields[sopnode.FieldConditionList]
  13965. return ok
  13966. }
  13967. // ResetConditionList resets all changes to the "condition_list" field.
  13968. func (m *SopNodeMutation) ResetConditionList() {
  13969. m.condition_list = nil
  13970. m.appendcondition_list = nil
  13971. delete(m.clearedFields, sopnode.FieldConditionList)
  13972. }
  13973. // SetNoReplyCondition sets the "no_reply_condition" field.
  13974. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  13975. m.no_reply_condition = &u
  13976. m.addno_reply_condition = nil
  13977. }
  13978. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  13979. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  13980. v := m.no_reply_condition
  13981. if v == nil {
  13982. return
  13983. }
  13984. return *v, true
  13985. }
  13986. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  13987. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  13988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13989. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  13990. if !m.op.Is(OpUpdateOne) {
  13991. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  13992. }
  13993. if m.id == nil || m.oldValue == nil {
  13994. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  13995. }
  13996. oldValue, err := m.oldValue(ctx)
  13997. if err != nil {
  13998. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  13999. }
  14000. return oldValue.NoReplyCondition, nil
  14001. }
  14002. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  14003. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  14004. if m.addno_reply_condition != nil {
  14005. *m.addno_reply_condition += u
  14006. } else {
  14007. m.addno_reply_condition = &u
  14008. }
  14009. }
  14010. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  14011. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  14012. v := m.addno_reply_condition
  14013. if v == nil {
  14014. return
  14015. }
  14016. return *v, true
  14017. }
  14018. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  14019. func (m *SopNodeMutation) ResetNoReplyCondition() {
  14020. m.no_reply_condition = nil
  14021. m.addno_reply_condition = nil
  14022. }
  14023. // SetActionMessage sets the "action_message" field.
  14024. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  14025. m.action_message = &ct
  14026. m.appendaction_message = nil
  14027. }
  14028. // ActionMessage returns the value of the "action_message" field in the mutation.
  14029. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  14030. v := m.action_message
  14031. if v == nil {
  14032. return
  14033. }
  14034. return *v, true
  14035. }
  14036. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  14037. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  14038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14039. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  14040. if !m.op.Is(OpUpdateOne) {
  14041. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  14042. }
  14043. if m.id == nil || m.oldValue == nil {
  14044. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  14045. }
  14046. oldValue, err := m.oldValue(ctx)
  14047. if err != nil {
  14048. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  14049. }
  14050. return oldValue.ActionMessage, nil
  14051. }
  14052. // AppendActionMessage adds ct to the "action_message" field.
  14053. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  14054. m.appendaction_message = append(m.appendaction_message, ct...)
  14055. }
  14056. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  14057. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  14058. if len(m.appendaction_message) == 0 {
  14059. return nil, false
  14060. }
  14061. return m.appendaction_message, true
  14062. }
  14063. // ClearActionMessage clears the value of the "action_message" field.
  14064. func (m *SopNodeMutation) ClearActionMessage() {
  14065. m.action_message = nil
  14066. m.appendaction_message = nil
  14067. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  14068. }
  14069. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  14070. func (m *SopNodeMutation) ActionMessageCleared() bool {
  14071. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  14072. return ok
  14073. }
  14074. // ResetActionMessage resets all changes to the "action_message" field.
  14075. func (m *SopNodeMutation) ResetActionMessage() {
  14076. m.action_message = nil
  14077. m.appendaction_message = nil
  14078. delete(m.clearedFields, sopnode.FieldActionMessage)
  14079. }
  14080. // SetActionLabel sets the "action_label" field.
  14081. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  14082. m.action_label = &u
  14083. m.appendaction_label = nil
  14084. }
  14085. // ActionLabel returns the value of the "action_label" field in the mutation.
  14086. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  14087. v := m.action_label
  14088. if v == nil {
  14089. return
  14090. }
  14091. return *v, true
  14092. }
  14093. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  14094. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  14095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14096. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  14097. if !m.op.Is(OpUpdateOne) {
  14098. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  14099. }
  14100. if m.id == nil || m.oldValue == nil {
  14101. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  14102. }
  14103. oldValue, err := m.oldValue(ctx)
  14104. if err != nil {
  14105. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  14106. }
  14107. return oldValue.ActionLabel, nil
  14108. }
  14109. // AppendActionLabel adds u to the "action_label" field.
  14110. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  14111. m.appendaction_label = append(m.appendaction_label, u...)
  14112. }
  14113. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  14114. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  14115. if len(m.appendaction_label) == 0 {
  14116. return nil, false
  14117. }
  14118. return m.appendaction_label, true
  14119. }
  14120. // ClearActionLabel clears the value of the "action_label" field.
  14121. func (m *SopNodeMutation) ClearActionLabel() {
  14122. m.action_label = nil
  14123. m.appendaction_label = nil
  14124. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  14125. }
  14126. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  14127. func (m *SopNodeMutation) ActionLabelCleared() bool {
  14128. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  14129. return ok
  14130. }
  14131. // ResetActionLabel resets all changes to the "action_label" field.
  14132. func (m *SopNodeMutation) ResetActionLabel() {
  14133. m.action_label = nil
  14134. m.appendaction_label = nil
  14135. delete(m.clearedFields, sopnode.FieldActionLabel)
  14136. }
  14137. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14138. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  14139. m.sop_stage = &id
  14140. }
  14141. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14142. func (m *SopNodeMutation) ClearSopStage() {
  14143. m.clearedsop_stage = true
  14144. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  14145. }
  14146. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14147. func (m *SopNodeMutation) SopStageCleared() bool {
  14148. return m.clearedsop_stage
  14149. }
  14150. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14151. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  14152. if m.sop_stage != nil {
  14153. return *m.sop_stage, true
  14154. }
  14155. return
  14156. }
  14157. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14158. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14159. // SopStageID instead. It exists only for internal usage by the builders.
  14160. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  14161. if id := m.sop_stage; id != nil {
  14162. ids = append(ids, *id)
  14163. }
  14164. return
  14165. }
  14166. // ResetSopStage resets all changes to the "sop_stage" edge.
  14167. func (m *SopNodeMutation) ResetSopStage() {
  14168. m.sop_stage = nil
  14169. m.clearedsop_stage = false
  14170. }
  14171. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  14172. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  14173. if m.node_messages == nil {
  14174. m.node_messages = make(map[uint64]struct{})
  14175. }
  14176. for i := range ids {
  14177. m.node_messages[ids[i]] = struct{}{}
  14178. }
  14179. }
  14180. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  14181. func (m *SopNodeMutation) ClearNodeMessages() {
  14182. m.clearednode_messages = true
  14183. }
  14184. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  14185. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  14186. return m.clearednode_messages
  14187. }
  14188. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  14189. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  14190. if m.removednode_messages == nil {
  14191. m.removednode_messages = make(map[uint64]struct{})
  14192. }
  14193. for i := range ids {
  14194. delete(m.node_messages, ids[i])
  14195. m.removednode_messages[ids[i]] = struct{}{}
  14196. }
  14197. }
  14198. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  14199. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  14200. for id := range m.removednode_messages {
  14201. ids = append(ids, id)
  14202. }
  14203. return
  14204. }
  14205. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  14206. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  14207. for id := range m.node_messages {
  14208. ids = append(ids, id)
  14209. }
  14210. return
  14211. }
  14212. // ResetNodeMessages resets all changes to the "node_messages" edge.
  14213. func (m *SopNodeMutation) ResetNodeMessages() {
  14214. m.node_messages = nil
  14215. m.clearednode_messages = false
  14216. m.removednode_messages = nil
  14217. }
  14218. // Where appends a list predicates to the SopNodeMutation builder.
  14219. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  14220. m.predicates = append(m.predicates, ps...)
  14221. }
  14222. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  14223. // users can use type-assertion to append predicates that do not depend on any generated package.
  14224. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  14225. p := make([]predicate.SopNode, len(ps))
  14226. for i := range ps {
  14227. p[i] = ps[i]
  14228. }
  14229. m.Where(p...)
  14230. }
  14231. // Op returns the operation name.
  14232. func (m *SopNodeMutation) Op() Op {
  14233. return m.op
  14234. }
  14235. // SetOp allows setting the mutation operation.
  14236. func (m *SopNodeMutation) SetOp(op Op) {
  14237. m.op = op
  14238. }
  14239. // Type returns the node type of this mutation (SopNode).
  14240. func (m *SopNodeMutation) Type() string {
  14241. return m.typ
  14242. }
  14243. // Fields returns all fields that were changed during this mutation. Note that in
  14244. // order to get all numeric fields that were incremented/decremented, call
  14245. // AddedFields().
  14246. func (m *SopNodeMutation) Fields() []string {
  14247. fields := make([]string, 0, 12)
  14248. if m.created_at != nil {
  14249. fields = append(fields, sopnode.FieldCreatedAt)
  14250. }
  14251. if m.updated_at != nil {
  14252. fields = append(fields, sopnode.FieldUpdatedAt)
  14253. }
  14254. if m.status != nil {
  14255. fields = append(fields, sopnode.FieldStatus)
  14256. }
  14257. if m.deleted_at != nil {
  14258. fields = append(fields, sopnode.FieldDeletedAt)
  14259. }
  14260. if m.sop_stage != nil {
  14261. fields = append(fields, sopnode.FieldStageID)
  14262. }
  14263. if m.parent_id != nil {
  14264. fields = append(fields, sopnode.FieldParentID)
  14265. }
  14266. if m.name != nil {
  14267. fields = append(fields, sopnode.FieldName)
  14268. }
  14269. if m.condition_type != nil {
  14270. fields = append(fields, sopnode.FieldConditionType)
  14271. }
  14272. if m.condition_list != nil {
  14273. fields = append(fields, sopnode.FieldConditionList)
  14274. }
  14275. if m.no_reply_condition != nil {
  14276. fields = append(fields, sopnode.FieldNoReplyCondition)
  14277. }
  14278. if m.action_message != nil {
  14279. fields = append(fields, sopnode.FieldActionMessage)
  14280. }
  14281. if m.action_label != nil {
  14282. fields = append(fields, sopnode.FieldActionLabel)
  14283. }
  14284. return fields
  14285. }
  14286. // Field returns the value of a field with the given name. The second boolean
  14287. // return value indicates that this field was not set, or was not defined in the
  14288. // schema.
  14289. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  14290. switch name {
  14291. case sopnode.FieldCreatedAt:
  14292. return m.CreatedAt()
  14293. case sopnode.FieldUpdatedAt:
  14294. return m.UpdatedAt()
  14295. case sopnode.FieldStatus:
  14296. return m.Status()
  14297. case sopnode.FieldDeletedAt:
  14298. return m.DeletedAt()
  14299. case sopnode.FieldStageID:
  14300. return m.StageID()
  14301. case sopnode.FieldParentID:
  14302. return m.ParentID()
  14303. case sopnode.FieldName:
  14304. return m.Name()
  14305. case sopnode.FieldConditionType:
  14306. return m.ConditionType()
  14307. case sopnode.FieldConditionList:
  14308. return m.ConditionList()
  14309. case sopnode.FieldNoReplyCondition:
  14310. return m.NoReplyCondition()
  14311. case sopnode.FieldActionMessage:
  14312. return m.ActionMessage()
  14313. case sopnode.FieldActionLabel:
  14314. return m.ActionLabel()
  14315. }
  14316. return nil, false
  14317. }
  14318. // OldField returns the old value of the field from the database. An error is
  14319. // returned if the mutation operation is not UpdateOne, or the query to the
  14320. // database failed.
  14321. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14322. switch name {
  14323. case sopnode.FieldCreatedAt:
  14324. return m.OldCreatedAt(ctx)
  14325. case sopnode.FieldUpdatedAt:
  14326. return m.OldUpdatedAt(ctx)
  14327. case sopnode.FieldStatus:
  14328. return m.OldStatus(ctx)
  14329. case sopnode.FieldDeletedAt:
  14330. return m.OldDeletedAt(ctx)
  14331. case sopnode.FieldStageID:
  14332. return m.OldStageID(ctx)
  14333. case sopnode.FieldParentID:
  14334. return m.OldParentID(ctx)
  14335. case sopnode.FieldName:
  14336. return m.OldName(ctx)
  14337. case sopnode.FieldConditionType:
  14338. return m.OldConditionType(ctx)
  14339. case sopnode.FieldConditionList:
  14340. return m.OldConditionList(ctx)
  14341. case sopnode.FieldNoReplyCondition:
  14342. return m.OldNoReplyCondition(ctx)
  14343. case sopnode.FieldActionMessage:
  14344. return m.OldActionMessage(ctx)
  14345. case sopnode.FieldActionLabel:
  14346. return m.OldActionLabel(ctx)
  14347. }
  14348. return nil, fmt.Errorf("unknown SopNode field %s", name)
  14349. }
  14350. // SetField sets the value of a field with the given name. It returns an error if
  14351. // the field is not defined in the schema, or if the type mismatched the field
  14352. // type.
  14353. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  14354. switch name {
  14355. case sopnode.FieldCreatedAt:
  14356. v, ok := value.(time.Time)
  14357. if !ok {
  14358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14359. }
  14360. m.SetCreatedAt(v)
  14361. return nil
  14362. case sopnode.FieldUpdatedAt:
  14363. v, ok := value.(time.Time)
  14364. if !ok {
  14365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14366. }
  14367. m.SetUpdatedAt(v)
  14368. return nil
  14369. case sopnode.FieldStatus:
  14370. v, ok := value.(uint8)
  14371. if !ok {
  14372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14373. }
  14374. m.SetStatus(v)
  14375. return nil
  14376. case sopnode.FieldDeletedAt:
  14377. v, ok := value.(time.Time)
  14378. if !ok {
  14379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14380. }
  14381. m.SetDeletedAt(v)
  14382. return nil
  14383. case sopnode.FieldStageID:
  14384. v, ok := value.(uint64)
  14385. if !ok {
  14386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14387. }
  14388. m.SetStageID(v)
  14389. return nil
  14390. case sopnode.FieldParentID:
  14391. v, ok := value.(uint64)
  14392. if !ok {
  14393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14394. }
  14395. m.SetParentID(v)
  14396. return nil
  14397. case sopnode.FieldName:
  14398. v, ok := value.(string)
  14399. if !ok {
  14400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14401. }
  14402. m.SetName(v)
  14403. return nil
  14404. case sopnode.FieldConditionType:
  14405. v, ok := value.(int)
  14406. if !ok {
  14407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14408. }
  14409. m.SetConditionType(v)
  14410. return nil
  14411. case sopnode.FieldConditionList:
  14412. v, ok := value.([]string)
  14413. if !ok {
  14414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14415. }
  14416. m.SetConditionList(v)
  14417. return nil
  14418. case sopnode.FieldNoReplyCondition:
  14419. v, ok := value.(uint64)
  14420. if !ok {
  14421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14422. }
  14423. m.SetNoReplyCondition(v)
  14424. return nil
  14425. case sopnode.FieldActionMessage:
  14426. v, ok := value.([]custom_types.Action)
  14427. if !ok {
  14428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14429. }
  14430. m.SetActionMessage(v)
  14431. return nil
  14432. case sopnode.FieldActionLabel:
  14433. v, ok := value.([]uint64)
  14434. if !ok {
  14435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14436. }
  14437. m.SetActionLabel(v)
  14438. return nil
  14439. }
  14440. return fmt.Errorf("unknown SopNode field %s", name)
  14441. }
  14442. // AddedFields returns all numeric fields that were incremented/decremented during
  14443. // this mutation.
  14444. func (m *SopNodeMutation) AddedFields() []string {
  14445. var fields []string
  14446. if m.addstatus != nil {
  14447. fields = append(fields, sopnode.FieldStatus)
  14448. }
  14449. if m.addparent_id != nil {
  14450. fields = append(fields, sopnode.FieldParentID)
  14451. }
  14452. if m.addcondition_type != nil {
  14453. fields = append(fields, sopnode.FieldConditionType)
  14454. }
  14455. if m.addno_reply_condition != nil {
  14456. fields = append(fields, sopnode.FieldNoReplyCondition)
  14457. }
  14458. return fields
  14459. }
  14460. // AddedField returns the numeric value that was incremented/decremented on a field
  14461. // with the given name. The second boolean return value indicates that this field
  14462. // was not set, or was not defined in the schema.
  14463. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  14464. switch name {
  14465. case sopnode.FieldStatus:
  14466. return m.AddedStatus()
  14467. case sopnode.FieldParentID:
  14468. return m.AddedParentID()
  14469. case sopnode.FieldConditionType:
  14470. return m.AddedConditionType()
  14471. case sopnode.FieldNoReplyCondition:
  14472. return m.AddedNoReplyCondition()
  14473. }
  14474. return nil, false
  14475. }
  14476. // AddField adds the value to the field with the given name. It returns an error if
  14477. // the field is not defined in the schema, or if the type mismatched the field
  14478. // type.
  14479. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  14480. switch name {
  14481. case sopnode.FieldStatus:
  14482. v, ok := value.(int8)
  14483. if !ok {
  14484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14485. }
  14486. m.AddStatus(v)
  14487. return nil
  14488. case sopnode.FieldParentID:
  14489. v, ok := value.(int64)
  14490. if !ok {
  14491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14492. }
  14493. m.AddParentID(v)
  14494. return nil
  14495. case sopnode.FieldConditionType:
  14496. v, ok := value.(int)
  14497. if !ok {
  14498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14499. }
  14500. m.AddConditionType(v)
  14501. return nil
  14502. case sopnode.FieldNoReplyCondition:
  14503. v, ok := value.(int64)
  14504. if !ok {
  14505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14506. }
  14507. m.AddNoReplyCondition(v)
  14508. return nil
  14509. }
  14510. return fmt.Errorf("unknown SopNode numeric field %s", name)
  14511. }
  14512. // ClearedFields returns all nullable fields that were cleared during this
  14513. // mutation.
  14514. func (m *SopNodeMutation) ClearedFields() []string {
  14515. var fields []string
  14516. if m.FieldCleared(sopnode.FieldStatus) {
  14517. fields = append(fields, sopnode.FieldStatus)
  14518. }
  14519. if m.FieldCleared(sopnode.FieldDeletedAt) {
  14520. fields = append(fields, sopnode.FieldDeletedAt)
  14521. }
  14522. if m.FieldCleared(sopnode.FieldConditionList) {
  14523. fields = append(fields, sopnode.FieldConditionList)
  14524. }
  14525. if m.FieldCleared(sopnode.FieldActionMessage) {
  14526. fields = append(fields, sopnode.FieldActionMessage)
  14527. }
  14528. if m.FieldCleared(sopnode.FieldActionLabel) {
  14529. fields = append(fields, sopnode.FieldActionLabel)
  14530. }
  14531. return fields
  14532. }
  14533. // FieldCleared returns a boolean indicating if a field with the given name was
  14534. // cleared in this mutation.
  14535. func (m *SopNodeMutation) FieldCleared(name string) bool {
  14536. _, ok := m.clearedFields[name]
  14537. return ok
  14538. }
  14539. // ClearField clears the value of the field with the given name. It returns an
  14540. // error if the field is not defined in the schema.
  14541. func (m *SopNodeMutation) ClearField(name string) error {
  14542. switch name {
  14543. case sopnode.FieldStatus:
  14544. m.ClearStatus()
  14545. return nil
  14546. case sopnode.FieldDeletedAt:
  14547. m.ClearDeletedAt()
  14548. return nil
  14549. case sopnode.FieldConditionList:
  14550. m.ClearConditionList()
  14551. return nil
  14552. case sopnode.FieldActionMessage:
  14553. m.ClearActionMessage()
  14554. return nil
  14555. case sopnode.FieldActionLabel:
  14556. m.ClearActionLabel()
  14557. return nil
  14558. }
  14559. return fmt.Errorf("unknown SopNode nullable field %s", name)
  14560. }
  14561. // ResetField resets all changes in the mutation for the field with the given name.
  14562. // It returns an error if the field is not defined in the schema.
  14563. func (m *SopNodeMutation) ResetField(name string) error {
  14564. switch name {
  14565. case sopnode.FieldCreatedAt:
  14566. m.ResetCreatedAt()
  14567. return nil
  14568. case sopnode.FieldUpdatedAt:
  14569. m.ResetUpdatedAt()
  14570. return nil
  14571. case sopnode.FieldStatus:
  14572. m.ResetStatus()
  14573. return nil
  14574. case sopnode.FieldDeletedAt:
  14575. m.ResetDeletedAt()
  14576. return nil
  14577. case sopnode.FieldStageID:
  14578. m.ResetStageID()
  14579. return nil
  14580. case sopnode.FieldParentID:
  14581. m.ResetParentID()
  14582. return nil
  14583. case sopnode.FieldName:
  14584. m.ResetName()
  14585. return nil
  14586. case sopnode.FieldConditionType:
  14587. m.ResetConditionType()
  14588. return nil
  14589. case sopnode.FieldConditionList:
  14590. m.ResetConditionList()
  14591. return nil
  14592. case sopnode.FieldNoReplyCondition:
  14593. m.ResetNoReplyCondition()
  14594. return nil
  14595. case sopnode.FieldActionMessage:
  14596. m.ResetActionMessage()
  14597. return nil
  14598. case sopnode.FieldActionLabel:
  14599. m.ResetActionLabel()
  14600. return nil
  14601. }
  14602. return fmt.Errorf("unknown SopNode field %s", name)
  14603. }
  14604. // AddedEdges returns all edge names that were set/added in this mutation.
  14605. func (m *SopNodeMutation) AddedEdges() []string {
  14606. edges := make([]string, 0, 2)
  14607. if m.sop_stage != nil {
  14608. edges = append(edges, sopnode.EdgeSopStage)
  14609. }
  14610. if m.node_messages != nil {
  14611. edges = append(edges, sopnode.EdgeNodeMessages)
  14612. }
  14613. return edges
  14614. }
  14615. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14616. // name in this mutation.
  14617. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  14618. switch name {
  14619. case sopnode.EdgeSopStage:
  14620. if id := m.sop_stage; id != nil {
  14621. return []ent.Value{*id}
  14622. }
  14623. case sopnode.EdgeNodeMessages:
  14624. ids := make([]ent.Value, 0, len(m.node_messages))
  14625. for id := range m.node_messages {
  14626. ids = append(ids, id)
  14627. }
  14628. return ids
  14629. }
  14630. return nil
  14631. }
  14632. // RemovedEdges returns all edge names that were removed in this mutation.
  14633. func (m *SopNodeMutation) RemovedEdges() []string {
  14634. edges := make([]string, 0, 2)
  14635. if m.removednode_messages != nil {
  14636. edges = append(edges, sopnode.EdgeNodeMessages)
  14637. }
  14638. return edges
  14639. }
  14640. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14641. // the given name in this mutation.
  14642. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  14643. switch name {
  14644. case sopnode.EdgeNodeMessages:
  14645. ids := make([]ent.Value, 0, len(m.removednode_messages))
  14646. for id := range m.removednode_messages {
  14647. ids = append(ids, id)
  14648. }
  14649. return ids
  14650. }
  14651. return nil
  14652. }
  14653. // ClearedEdges returns all edge names that were cleared in this mutation.
  14654. func (m *SopNodeMutation) ClearedEdges() []string {
  14655. edges := make([]string, 0, 2)
  14656. if m.clearedsop_stage {
  14657. edges = append(edges, sopnode.EdgeSopStage)
  14658. }
  14659. if m.clearednode_messages {
  14660. edges = append(edges, sopnode.EdgeNodeMessages)
  14661. }
  14662. return edges
  14663. }
  14664. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14665. // was cleared in this mutation.
  14666. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  14667. switch name {
  14668. case sopnode.EdgeSopStage:
  14669. return m.clearedsop_stage
  14670. case sopnode.EdgeNodeMessages:
  14671. return m.clearednode_messages
  14672. }
  14673. return false
  14674. }
  14675. // ClearEdge clears the value of the edge with the given name. It returns an error
  14676. // if that edge is not defined in the schema.
  14677. func (m *SopNodeMutation) ClearEdge(name string) error {
  14678. switch name {
  14679. case sopnode.EdgeSopStage:
  14680. m.ClearSopStage()
  14681. return nil
  14682. }
  14683. return fmt.Errorf("unknown SopNode unique edge %s", name)
  14684. }
  14685. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14686. // It returns an error if the edge is not defined in the schema.
  14687. func (m *SopNodeMutation) ResetEdge(name string) error {
  14688. switch name {
  14689. case sopnode.EdgeSopStage:
  14690. m.ResetSopStage()
  14691. return nil
  14692. case sopnode.EdgeNodeMessages:
  14693. m.ResetNodeMessages()
  14694. return nil
  14695. }
  14696. return fmt.Errorf("unknown SopNode edge %s", name)
  14697. }
  14698. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  14699. type SopStageMutation struct {
  14700. config
  14701. op Op
  14702. typ string
  14703. id *uint64
  14704. created_at *time.Time
  14705. updated_at *time.Time
  14706. status *uint8
  14707. addstatus *int8
  14708. deleted_at *time.Time
  14709. name *string
  14710. condition_type *int
  14711. addcondition_type *int
  14712. condition_operator *int
  14713. addcondition_operator *int
  14714. condition_list *[]custom_types.Condition
  14715. appendcondition_list []custom_types.Condition
  14716. action_message *[]custom_types.Action
  14717. appendaction_message []custom_types.Action
  14718. action_label *[]uint64
  14719. appendaction_label []uint64
  14720. index_sort *int
  14721. addindex_sort *int
  14722. clearedFields map[string]struct{}
  14723. sop_task *uint64
  14724. clearedsop_task bool
  14725. stage_nodes map[uint64]struct{}
  14726. removedstage_nodes map[uint64]struct{}
  14727. clearedstage_nodes bool
  14728. stage_messages map[uint64]struct{}
  14729. removedstage_messages map[uint64]struct{}
  14730. clearedstage_messages bool
  14731. done bool
  14732. oldValue func(context.Context) (*SopStage, error)
  14733. predicates []predicate.SopStage
  14734. }
  14735. var _ ent.Mutation = (*SopStageMutation)(nil)
  14736. // sopstageOption allows management of the mutation configuration using functional options.
  14737. type sopstageOption func(*SopStageMutation)
  14738. // newSopStageMutation creates new mutation for the SopStage entity.
  14739. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  14740. m := &SopStageMutation{
  14741. config: c,
  14742. op: op,
  14743. typ: TypeSopStage,
  14744. clearedFields: make(map[string]struct{}),
  14745. }
  14746. for _, opt := range opts {
  14747. opt(m)
  14748. }
  14749. return m
  14750. }
  14751. // withSopStageID sets the ID field of the mutation.
  14752. func withSopStageID(id uint64) sopstageOption {
  14753. return func(m *SopStageMutation) {
  14754. var (
  14755. err error
  14756. once sync.Once
  14757. value *SopStage
  14758. )
  14759. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  14760. once.Do(func() {
  14761. if m.done {
  14762. err = errors.New("querying old values post mutation is not allowed")
  14763. } else {
  14764. value, err = m.Client().SopStage.Get(ctx, id)
  14765. }
  14766. })
  14767. return value, err
  14768. }
  14769. m.id = &id
  14770. }
  14771. }
  14772. // withSopStage sets the old SopStage of the mutation.
  14773. func withSopStage(node *SopStage) sopstageOption {
  14774. return func(m *SopStageMutation) {
  14775. m.oldValue = func(context.Context) (*SopStage, error) {
  14776. return node, nil
  14777. }
  14778. m.id = &node.ID
  14779. }
  14780. }
  14781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14782. // executed in a transaction (ent.Tx), a transactional client is returned.
  14783. func (m SopStageMutation) Client() *Client {
  14784. client := &Client{config: m.config}
  14785. client.init()
  14786. return client
  14787. }
  14788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14789. // it returns an error otherwise.
  14790. func (m SopStageMutation) Tx() (*Tx, error) {
  14791. if _, ok := m.driver.(*txDriver); !ok {
  14792. return nil, errors.New("ent: mutation is not running in a transaction")
  14793. }
  14794. tx := &Tx{config: m.config}
  14795. tx.init()
  14796. return tx, nil
  14797. }
  14798. // SetID sets the value of the id field. Note that this
  14799. // operation is only accepted on creation of SopStage entities.
  14800. func (m *SopStageMutation) SetID(id uint64) {
  14801. m.id = &id
  14802. }
  14803. // ID returns the ID value in the mutation. Note that the ID is only available
  14804. // if it was provided to the builder or after it was returned from the database.
  14805. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  14806. if m.id == nil {
  14807. return
  14808. }
  14809. return *m.id, true
  14810. }
  14811. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14812. // That means, if the mutation is applied within a transaction with an isolation level such
  14813. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14814. // or updated by the mutation.
  14815. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  14816. switch {
  14817. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14818. id, exists := m.ID()
  14819. if exists {
  14820. return []uint64{id}, nil
  14821. }
  14822. fallthrough
  14823. case m.op.Is(OpUpdate | OpDelete):
  14824. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  14825. default:
  14826. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14827. }
  14828. }
  14829. // SetCreatedAt sets the "created_at" field.
  14830. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  14831. m.created_at = &t
  14832. }
  14833. // CreatedAt returns the value of the "created_at" field in the mutation.
  14834. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  14835. v := m.created_at
  14836. if v == nil {
  14837. return
  14838. }
  14839. return *v, true
  14840. }
  14841. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  14842. // If the SopStage 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 *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14845. if !m.op.Is(OpUpdateOne) {
  14846. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14847. }
  14848. if m.id == nil || m.oldValue == nil {
  14849. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  14854. }
  14855. return oldValue.CreatedAt, nil
  14856. }
  14857. // ResetCreatedAt resets all changes to the "created_at" field.
  14858. func (m *SopStageMutation) ResetCreatedAt() {
  14859. m.created_at = nil
  14860. }
  14861. // SetUpdatedAt sets the "updated_at" field.
  14862. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  14863. m.updated_at = &t
  14864. }
  14865. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14866. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  14867. v := m.updated_at
  14868. if v == nil {
  14869. return
  14870. }
  14871. return *v, true
  14872. }
  14873. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  14874. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14876. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14877. if !m.op.Is(OpUpdateOne) {
  14878. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14879. }
  14880. if m.id == nil || m.oldValue == nil {
  14881. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14882. }
  14883. oldValue, err := m.oldValue(ctx)
  14884. if err != nil {
  14885. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14886. }
  14887. return oldValue.UpdatedAt, nil
  14888. }
  14889. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14890. func (m *SopStageMutation) ResetUpdatedAt() {
  14891. m.updated_at = nil
  14892. }
  14893. // SetStatus sets the "status" field.
  14894. func (m *SopStageMutation) SetStatus(u uint8) {
  14895. m.status = &u
  14896. m.addstatus = nil
  14897. }
  14898. // Status returns the value of the "status" field in the mutation.
  14899. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  14900. v := m.status
  14901. if v == nil {
  14902. return
  14903. }
  14904. return *v, true
  14905. }
  14906. // OldStatus returns the old "status" field's value of the SopStage entity.
  14907. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14909. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14910. if !m.op.Is(OpUpdateOne) {
  14911. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14912. }
  14913. if m.id == nil || m.oldValue == nil {
  14914. return v, errors.New("OldStatus requires an ID field in the mutation")
  14915. }
  14916. oldValue, err := m.oldValue(ctx)
  14917. if err != nil {
  14918. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14919. }
  14920. return oldValue.Status, nil
  14921. }
  14922. // AddStatus adds u to the "status" field.
  14923. func (m *SopStageMutation) AddStatus(u int8) {
  14924. if m.addstatus != nil {
  14925. *m.addstatus += u
  14926. } else {
  14927. m.addstatus = &u
  14928. }
  14929. }
  14930. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14931. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  14932. v := m.addstatus
  14933. if v == nil {
  14934. return
  14935. }
  14936. return *v, true
  14937. }
  14938. // ClearStatus clears the value of the "status" field.
  14939. func (m *SopStageMutation) ClearStatus() {
  14940. m.status = nil
  14941. m.addstatus = nil
  14942. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  14943. }
  14944. // StatusCleared returns if the "status" field was cleared in this mutation.
  14945. func (m *SopStageMutation) StatusCleared() bool {
  14946. _, ok := m.clearedFields[sopstage.FieldStatus]
  14947. return ok
  14948. }
  14949. // ResetStatus resets all changes to the "status" field.
  14950. func (m *SopStageMutation) ResetStatus() {
  14951. m.status = nil
  14952. m.addstatus = nil
  14953. delete(m.clearedFields, sopstage.FieldStatus)
  14954. }
  14955. // SetDeletedAt sets the "deleted_at" field.
  14956. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  14957. m.deleted_at = &t
  14958. }
  14959. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14960. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  14961. v := m.deleted_at
  14962. if v == nil {
  14963. return
  14964. }
  14965. return *v, true
  14966. }
  14967. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  14968. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  14969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14970. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14971. if !m.op.Is(OpUpdateOne) {
  14972. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14973. }
  14974. if m.id == nil || m.oldValue == nil {
  14975. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14976. }
  14977. oldValue, err := m.oldValue(ctx)
  14978. if err != nil {
  14979. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14980. }
  14981. return oldValue.DeletedAt, nil
  14982. }
  14983. // ClearDeletedAt clears the value of the "deleted_at" field.
  14984. func (m *SopStageMutation) ClearDeletedAt() {
  14985. m.deleted_at = nil
  14986. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  14987. }
  14988. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14989. func (m *SopStageMutation) DeletedAtCleared() bool {
  14990. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  14991. return ok
  14992. }
  14993. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14994. func (m *SopStageMutation) ResetDeletedAt() {
  14995. m.deleted_at = nil
  14996. delete(m.clearedFields, sopstage.FieldDeletedAt)
  14997. }
  14998. // SetTaskID sets the "task_id" field.
  14999. func (m *SopStageMutation) SetTaskID(u uint64) {
  15000. m.sop_task = &u
  15001. }
  15002. // TaskID returns the value of the "task_id" field in the mutation.
  15003. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  15004. v := m.sop_task
  15005. if v == nil {
  15006. return
  15007. }
  15008. return *v, true
  15009. }
  15010. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  15011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15013. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  15014. if !m.op.Is(OpUpdateOne) {
  15015. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  15016. }
  15017. if m.id == nil || m.oldValue == nil {
  15018. return v, errors.New("OldTaskID requires an ID field in the mutation")
  15019. }
  15020. oldValue, err := m.oldValue(ctx)
  15021. if err != nil {
  15022. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  15023. }
  15024. return oldValue.TaskID, nil
  15025. }
  15026. // ResetTaskID resets all changes to the "task_id" field.
  15027. func (m *SopStageMutation) ResetTaskID() {
  15028. m.sop_task = nil
  15029. }
  15030. // SetName sets the "name" field.
  15031. func (m *SopStageMutation) SetName(s string) {
  15032. m.name = &s
  15033. }
  15034. // Name returns the value of the "name" field in the mutation.
  15035. func (m *SopStageMutation) Name() (r string, exists bool) {
  15036. v := m.name
  15037. if v == nil {
  15038. return
  15039. }
  15040. return *v, true
  15041. }
  15042. // OldName returns the old "name" field's value of the SopStage entity.
  15043. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15045. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  15046. if !m.op.Is(OpUpdateOne) {
  15047. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15048. }
  15049. if m.id == nil || m.oldValue == nil {
  15050. return v, errors.New("OldName requires an ID field in the mutation")
  15051. }
  15052. oldValue, err := m.oldValue(ctx)
  15053. if err != nil {
  15054. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15055. }
  15056. return oldValue.Name, nil
  15057. }
  15058. // ResetName resets all changes to the "name" field.
  15059. func (m *SopStageMutation) ResetName() {
  15060. m.name = nil
  15061. }
  15062. // SetConditionType sets the "condition_type" field.
  15063. func (m *SopStageMutation) SetConditionType(i int) {
  15064. m.condition_type = &i
  15065. m.addcondition_type = nil
  15066. }
  15067. // ConditionType returns the value of the "condition_type" field in the mutation.
  15068. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  15069. v := m.condition_type
  15070. if v == nil {
  15071. return
  15072. }
  15073. return *v, true
  15074. }
  15075. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  15076. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15078. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  15079. if !m.op.Is(OpUpdateOne) {
  15080. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  15081. }
  15082. if m.id == nil || m.oldValue == nil {
  15083. return v, errors.New("OldConditionType requires an ID field in the mutation")
  15084. }
  15085. oldValue, err := m.oldValue(ctx)
  15086. if err != nil {
  15087. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  15088. }
  15089. return oldValue.ConditionType, nil
  15090. }
  15091. // AddConditionType adds i to the "condition_type" field.
  15092. func (m *SopStageMutation) AddConditionType(i int) {
  15093. if m.addcondition_type != nil {
  15094. *m.addcondition_type += i
  15095. } else {
  15096. m.addcondition_type = &i
  15097. }
  15098. }
  15099. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  15100. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  15101. v := m.addcondition_type
  15102. if v == nil {
  15103. return
  15104. }
  15105. return *v, true
  15106. }
  15107. // ResetConditionType resets all changes to the "condition_type" field.
  15108. func (m *SopStageMutation) ResetConditionType() {
  15109. m.condition_type = nil
  15110. m.addcondition_type = nil
  15111. }
  15112. // SetConditionOperator sets the "condition_operator" field.
  15113. func (m *SopStageMutation) SetConditionOperator(i int) {
  15114. m.condition_operator = &i
  15115. m.addcondition_operator = nil
  15116. }
  15117. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  15118. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  15119. v := m.condition_operator
  15120. if v == nil {
  15121. return
  15122. }
  15123. return *v, true
  15124. }
  15125. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  15126. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15128. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  15129. if !m.op.Is(OpUpdateOne) {
  15130. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  15131. }
  15132. if m.id == nil || m.oldValue == nil {
  15133. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  15134. }
  15135. oldValue, err := m.oldValue(ctx)
  15136. if err != nil {
  15137. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  15138. }
  15139. return oldValue.ConditionOperator, nil
  15140. }
  15141. // AddConditionOperator adds i to the "condition_operator" field.
  15142. func (m *SopStageMutation) AddConditionOperator(i int) {
  15143. if m.addcondition_operator != nil {
  15144. *m.addcondition_operator += i
  15145. } else {
  15146. m.addcondition_operator = &i
  15147. }
  15148. }
  15149. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  15150. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  15151. v := m.addcondition_operator
  15152. if v == nil {
  15153. return
  15154. }
  15155. return *v, true
  15156. }
  15157. // ResetConditionOperator resets all changes to the "condition_operator" field.
  15158. func (m *SopStageMutation) ResetConditionOperator() {
  15159. m.condition_operator = nil
  15160. m.addcondition_operator = nil
  15161. }
  15162. // SetConditionList sets the "condition_list" field.
  15163. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  15164. m.condition_list = &ct
  15165. m.appendcondition_list = nil
  15166. }
  15167. // ConditionList returns the value of the "condition_list" field in the mutation.
  15168. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  15169. v := m.condition_list
  15170. if v == nil {
  15171. return
  15172. }
  15173. return *v, true
  15174. }
  15175. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  15176. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15178. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  15179. if !m.op.Is(OpUpdateOne) {
  15180. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  15181. }
  15182. if m.id == nil || m.oldValue == nil {
  15183. return v, errors.New("OldConditionList requires an ID field in the mutation")
  15184. }
  15185. oldValue, err := m.oldValue(ctx)
  15186. if err != nil {
  15187. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  15188. }
  15189. return oldValue.ConditionList, nil
  15190. }
  15191. // AppendConditionList adds ct to the "condition_list" field.
  15192. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  15193. m.appendcondition_list = append(m.appendcondition_list, ct...)
  15194. }
  15195. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  15196. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  15197. if len(m.appendcondition_list) == 0 {
  15198. return nil, false
  15199. }
  15200. return m.appendcondition_list, true
  15201. }
  15202. // ResetConditionList resets all changes to the "condition_list" field.
  15203. func (m *SopStageMutation) ResetConditionList() {
  15204. m.condition_list = nil
  15205. m.appendcondition_list = nil
  15206. }
  15207. // SetActionMessage sets the "action_message" field.
  15208. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  15209. m.action_message = &ct
  15210. m.appendaction_message = nil
  15211. }
  15212. // ActionMessage returns the value of the "action_message" field in the mutation.
  15213. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  15214. v := m.action_message
  15215. if v == nil {
  15216. return
  15217. }
  15218. return *v, true
  15219. }
  15220. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  15221. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15223. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  15224. if !m.op.Is(OpUpdateOne) {
  15225. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  15226. }
  15227. if m.id == nil || m.oldValue == nil {
  15228. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  15229. }
  15230. oldValue, err := m.oldValue(ctx)
  15231. if err != nil {
  15232. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  15233. }
  15234. return oldValue.ActionMessage, nil
  15235. }
  15236. // AppendActionMessage adds ct to the "action_message" field.
  15237. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  15238. m.appendaction_message = append(m.appendaction_message, ct...)
  15239. }
  15240. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  15241. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  15242. if len(m.appendaction_message) == 0 {
  15243. return nil, false
  15244. }
  15245. return m.appendaction_message, true
  15246. }
  15247. // ClearActionMessage clears the value of the "action_message" field.
  15248. func (m *SopStageMutation) ClearActionMessage() {
  15249. m.action_message = nil
  15250. m.appendaction_message = nil
  15251. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  15252. }
  15253. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  15254. func (m *SopStageMutation) ActionMessageCleared() bool {
  15255. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  15256. return ok
  15257. }
  15258. // ResetActionMessage resets all changes to the "action_message" field.
  15259. func (m *SopStageMutation) ResetActionMessage() {
  15260. m.action_message = nil
  15261. m.appendaction_message = nil
  15262. delete(m.clearedFields, sopstage.FieldActionMessage)
  15263. }
  15264. // SetActionLabel sets the "action_label" field.
  15265. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  15266. m.action_label = &u
  15267. m.appendaction_label = nil
  15268. }
  15269. // ActionLabel returns the value of the "action_label" field in the mutation.
  15270. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  15271. v := m.action_label
  15272. if v == nil {
  15273. return
  15274. }
  15275. return *v, true
  15276. }
  15277. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  15278. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15280. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  15281. if !m.op.Is(OpUpdateOne) {
  15282. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  15283. }
  15284. if m.id == nil || m.oldValue == nil {
  15285. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  15286. }
  15287. oldValue, err := m.oldValue(ctx)
  15288. if err != nil {
  15289. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  15290. }
  15291. return oldValue.ActionLabel, nil
  15292. }
  15293. // AppendActionLabel adds u to the "action_label" field.
  15294. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  15295. m.appendaction_label = append(m.appendaction_label, u...)
  15296. }
  15297. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  15298. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  15299. if len(m.appendaction_label) == 0 {
  15300. return nil, false
  15301. }
  15302. return m.appendaction_label, true
  15303. }
  15304. // ClearActionLabel clears the value of the "action_label" field.
  15305. func (m *SopStageMutation) ClearActionLabel() {
  15306. m.action_label = nil
  15307. m.appendaction_label = nil
  15308. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  15309. }
  15310. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  15311. func (m *SopStageMutation) ActionLabelCleared() bool {
  15312. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  15313. return ok
  15314. }
  15315. // ResetActionLabel resets all changes to the "action_label" field.
  15316. func (m *SopStageMutation) ResetActionLabel() {
  15317. m.action_label = nil
  15318. m.appendaction_label = nil
  15319. delete(m.clearedFields, sopstage.FieldActionLabel)
  15320. }
  15321. // SetIndexSort sets the "index_sort" field.
  15322. func (m *SopStageMutation) SetIndexSort(i int) {
  15323. m.index_sort = &i
  15324. m.addindex_sort = nil
  15325. }
  15326. // IndexSort returns the value of the "index_sort" field in the mutation.
  15327. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  15328. v := m.index_sort
  15329. if v == nil {
  15330. return
  15331. }
  15332. return *v, true
  15333. }
  15334. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  15335. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  15336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15337. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  15338. if !m.op.Is(OpUpdateOne) {
  15339. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  15340. }
  15341. if m.id == nil || m.oldValue == nil {
  15342. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  15343. }
  15344. oldValue, err := m.oldValue(ctx)
  15345. if err != nil {
  15346. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  15347. }
  15348. return oldValue.IndexSort, nil
  15349. }
  15350. // AddIndexSort adds i to the "index_sort" field.
  15351. func (m *SopStageMutation) AddIndexSort(i int) {
  15352. if m.addindex_sort != nil {
  15353. *m.addindex_sort += i
  15354. } else {
  15355. m.addindex_sort = &i
  15356. }
  15357. }
  15358. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  15359. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  15360. v := m.addindex_sort
  15361. if v == nil {
  15362. return
  15363. }
  15364. return *v, true
  15365. }
  15366. // ClearIndexSort clears the value of the "index_sort" field.
  15367. func (m *SopStageMutation) ClearIndexSort() {
  15368. m.index_sort = nil
  15369. m.addindex_sort = nil
  15370. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  15371. }
  15372. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  15373. func (m *SopStageMutation) IndexSortCleared() bool {
  15374. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  15375. return ok
  15376. }
  15377. // ResetIndexSort resets all changes to the "index_sort" field.
  15378. func (m *SopStageMutation) ResetIndexSort() {
  15379. m.index_sort = nil
  15380. m.addindex_sort = nil
  15381. delete(m.clearedFields, sopstage.FieldIndexSort)
  15382. }
  15383. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  15384. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  15385. m.sop_task = &id
  15386. }
  15387. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  15388. func (m *SopStageMutation) ClearSopTask() {
  15389. m.clearedsop_task = true
  15390. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  15391. }
  15392. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  15393. func (m *SopStageMutation) SopTaskCleared() bool {
  15394. return m.clearedsop_task
  15395. }
  15396. // SopTaskID returns the "sop_task" edge ID in the mutation.
  15397. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  15398. if m.sop_task != nil {
  15399. return *m.sop_task, true
  15400. }
  15401. return
  15402. }
  15403. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  15404. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15405. // SopTaskID instead. It exists only for internal usage by the builders.
  15406. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  15407. if id := m.sop_task; id != nil {
  15408. ids = append(ids, *id)
  15409. }
  15410. return
  15411. }
  15412. // ResetSopTask resets all changes to the "sop_task" edge.
  15413. func (m *SopStageMutation) ResetSopTask() {
  15414. m.sop_task = nil
  15415. m.clearedsop_task = false
  15416. }
  15417. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  15418. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  15419. if m.stage_nodes == nil {
  15420. m.stage_nodes = make(map[uint64]struct{})
  15421. }
  15422. for i := range ids {
  15423. m.stage_nodes[ids[i]] = struct{}{}
  15424. }
  15425. }
  15426. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  15427. func (m *SopStageMutation) ClearStageNodes() {
  15428. m.clearedstage_nodes = true
  15429. }
  15430. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  15431. func (m *SopStageMutation) StageNodesCleared() bool {
  15432. return m.clearedstage_nodes
  15433. }
  15434. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  15435. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  15436. if m.removedstage_nodes == nil {
  15437. m.removedstage_nodes = make(map[uint64]struct{})
  15438. }
  15439. for i := range ids {
  15440. delete(m.stage_nodes, ids[i])
  15441. m.removedstage_nodes[ids[i]] = struct{}{}
  15442. }
  15443. }
  15444. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  15445. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  15446. for id := range m.removedstage_nodes {
  15447. ids = append(ids, id)
  15448. }
  15449. return
  15450. }
  15451. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  15452. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  15453. for id := range m.stage_nodes {
  15454. ids = append(ids, id)
  15455. }
  15456. return
  15457. }
  15458. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  15459. func (m *SopStageMutation) ResetStageNodes() {
  15460. m.stage_nodes = nil
  15461. m.clearedstage_nodes = false
  15462. m.removedstage_nodes = nil
  15463. }
  15464. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  15465. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  15466. if m.stage_messages == nil {
  15467. m.stage_messages = make(map[uint64]struct{})
  15468. }
  15469. for i := range ids {
  15470. m.stage_messages[ids[i]] = struct{}{}
  15471. }
  15472. }
  15473. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  15474. func (m *SopStageMutation) ClearStageMessages() {
  15475. m.clearedstage_messages = true
  15476. }
  15477. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  15478. func (m *SopStageMutation) StageMessagesCleared() bool {
  15479. return m.clearedstage_messages
  15480. }
  15481. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  15482. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  15483. if m.removedstage_messages == nil {
  15484. m.removedstage_messages = make(map[uint64]struct{})
  15485. }
  15486. for i := range ids {
  15487. delete(m.stage_messages, ids[i])
  15488. m.removedstage_messages[ids[i]] = struct{}{}
  15489. }
  15490. }
  15491. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  15492. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  15493. for id := range m.removedstage_messages {
  15494. ids = append(ids, id)
  15495. }
  15496. return
  15497. }
  15498. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  15499. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  15500. for id := range m.stage_messages {
  15501. ids = append(ids, id)
  15502. }
  15503. return
  15504. }
  15505. // ResetStageMessages resets all changes to the "stage_messages" edge.
  15506. func (m *SopStageMutation) ResetStageMessages() {
  15507. m.stage_messages = nil
  15508. m.clearedstage_messages = false
  15509. m.removedstage_messages = nil
  15510. }
  15511. // Where appends a list predicates to the SopStageMutation builder.
  15512. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  15513. m.predicates = append(m.predicates, ps...)
  15514. }
  15515. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  15516. // users can use type-assertion to append predicates that do not depend on any generated package.
  15517. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  15518. p := make([]predicate.SopStage, len(ps))
  15519. for i := range ps {
  15520. p[i] = ps[i]
  15521. }
  15522. m.Where(p...)
  15523. }
  15524. // Op returns the operation name.
  15525. func (m *SopStageMutation) Op() Op {
  15526. return m.op
  15527. }
  15528. // SetOp allows setting the mutation operation.
  15529. func (m *SopStageMutation) SetOp(op Op) {
  15530. m.op = op
  15531. }
  15532. // Type returns the node type of this mutation (SopStage).
  15533. func (m *SopStageMutation) Type() string {
  15534. return m.typ
  15535. }
  15536. // Fields returns all fields that were changed during this mutation. Note that in
  15537. // order to get all numeric fields that were incremented/decremented, call
  15538. // AddedFields().
  15539. func (m *SopStageMutation) Fields() []string {
  15540. fields := make([]string, 0, 12)
  15541. if m.created_at != nil {
  15542. fields = append(fields, sopstage.FieldCreatedAt)
  15543. }
  15544. if m.updated_at != nil {
  15545. fields = append(fields, sopstage.FieldUpdatedAt)
  15546. }
  15547. if m.status != nil {
  15548. fields = append(fields, sopstage.FieldStatus)
  15549. }
  15550. if m.deleted_at != nil {
  15551. fields = append(fields, sopstage.FieldDeletedAt)
  15552. }
  15553. if m.sop_task != nil {
  15554. fields = append(fields, sopstage.FieldTaskID)
  15555. }
  15556. if m.name != nil {
  15557. fields = append(fields, sopstage.FieldName)
  15558. }
  15559. if m.condition_type != nil {
  15560. fields = append(fields, sopstage.FieldConditionType)
  15561. }
  15562. if m.condition_operator != nil {
  15563. fields = append(fields, sopstage.FieldConditionOperator)
  15564. }
  15565. if m.condition_list != nil {
  15566. fields = append(fields, sopstage.FieldConditionList)
  15567. }
  15568. if m.action_message != nil {
  15569. fields = append(fields, sopstage.FieldActionMessage)
  15570. }
  15571. if m.action_label != nil {
  15572. fields = append(fields, sopstage.FieldActionLabel)
  15573. }
  15574. if m.index_sort != nil {
  15575. fields = append(fields, sopstage.FieldIndexSort)
  15576. }
  15577. return fields
  15578. }
  15579. // Field returns the value of a field with the given name. The second boolean
  15580. // return value indicates that this field was not set, or was not defined in the
  15581. // schema.
  15582. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  15583. switch name {
  15584. case sopstage.FieldCreatedAt:
  15585. return m.CreatedAt()
  15586. case sopstage.FieldUpdatedAt:
  15587. return m.UpdatedAt()
  15588. case sopstage.FieldStatus:
  15589. return m.Status()
  15590. case sopstage.FieldDeletedAt:
  15591. return m.DeletedAt()
  15592. case sopstage.FieldTaskID:
  15593. return m.TaskID()
  15594. case sopstage.FieldName:
  15595. return m.Name()
  15596. case sopstage.FieldConditionType:
  15597. return m.ConditionType()
  15598. case sopstage.FieldConditionOperator:
  15599. return m.ConditionOperator()
  15600. case sopstage.FieldConditionList:
  15601. return m.ConditionList()
  15602. case sopstage.FieldActionMessage:
  15603. return m.ActionMessage()
  15604. case sopstage.FieldActionLabel:
  15605. return m.ActionLabel()
  15606. case sopstage.FieldIndexSort:
  15607. return m.IndexSort()
  15608. }
  15609. return nil, false
  15610. }
  15611. // OldField returns the old value of the field from the database. An error is
  15612. // returned if the mutation operation is not UpdateOne, or the query to the
  15613. // database failed.
  15614. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15615. switch name {
  15616. case sopstage.FieldCreatedAt:
  15617. return m.OldCreatedAt(ctx)
  15618. case sopstage.FieldUpdatedAt:
  15619. return m.OldUpdatedAt(ctx)
  15620. case sopstage.FieldStatus:
  15621. return m.OldStatus(ctx)
  15622. case sopstage.FieldDeletedAt:
  15623. return m.OldDeletedAt(ctx)
  15624. case sopstage.FieldTaskID:
  15625. return m.OldTaskID(ctx)
  15626. case sopstage.FieldName:
  15627. return m.OldName(ctx)
  15628. case sopstage.FieldConditionType:
  15629. return m.OldConditionType(ctx)
  15630. case sopstage.FieldConditionOperator:
  15631. return m.OldConditionOperator(ctx)
  15632. case sopstage.FieldConditionList:
  15633. return m.OldConditionList(ctx)
  15634. case sopstage.FieldActionMessage:
  15635. return m.OldActionMessage(ctx)
  15636. case sopstage.FieldActionLabel:
  15637. return m.OldActionLabel(ctx)
  15638. case sopstage.FieldIndexSort:
  15639. return m.OldIndexSort(ctx)
  15640. }
  15641. return nil, fmt.Errorf("unknown SopStage field %s", name)
  15642. }
  15643. // SetField sets the value of a field with the given name. It returns an error if
  15644. // the field is not defined in the schema, or if the type mismatched the field
  15645. // type.
  15646. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  15647. switch name {
  15648. case sopstage.FieldCreatedAt:
  15649. v, ok := value.(time.Time)
  15650. if !ok {
  15651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15652. }
  15653. m.SetCreatedAt(v)
  15654. return nil
  15655. case sopstage.FieldUpdatedAt:
  15656. v, ok := value.(time.Time)
  15657. if !ok {
  15658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15659. }
  15660. m.SetUpdatedAt(v)
  15661. return nil
  15662. case sopstage.FieldStatus:
  15663. v, ok := value.(uint8)
  15664. if !ok {
  15665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15666. }
  15667. m.SetStatus(v)
  15668. return nil
  15669. case sopstage.FieldDeletedAt:
  15670. v, ok := value.(time.Time)
  15671. if !ok {
  15672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15673. }
  15674. m.SetDeletedAt(v)
  15675. return nil
  15676. case sopstage.FieldTaskID:
  15677. v, ok := value.(uint64)
  15678. if !ok {
  15679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15680. }
  15681. m.SetTaskID(v)
  15682. return nil
  15683. case sopstage.FieldName:
  15684. v, ok := value.(string)
  15685. if !ok {
  15686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15687. }
  15688. m.SetName(v)
  15689. return nil
  15690. case sopstage.FieldConditionType:
  15691. v, ok := value.(int)
  15692. if !ok {
  15693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15694. }
  15695. m.SetConditionType(v)
  15696. return nil
  15697. case sopstage.FieldConditionOperator:
  15698. v, ok := value.(int)
  15699. if !ok {
  15700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15701. }
  15702. m.SetConditionOperator(v)
  15703. return nil
  15704. case sopstage.FieldConditionList:
  15705. v, ok := value.([]custom_types.Condition)
  15706. if !ok {
  15707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15708. }
  15709. m.SetConditionList(v)
  15710. return nil
  15711. case sopstage.FieldActionMessage:
  15712. v, ok := value.([]custom_types.Action)
  15713. if !ok {
  15714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15715. }
  15716. m.SetActionMessage(v)
  15717. return nil
  15718. case sopstage.FieldActionLabel:
  15719. v, ok := value.([]uint64)
  15720. if !ok {
  15721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15722. }
  15723. m.SetActionLabel(v)
  15724. return nil
  15725. case sopstage.FieldIndexSort:
  15726. v, ok := value.(int)
  15727. if !ok {
  15728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15729. }
  15730. m.SetIndexSort(v)
  15731. return nil
  15732. }
  15733. return fmt.Errorf("unknown SopStage field %s", name)
  15734. }
  15735. // AddedFields returns all numeric fields that were incremented/decremented during
  15736. // this mutation.
  15737. func (m *SopStageMutation) AddedFields() []string {
  15738. var fields []string
  15739. if m.addstatus != nil {
  15740. fields = append(fields, sopstage.FieldStatus)
  15741. }
  15742. if m.addcondition_type != nil {
  15743. fields = append(fields, sopstage.FieldConditionType)
  15744. }
  15745. if m.addcondition_operator != nil {
  15746. fields = append(fields, sopstage.FieldConditionOperator)
  15747. }
  15748. if m.addindex_sort != nil {
  15749. fields = append(fields, sopstage.FieldIndexSort)
  15750. }
  15751. return fields
  15752. }
  15753. // AddedField returns the numeric value that was incremented/decremented on a field
  15754. // with the given name. The second boolean return value indicates that this field
  15755. // was not set, or was not defined in the schema.
  15756. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  15757. switch name {
  15758. case sopstage.FieldStatus:
  15759. return m.AddedStatus()
  15760. case sopstage.FieldConditionType:
  15761. return m.AddedConditionType()
  15762. case sopstage.FieldConditionOperator:
  15763. return m.AddedConditionOperator()
  15764. case sopstage.FieldIndexSort:
  15765. return m.AddedIndexSort()
  15766. }
  15767. return nil, false
  15768. }
  15769. // AddField adds the value to the field with the given name. It returns an error if
  15770. // the field is not defined in the schema, or if the type mismatched the field
  15771. // type.
  15772. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  15773. switch name {
  15774. case sopstage.FieldStatus:
  15775. v, ok := value.(int8)
  15776. if !ok {
  15777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15778. }
  15779. m.AddStatus(v)
  15780. return nil
  15781. case sopstage.FieldConditionType:
  15782. v, ok := value.(int)
  15783. if !ok {
  15784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15785. }
  15786. m.AddConditionType(v)
  15787. return nil
  15788. case sopstage.FieldConditionOperator:
  15789. v, ok := value.(int)
  15790. if !ok {
  15791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15792. }
  15793. m.AddConditionOperator(v)
  15794. return nil
  15795. case sopstage.FieldIndexSort:
  15796. v, ok := value.(int)
  15797. if !ok {
  15798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15799. }
  15800. m.AddIndexSort(v)
  15801. return nil
  15802. }
  15803. return fmt.Errorf("unknown SopStage numeric field %s", name)
  15804. }
  15805. // ClearedFields returns all nullable fields that were cleared during this
  15806. // mutation.
  15807. func (m *SopStageMutation) ClearedFields() []string {
  15808. var fields []string
  15809. if m.FieldCleared(sopstage.FieldStatus) {
  15810. fields = append(fields, sopstage.FieldStatus)
  15811. }
  15812. if m.FieldCleared(sopstage.FieldDeletedAt) {
  15813. fields = append(fields, sopstage.FieldDeletedAt)
  15814. }
  15815. if m.FieldCleared(sopstage.FieldActionMessage) {
  15816. fields = append(fields, sopstage.FieldActionMessage)
  15817. }
  15818. if m.FieldCleared(sopstage.FieldActionLabel) {
  15819. fields = append(fields, sopstage.FieldActionLabel)
  15820. }
  15821. if m.FieldCleared(sopstage.FieldIndexSort) {
  15822. fields = append(fields, sopstage.FieldIndexSort)
  15823. }
  15824. return fields
  15825. }
  15826. // FieldCleared returns a boolean indicating if a field with the given name was
  15827. // cleared in this mutation.
  15828. func (m *SopStageMutation) FieldCleared(name string) bool {
  15829. _, ok := m.clearedFields[name]
  15830. return ok
  15831. }
  15832. // ClearField clears the value of the field with the given name. It returns an
  15833. // error if the field is not defined in the schema.
  15834. func (m *SopStageMutation) ClearField(name string) error {
  15835. switch name {
  15836. case sopstage.FieldStatus:
  15837. m.ClearStatus()
  15838. return nil
  15839. case sopstage.FieldDeletedAt:
  15840. m.ClearDeletedAt()
  15841. return nil
  15842. case sopstage.FieldActionMessage:
  15843. m.ClearActionMessage()
  15844. return nil
  15845. case sopstage.FieldActionLabel:
  15846. m.ClearActionLabel()
  15847. return nil
  15848. case sopstage.FieldIndexSort:
  15849. m.ClearIndexSort()
  15850. return nil
  15851. }
  15852. return fmt.Errorf("unknown SopStage nullable field %s", name)
  15853. }
  15854. // ResetField resets all changes in the mutation for the field with the given name.
  15855. // It returns an error if the field is not defined in the schema.
  15856. func (m *SopStageMutation) ResetField(name string) error {
  15857. switch name {
  15858. case sopstage.FieldCreatedAt:
  15859. m.ResetCreatedAt()
  15860. return nil
  15861. case sopstage.FieldUpdatedAt:
  15862. m.ResetUpdatedAt()
  15863. return nil
  15864. case sopstage.FieldStatus:
  15865. m.ResetStatus()
  15866. return nil
  15867. case sopstage.FieldDeletedAt:
  15868. m.ResetDeletedAt()
  15869. return nil
  15870. case sopstage.FieldTaskID:
  15871. m.ResetTaskID()
  15872. return nil
  15873. case sopstage.FieldName:
  15874. m.ResetName()
  15875. return nil
  15876. case sopstage.FieldConditionType:
  15877. m.ResetConditionType()
  15878. return nil
  15879. case sopstage.FieldConditionOperator:
  15880. m.ResetConditionOperator()
  15881. return nil
  15882. case sopstage.FieldConditionList:
  15883. m.ResetConditionList()
  15884. return nil
  15885. case sopstage.FieldActionMessage:
  15886. m.ResetActionMessage()
  15887. return nil
  15888. case sopstage.FieldActionLabel:
  15889. m.ResetActionLabel()
  15890. return nil
  15891. case sopstage.FieldIndexSort:
  15892. m.ResetIndexSort()
  15893. return nil
  15894. }
  15895. return fmt.Errorf("unknown SopStage field %s", name)
  15896. }
  15897. // AddedEdges returns all edge names that were set/added in this mutation.
  15898. func (m *SopStageMutation) AddedEdges() []string {
  15899. edges := make([]string, 0, 3)
  15900. if m.sop_task != nil {
  15901. edges = append(edges, sopstage.EdgeSopTask)
  15902. }
  15903. if m.stage_nodes != nil {
  15904. edges = append(edges, sopstage.EdgeStageNodes)
  15905. }
  15906. if m.stage_messages != nil {
  15907. edges = append(edges, sopstage.EdgeStageMessages)
  15908. }
  15909. return edges
  15910. }
  15911. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15912. // name in this mutation.
  15913. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  15914. switch name {
  15915. case sopstage.EdgeSopTask:
  15916. if id := m.sop_task; id != nil {
  15917. return []ent.Value{*id}
  15918. }
  15919. case sopstage.EdgeStageNodes:
  15920. ids := make([]ent.Value, 0, len(m.stage_nodes))
  15921. for id := range m.stage_nodes {
  15922. ids = append(ids, id)
  15923. }
  15924. return ids
  15925. case sopstage.EdgeStageMessages:
  15926. ids := make([]ent.Value, 0, len(m.stage_messages))
  15927. for id := range m.stage_messages {
  15928. ids = append(ids, id)
  15929. }
  15930. return ids
  15931. }
  15932. return nil
  15933. }
  15934. // RemovedEdges returns all edge names that were removed in this mutation.
  15935. func (m *SopStageMutation) RemovedEdges() []string {
  15936. edges := make([]string, 0, 3)
  15937. if m.removedstage_nodes != nil {
  15938. edges = append(edges, sopstage.EdgeStageNodes)
  15939. }
  15940. if m.removedstage_messages != nil {
  15941. edges = append(edges, sopstage.EdgeStageMessages)
  15942. }
  15943. return edges
  15944. }
  15945. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15946. // the given name in this mutation.
  15947. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  15948. switch name {
  15949. case sopstage.EdgeStageNodes:
  15950. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  15951. for id := range m.removedstage_nodes {
  15952. ids = append(ids, id)
  15953. }
  15954. return ids
  15955. case sopstage.EdgeStageMessages:
  15956. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  15957. for id := range m.removedstage_messages {
  15958. ids = append(ids, id)
  15959. }
  15960. return ids
  15961. }
  15962. return nil
  15963. }
  15964. // ClearedEdges returns all edge names that were cleared in this mutation.
  15965. func (m *SopStageMutation) ClearedEdges() []string {
  15966. edges := make([]string, 0, 3)
  15967. if m.clearedsop_task {
  15968. edges = append(edges, sopstage.EdgeSopTask)
  15969. }
  15970. if m.clearedstage_nodes {
  15971. edges = append(edges, sopstage.EdgeStageNodes)
  15972. }
  15973. if m.clearedstage_messages {
  15974. edges = append(edges, sopstage.EdgeStageMessages)
  15975. }
  15976. return edges
  15977. }
  15978. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15979. // was cleared in this mutation.
  15980. func (m *SopStageMutation) EdgeCleared(name string) bool {
  15981. switch name {
  15982. case sopstage.EdgeSopTask:
  15983. return m.clearedsop_task
  15984. case sopstage.EdgeStageNodes:
  15985. return m.clearedstage_nodes
  15986. case sopstage.EdgeStageMessages:
  15987. return m.clearedstage_messages
  15988. }
  15989. return false
  15990. }
  15991. // ClearEdge clears the value of the edge with the given name. It returns an error
  15992. // if that edge is not defined in the schema.
  15993. func (m *SopStageMutation) ClearEdge(name string) error {
  15994. switch name {
  15995. case sopstage.EdgeSopTask:
  15996. m.ClearSopTask()
  15997. return nil
  15998. }
  15999. return fmt.Errorf("unknown SopStage unique edge %s", name)
  16000. }
  16001. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16002. // It returns an error if the edge is not defined in the schema.
  16003. func (m *SopStageMutation) ResetEdge(name string) error {
  16004. switch name {
  16005. case sopstage.EdgeSopTask:
  16006. m.ResetSopTask()
  16007. return nil
  16008. case sopstage.EdgeStageNodes:
  16009. m.ResetStageNodes()
  16010. return nil
  16011. case sopstage.EdgeStageMessages:
  16012. m.ResetStageMessages()
  16013. return nil
  16014. }
  16015. return fmt.Errorf("unknown SopStage edge %s", name)
  16016. }
  16017. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  16018. type SopTaskMutation struct {
  16019. config
  16020. op Op
  16021. typ string
  16022. id *uint64
  16023. created_at *time.Time
  16024. updated_at *time.Time
  16025. status *uint8
  16026. addstatus *int8
  16027. deleted_at *time.Time
  16028. name *string
  16029. bot_wxid_list *[]string
  16030. appendbot_wxid_list []string
  16031. _type *int
  16032. add_type *int
  16033. plan_start_time *time.Time
  16034. plan_end_time *time.Time
  16035. creator_id *string
  16036. organization_id *uint64
  16037. addorganization_id *int64
  16038. clearedFields map[string]struct{}
  16039. task_stages map[uint64]struct{}
  16040. removedtask_stages map[uint64]struct{}
  16041. clearedtask_stages bool
  16042. done bool
  16043. oldValue func(context.Context) (*SopTask, error)
  16044. predicates []predicate.SopTask
  16045. }
  16046. var _ ent.Mutation = (*SopTaskMutation)(nil)
  16047. // soptaskOption allows management of the mutation configuration using functional options.
  16048. type soptaskOption func(*SopTaskMutation)
  16049. // newSopTaskMutation creates new mutation for the SopTask entity.
  16050. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  16051. m := &SopTaskMutation{
  16052. config: c,
  16053. op: op,
  16054. typ: TypeSopTask,
  16055. clearedFields: make(map[string]struct{}),
  16056. }
  16057. for _, opt := range opts {
  16058. opt(m)
  16059. }
  16060. return m
  16061. }
  16062. // withSopTaskID sets the ID field of the mutation.
  16063. func withSopTaskID(id uint64) soptaskOption {
  16064. return func(m *SopTaskMutation) {
  16065. var (
  16066. err error
  16067. once sync.Once
  16068. value *SopTask
  16069. )
  16070. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  16071. once.Do(func() {
  16072. if m.done {
  16073. err = errors.New("querying old values post mutation is not allowed")
  16074. } else {
  16075. value, err = m.Client().SopTask.Get(ctx, id)
  16076. }
  16077. })
  16078. return value, err
  16079. }
  16080. m.id = &id
  16081. }
  16082. }
  16083. // withSopTask sets the old SopTask of the mutation.
  16084. func withSopTask(node *SopTask) soptaskOption {
  16085. return func(m *SopTaskMutation) {
  16086. m.oldValue = func(context.Context) (*SopTask, error) {
  16087. return node, nil
  16088. }
  16089. m.id = &node.ID
  16090. }
  16091. }
  16092. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16093. // executed in a transaction (ent.Tx), a transactional client is returned.
  16094. func (m SopTaskMutation) Client() *Client {
  16095. client := &Client{config: m.config}
  16096. client.init()
  16097. return client
  16098. }
  16099. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16100. // it returns an error otherwise.
  16101. func (m SopTaskMutation) Tx() (*Tx, error) {
  16102. if _, ok := m.driver.(*txDriver); !ok {
  16103. return nil, errors.New("ent: mutation is not running in a transaction")
  16104. }
  16105. tx := &Tx{config: m.config}
  16106. tx.init()
  16107. return tx, nil
  16108. }
  16109. // SetID sets the value of the id field. Note that this
  16110. // operation is only accepted on creation of SopTask entities.
  16111. func (m *SopTaskMutation) SetID(id uint64) {
  16112. m.id = &id
  16113. }
  16114. // ID returns the ID value in the mutation. Note that the ID is only available
  16115. // if it was provided to the builder or after it was returned from the database.
  16116. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  16117. if m.id == nil {
  16118. return
  16119. }
  16120. return *m.id, true
  16121. }
  16122. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16123. // That means, if the mutation is applied within a transaction with an isolation level such
  16124. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16125. // or updated by the mutation.
  16126. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  16127. switch {
  16128. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16129. id, exists := m.ID()
  16130. if exists {
  16131. return []uint64{id}, nil
  16132. }
  16133. fallthrough
  16134. case m.op.Is(OpUpdate | OpDelete):
  16135. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  16136. default:
  16137. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16138. }
  16139. }
  16140. // SetCreatedAt sets the "created_at" field.
  16141. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  16142. m.created_at = &t
  16143. }
  16144. // CreatedAt returns the value of the "created_at" field in the mutation.
  16145. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  16146. v := m.created_at
  16147. if v == nil {
  16148. return
  16149. }
  16150. return *v, true
  16151. }
  16152. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  16153. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16155. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16156. if !m.op.Is(OpUpdateOne) {
  16157. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16158. }
  16159. if m.id == nil || m.oldValue == nil {
  16160. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16161. }
  16162. oldValue, err := m.oldValue(ctx)
  16163. if err != nil {
  16164. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16165. }
  16166. return oldValue.CreatedAt, nil
  16167. }
  16168. // ResetCreatedAt resets all changes to the "created_at" field.
  16169. func (m *SopTaskMutation) ResetCreatedAt() {
  16170. m.created_at = nil
  16171. }
  16172. // SetUpdatedAt sets the "updated_at" field.
  16173. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  16174. m.updated_at = &t
  16175. }
  16176. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16177. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  16178. v := m.updated_at
  16179. if v == nil {
  16180. return
  16181. }
  16182. return *v, true
  16183. }
  16184. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  16185. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16187. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16188. if !m.op.Is(OpUpdateOne) {
  16189. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16190. }
  16191. if m.id == nil || m.oldValue == nil {
  16192. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16193. }
  16194. oldValue, err := m.oldValue(ctx)
  16195. if err != nil {
  16196. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16197. }
  16198. return oldValue.UpdatedAt, nil
  16199. }
  16200. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16201. func (m *SopTaskMutation) ResetUpdatedAt() {
  16202. m.updated_at = nil
  16203. }
  16204. // SetStatus sets the "status" field.
  16205. func (m *SopTaskMutation) SetStatus(u uint8) {
  16206. m.status = &u
  16207. m.addstatus = nil
  16208. }
  16209. // Status returns the value of the "status" field in the mutation.
  16210. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  16211. v := m.status
  16212. if v == nil {
  16213. return
  16214. }
  16215. return *v, true
  16216. }
  16217. // OldStatus returns the old "status" field's value of the SopTask entity.
  16218. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16220. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16221. if !m.op.Is(OpUpdateOne) {
  16222. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16223. }
  16224. if m.id == nil || m.oldValue == nil {
  16225. return v, errors.New("OldStatus requires an ID field in the mutation")
  16226. }
  16227. oldValue, err := m.oldValue(ctx)
  16228. if err != nil {
  16229. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16230. }
  16231. return oldValue.Status, nil
  16232. }
  16233. // AddStatus adds u to the "status" field.
  16234. func (m *SopTaskMutation) AddStatus(u int8) {
  16235. if m.addstatus != nil {
  16236. *m.addstatus += u
  16237. } else {
  16238. m.addstatus = &u
  16239. }
  16240. }
  16241. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16242. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  16243. v := m.addstatus
  16244. if v == nil {
  16245. return
  16246. }
  16247. return *v, true
  16248. }
  16249. // ClearStatus clears the value of the "status" field.
  16250. func (m *SopTaskMutation) ClearStatus() {
  16251. m.status = nil
  16252. m.addstatus = nil
  16253. m.clearedFields[soptask.FieldStatus] = struct{}{}
  16254. }
  16255. // StatusCleared returns if the "status" field was cleared in this mutation.
  16256. func (m *SopTaskMutation) StatusCleared() bool {
  16257. _, ok := m.clearedFields[soptask.FieldStatus]
  16258. return ok
  16259. }
  16260. // ResetStatus resets all changes to the "status" field.
  16261. func (m *SopTaskMutation) ResetStatus() {
  16262. m.status = nil
  16263. m.addstatus = nil
  16264. delete(m.clearedFields, soptask.FieldStatus)
  16265. }
  16266. // SetDeletedAt sets the "deleted_at" field.
  16267. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  16268. m.deleted_at = &t
  16269. }
  16270. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16271. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  16272. v := m.deleted_at
  16273. if v == nil {
  16274. return
  16275. }
  16276. return *v, true
  16277. }
  16278. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  16279. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16281. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16282. if !m.op.Is(OpUpdateOne) {
  16283. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16284. }
  16285. if m.id == nil || m.oldValue == nil {
  16286. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16287. }
  16288. oldValue, err := m.oldValue(ctx)
  16289. if err != nil {
  16290. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16291. }
  16292. return oldValue.DeletedAt, nil
  16293. }
  16294. // ClearDeletedAt clears the value of the "deleted_at" field.
  16295. func (m *SopTaskMutation) ClearDeletedAt() {
  16296. m.deleted_at = nil
  16297. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  16298. }
  16299. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16300. func (m *SopTaskMutation) DeletedAtCleared() bool {
  16301. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  16302. return ok
  16303. }
  16304. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16305. func (m *SopTaskMutation) ResetDeletedAt() {
  16306. m.deleted_at = nil
  16307. delete(m.clearedFields, soptask.FieldDeletedAt)
  16308. }
  16309. // SetName sets the "name" field.
  16310. func (m *SopTaskMutation) SetName(s string) {
  16311. m.name = &s
  16312. }
  16313. // Name returns the value of the "name" field in the mutation.
  16314. func (m *SopTaskMutation) Name() (r string, exists bool) {
  16315. v := m.name
  16316. if v == nil {
  16317. return
  16318. }
  16319. return *v, true
  16320. }
  16321. // OldName returns the old "name" field's value of the SopTask entity.
  16322. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16324. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  16325. if !m.op.Is(OpUpdateOne) {
  16326. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16327. }
  16328. if m.id == nil || m.oldValue == nil {
  16329. return v, errors.New("OldName requires an ID field in the mutation")
  16330. }
  16331. oldValue, err := m.oldValue(ctx)
  16332. if err != nil {
  16333. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16334. }
  16335. return oldValue.Name, nil
  16336. }
  16337. // ResetName resets all changes to the "name" field.
  16338. func (m *SopTaskMutation) ResetName() {
  16339. m.name = nil
  16340. }
  16341. // SetBotWxidList sets the "bot_wxid_list" field.
  16342. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  16343. m.bot_wxid_list = &s
  16344. m.appendbot_wxid_list = nil
  16345. }
  16346. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  16347. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  16348. v := m.bot_wxid_list
  16349. if v == nil {
  16350. return
  16351. }
  16352. return *v, true
  16353. }
  16354. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  16355. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16357. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  16358. if !m.op.Is(OpUpdateOne) {
  16359. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  16360. }
  16361. if m.id == nil || m.oldValue == nil {
  16362. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  16363. }
  16364. oldValue, err := m.oldValue(ctx)
  16365. if err != nil {
  16366. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  16367. }
  16368. return oldValue.BotWxidList, nil
  16369. }
  16370. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  16371. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  16372. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  16373. }
  16374. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  16375. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  16376. if len(m.appendbot_wxid_list) == 0 {
  16377. return nil, false
  16378. }
  16379. return m.appendbot_wxid_list, true
  16380. }
  16381. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  16382. func (m *SopTaskMutation) ClearBotWxidList() {
  16383. m.bot_wxid_list = nil
  16384. m.appendbot_wxid_list = nil
  16385. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  16386. }
  16387. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  16388. func (m *SopTaskMutation) BotWxidListCleared() bool {
  16389. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  16390. return ok
  16391. }
  16392. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  16393. func (m *SopTaskMutation) ResetBotWxidList() {
  16394. m.bot_wxid_list = nil
  16395. m.appendbot_wxid_list = nil
  16396. delete(m.clearedFields, soptask.FieldBotWxidList)
  16397. }
  16398. // SetType sets the "type" field.
  16399. func (m *SopTaskMutation) SetType(i int) {
  16400. m._type = &i
  16401. m.add_type = nil
  16402. }
  16403. // GetType returns the value of the "type" field in the mutation.
  16404. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  16405. v := m._type
  16406. if v == nil {
  16407. return
  16408. }
  16409. return *v, true
  16410. }
  16411. // OldType returns the old "type" field's value of the SopTask entity.
  16412. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16414. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  16415. if !m.op.Is(OpUpdateOne) {
  16416. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16417. }
  16418. if m.id == nil || m.oldValue == nil {
  16419. return v, errors.New("OldType requires an ID field in the mutation")
  16420. }
  16421. oldValue, err := m.oldValue(ctx)
  16422. if err != nil {
  16423. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16424. }
  16425. return oldValue.Type, nil
  16426. }
  16427. // AddType adds i to the "type" field.
  16428. func (m *SopTaskMutation) AddType(i int) {
  16429. if m.add_type != nil {
  16430. *m.add_type += i
  16431. } else {
  16432. m.add_type = &i
  16433. }
  16434. }
  16435. // AddedType returns the value that was added to the "type" field in this mutation.
  16436. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  16437. v := m.add_type
  16438. if v == nil {
  16439. return
  16440. }
  16441. return *v, true
  16442. }
  16443. // ResetType resets all changes to the "type" field.
  16444. func (m *SopTaskMutation) ResetType() {
  16445. m._type = nil
  16446. m.add_type = nil
  16447. }
  16448. // SetPlanStartTime sets the "plan_start_time" field.
  16449. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  16450. m.plan_start_time = &t
  16451. }
  16452. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  16453. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  16454. v := m.plan_start_time
  16455. if v == nil {
  16456. return
  16457. }
  16458. return *v, true
  16459. }
  16460. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  16461. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16463. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  16464. if !m.op.Is(OpUpdateOne) {
  16465. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  16466. }
  16467. if m.id == nil || m.oldValue == nil {
  16468. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  16469. }
  16470. oldValue, err := m.oldValue(ctx)
  16471. if err != nil {
  16472. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  16473. }
  16474. return oldValue.PlanStartTime, nil
  16475. }
  16476. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  16477. func (m *SopTaskMutation) ClearPlanStartTime() {
  16478. m.plan_start_time = nil
  16479. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  16480. }
  16481. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  16482. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  16483. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  16484. return ok
  16485. }
  16486. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  16487. func (m *SopTaskMutation) ResetPlanStartTime() {
  16488. m.plan_start_time = nil
  16489. delete(m.clearedFields, soptask.FieldPlanStartTime)
  16490. }
  16491. // SetPlanEndTime sets the "plan_end_time" field.
  16492. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  16493. m.plan_end_time = &t
  16494. }
  16495. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  16496. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  16497. v := m.plan_end_time
  16498. if v == nil {
  16499. return
  16500. }
  16501. return *v, true
  16502. }
  16503. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  16504. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16506. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  16507. if !m.op.Is(OpUpdateOne) {
  16508. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  16509. }
  16510. if m.id == nil || m.oldValue == nil {
  16511. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  16512. }
  16513. oldValue, err := m.oldValue(ctx)
  16514. if err != nil {
  16515. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  16516. }
  16517. return oldValue.PlanEndTime, nil
  16518. }
  16519. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  16520. func (m *SopTaskMutation) ClearPlanEndTime() {
  16521. m.plan_end_time = nil
  16522. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  16523. }
  16524. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  16525. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  16526. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  16527. return ok
  16528. }
  16529. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  16530. func (m *SopTaskMutation) ResetPlanEndTime() {
  16531. m.plan_end_time = nil
  16532. delete(m.clearedFields, soptask.FieldPlanEndTime)
  16533. }
  16534. // SetCreatorID sets the "creator_id" field.
  16535. func (m *SopTaskMutation) SetCreatorID(s string) {
  16536. m.creator_id = &s
  16537. }
  16538. // CreatorID returns the value of the "creator_id" field in the mutation.
  16539. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  16540. v := m.creator_id
  16541. if v == nil {
  16542. return
  16543. }
  16544. return *v, true
  16545. }
  16546. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  16547. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16549. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  16550. if !m.op.Is(OpUpdateOne) {
  16551. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  16552. }
  16553. if m.id == nil || m.oldValue == nil {
  16554. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  16555. }
  16556. oldValue, err := m.oldValue(ctx)
  16557. if err != nil {
  16558. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  16559. }
  16560. return oldValue.CreatorID, nil
  16561. }
  16562. // ClearCreatorID clears the value of the "creator_id" field.
  16563. func (m *SopTaskMutation) ClearCreatorID() {
  16564. m.creator_id = nil
  16565. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  16566. }
  16567. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  16568. func (m *SopTaskMutation) CreatorIDCleared() bool {
  16569. _, ok := m.clearedFields[soptask.FieldCreatorID]
  16570. return ok
  16571. }
  16572. // ResetCreatorID resets all changes to the "creator_id" field.
  16573. func (m *SopTaskMutation) ResetCreatorID() {
  16574. m.creator_id = nil
  16575. delete(m.clearedFields, soptask.FieldCreatorID)
  16576. }
  16577. // SetOrganizationID sets the "organization_id" field.
  16578. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  16579. m.organization_id = &u
  16580. m.addorganization_id = nil
  16581. }
  16582. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16583. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  16584. v := m.organization_id
  16585. if v == nil {
  16586. return
  16587. }
  16588. return *v, true
  16589. }
  16590. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  16591. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  16592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16593. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16594. if !m.op.Is(OpUpdateOne) {
  16595. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16596. }
  16597. if m.id == nil || m.oldValue == nil {
  16598. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16599. }
  16600. oldValue, err := m.oldValue(ctx)
  16601. if err != nil {
  16602. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16603. }
  16604. return oldValue.OrganizationID, nil
  16605. }
  16606. // AddOrganizationID adds u to the "organization_id" field.
  16607. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  16608. if m.addorganization_id != nil {
  16609. *m.addorganization_id += u
  16610. } else {
  16611. m.addorganization_id = &u
  16612. }
  16613. }
  16614. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16615. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  16616. v := m.addorganization_id
  16617. if v == nil {
  16618. return
  16619. }
  16620. return *v, true
  16621. }
  16622. // ClearOrganizationID clears the value of the "organization_id" field.
  16623. func (m *SopTaskMutation) ClearOrganizationID() {
  16624. m.organization_id = nil
  16625. m.addorganization_id = nil
  16626. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  16627. }
  16628. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16629. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  16630. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  16631. return ok
  16632. }
  16633. // ResetOrganizationID resets all changes to the "organization_id" field.
  16634. func (m *SopTaskMutation) ResetOrganizationID() {
  16635. m.organization_id = nil
  16636. m.addorganization_id = nil
  16637. delete(m.clearedFields, soptask.FieldOrganizationID)
  16638. }
  16639. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  16640. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  16641. if m.task_stages == nil {
  16642. m.task_stages = make(map[uint64]struct{})
  16643. }
  16644. for i := range ids {
  16645. m.task_stages[ids[i]] = struct{}{}
  16646. }
  16647. }
  16648. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  16649. func (m *SopTaskMutation) ClearTaskStages() {
  16650. m.clearedtask_stages = true
  16651. }
  16652. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  16653. func (m *SopTaskMutation) TaskStagesCleared() bool {
  16654. return m.clearedtask_stages
  16655. }
  16656. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  16657. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  16658. if m.removedtask_stages == nil {
  16659. m.removedtask_stages = make(map[uint64]struct{})
  16660. }
  16661. for i := range ids {
  16662. delete(m.task_stages, ids[i])
  16663. m.removedtask_stages[ids[i]] = struct{}{}
  16664. }
  16665. }
  16666. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  16667. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  16668. for id := range m.removedtask_stages {
  16669. ids = append(ids, id)
  16670. }
  16671. return
  16672. }
  16673. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  16674. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  16675. for id := range m.task_stages {
  16676. ids = append(ids, id)
  16677. }
  16678. return
  16679. }
  16680. // ResetTaskStages resets all changes to the "task_stages" edge.
  16681. func (m *SopTaskMutation) ResetTaskStages() {
  16682. m.task_stages = nil
  16683. m.clearedtask_stages = false
  16684. m.removedtask_stages = nil
  16685. }
  16686. // Where appends a list predicates to the SopTaskMutation builder.
  16687. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  16688. m.predicates = append(m.predicates, ps...)
  16689. }
  16690. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  16691. // users can use type-assertion to append predicates that do not depend on any generated package.
  16692. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  16693. p := make([]predicate.SopTask, len(ps))
  16694. for i := range ps {
  16695. p[i] = ps[i]
  16696. }
  16697. m.Where(p...)
  16698. }
  16699. // Op returns the operation name.
  16700. func (m *SopTaskMutation) Op() Op {
  16701. return m.op
  16702. }
  16703. // SetOp allows setting the mutation operation.
  16704. func (m *SopTaskMutation) SetOp(op Op) {
  16705. m.op = op
  16706. }
  16707. // Type returns the node type of this mutation (SopTask).
  16708. func (m *SopTaskMutation) Type() string {
  16709. return m.typ
  16710. }
  16711. // Fields returns all fields that were changed during this mutation. Note that in
  16712. // order to get all numeric fields that were incremented/decremented, call
  16713. // AddedFields().
  16714. func (m *SopTaskMutation) Fields() []string {
  16715. fields := make([]string, 0, 11)
  16716. if m.created_at != nil {
  16717. fields = append(fields, soptask.FieldCreatedAt)
  16718. }
  16719. if m.updated_at != nil {
  16720. fields = append(fields, soptask.FieldUpdatedAt)
  16721. }
  16722. if m.status != nil {
  16723. fields = append(fields, soptask.FieldStatus)
  16724. }
  16725. if m.deleted_at != nil {
  16726. fields = append(fields, soptask.FieldDeletedAt)
  16727. }
  16728. if m.name != nil {
  16729. fields = append(fields, soptask.FieldName)
  16730. }
  16731. if m.bot_wxid_list != nil {
  16732. fields = append(fields, soptask.FieldBotWxidList)
  16733. }
  16734. if m._type != nil {
  16735. fields = append(fields, soptask.FieldType)
  16736. }
  16737. if m.plan_start_time != nil {
  16738. fields = append(fields, soptask.FieldPlanStartTime)
  16739. }
  16740. if m.plan_end_time != nil {
  16741. fields = append(fields, soptask.FieldPlanEndTime)
  16742. }
  16743. if m.creator_id != nil {
  16744. fields = append(fields, soptask.FieldCreatorID)
  16745. }
  16746. if m.organization_id != nil {
  16747. fields = append(fields, soptask.FieldOrganizationID)
  16748. }
  16749. return fields
  16750. }
  16751. // Field returns the value of a field with the given name. The second boolean
  16752. // return value indicates that this field was not set, or was not defined in the
  16753. // schema.
  16754. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  16755. switch name {
  16756. case soptask.FieldCreatedAt:
  16757. return m.CreatedAt()
  16758. case soptask.FieldUpdatedAt:
  16759. return m.UpdatedAt()
  16760. case soptask.FieldStatus:
  16761. return m.Status()
  16762. case soptask.FieldDeletedAt:
  16763. return m.DeletedAt()
  16764. case soptask.FieldName:
  16765. return m.Name()
  16766. case soptask.FieldBotWxidList:
  16767. return m.BotWxidList()
  16768. case soptask.FieldType:
  16769. return m.GetType()
  16770. case soptask.FieldPlanStartTime:
  16771. return m.PlanStartTime()
  16772. case soptask.FieldPlanEndTime:
  16773. return m.PlanEndTime()
  16774. case soptask.FieldCreatorID:
  16775. return m.CreatorID()
  16776. case soptask.FieldOrganizationID:
  16777. return m.OrganizationID()
  16778. }
  16779. return nil, false
  16780. }
  16781. // OldField returns the old value of the field from the database. An error is
  16782. // returned if the mutation operation is not UpdateOne, or the query to the
  16783. // database failed.
  16784. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16785. switch name {
  16786. case soptask.FieldCreatedAt:
  16787. return m.OldCreatedAt(ctx)
  16788. case soptask.FieldUpdatedAt:
  16789. return m.OldUpdatedAt(ctx)
  16790. case soptask.FieldStatus:
  16791. return m.OldStatus(ctx)
  16792. case soptask.FieldDeletedAt:
  16793. return m.OldDeletedAt(ctx)
  16794. case soptask.FieldName:
  16795. return m.OldName(ctx)
  16796. case soptask.FieldBotWxidList:
  16797. return m.OldBotWxidList(ctx)
  16798. case soptask.FieldType:
  16799. return m.OldType(ctx)
  16800. case soptask.FieldPlanStartTime:
  16801. return m.OldPlanStartTime(ctx)
  16802. case soptask.FieldPlanEndTime:
  16803. return m.OldPlanEndTime(ctx)
  16804. case soptask.FieldCreatorID:
  16805. return m.OldCreatorID(ctx)
  16806. case soptask.FieldOrganizationID:
  16807. return m.OldOrganizationID(ctx)
  16808. }
  16809. return nil, fmt.Errorf("unknown SopTask field %s", name)
  16810. }
  16811. // SetField sets the value of a field with the given name. It returns an error if
  16812. // the field is not defined in the schema, or if the type mismatched the field
  16813. // type.
  16814. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  16815. switch name {
  16816. case soptask.FieldCreatedAt:
  16817. v, ok := value.(time.Time)
  16818. if !ok {
  16819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16820. }
  16821. m.SetCreatedAt(v)
  16822. return nil
  16823. case soptask.FieldUpdatedAt:
  16824. v, ok := value.(time.Time)
  16825. if !ok {
  16826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16827. }
  16828. m.SetUpdatedAt(v)
  16829. return nil
  16830. case soptask.FieldStatus:
  16831. v, ok := value.(uint8)
  16832. if !ok {
  16833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16834. }
  16835. m.SetStatus(v)
  16836. return nil
  16837. case soptask.FieldDeletedAt:
  16838. v, ok := value.(time.Time)
  16839. if !ok {
  16840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16841. }
  16842. m.SetDeletedAt(v)
  16843. return nil
  16844. case soptask.FieldName:
  16845. v, ok := value.(string)
  16846. if !ok {
  16847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16848. }
  16849. m.SetName(v)
  16850. return nil
  16851. case soptask.FieldBotWxidList:
  16852. v, ok := value.([]string)
  16853. if !ok {
  16854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16855. }
  16856. m.SetBotWxidList(v)
  16857. return nil
  16858. case soptask.FieldType:
  16859. v, ok := value.(int)
  16860. if !ok {
  16861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16862. }
  16863. m.SetType(v)
  16864. return nil
  16865. case soptask.FieldPlanStartTime:
  16866. v, ok := value.(time.Time)
  16867. if !ok {
  16868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16869. }
  16870. m.SetPlanStartTime(v)
  16871. return nil
  16872. case soptask.FieldPlanEndTime:
  16873. v, ok := value.(time.Time)
  16874. if !ok {
  16875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16876. }
  16877. m.SetPlanEndTime(v)
  16878. return nil
  16879. case soptask.FieldCreatorID:
  16880. v, ok := value.(string)
  16881. if !ok {
  16882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16883. }
  16884. m.SetCreatorID(v)
  16885. return nil
  16886. case soptask.FieldOrganizationID:
  16887. v, ok := value.(uint64)
  16888. if !ok {
  16889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16890. }
  16891. m.SetOrganizationID(v)
  16892. return nil
  16893. }
  16894. return fmt.Errorf("unknown SopTask field %s", name)
  16895. }
  16896. // AddedFields returns all numeric fields that were incremented/decremented during
  16897. // this mutation.
  16898. func (m *SopTaskMutation) AddedFields() []string {
  16899. var fields []string
  16900. if m.addstatus != nil {
  16901. fields = append(fields, soptask.FieldStatus)
  16902. }
  16903. if m.add_type != nil {
  16904. fields = append(fields, soptask.FieldType)
  16905. }
  16906. if m.addorganization_id != nil {
  16907. fields = append(fields, soptask.FieldOrganizationID)
  16908. }
  16909. return fields
  16910. }
  16911. // AddedField returns the numeric value that was incremented/decremented on a field
  16912. // with the given name. The second boolean return value indicates that this field
  16913. // was not set, or was not defined in the schema.
  16914. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  16915. switch name {
  16916. case soptask.FieldStatus:
  16917. return m.AddedStatus()
  16918. case soptask.FieldType:
  16919. return m.AddedType()
  16920. case soptask.FieldOrganizationID:
  16921. return m.AddedOrganizationID()
  16922. }
  16923. return nil, false
  16924. }
  16925. // AddField adds the value to the field with the given name. It returns an error if
  16926. // the field is not defined in the schema, or if the type mismatched the field
  16927. // type.
  16928. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  16929. switch name {
  16930. case soptask.FieldStatus:
  16931. v, ok := value.(int8)
  16932. if !ok {
  16933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16934. }
  16935. m.AddStatus(v)
  16936. return nil
  16937. case soptask.FieldType:
  16938. v, ok := value.(int)
  16939. if !ok {
  16940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16941. }
  16942. m.AddType(v)
  16943. return nil
  16944. case soptask.FieldOrganizationID:
  16945. v, ok := value.(int64)
  16946. if !ok {
  16947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16948. }
  16949. m.AddOrganizationID(v)
  16950. return nil
  16951. }
  16952. return fmt.Errorf("unknown SopTask numeric field %s", name)
  16953. }
  16954. // ClearedFields returns all nullable fields that were cleared during this
  16955. // mutation.
  16956. func (m *SopTaskMutation) ClearedFields() []string {
  16957. var fields []string
  16958. if m.FieldCleared(soptask.FieldStatus) {
  16959. fields = append(fields, soptask.FieldStatus)
  16960. }
  16961. if m.FieldCleared(soptask.FieldDeletedAt) {
  16962. fields = append(fields, soptask.FieldDeletedAt)
  16963. }
  16964. if m.FieldCleared(soptask.FieldBotWxidList) {
  16965. fields = append(fields, soptask.FieldBotWxidList)
  16966. }
  16967. if m.FieldCleared(soptask.FieldPlanStartTime) {
  16968. fields = append(fields, soptask.FieldPlanStartTime)
  16969. }
  16970. if m.FieldCleared(soptask.FieldPlanEndTime) {
  16971. fields = append(fields, soptask.FieldPlanEndTime)
  16972. }
  16973. if m.FieldCleared(soptask.FieldCreatorID) {
  16974. fields = append(fields, soptask.FieldCreatorID)
  16975. }
  16976. if m.FieldCleared(soptask.FieldOrganizationID) {
  16977. fields = append(fields, soptask.FieldOrganizationID)
  16978. }
  16979. return fields
  16980. }
  16981. // FieldCleared returns a boolean indicating if a field with the given name was
  16982. // cleared in this mutation.
  16983. func (m *SopTaskMutation) FieldCleared(name string) bool {
  16984. _, ok := m.clearedFields[name]
  16985. return ok
  16986. }
  16987. // ClearField clears the value of the field with the given name. It returns an
  16988. // error if the field is not defined in the schema.
  16989. func (m *SopTaskMutation) ClearField(name string) error {
  16990. switch name {
  16991. case soptask.FieldStatus:
  16992. m.ClearStatus()
  16993. return nil
  16994. case soptask.FieldDeletedAt:
  16995. m.ClearDeletedAt()
  16996. return nil
  16997. case soptask.FieldBotWxidList:
  16998. m.ClearBotWxidList()
  16999. return nil
  17000. case soptask.FieldPlanStartTime:
  17001. m.ClearPlanStartTime()
  17002. return nil
  17003. case soptask.FieldPlanEndTime:
  17004. m.ClearPlanEndTime()
  17005. return nil
  17006. case soptask.FieldCreatorID:
  17007. m.ClearCreatorID()
  17008. return nil
  17009. case soptask.FieldOrganizationID:
  17010. m.ClearOrganizationID()
  17011. return nil
  17012. }
  17013. return fmt.Errorf("unknown SopTask nullable field %s", name)
  17014. }
  17015. // ResetField resets all changes in the mutation for the field with the given name.
  17016. // It returns an error if the field is not defined in the schema.
  17017. func (m *SopTaskMutation) ResetField(name string) error {
  17018. switch name {
  17019. case soptask.FieldCreatedAt:
  17020. m.ResetCreatedAt()
  17021. return nil
  17022. case soptask.FieldUpdatedAt:
  17023. m.ResetUpdatedAt()
  17024. return nil
  17025. case soptask.FieldStatus:
  17026. m.ResetStatus()
  17027. return nil
  17028. case soptask.FieldDeletedAt:
  17029. m.ResetDeletedAt()
  17030. return nil
  17031. case soptask.FieldName:
  17032. m.ResetName()
  17033. return nil
  17034. case soptask.FieldBotWxidList:
  17035. m.ResetBotWxidList()
  17036. return nil
  17037. case soptask.FieldType:
  17038. m.ResetType()
  17039. return nil
  17040. case soptask.FieldPlanStartTime:
  17041. m.ResetPlanStartTime()
  17042. return nil
  17043. case soptask.FieldPlanEndTime:
  17044. m.ResetPlanEndTime()
  17045. return nil
  17046. case soptask.FieldCreatorID:
  17047. m.ResetCreatorID()
  17048. return nil
  17049. case soptask.FieldOrganizationID:
  17050. m.ResetOrganizationID()
  17051. return nil
  17052. }
  17053. return fmt.Errorf("unknown SopTask field %s", name)
  17054. }
  17055. // AddedEdges returns all edge names that were set/added in this mutation.
  17056. func (m *SopTaskMutation) AddedEdges() []string {
  17057. edges := make([]string, 0, 1)
  17058. if m.task_stages != nil {
  17059. edges = append(edges, soptask.EdgeTaskStages)
  17060. }
  17061. return edges
  17062. }
  17063. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17064. // name in this mutation.
  17065. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  17066. switch name {
  17067. case soptask.EdgeTaskStages:
  17068. ids := make([]ent.Value, 0, len(m.task_stages))
  17069. for id := range m.task_stages {
  17070. ids = append(ids, id)
  17071. }
  17072. return ids
  17073. }
  17074. return nil
  17075. }
  17076. // RemovedEdges returns all edge names that were removed in this mutation.
  17077. func (m *SopTaskMutation) RemovedEdges() []string {
  17078. edges := make([]string, 0, 1)
  17079. if m.removedtask_stages != nil {
  17080. edges = append(edges, soptask.EdgeTaskStages)
  17081. }
  17082. return edges
  17083. }
  17084. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17085. // the given name in this mutation.
  17086. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  17087. switch name {
  17088. case soptask.EdgeTaskStages:
  17089. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  17090. for id := range m.removedtask_stages {
  17091. ids = append(ids, id)
  17092. }
  17093. return ids
  17094. }
  17095. return nil
  17096. }
  17097. // ClearedEdges returns all edge names that were cleared in this mutation.
  17098. func (m *SopTaskMutation) ClearedEdges() []string {
  17099. edges := make([]string, 0, 1)
  17100. if m.clearedtask_stages {
  17101. edges = append(edges, soptask.EdgeTaskStages)
  17102. }
  17103. return edges
  17104. }
  17105. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17106. // was cleared in this mutation.
  17107. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  17108. switch name {
  17109. case soptask.EdgeTaskStages:
  17110. return m.clearedtask_stages
  17111. }
  17112. return false
  17113. }
  17114. // ClearEdge clears the value of the edge with the given name. It returns an error
  17115. // if that edge is not defined in the schema.
  17116. func (m *SopTaskMutation) ClearEdge(name string) error {
  17117. switch name {
  17118. }
  17119. return fmt.Errorf("unknown SopTask unique edge %s", name)
  17120. }
  17121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17122. // It returns an error if the edge is not defined in the schema.
  17123. func (m *SopTaskMutation) ResetEdge(name string) error {
  17124. switch name {
  17125. case soptask.EdgeTaskStages:
  17126. m.ResetTaskStages()
  17127. return nil
  17128. }
  17129. return fmt.Errorf("unknown SopTask edge %s", name)
  17130. }
  17131. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  17132. type TokenMutation struct {
  17133. config
  17134. op Op
  17135. typ string
  17136. id *uint64
  17137. created_at *time.Time
  17138. updated_at *time.Time
  17139. deleted_at *time.Time
  17140. expire_at *time.Time
  17141. token *string
  17142. mac *string
  17143. clearedFields map[string]struct{}
  17144. done bool
  17145. oldValue func(context.Context) (*Token, error)
  17146. predicates []predicate.Token
  17147. }
  17148. var _ ent.Mutation = (*TokenMutation)(nil)
  17149. // tokenOption allows management of the mutation configuration using functional options.
  17150. type tokenOption func(*TokenMutation)
  17151. // newTokenMutation creates new mutation for the Token entity.
  17152. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  17153. m := &TokenMutation{
  17154. config: c,
  17155. op: op,
  17156. typ: TypeToken,
  17157. clearedFields: make(map[string]struct{}),
  17158. }
  17159. for _, opt := range opts {
  17160. opt(m)
  17161. }
  17162. return m
  17163. }
  17164. // withTokenID sets the ID field of the mutation.
  17165. func withTokenID(id uint64) tokenOption {
  17166. return func(m *TokenMutation) {
  17167. var (
  17168. err error
  17169. once sync.Once
  17170. value *Token
  17171. )
  17172. m.oldValue = func(ctx context.Context) (*Token, error) {
  17173. once.Do(func() {
  17174. if m.done {
  17175. err = errors.New("querying old values post mutation is not allowed")
  17176. } else {
  17177. value, err = m.Client().Token.Get(ctx, id)
  17178. }
  17179. })
  17180. return value, err
  17181. }
  17182. m.id = &id
  17183. }
  17184. }
  17185. // withToken sets the old Token of the mutation.
  17186. func withToken(node *Token) tokenOption {
  17187. return func(m *TokenMutation) {
  17188. m.oldValue = func(context.Context) (*Token, error) {
  17189. return node, nil
  17190. }
  17191. m.id = &node.ID
  17192. }
  17193. }
  17194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17195. // executed in a transaction (ent.Tx), a transactional client is returned.
  17196. func (m TokenMutation) Client() *Client {
  17197. client := &Client{config: m.config}
  17198. client.init()
  17199. return client
  17200. }
  17201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17202. // it returns an error otherwise.
  17203. func (m TokenMutation) Tx() (*Tx, error) {
  17204. if _, ok := m.driver.(*txDriver); !ok {
  17205. return nil, errors.New("ent: mutation is not running in a transaction")
  17206. }
  17207. tx := &Tx{config: m.config}
  17208. tx.init()
  17209. return tx, nil
  17210. }
  17211. // SetID sets the value of the id field. Note that this
  17212. // operation is only accepted on creation of Token entities.
  17213. func (m *TokenMutation) SetID(id uint64) {
  17214. m.id = &id
  17215. }
  17216. // ID returns the ID value in the mutation. Note that the ID is only available
  17217. // if it was provided to the builder or after it was returned from the database.
  17218. func (m *TokenMutation) ID() (id uint64, exists bool) {
  17219. if m.id == nil {
  17220. return
  17221. }
  17222. return *m.id, true
  17223. }
  17224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17225. // That means, if the mutation is applied within a transaction with an isolation level such
  17226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17227. // or updated by the mutation.
  17228. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  17229. switch {
  17230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17231. id, exists := m.ID()
  17232. if exists {
  17233. return []uint64{id}, nil
  17234. }
  17235. fallthrough
  17236. case m.op.Is(OpUpdate | OpDelete):
  17237. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  17238. default:
  17239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17240. }
  17241. }
  17242. // SetCreatedAt sets the "created_at" field.
  17243. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  17244. m.created_at = &t
  17245. }
  17246. // CreatedAt returns the value of the "created_at" field in the mutation.
  17247. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  17248. v := m.created_at
  17249. if v == nil {
  17250. return
  17251. }
  17252. return *v, true
  17253. }
  17254. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  17255. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  17256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17257. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17258. if !m.op.Is(OpUpdateOne) {
  17259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17260. }
  17261. if m.id == nil || m.oldValue == nil {
  17262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17263. }
  17264. oldValue, err := m.oldValue(ctx)
  17265. if err != nil {
  17266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17267. }
  17268. return oldValue.CreatedAt, nil
  17269. }
  17270. // ResetCreatedAt resets all changes to the "created_at" field.
  17271. func (m *TokenMutation) ResetCreatedAt() {
  17272. m.created_at = nil
  17273. }
  17274. // SetUpdatedAt sets the "updated_at" field.
  17275. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  17276. m.updated_at = &t
  17277. }
  17278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17279. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  17280. v := m.updated_at
  17281. if v == nil {
  17282. return
  17283. }
  17284. return *v, true
  17285. }
  17286. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  17287. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  17288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17289. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17290. if !m.op.Is(OpUpdateOne) {
  17291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17292. }
  17293. if m.id == nil || m.oldValue == nil {
  17294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17295. }
  17296. oldValue, err := m.oldValue(ctx)
  17297. if err != nil {
  17298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17299. }
  17300. return oldValue.UpdatedAt, nil
  17301. }
  17302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17303. func (m *TokenMutation) ResetUpdatedAt() {
  17304. m.updated_at = nil
  17305. }
  17306. // SetDeletedAt sets the "deleted_at" field.
  17307. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  17308. m.deleted_at = &t
  17309. }
  17310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17311. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  17312. v := m.deleted_at
  17313. if v == nil {
  17314. return
  17315. }
  17316. return *v, true
  17317. }
  17318. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  17319. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  17320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17321. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17322. if !m.op.Is(OpUpdateOne) {
  17323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17324. }
  17325. if m.id == nil || m.oldValue == nil {
  17326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17327. }
  17328. oldValue, err := m.oldValue(ctx)
  17329. if err != nil {
  17330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17331. }
  17332. return oldValue.DeletedAt, nil
  17333. }
  17334. // ClearDeletedAt clears the value of the "deleted_at" field.
  17335. func (m *TokenMutation) ClearDeletedAt() {
  17336. m.deleted_at = nil
  17337. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  17338. }
  17339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17340. func (m *TokenMutation) DeletedAtCleared() bool {
  17341. _, ok := m.clearedFields[token.FieldDeletedAt]
  17342. return ok
  17343. }
  17344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17345. func (m *TokenMutation) ResetDeletedAt() {
  17346. m.deleted_at = nil
  17347. delete(m.clearedFields, token.FieldDeletedAt)
  17348. }
  17349. // SetExpireAt sets the "expire_at" field.
  17350. func (m *TokenMutation) SetExpireAt(t time.Time) {
  17351. m.expire_at = &t
  17352. }
  17353. // ExpireAt returns the value of the "expire_at" field in the mutation.
  17354. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  17355. v := m.expire_at
  17356. if v == nil {
  17357. return
  17358. }
  17359. return *v, true
  17360. }
  17361. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  17362. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  17363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17364. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  17365. if !m.op.Is(OpUpdateOne) {
  17366. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  17367. }
  17368. if m.id == nil || m.oldValue == nil {
  17369. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  17370. }
  17371. oldValue, err := m.oldValue(ctx)
  17372. if err != nil {
  17373. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  17374. }
  17375. return oldValue.ExpireAt, nil
  17376. }
  17377. // ClearExpireAt clears the value of the "expire_at" field.
  17378. func (m *TokenMutation) ClearExpireAt() {
  17379. m.expire_at = nil
  17380. m.clearedFields[token.FieldExpireAt] = struct{}{}
  17381. }
  17382. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  17383. func (m *TokenMutation) ExpireAtCleared() bool {
  17384. _, ok := m.clearedFields[token.FieldExpireAt]
  17385. return ok
  17386. }
  17387. // ResetExpireAt resets all changes to the "expire_at" field.
  17388. func (m *TokenMutation) ResetExpireAt() {
  17389. m.expire_at = nil
  17390. delete(m.clearedFields, token.FieldExpireAt)
  17391. }
  17392. // SetToken sets the "token" field.
  17393. func (m *TokenMutation) SetToken(s string) {
  17394. m.token = &s
  17395. }
  17396. // Token returns the value of the "token" field in the mutation.
  17397. func (m *TokenMutation) Token() (r string, exists bool) {
  17398. v := m.token
  17399. if v == nil {
  17400. return
  17401. }
  17402. return *v, true
  17403. }
  17404. // OldToken returns the old "token" field's value of the Token entity.
  17405. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  17406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17407. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  17408. if !m.op.Is(OpUpdateOne) {
  17409. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  17410. }
  17411. if m.id == nil || m.oldValue == nil {
  17412. return v, errors.New("OldToken requires an ID field in the mutation")
  17413. }
  17414. oldValue, err := m.oldValue(ctx)
  17415. if err != nil {
  17416. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  17417. }
  17418. return oldValue.Token, nil
  17419. }
  17420. // ClearToken clears the value of the "token" field.
  17421. func (m *TokenMutation) ClearToken() {
  17422. m.token = nil
  17423. m.clearedFields[token.FieldToken] = struct{}{}
  17424. }
  17425. // TokenCleared returns if the "token" field was cleared in this mutation.
  17426. func (m *TokenMutation) TokenCleared() bool {
  17427. _, ok := m.clearedFields[token.FieldToken]
  17428. return ok
  17429. }
  17430. // ResetToken resets all changes to the "token" field.
  17431. func (m *TokenMutation) ResetToken() {
  17432. m.token = nil
  17433. delete(m.clearedFields, token.FieldToken)
  17434. }
  17435. // SetMAC sets the "mac" field.
  17436. func (m *TokenMutation) SetMAC(s string) {
  17437. m.mac = &s
  17438. }
  17439. // MAC returns the value of the "mac" field in the mutation.
  17440. func (m *TokenMutation) MAC() (r string, exists bool) {
  17441. v := m.mac
  17442. if v == nil {
  17443. return
  17444. }
  17445. return *v, true
  17446. }
  17447. // OldMAC returns the old "mac" field's value of the Token entity.
  17448. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  17449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17450. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  17451. if !m.op.Is(OpUpdateOne) {
  17452. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  17453. }
  17454. if m.id == nil || m.oldValue == nil {
  17455. return v, errors.New("OldMAC requires an ID field in the mutation")
  17456. }
  17457. oldValue, err := m.oldValue(ctx)
  17458. if err != nil {
  17459. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  17460. }
  17461. return oldValue.MAC, nil
  17462. }
  17463. // ResetMAC resets all changes to the "mac" field.
  17464. func (m *TokenMutation) ResetMAC() {
  17465. m.mac = nil
  17466. }
  17467. // Where appends a list predicates to the TokenMutation builder.
  17468. func (m *TokenMutation) Where(ps ...predicate.Token) {
  17469. m.predicates = append(m.predicates, ps...)
  17470. }
  17471. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  17472. // users can use type-assertion to append predicates that do not depend on any generated package.
  17473. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  17474. p := make([]predicate.Token, len(ps))
  17475. for i := range ps {
  17476. p[i] = ps[i]
  17477. }
  17478. m.Where(p...)
  17479. }
  17480. // Op returns the operation name.
  17481. func (m *TokenMutation) Op() Op {
  17482. return m.op
  17483. }
  17484. // SetOp allows setting the mutation operation.
  17485. func (m *TokenMutation) SetOp(op Op) {
  17486. m.op = op
  17487. }
  17488. // Type returns the node type of this mutation (Token).
  17489. func (m *TokenMutation) Type() string {
  17490. return m.typ
  17491. }
  17492. // Fields returns all fields that were changed during this mutation. Note that in
  17493. // order to get all numeric fields that were incremented/decremented, call
  17494. // AddedFields().
  17495. func (m *TokenMutation) Fields() []string {
  17496. fields := make([]string, 0, 6)
  17497. if m.created_at != nil {
  17498. fields = append(fields, token.FieldCreatedAt)
  17499. }
  17500. if m.updated_at != nil {
  17501. fields = append(fields, token.FieldUpdatedAt)
  17502. }
  17503. if m.deleted_at != nil {
  17504. fields = append(fields, token.FieldDeletedAt)
  17505. }
  17506. if m.expire_at != nil {
  17507. fields = append(fields, token.FieldExpireAt)
  17508. }
  17509. if m.token != nil {
  17510. fields = append(fields, token.FieldToken)
  17511. }
  17512. if m.mac != nil {
  17513. fields = append(fields, token.FieldMAC)
  17514. }
  17515. return fields
  17516. }
  17517. // Field returns the value of a field with the given name. The second boolean
  17518. // return value indicates that this field was not set, or was not defined in the
  17519. // schema.
  17520. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  17521. switch name {
  17522. case token.FieldCreatedAt:
  17523. return m.CreatedAt()
  17524. case token.FieldUpdatedAt:
  17525. return m.UpdatedAt()
  17526. case token.FieldDeletedAt:
  17527. return m.DeletedAt()
  17528. case token.FieldExpireAt:
  17529. return m.ExpireAt()
  17530. case token.FieldToken:
  17531. return m.Token()
  17532. case token.FieldMAC:
  17533. return m.MAC()
  17534. }
  17535. return nil, false
  17536. }
  17537. // OldField returns the old value of the field from the database. An error is
  17538. // returned if the mutation operation is not UpdateOne, or the query to the
  17539. // database failed.
  17540. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17541. switch name {
  17542. case token.FieldCreatedAt:
  17543. return m.OldCreatedAt(ctx)
  17544. case token.FieldUpdatedAt:
  17545. return m.OldUpdatedAt(ctx)
  17546. case token.FieldDeletedAt:
  17547. return m.OldDeletedAt(ctx)
  17548. case token.FieldExpireAt:
  17549. return m.OldExpireAt(ctx)
  17550. case token.FieldToken:
  17551. return m.OldToken(ctx)
  17552. case token.FieldMAC:
  17553. return m.OldMAC(ctx)
  17554. }
  17555. return nil, fmt.Errorf("unknown Token field %s", name)
  17556. }
  17557. // SetField sets the value of a field with the given name. It returns an error if
  17558. // the field is not defined in the schema, or if the type mismatched the field
  17559. // type.
  17560. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  17561. switch name {
  17562. case token.FieldCreatedAt:
  17563. v, ok := value.(time.Time)
  17564. if !ok {
  17565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17566. }
  17567. m.SetCreatedAt(v)
  17568. return nil
  17569. case token.FieldUpdatedAt:
  17570. v, ok := value.(time.Time)
  17571. if !ok {
  17572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17573. }
  17574. m.SetUpdatedAt(v)
  17575. return nil
  17576. case token.FieldDeletedAt:
  17577. v, ok := value.(time.Time)
  17578. if !ok {
  17579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17580. }
  17581. m.SetDeletedAt(v)
  17582. return nil
  17583. case token.FieldExpireAt:
  17584. v, ok := value.(time.Time)
  17585. if !ok {
  17586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17587. }
  17588. m.SetExpireAt(v)
  17589. return nil
  17590. case token.FieldToken:
  17591. v, ok := value.(string)
  17592. if !ok {
  17593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17594. }
  17595. m.SetToken(v)
  17596. return nil
  17597. case token.FieldMAC:
  17598. v, ok := value.(string)
  17599. if !ok {
  17600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17601. }
  17602. m.SetMAC(v)
  17603. return nil
  17604. }
  17605. return fmt.Errorf("unknown Token field %s", name)
  17606. }
  17607. // AddedFields returns all numeric fields that were incremented/decremented during
  17608. // this mutation.
  17609. func (m *TokenMutation) AddedFields() []string {
  17610. return nil
  17611. }
  17612. // AddedField returns the numeric value that was incremented/decremented on a field
  17613. // with the given name. The second boolean return value indicates that this field
  17614. // was not set, or was not defined in the schema.
  17615. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  17616. return nil, false
  17617. }
  17618. // AddField adds the value to the field with the given name. It returns an error if
  17619. // the field is not defined in the schema, or if the type mismatched the field
  17620. // type.
  17621. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  17622. switch name {
  17623. }
  17624. return fmt.Errorf("unknown Token numeric field %s", name)
  17625. }
  17626. // ClearedFields returns all nullable fields that were cleared during this
  17627. // mutation.
  17628. func (m *TokenMutation) ClearedFields() []string {
  17629. var fields []string
  17630. if m.FieldCleared(token.FieldDeletedAt) {
  17631. fields = append(fields, token.FieldDeletedAt)
  17632. }
  17633. if m.FieldCleared(token.FieldExpireAt) {
  17634. fields = append(fields, token.FieldExpireAt)
  17635. }
  17636. if m.FieldCleared(token.FieldToken) {
  17637. fields = append(fields, token.FieldToken)
  17638. }
  17639. return fields
  17640. }
  17641. // FieldCleared returns a boolean indicating if a field with the given name was
  17642. // cleared in this mutation.
  17643. func (m *TokenMutation) FieldCleared(name string) bool {
  17644. _, ok := m.clearedFields[name]
  17645. return ok
  17646. }
  17647. // ClearField clears the value of the field with the given name. It returns an
  17648. // error if the field is not defined in the schema.
  17649. func (m *TokenMutation) ClearField(name string) error {
  17650. switch name {
  17651. case token.FieldDeletedAt:
  17652. m.ClearDeletedAt()
  17653. return nil
  17654. case token.FieldExpireAt:
  17655. m.ClearExpireAt()
  17656. return nil
  17657. case token.FieldToken:
  17658. m.ClearToken()
  17659. return nil
  17660. }
  17661. return fmt.Errorf("unknown Token nullable field %s", name)
  17662. }
  17663. // ResetField resets all changes in the mutation for the field with the given name.
  17664. // It returns an error if the field is not defined in the schema.
  17665. func (m *TokenMutation) ResetField(name string) error {
  17666. switch name {
  17667. case token.FieldCreatedAt:
  17668. m.ResetCreatedAt()
  17669. return nil
  17670. case token.FieldUpdatedAt:
  17671. m.ResetUpdatedAt()
  17672. return nil
  17673. case token.FieldDeletedAt:
  17674. m.ResetDeletedAt()
  17675. return nil
  17676. case token.FieldExpireAt:
  17677. m.ResetExpireAt()
  17678. return nil
  17679. case token.FieldToken:
  17680. m.ResetToken()
  17681. return nil
  17682. case token.FieldMAC:
  17683. m.ResetMAC()
  17684. return nil
  17685. }
  17686. return fmt.Errorf("unknown Token field %s", name)
  17687. }
  17688. // AddedEdges returns all edge names that were set/added in this mutation.
  17689. func (m *TokenMutation) AddedEdges() []string {
  17690. edges := make([]string, 0, 0)
  17691. return edges
  17692. }
  17693. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17694. // name in this mutation.
  17695. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  17696. return nil
  17697. }
  17698. // RemovedEdges returns all edge names that were removed in this mutation.
  17699. func (m *TokenMutation) RemovedEdges() []string {
  17700. edges := make([]string, 0, 0)
  17701. return edges
  17702. }
  17703. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17704. // the given name in this mutation.
  17705. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  17706. return nil
  17707. }
  17708. // ClearedEdges returns all edge names that were cleared in this mutation.
  17709. func (m *TokenMutation) ClearedEdges() []string {
  17710. edges := make([]string, 0, 0)
  17711. return edges
  17712. }
  17713. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17714. // was cleared in this mutation.
  17715. func (m *TokenMutation) EdgeCleared(name string) bool {
  17716. return false
  17717. }
  17718. // ClearEdge clears the value of the edge with the given name. It returns an error
  17719. // if that edge is not defined in the schema.
  17720. func (m *TokenMutation) ClearEdge(name string) error {
  17721. return fmt.Errorf("unknown Token unique edge %s", name)
  17722. }
  17723. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17724. // It returns an error if the edge is not defined in the schema.
  17725. func (m *TokenMutation) ResetEdge(name string) error {
  17726. return fmt.Errorf("unknown Token edge %s", name)
  17727. }
  17728. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  17729. type TutorialMutation struct {
  17730. config
  17731. op Op
  17732. typ string
  17733. id *uint64
  17734. created_at *time.Time
  17735. updated_at *time.Time
  17736. deleted_at *time.Time
  17737. index *int
  17738. addindex *int
  17739. title *string
  17740. content *string
  17741. organization_id *uint64
  17742. addorganization_id *int64
  17743. clearedFields map[string]struct{}
  17744. employee *uint64
  17745. clearedemployee bool
  17746. done bool
  17747. oldValue func(context.Context) (*Tutorial, error)
  17748. predicates []predicate.Tutorial
  17749. }
  17750. var _ ent.Mutation = (*TutorialMutation)(nil)
  17751. // tutorialOption allows management of the mutation configuration using functional options.
  17752. type tutorialOption func(*TutorialMutation)
  17753. // newTutorialMutation creates new mutation for the Tutorial entity.
  17754. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  17755. m := &TutorialMutation{
  17756. config: c,
  17757. op: op,
  17758. typ: TypeTutorial,
  17759. clearedFields: make(map[string]struct{}),
  17760. }
  17761. for _, opt := range opts {
  17762. opt(m)
  17763. }
  17764. return m
  17765. }
  17766. // withTutorialID sets the ID field of the mutation.
  17767. func withTutorialID(id uint64) tutorialOption {
  17768. return func(m *TutorialMutation) {
  17769. var (
  17770. err error
  17771. once sync.Once
  17772. value *Tutorial
  17773. )
  17774. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  17775. once.Do(func() {
  17776. if m.done {
  17777. err = errors.New("querying old values post mutation is not allowed")
  17778. } else {
  17779. value, err = m.Client().Tutorial.Get(ctx, id)
  17780. }
  17781. })
  17782. return value, err
  17783. }
  17784. m.id = &id
  17785. }
  17786. }
  17787. // withTutorial sets the old Tutorial of the mutation.
  17788. func withTutorial(node *Tutorial) tutorialOption {
  17789. return func(m *TutorialMutation) {
  17790. m.oldValue = func(context.Context) (*Tutorial, error) {
  17791. return node, nil
  17792. }
  17793. m.id = &node.ID
  17794. }
  17795. }
  17796. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17797. // executed in a transaction (ent.Tx), a transactional client is returned.
  17798. func (m TutorialMutation) Client() *Client {
  17799. client := &Client{config: m.config}
  17800. client.init()
  17801. return client
  17802. }
  17803. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17804. // it returns an error otherwise.
  17805. func (m TutorialMutation) Tx() (*Tx, error) {
  17806. if _, ok := m.driver.(*txDriver); !ok {
  17807. return nil, errors.New("ent: mutation is not running in a transaction")
  17808. }
  17809. tx := &Tx{config: m.config}
  17810. tx.init()
  17811. return tx, nil
  17812. }
  17813. // SetID sets the value of the id field. Note that this
  17814. // operation is only accepted on creation of Tutorial entities.
  17815. func (m *TutorialMutation) SetID(id uint64) {
  17816. m.id = &id
  17817. }
  17818. // ID returns the ID value in the mutation. Note that the ID is only available
  17819. // if it was provided to the builder or after it was returned from the database.
  17820. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  17821. if m.id == nil {
  17822. return
  17823. }
  17824. return *m.id, true
  17825. }
  17826. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17827. // That means, if the mutation is applied within a transaction with an isolation level such
  17828. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17829. // or updated by the mutation.
  17830. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  17831. switch {
  17832. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17833. id, exists := m.ID()
  17834. if exists {
  17835. return []uint64{id}, nil
  17836. }
  17837. fallthrough
  17838. case m.op.Is(OpUpdate | OpDelete):
  17839. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  17840. default:
  17841. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17842. }
  17843. }
  17844. // SetCreatedAt sets the "created_at" field.
  17845. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  17846. m.created_at = &t
  17847. }
  17848. // CreatedAt returns the value of the "created_at" field in the mutation.
  17849. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  17850. v := m.created_at
  17851. if v == nil {
  17852. return
  17853. }
  17854. return *v, true
  17855. }
  17856. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  17857. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17859. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17860. if !m.op.Is(OpUpdateOne) {
  17861. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17862. }
  17863. if m.id == nil || m.oldValue == nil {
  17864. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17865. }
  17866. oldValue, err := m.oldValue(ctx)
  17867. if err != nil {
  17868. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17869. }
  17870. return oldValue.CreatedAt, nil
  17871. }
  17872. // ResetCreatedAt resets all changes to the "created_at" field.
  17873. func (m *TutorialMutation) ResetCreatedAt() {
  17874. m.created_at = nil
  17875. }
  17876. // SetUpdatedAt sets the "updated_at" field.
  17877. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  17878. m.updated_at = &t
  17879. }
  17880. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17881. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  17882. v := m.updated_at
  17883. if v == nil {
  17884. return
  17885. }
  17886. return *v, true
  17887. }
  17888. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  17889. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17891. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17892. if !m.op.Is(OpUpdateOne) {
  17893. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17894. }
  17895. if m.id == nil || m.oldValue == nil {
  17896. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17897. }
  17898. oldValue, err := m.oldValue(ctx)
  17899. if err != nil {
  17900. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17901. }
  17902. return oldValue.UpdatedAt, nil
  17903. }
  17904. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17905. func (m *TutorialMutation) ResetUpdatedAt() {
  17906. m.updated_at = nil
  17907. }
  17908. // SetDeletedAt sets the "deleted_at" field.
  17909. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  17910. m.deleted_at = &t
  17911. }
  17912. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17913. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  17914. v := m.deleted_at
  17915. if v == nil {
  17916. return
  17917. }
  17918. return *v, true
  17919. }
  17920. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  17921. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17923. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17924. if !m.op.Is(OpUpdateOne) {
  17925. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17926. }
  17927. if m.id == nil || m.oldValue == nil {
  17928. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17929. }
  17930. oldValue, err := m.oldValue(ctx)
  17931. if err != nil {
  17932. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17933. }
  17934. return oldValue.DeletedAt, nil
  17935. }
  17936. // ClearDeletedAt clears the value of the "deleted_at" field.
  17937. func (m *TutorialMutation) ClearDeletedAt() {
  17938. m.deleted_at = nil
  17939. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  17940. }
  17941. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17942. func (m *TutorialMutation) DeletedAtCleared() bool {
  17943. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  17944. return ok
  17945. }
  17946. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17947. func (m *TutorialMutation) ResetDeletedAt() {
  17948. m.deleted_at = nil
  17949. delete(m.clearedFields, tutorial.FieldDeletedAt)
  17950. }
  17951. // SetEmployeeID sets the "employee_id" field.
  17952. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  17953. m.employee = &u
  17954. }
  17955. // EmployeeID returns the value of the "employee_id" field in the mutation.
  17956. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  17957. v := m.employee
  17958. if v == nil {
  17959. return
  17960. }
  17961. return *v, true
  17962. }
  17963. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  17964. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17966. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  17967. if !m.op.Is(OpUpdateOne) {
  17968. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  17969. }
  17970. if m.id == nil || m.oldValue == nil {
  17971. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  17972. }
  17973. oldValue, err := m.oldValue(ctx)
  17974. if err != nil {
  17975. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  17976. }
  17977. return oldValue.EmployeeID, nil
  17978. }
  17979. // ResetEmployeeID resets all changes to the "employee_id" field.
  17980. func (m *TutorialMutation) ResetEmployeeID() {
  17981. m.employee = nil
  17982. }
  17983. // SetIndex sets the "index" field.
  17984. func (m *TutorialMutation) SetIndex(i int) {
  17985. m.index = &i
  17986. m.addindex = nil
  17987. }
  17988. // Index returns the value of the "index" field in the mutation.
  17989. func (m *TutorialMutation) Index() (r int, exists bool) {
  17990. v := m.index
  17991. if v == nil {
  17992. return
  17993. }
  17994. return *v, true
  17995. }
  17996. // OldIndex returns the old "index" field's value of the Tutorial entity.
  17997. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  17998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17999. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  18000. if !m.op.Is(OpUpdateOne) {
  18001. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  18002. }
  18003. if m.id == nil || m.oldValue == nil {
  18004. return v, errors.New("OldIndex requires an ID field in the mutation")
  18005. }
  18006. oldValue, err := m.oldValue(ctx)
  18007. if err != nil {
  18008. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  18009. }
  18010. return oldValue.Index, nil
  18011. }
  18012. // AddIndex adds i to the "index" field.
  18013. func (m *TutorialMutation) AddIndex(i int) {
  18014. if m.addindex != nil {
  18015. *m.addindex += i
  18016. } else {
  18017. m.addindex = &i
  18018. }
  18019. }
  18020. // AddedIndex returns the value that was added to the "index" field in this mutation.
  18021. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  18022. v := m.addindex
  18023. if v == nil {
  18024. return
  18025. }
  18026. return *v, true
  18027. }
  18028. // ResetIndex resets all changes to the "index" field.
  18029. func (m *TutorialMutation) ResetIndex() {
  18030. m.index = nil
  18031. m.addindex = nil
  18032. }
  18033. // SetTitle sets the "title" field.
  18034. func (m *TutorialMutation) SetTitle(s string) {
  18035. m.title = &s
  18036. }
  18037. // Title returns the value of the "title" field in the mutation.
  18038. func (m *TutorialMutation) Title() (r string, exists bool) {
  18039. v := m.title
  18040. if v == nil {
  18041. return
  18042. }
  18043. return *v, true
  18044. }
  18045. // OldTitle returns the old "title" field's value of the Tutorial entity.
  18046. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  18047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18048. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  18049. if !m.op.Is(OpUpdateOne) {
  18050. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18051. }
  18052. if m.id == nil || m.oldValue == nil {
  18053. return v, errors.New("OldTitle requires an ID field in the mutation")
  18054. }
  18055. oldValue, err := m.oldValue(ctx)
  18056. if err != nil {
  18057. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18058. }
  18059. return oldValue.Title, nil
  18060. }
  18061. // ResetTitle resets all changes to the "title" field.
  18062. func (m *TutorialMutation) ResetTitle() {
  18063. m.title = nil
  18064. }
  18065. // SetContent sets the "content" field.
  18066. func (m *TutorialMutation) SetContent(s string) {
  18067. m.content = &s
  18068. }
  18069. // Content returns the value of the "content" field in the mutation.
  18070. func (m *TutorialMutation) Content() (r string, exists bool) {
  18071. v := m.content
  18072. if v == nil {
  18073. return
  18074. }
  18075. return *v, true
  18076. }
  18077. // OldContent returns the old "content" field's value of the Tutorial entity.
  18078. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  18079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18080. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  18081. if !m.op.Is(OpUpdateOne) {
  18082. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18083. }
  18084. if m.id == nil || m.oldValue == nil {
  18085. return v, errors.New("OldContent requires an ID field in the mutation")
  18086. }
  18087. oldValue, err := m.oldValue(ctx)
  18088. if err != nil {
  18089. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18090. }
  18091. return oldValue.Content, nil
  18092. }
  18093. // ResetContent resets all changes to the "content" field.
  18094. func (m *TutorialMutation) ResetContent() {
  18095. m.content = nil
  18096. }
  18097. // SetOrganizationID sets the "organization_id" field.
  18098. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  18099. m.organization_id = &u
  18100. m.addorganization_id = nil
  18101. }
  18102. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18103. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  18104. v := m.organization_id
  18105. if v == nil {
  18106. return
  18107. }
  18108. return *v, true
  18109. }
  18110. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  18111. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  18112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18113. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18114. if !m.op.Is(OpUpdateOne) {
  18115. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18116. }
  18117. if m.id == nil || m.oldValue == nil {
  18118. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18119. }
  18120. oldValue, err := m.oldValue(ctx)
  18121. if err != nil {
  18122. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18123. }
  18124. return oldValue.OrganizationID, nil
  18125. }
  18126. // AddOrganizationID adds u to the "organization_id" field.
  18127. func (m *TutorialMutation) AddOrganizationID(u int64) {
  18128. if m.addorganization_id != nil {
  18129. *m.addorganization_id += u
  18130. } else {
  18131. m.addorganization_id = &u
  18132. }
  18133. }
  18134. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18135. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  18136. v := m.addorganization_id
  18137. if v == nil {
  18138. return
  18139. }
  18140. return *v, true
  18141. }
  18142. // ResetOrganizationID resets all changes to the "organization_id" field.
  18143. func (m *TutorialMutation) ResetOrganizationID() {
  18144. m.organization_id = nil
  18145. m.addorganization_id = nil
  18146. }
  18147. // ClearEmployee clears the "employee" edge to the Employee entity.
  18148. func (m *TutorialMutation) ClearEmployee() {
  18149. m.clearedemployee = true
  18150. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  18151. }
  18152. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  18153. func (m *TutorialMutation) EmployeeCleared() bool {
  18154. return m.clearedemployee
  18155. }
  18156. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  18157. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18158. // EmployeeID instead. It exists only for internal usage by the builders.
  18159. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  18160. if id := m.employee; id != nil {
  18161. ids = append(ids, *id)
  18162. }
  18163. return
  18164. }
  18165. // ResetEmployee resets all changes to the "employee" edge.
  18166. func (m *TutorialMutation) ResetEmployee() {
  18167. m.employee = nil
  18168. m.clearedemployee = false
  18169. }
  18170. // Where appends a list predicates to the TutorialMutation builder.
  18171. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  18172. m.predicates = append(m.predicates, ps...)
  18173. }
  18174. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  18175. // users can use type-assertion to append predicates that do not depend on any generated package.
  18176. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  18177. p := make([]predicate.Tutorial, len(ps))
  18178. for i := range ps {
  18179. p[i] = ps[i]
  18180. }
  18181. m.Where(p...)
  18182. }
  18183. // Op returns the operation name.
  18184. func (m *TutorialMutation) Op() Op {
  18185. return m.op
  18186. }
  18187. // SetOp allows setting the mutation operation.
  18188. func (m *TutorialMutation) SetOp(op Op) {
  18189. m.op = op
  18190. }
  18191. // Type returns the node type of this mutation (Tutorial).
  18192. func (m *TutorialMutation) Type() string {
  18193. return m.typ
  18194. }
  18195. // Fields returns all fields that were changed during this mutation. Note that in
  18196. // order to get all numeric fields that were incremented/decremented, call
  18197. // AddedFields().
  18198. func (m *TutorialMutation) Fields() []string {
  18199. fields := make([]string, 0, 8)
  18200. if m.created_at != nil {
  18201. fields = append(fields, tutorial.FieldCreatedAt)
  18202. }
  18203. if m.updated_at != nil {
  18204. fields = append(fields, tutorial.FieldUpdatedAt)
  18205. }
  18206. if m.deleted_at != nil {
  18207. fields = append(fields, tutorial.FieldDeletedAt)
  18208. }
  18209. if m.employee != nil {
  18210. fields = append(fields, tutorial.FieldEmployeeID)
  18211. }
  18212. if m.index != nil {
  18213. fields = append(fields, tutorial.FieldIndex)
  18214. }
  18215. if m.title != nil {
  18216. fields = append(fields, tutorial.FieldTitle)
  18217. }
  18218. if m.content != nil {
  18219. fields = append(fields, tutorial.FieldContent)
  18220. }
  18221. if m.organization_id != nil {
  18222. fields = append(fields, tutorial.FieldOrganizationID)
  18223. }
  18224. return fields
  18225. }
  18226. // Field returns the value of a field with the given name. The second boolean
  18227. // return value indicates that this field was not set, or was not defined in the
  18228. // schema.
  18229. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  18230. switch name {
  18231. case tutorial.FieldCreatedAt:
  18232. return m.CreatedAt()
  18233. case tutorial.FieldUpdatedAt:
  18234. return m.UpdatedAt()
  18235. case tutorial.FieldDeletedAt:
  18236. return m.DeletedAt()
  18237. case tutorial.FieldEmployeeID:
  18238. return m.EmployeeID()
  18239. case tutorial.FieldIndex:
  18240. return m.Index()
  18241. case tutorial.FieldTitle:
  18242. return m.Title()
  18243. case tutorial.FieldContent:
  18244. return m.Content()
  18245. case tutorial.FieldOrganizationID:
  18246. return m.OrganizationID()
  18247. }
  18248. return nil, false
  18249. }
  18250. // OldField returns the old value of the field from the database. An error is
  18251. // returned if the mutation operation is not UpdateOne, or the query to the
  18252. // database failed.
  18253. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18254. switch name {
  18255. case tutorial.FieldCreatedAt:
  18256. return m.OldCreatedAt(ctx)
  18257. case tutorial.FieldUpdatedAt:
  18258. return m.OldUpdatedAt(ctx)
  18259. case tutorial.FieldDeletedAt:
  18260. return m.OldDeletedAt(ctx)
  18261. case tutorial.FieldEmployeeID:
  18262. return m.OldEmployeeID(ctx)
  18263. case tutorial.FieldIndex:
  18264. return m.OldIndex(ctx)
  18265. case tutorial.FieldTitle:
  18266. return m.OldTitle(ctx)
  18267. case tutorial.FieldContent:
  18268. return m.OldContent(ctx)
  18269. case tutorial.FieldOrganizationID:
  18270. return m.OldOrganizationID(ctx)
  18271. }
  18272. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  18273. }
  18274. // SetField sets the value of a field with the given name. It returns an error if
  18275. // the field is not defined in the schema, or if the type mismatched the field
  18276. // type.
  18277. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  18278. switch name {
  18279. case tutorial.FieldCreatedAt:
  18280. v, ok := value.(time.Time)
  18281. if !ok {
  18282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18283. }
  18284. m.SetCreatedAt(v)
  18285. return nil
  18286. case tutorial.FieldUpdatedAt:
  18287. v, ok := value.(time.Time)
  18288. if !ok {
  18289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18290. }
  18291. m.SetUpdatedAt(v)
  18292. return nil
  18293. case tutorial.FieldDeletedAt:
  18294. v, ok := value.(time.Time)
  18295. if !ok {
  18296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18297. }
  18298. m.SetDeletedAt(v)
  18299. return nil
  18300. case tutorial.FieldEmployeeID:
  18301. v, ok := value.(uint64)
  18302. if !ok {
  18303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18304. }
  18305. m.SetEmployeeID(v)
  18306. return nil
  18307. case tutorial.FieldIndex:
  18308. v, ok := value.(int)
  18309. if !ok {
  18310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18311. }
  18312. m.SetIndex(v)
  18313. return nil
  18314. case tutorial.FieldTitle:
  18315. v, ok := value.(string)
  18316. if !ok {
  18317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18318. }
  18319. m.SetTitle(v)
  18320. return nil
  18321. case tutorial.FieldContent:
  18322. v, ok := value.(string)
  18323. if !ok {
  18324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18325. }
  18326. m.SetContent(v)
  18327. return nil
  18328. case tutorial.FieldOrganizationID:
  18329. v, ok := value.(uint64)
  18330. if !ok {
  18331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18332. }
  18333. m.SetOrganizationID(v)
  18334. return nil
  18335. }
  18336. return fmt.Errorf("unknown Tutorial field %s", name)
  18337. }
  18338. // AddedFields returns all numeric fields that were incremented/decremented during
  18339. // this mutation.
  18340. func (m *TutorialMutation) AddedFields() []string {
  18341. var fields []string
  18342. if m.addindex != nil {
  18343. fields = append(fields, tutorial.FieldIndex)
  18344. }
  18345. if m.addorganization_id != nil {
  18346. fields = append(fields, tutorial.FieldOrganizationID)
  18347. }
  18348. return fields
  18349. }
  18350. // AddedField returns the numeric value that was incremented/decremented on a field
  18351. // with the given name. The second boolean return value indicates that this field
  18352. // was not set, or was not defined in the schema.
  18353. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  18354. switch name {
  18355. case tutorial.FieldIndex:
  18356. return m.AddedIndex()
  18357. case tutorial.FieldOrganizationID:
  18358. return m.AddedOrganizationID()
  18359. }
  18360. return nil, false
  18361. }
  18362. // AddField adds the value to the field with the given name. It returns an error if
  18363. // the field is not defined in the schema, or if the type mismatched the field
  18364. // type.
  18365. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  18366. switch name {
  18367. case tutorial.FieldIndex:
  18368. v, ok := value.(int)
  18369. if !ok {
  18370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18371. }
  18372. m.AddIndex(v)
  18373. return nil
  18374. case tutorial.FieldOrganizationID:
  18375. v, ok := value.(int64)
  18376. if !ok {
  18377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18378. }
  18379. m.AddOrganizationID(v)
  18380. return nil
  18381. }
  18382. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  18383. }
  18384. // ClearedFields returns all nullable fields that were cleared during this
  18385. // mutation.
  18386. func (m *TutorialMutation) ClearedFields() []string {
  18387. var fields []string
  18388. if m.FieldCleared(tutorial.FieldDeletedAt) {
  18389. fields = append(fields, tutorial.FieldDeletedAt)
  18390. }
  18391. return fields
  18392. }
  18393. // FieldCleared returns a boolean indicating if a field with the given name was
  18394. // cleared in this mutation.
  18395. func (m *TutorialMutation) FieldCleared(name string) bool {
  18396. _, ok := m.clearedFields[name]
  18397. return ok
  18398. }
  18399. // ClearField clears the value of the field with the given name. It returns an
  18400. // error if the field is not defined in the schema.
  18401. func (m *TutorialMutation) ClearField(name string) error {
  18402. switch name {
  18403. case tutorial.FieldDeletedAt:
  18404. m.ClearDeletedAt()
  18405. return nil
  18406. }
  18407. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  18408. }
  18409. // ResetField resets all changes in the mutation for the field with the given name.
  18410. // It returns an error if the field is not defined in the schema.
  18411. func (m *TutorialMutation) ResetField(name string) error {
  18412. switch name {
  18413. case tutorial.FieldCreatedAt:
  18414. m.ResetCreatedAt()
  18415. return nil
  18416. case tutorial.FieldUpdatedAt:
  18417. m.ResetUpdatedAt()
  18418. return nil
  18419. case tutorial.FieldDeletedAt:
  18420. m.ResetDeletedAt()
  18421. return nil
  18422. case tutorial.FieldEmployeeID:
  18423. m.ResetEmployeeID()
  18424. return nil
  18425. case tutorial.FieldIndex:
  18426. m.ResetIndex()
  18427. return nil
  18428. case tutorial.FieldTitle:
  18429. m.ResetTitle()
  18430. return nil
  18431. case tutorial.FieldContent:
  18432. m.ResetContent()
  18433. return nil
  18434. case tutorial.FieldOrganizationID:
  18435. m.ResetOrganizationID()
  18436. return nil
  18437. }
  18438. return fmt.Errorf("unknown Tutorial field %s", name)
  18439. }
  18440. // AddedEdges returns all edge names that were set/added in this mutation.
  18441. func (m *TutorialMutation) AddedEdges() []string {
  18442. edges := make([]string, 0, 1)
  18443. if m.employee != nil {
  18444. edges = append(edges, tutorial.EdgeEmployee)
  18445. }
  18446. return edges
  18447. }
  18448. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18449. // name in this mutation.
  18450. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  18451. switch name {
  18452. case tutorial.EdgeEmployee:
  18453. if id := m.employee; id != nil {
  18454. return []ent.Value{*id}
  18455. }
  18456. }
  18457. return nil
  18458. }
  18459. // RemovedEdges returns all edge names that were removed in this mutation.
  18460. func (m *TutorialMutation) RemovedEdges() []string {
  18461. edges := make([]string, 0, 1)
  18462. return edges
  18463. }
  18464. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18465. // the given name in this mutation.
  18466. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  18467. return nil
  18468. }
  18469. // ClearedEdges returns all edge names that were cleared in this mutation.
  18470. func (m *TutorialMutation) ClearedEdges() []string {
  18471. edges := make([]string, 0, 1)
  18472. if m.clearedemployee {
  18473. edges = append(edges, tutorial.EdgeEmployee)
  18474. }
  18475. return edges
  18476. }
  18477. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18478. // was cleared in this mutation.
  18479. func (m *TutorialMutation) EdgeCleared(name string) bool {
  18480. switch name {
  18481. case tutorial.EdgeEmployee:
  18482. return m.clearedemployee
  18483. }
  18484. return false
  18485. }
  18486. // ClearEdge clears the value of the edge with the given name. It returns an error
  18487. // if that edge is not defined in the schema.
  18488. func (m *TutorialMutation) ClearEdge(name string) error {
  18489. switch name {
  18490. case tutorial.EdgeEmployee:
  18491. m.ClearEmployee()
  18492. return nil
  18493. }
  18494. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  18495. }
  18496. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18497. // It returns an error if the edge is not defined in the schema.
  18498. func (m *TutorialMutation) ResetEdge(name string) error {
  18499. switch name {
  18500. case tutorial.EdgeEmployee:
  18501. m.ResetEmployee()
  18502. return nil
  18503. }
  18504. return fmt.Errorf("unknown Tutorial edge %s", name)
  18505. }
  18506. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  18507. type WorkExperienceMutation struct {
  18508. config
  18509. op Op
  18510. typ string
  18511. id *uint64
  18512. created_at *time.Time
  18513. updated_at *time.Time
  18514. deleted_at *time.Time
  18515. start_date *time.Time
  18516. end_date *time.Time
  18517. company *string
  18518. experience *string
  18519. organization_id *uint64
  18520. addorganization_id *int64
  18521. clearedFields map[string]struct{}
  18522. employee *uint64
  18523. clearedemployee bool
  18524. done bool
  18525. oldValue func(context.Context) (*WorkExperience, error)
  18526. predicates []predicate.WorkExperience
  18527. }
  18528. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  18529. // workexperienceOption allows management of the mutation configuration using functional options.
  18530. type workexperienceOption func(*WorkExperienceMutation)
  18531. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  18532. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  18533. m := &WorkExperienceMutation{
  18534. config: c,
  18535. op: op,
  18536. typ: TypeWorkExperience,
  18537. clearedFields: make(map[string]struct{}),
  18538. }
  18539. for _, opt := range opts {
  18540. opt(m)
  18541. }
  18542. return m
  18543. }
  18544. // withWorkExperienceID sets the ID field of the mutation.
  18545. func withWorkExperienceID(id uint64) workexperienceOption {
  18546. return func(m *WorkExperienceMutation) {
  18547. var (
  18548. err error
  18549. once sync.Once
  18550. value *WorkExperience
  18551. )
  18552. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  18553. once.Do(func() {
  18554. if m.done {
  18555. err = errors.New("querying old values post mutation is not allowed")
  18556. } else {
  18557. value, err = m.Client().WorkExperience.Get(ctx, id)
  18558. }
  18559. })
  18560. return value, err
  18561. }
  18562. m.id = &id
  18563. }
  18564. }
  18565. // withWorkExperience sets the old WorkExperience of the mutation.
  18566. func withWorkExperience(node *WorkExperience) workexperienceOption {
  18567. return func(m *WorkExperienceMutation) {
  18568. m.oldValue = func(context.Context) (*WorkExperience, error) {
  18569. return node, nil
  18570. }
  18571. m.id = &node.ID
  18572. }
  18573. }
  18574. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18575. // executed in a transaction (ent.Tx), a transactional client is returned.
  18576. func (m WorkExperienceMutation) Client() *Client {
  18577. client := &Client{config: m.config}
  18578. client.init()
  18579. return client
  18580. }
  18581. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18582. // it returns an error otherwise.
  18583. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  18584. if _, ok := m.driver.(*txDriver); !ok {
  18585. return nil, errors.New("ent: mutation is not running in a transaction")
  18586. }
  18587. tx := &Tx{config: m.config}
  18588. tx.init()
  18589. return tx, nil
  18590. }
  18591. // SetID sets the value of the id field. Note that this
  18592. // operation is only accepted on creation of WorkExperience entities.
  18593. func (m *WorkExperienceMutation) SetID(id uint64) {
  18594. m.id = &id
  18595. }
  18596. // ID returns the ID value in the mutation. Note that the ID is only available
  18597. // if it was provided to the builder or after it was returned from the database.
  18598. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  18599. if m.id == nil {
  18600. return
  18601. }
  18602. return *m.id, true
  18603. }
  18604. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18605. // That means, if the mutation is applied within a transaction with an isolation level such
  18606. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18607. // or updated by the mutation.
  18608. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  18609. switch {
  18610. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18611. id, exists := m.ID()
  18612. if exists {
  18613. return []uint64{id}, nil
  18614. }
  18615. fallthrough
  18616. case m.op.Is(OpUpdate | OpDelete):
  18617. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  18618. default:
  18619. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18620. }
  18621. }
  18622. // SetCreatedAt sets the "created_at" field.
  18623. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  18624. m.created_at = &t
  18625. }
  18626. // CreatedAt returns the value of the "created_at" field in the mutation.
  18627. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  18628. v := m.created_at
  18629. if v == nil {
  18630. return
  18631. }
  18632. return *v, true
  18633. }
  18634. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  18635. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18637. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18638. if !m.op.Is(OpUpdateOne) {
  18639. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18640. }
  18641. if m.id == nil || m.oldValue == nil {
  18642. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18643. }
  18644. oldValue, err := m.oldValue(ctx)
  18645. if err != nil {
  18646. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18647. }
  18648. return oldValue.CreatedAt, nil
  18649. }
  18650. // ResetCreatedAt resets all changes to the "created_at" field.
  18651. func (m *WorkExperienceMutation) ResetCreatedAt() {
  18652. m.created_at = nil
  18653. }
  18654. // SetUpdatedAt sets the "updated_at" field.
  18655. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  18656. m.updated_at = &t
  18657. }
  18658. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18659. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  18660. v := m.updated_at
  18661. if v == nil {
  18662. return
  18663. }
  18664. return *v, true
  18665. }
  18666. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  18667. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18669. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18670. if !m.op.Is(OpUpdateOne) {
  18671. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18672. }
  18673. if m.id == nil || m.oldValue == nil {
  18674. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18675. }
  18676. oldValue, err := m.oldValue(ctx)
  18677. if err != nil {
  18678. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18679. }
  18680. return oldValue.UpdatedAt, nil
  18681. }
  18682. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18683. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  18684. m.updated_at = nil
  18685. }
  18686. // SetDeletedAt sets the "deleted_at" field.
  18687. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  18688. m.deleted_at = &t
  18689. }
  18690. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18691. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  18692. v := m.deleted_at
  18693. if v == nil {
  18694. return
  18695. }
  18696. return *v, true
  18697. }
  18698. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  18699. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18701. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18702. if !m.op.Is(OpUpdateOne) {
  18703. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18704. }
  18705. if m.id == nil || m.oldValue == nil {
  18706. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18707. }
  18708. oldValue, err := m.oldValue(ctx)
  18709. if err != nil {
  18710. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18711. }
  18712. return oldValue.DeletedAt, nil
  18713. }
  18714. // ClearDeletedAt clears the value of the "deleted_at" field.
  18715. func (m *WorkExperienceMutation) ClearDeletedAt() {
  18716. m.deleted_at = nil
  18717. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  18718. }
  18719. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18720. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  18721. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  18722. return ok
  18723. }
  18724. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18725. func (m *WorkExperienceMutation) ResetDeletedAt() {
  18726. m.deleted_at = nil
  18727. delete(m.clearedFields, workexperience.FieldDeletedAt)
  18728. }
  18729. // SetEmployeeID sets the "employee_id" field.
  18730. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  18731. m.employee = &u
  18732. }
  18733. // EmployeeID returns the value of the "employee_id" field in the mutation.
  18734. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  18735. v := m.employee
  18736. if v == nil {
  18737. return
  18738. }
  18739. return *v, true
  18740. }
  18741. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  18742. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18744. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  18745. if !m.op.Is(OpUpdateOne) {
  18746. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  18747. }
  18748. if m.id == nil || m.oldValue == nil {
  18749. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  18750. }
  18751. oldValue, err := m.oldValue(ctx)
  18752. if err != nil {
  18753. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  18754. }
  18755. return oldValue.EmployeeID, nil
  18756. }
  18757. // ResetEmployeeID resets all changes to the "employee_id" field.
  18758. func (m *WorkExperienceMutation) ResetEmployeeID() {
  18759. m.employee = nil
  18760. }
  18761. // SetStartDate sets the "start_date" field.
  18762. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  18763. m.start_date = &t
  18764. }
  18765. // StartDate returns the value of the "start_date" field in the mutation.
  18766. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  18767. v := m.start_date
  18768. if v == nil {
  18769. return
  18770. }
  18771. return *v, true
  18772. }
  18773. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  18774. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18776. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  18777. if !m.op.Is(OpUpdateOne) {
  18778. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  18779. }
  18780. if m.id == nil || m.oldValue == nil {
  18781. return v, errors.New("OldStartDate requires an ID field in the mutation")
  18782. }
  18783. oldValue, err := m.oldValue(ctx)
  18784. if err != nil {
  18785. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  18786. }
  18787. return oldValue.StartDate, nil
  18788. }
  18789. // ResetStartDate resets all changes to the "start_date" field.
  18790. func (m *WorkExperienceMutation) ResetStartDate() {
  18791. m.start_date = nil
  18792. }
  18793. // SetEndDate sets the "end_date" field.
  18794. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  18795. m.end_date = &t
  18796. }
  18797. // EndDate returns the value of the "end_date" field in the mutation.
  18798. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  18799. v := m.end_date
  18800. if v == nil {
  18801. return
  18802. }
  18803. return *v, true
  18804. }
  18805. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  18806. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18808. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  18809. if !m.op.Is(OpUpdateOne) {
  18810. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  18811. }
  18812. if m.id == nil || m.oldValue == nil {
  18813. return v, errors.New("OldEndDate requires an ID field in the mutation")
  18814. }
  18815. oldValue, err := m.oldValue(ctx)
  18816. if err != nil {
  18817. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  18818. }
  18819. return oldValue.EndDate, nil
  18820. }
  18821. // ResetEndDate resets all changes to the "end_date" field.
  18822. func (m *WorkExperienceMutation) ResetEndDate() {
  18823. m.end_date = nil
  18824. }
  18825. // SetCompany sets the "company" field.
  18826. func (m *WorkExperienceMutation) SetCompany(s string) {
  18827. m.company = &s
  18828. }
  18829. // Company returns the value of the "company" field in the mutation.
  18830. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  18831. v := m.company
  18832. if v == nil {
  18833. return
  18834. }
  18835. return *v, true
  18836. }
  18837. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  18838. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18840. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  18841. if !m.op.Is(OpUpdateOne) {
  18842. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  18843. }
  18844. if m.id == nil || m.oldValue == nil {
  18845. return v, errors.New("OldCompany requires an ID field in the mutation")
  18846. }
  18847. oldValue, err := m.oldValue(ctx)
  18848. if err != nil {
  18849. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  18850. }
  18851. return oldValue.Company, nil
  18852. }
  18853. // ResetCompany resets all changes to the "company" field.
  18854. func (m *WorkExperienceMutation) ResetCompany() {
  18855. m.company = nil
  18856. }
  18857. // SetExperience sets the "experience" field.
  18858. func (m *WorkExperienceMutation) SetExperience(s string) {
  18859. m.experience = &s
  18860. }
  18861. // Experience returns the value of the "experience" field in the mutation.
  18862. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  18863. v := m.experience
  18864. if v == nil {
  18865. return
  18866. }
  18867. return *v, true
  18868. }
  18869. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  18870. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18872. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  18873. if !m.op.Is(OpUpdateOne) {
  18874. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  18875. }
  18876. if m.id == nil || m.oldValue == nil {
  18877. return v, errors.New("OldExperience requires an ID field in the mutation")
  18878. }
  18879. oldValue, err := m.oldValue(ctx)
  18880. if err != nil {
  18881. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  18882. }
  18883. return oldValue.Experience, nil
  18884. }
  18885. // ResetExperience resets all changes to the "experience" field.
  18886. func (m *WorkExperienceMutation) ResetExperience() {
  18887. m.experience = nil
  18888. }
  18889. // SetOrganizationID sets the "organization_id" field.
  18890. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  18891. m.organization_id = &u
  18892. m.addorganization_id = nil
  18893. }
  18894. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18895. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  18896. v := m.organization_id
  18897. if v == nil {
  18898. return
  18899. }
  18900. return *v, true
  18901. }
  18902. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  18903. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  18904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18905. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18906. if !m.op.Is(OpUpdateOne) {
  18907. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18908. }
  18909. if m.id == nil || m.oldValue == nil {
  18910. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18911. }
  18912. oldValue, err := m.oldValue(ctx)
  18913. if err != nil {
  18914. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18915. }
  18916. return oldValue.OrganizationID, nil
  18917. }
  18918. // AddOrganizationID adds u to the "organization_id" field.
  18919. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  18920. if m.addorganization_id != nil {
  18921. *m.addorganization_id += u
  18922. } else {
  18923. m.addorganization_id = &u
  18924. }
  18925. }
  18926. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18927. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  18928. v := m.addorganization_id
  18929. if v == nil {
  18930. return
  18931. }
  18932. return *v, true
  18933. }
  18934. // ResetOrganizationID resets all changes to the "organization_id" field.
  18935. func (m *WorkExperienceMutation) ResetOrganizationID() {
  18936. m.organization_id = nil
  18937. m.addorganization_id = nil
  18938. }
  18939. // ClearEmployee clears the "employee" edge to the Employee entity.
  18940. func (m *WorkExperienceMutation) ClearEmployee() {
  18941. m.clearedemployee = true
  18942. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  18943. }
  18944. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  18945. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  18946. return m.clearedemployee
  18947. }
  18948. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  18949. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18950. // EmployeeID instead. It exists only for internal usage by the builders.
  18951. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  18952. if id := m.employee; id != nil {
  18953. ids = append(ids, *id)
  18954. }
  18955. return
  18956. }
  18957. // ResetEmployee resets all changes to the "employee" edge.
  18958. func (m *WorkExperienceMutation) ResetEmployee() {
  18959. m.employee = nil
  18960. m.clearedemployee = false
  18961. }
  18962. // Where appends a list predicates to the WorkExperienceMutation builder.
  18963. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  18964. m.predicates = append(m.predicates, ps...)
  18965. }
  18966. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  18967. // users can use type-assertion to append predicates that do not depend on any generated package.
  18968. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  18969. p := make([]predicate.WorkExperience, len(ps))
  18970. for i := range ps {
  18971. p[i] = ps[i]
  18972. }
  18973. m.Where(p...)
  18974. }
  18975. // Op returns the operation name.
  18976. func (m *WorkExperienceMutation) Op() Op {
  18977. return m.op
  18978. }
  18979. // SetOp allows setting the mutation operation.
  18980. func (m *WorkExperienceMutation) SetOp(op Op) {
  18981. m.op = op
  18982. }
  18983. // Type returns the node type of this mutation (WorkExperience).
  18984. func (m *WorkExperienceMutation) Type() string {
  18985. return m.typ
  18986. }
  18987. // Fields returns all fields that were changed during this mutation. Note that in
  18988. // order to get all numeric fields that were incremented/decremented, call
  18989. // AddedFields().
  18990. func (m *WorkExperienceMutation) Fields() []string {
  18991. fields := make([]string, 0, 9)
  18992. if m.created_at != nil {
  18993. fields = append(fields, workexperience.FieldCreatedAt)
  18994. }
  18995. if m.updated_at != nil {
  18996. fields = append(fields, workexperience.FieldUpdatedAt)
  18997. }
  18998. if m.deleted_at != nil {
  18999. fields = append(fields, workexperience.FieldDeletedAt)
  19000. }
  19001. if m.employee != nil {
  19002. fields = append(fields, workexperience.FieldEmployeeID)
  19003. }
  19004. if m.start_date != nil {
  19005. fields = append(fields, workexperience.FieldStartDate)
  19006. }
  19007. if m.end_date != nil {
  19008. fields = append(fields, workexperience.FieldEndDate)
  19009. }
  19010. if m.company != nil {
  19011. fields = append(fields, workexperience.FieldCompany)
  19012. }
  19013. if m.experience != nil {
  19014. fields = append(fields, workexperience.FieldExperience)
  19015. }
  19016. if m.organization_id != nil {
  19017. fields = append(fields, workexperience.FieldOrganizationID)
  19018. }
  19019. return fields
  19020. }
  19021. // Field returns the value of a field with the given name. The second boolean
  19022. // return value indicates that this field was not set, or was not defined in the
  19023. // schema.
  19024. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  19025. switch name {
  19026. case workexperience.FieldCreatedAt:
  19027. return m.CreatedAt()
  19028. case workexperience.FieldUpdatedAt:
  19029. return m.UpdatedAt()
  19030. case workexperience.FieldDeletedAt:
  19031. return m.DeletedAt()
  19032. case workexperience.FieldEmployeeID:
  19033. return m.EmployeeID()
  19034. case workexperience.FieldStartDate:
  19035. return m.StartDate()
  19036. case workexperience.FieldEndDate:
  19037. return m.EndDate()
  19038. case workexperience.FieldCompany:
  19039. return m.Company()
  19040. case workexperience.FieldExperience:
  19041. return m.Experience()
  19042. case workexperience.FieldOrganizationID:
  19043. return m.OrganizationID()
  19044. }
  19045. return nil, false
  19046. }
  19047. // OldField returns the old value of the field from the database. An error is
  19048. // returned if the mutation operation is not UpdateOne, or the query to the
  19049. // database failed.
  19050. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19051. switch name {
  19052. case workexperience.FieldCreatedAt:
  19053. return m.OldCreatedAt(ctx)
  19054. case workexperience.FieldUpdatedAt:
  19055. return m.OldUpdatedAt(ctx)
  19056. case workexperience.FieldDeletedAt:
  19057. return m.OldDeletedAt(ctx)
  19058. case workexperience.FieldEmployeeID:
  19059. return m.OldEmployeeID(ctx)
  19060. case workexperience.FieldStartDate:
  19061. return m.OldStartDate(ctx)
  19062. case workexperience.FieldEndDate:
  19063. return m.OldEndDate(ctx)
  19064. case workexperience.FieldCompany:
  19065. return m.OldCompany(ctx)
  19066. case workexperience.FieldExperience:
  19067. return m.OldExperience(ctx)
  19068. case workexperience.FieldOrganizationID:
  19069. return m.OldOrganizationID(ctx)
  19070. }
  19071. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  19072. }
  19073. // SetField sets the value of a field with the given name. It returns an error if
  19074. // the field is not defined in the schema, or if the type mismatched the field
  19075. // type.
  19076. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  19077. switch name {
  19078. case workexperience.FieldCreatedAt:
  19079. v, ok := value.(time.Time)
  19080. if !ok {
  19081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19082. }
  19083. m.SetCreatedAt(v)
  19084. return nil
  19085. case workexperience.FieldUpdatedAt:
  19086. v, ok := value.(time.Time)
  19087. if !ok {
  19088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19089. }
  19090. m.SetUpdatedAt(v)
  19091. return nil
  19092. case workexperience.FieldDeletedAt:
  19093. v, ok := value.(time.Time)
  19094. if !ok {
  19095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19096. }
  19097. m.SetDeletedAt(v)
  19098. return nil
  19099. case workexperience.FieldEmployeeID:
  19100. v, ok := value.(uint64)
  19101. if !ok {
  19102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19103. }
  19104. m.SetEmployeeID(v)
  19105. return nil
  19106. case workexperience.FieldStartDate:
  19107. v, ok := value.(time.Time)
  19108. if !ok {
  19109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19110. }
  19111. m.SetStartDate(v)
  19112. return nil
  19113. case workexperience.FieldEndDate:
  19114. v, ok := value.(time.Time)
  19115. if !ok {
  19116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19117. }
  19118. m.SetEndDate(v)
  19119. return nil
  19120. case workexperience.FieldCompany:
  19121. v, ok := value.(string)
  19122. if !ok {
  19123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19124. }
  19125. m.SetCompany(v)
  19126. return nil
  19127. case workexperience.FieldExperience:
  19128. v, ok := value.(string)
  19129. if !ok {
  19130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19131. }
  19132. m.SetExperience(v)
  19133. return nil
  19134. case workexperience.FieldOrganizationID:
  19135. v, ok := value.(uint64)
  19136. if !ok {
  19137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19138. }
  19139. m.SetOrganizationID(v)
  19140. return nil
  19141. }
  19142. return fmt.Errorf("unknown WorkExperience field %s", name)
  19143. }
  19144. // AddedFields returns all numeric fields that were incremented/decremented during
  19145. // this mutation.
  19146. func (m *WorkExperienceMutation) AddedFields() []string {
  19147. var fields []string
  19148. if m.addorganization_id != nil {
  19149. fields = append(fields, workexperience.FieldOrganizationID)
  19150. }
  19151. return fields
  19152. }
  19153. // AddedField returns the numeric value that was incremented/decremented on a field
  19154. // with the given name. The second boolean return value indicates that this field
  19155. // was not set, or was not defined in the schema.
  19156. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  19157. switch name {
  19158. case workexperience.FieldOrganizationID:
  19159. return m.AddedOrganizationID()
  19160. }
  19161. return nil, false
  19162. }
  19163. // AddField adds the value to the field with the given name. It returns an error if
  19164. // the field is not defined in the schema, or if the type mismatched the field
  19165. // type.
  19166. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  19167. switch name {
  19168. case workexperience.FieldOrganizationID:
  19169. v, ok := value.(int64)
  19170. if !ok {
  19171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19172. }
  19173. m.AddOrganizationID(v)
  19174. return nil
  19175. }
  19176. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  19177. }
  19178. // ClearedFields returns all nullable fields that were cleared during this
  19179. // mutation.
  19180. func (m *WorkExperienceMutation) ClearedFields() []string {
  19181. var fields []string
  19182. if m.FieldCleared(workexperience.FieldDeletedAt) {
  19183. fields = append(fields, workexperience.FieldDeletedAt)
  19184. }
  19185. return fields
  19186. }
  19187. // FieldCleared returns a boolean indicating if a field with the given name was
  19188. // cleared in this mutation.
  19189. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  19190. _, ok := m.clearedFields[name]
  19191. return ok
  19192. }
  19193. // ClearField clears the value of the field with the given name. It returns an
  19194. // error if the field is not defined in the schema.
  19195. func (m *WorkExperienceMutation) ClearField(name string) error {
  19196. switch name {
  19197. case workexperience.FieldDeletedAt:
  19198. m.ClearDeletedAt()
  19199. return nil
  19200. }
  19201. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  19202. }
  19203. // ResetField resets all changes in the mutation for the field with the given name.
  19204. // It returns an error if the field is not defined in the schema.
  19205. func (m *WorkExperienceMutation) ResetField(name string) error {
  19206. switch name {
  19207. case workexperience.FieldCreatedAt:
  19208. m.ResetCreatedAt()
  19209. return nil
  19210. case workexperience.FieldUpdatedAt:
  19211. m.ResetUpdatedAt()
  19212. return nil
  19213. case workexperience.FieldDeletedAt:
  19214. m.ResetDeletedAt()
  19215. return nil
  19216. case workexperience.FieldEmployeeID:
  19217. m.ResetEmployeeID()
  19218. return nil
  19219. case workexperience.FieldStartDate:
  19220. m.ResetStartDate()
  19221. return nil
  19222. case workexperience.FieldEndDate:
  19223. m.ResetEndDate()
  19224. return nil
  19225. case workexperience.FieldCompany:
  19226. m.ResetCompany()
  19227. return nil
  19228. case workexperience.FieldExperience:
  19229. m.ResetExperience()
  19230. return nil
  19231. case workexperience.FieldOrganizationID:
  19232. m.ResetOrganizationID()
  19233. return nil
  19234. }
  19235. return fmt.Errorf("unknown WorkExperience field %s", name)
  19236. }
  19237. // AddedEdges returns all edge names that were set/added in this mutation.
  19238. func (m *WorkExperienceMutation) AddedEdges() []string {
  19239. edges := make([]string, 0, 1)
  19240. if m.employee != nil {
  19241. edges = append(edges, workexperience.EdgeEmployee)
  19242. }
  19243. return edges
  19244. }
  19245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19246. // name in this mutation.
  19247. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  19248. switch name {
  19249. case workexperience.EdgeEmployee:
  19250. if id := m.employee; id != nil {
  19251. return []ent.Value{*id}
  19252. }
  19253. }
  19254. return nil
  19255. }
  19256. // RemovedEdges returns all edge names that were removed in this mutation.
  19257. func (m *WorkExperienceMutation) RemovedEdges() []string {
  19258. edges := make([]string, 0, 1)
  19259. return edges
  19260. }
  19261. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19262. // the given name in this mutation.
  19263. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  19264. return nil
  19265. }
  19266. // ClearedEdges returns all edge names that were cleared in this mutation.
  19267. func (m *WorkExperienceMutation) ClearedEdges() []string {
  19268. edges := make([]string, 0, 1)
  19269. if m.clearedemployee {
  19270. edges = append(edges, workexperience.EdgeEmployee)
  19271. }
  19272. return edges
  19273. }
  19274. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19275. // was cleared in this mutation.
  19276. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  19277. switch name {
  19278. case workexperience.EdgeEmployee:
  19279. return m.clearedemployee
  19280. }
  19281. return false
  19282. }
  19283. // ClearEdge clears the value of the edge with the given name. It returns an error
  19284. // if that edge is not defined in the schema.
  19285. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  19286. switch name {
  19287. case workexperience.EdgeEmployee:
  19288. m.ClearEmployee()
  19289. return nil
  19290. }
  19291. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  19292. }
  19293. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19294. // It returns an error if the edge is not defined in the schema.
  19295. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  19296. switch name {
  19297. case workexperience.EdgeEmployee:
  19298. m.ResetEmployee()
  19299. return nil
  19300. }
  19301. return fmt.Errorf("unknown WorkExperience edge %s", name)
  19302. }
  19303. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  19304. type WxMutation struct {
  19305. config
  19306. op Op
  19307. typ string
  19308. id *uint64
  19309. created_at *time.Time
  19310. updated_at *time.Time
  19311. status *uint8
  19312. addstatus *int8
  19313. deleted_at *time.Time
  19314. port *string
  19315. process_id *string
  19316. callback *string
  19317. wxid *string
  19318. account *string
  19319. nickname *string
  19320. tel *string
  19321. head_big *string
  19322. organization_id *uint64
  19323. addorganization_id *int64
  19324. api_base *string
  19325. api_key *string
  19326. allow_list *[]string
  19327. appendallow_list []string
  19328. group_allow_list *[]string
  19329. appendgroup_allow_list []string
  19330. block_list *[]string
  19331. appendblock_list []string
  19332. group_block_list *[]string
  19333. appendgroup_block_list []string
  19334. clearedFields map[string]struct{}
  19335. server *uint64
  19336. clearedserver bool
  19337. agent *uint64
  19338. clearedagent bool
  19339. done bool
  19340. oldValue func(context.Context) (*Wx, error)
  19341. predicates []predicate.Wx
  19342. }
  19343. var _ ent.Mutation = (*WxMutation)(nil)
  19344. // wxOption allows management of the mutation configuration using functional options.
  19345. type wxOption func(*WxMutation)
  19346. // newWxMutation creates new mutation for the Wx entity.
  19347. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  19348. m := &WxMutation{
  19349. config: c,
  19350. op: op,
  19351. typ: TypeWx,
  19352. clearedFields: make(map[string]struct{}),
  19353. }
  19354. for _, opt := range opts {
  19355. opt(m)
  19356. }
  19357. return m
  19358. }
  19359. // withWxID sets the ID field of the mutation.
  19360. func withWxID(id uint64) wxOption {
  19361. return func(m *WxMutation) {
  19362. var (
  19363. err error
  19364. once sync.Once
  19365. value *Wx
  19366. )
  19367. m.oldValue = func(ctx context.Context) (*Wx, error) {
  19368. once.Do(func() {
  19369. if m.done {
  19370. err = errors.New("querying old values post mutation is not allowed")
  19371. } else {
  19372. value, err = m.Client().Wx.Get(ctx, id)
  19373. }
  19374. })
  19375. return value, err
  19376. }
  19377. m.id = &id
  19378. }
  19379. }
  19380. // withWx sets the old Wx of the mutation.
  19381. func withWx(node *Wx) wxOption {
  19382. return func(m *WxMutation) {
  19383. m.oldValue = func(context.Context) (*Wx, error) {
  19384. return node, nil
  19385. }
  19386. m.id = &node.ID
  19387. }
  19388. }
  19389. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19390. // executed in a transaction (ent.Tx), a transactional client is returned.
  19391. func (m WxMutation) Client() *Client {
  19392. client := &Client{config: m.config}
  19393. client.init()
  19394. return client
  19395. }
  19396. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19397. // it returns an error otherwise.
  19398. func (m WxMutation) Tx() (*Tx, error) {
  19399. if _, ok := m.driver.(*txDriver); !ok {
  19400. return nil, errors.New("ent: mutation is not running in a transaction")
  19401. }
  19402. tx := &Tx{config: m.config}
  19403. tx.init()
  19404. return tx, nil
  19405. }
  19406. // SetID sets the value of the id field. Note that this
  19407. // operation is only accepted on creation of Wx entities.
  19408. func (m *WxMutation) SetID(id uint64) {
  19409. m.id = &id
  19410. }
  19411. // ID returns the ID value in the mutation. Note that the ID is only available
  19412. // if it was provided to the builder or after it was returned from the database.
  19413. func (m *WxMutation) ID() (id uint64, exists bool) {
  19414. if m.id == nil {
  19415. return
  19416. }
  19417. return *m.id, true
  19418. }
  19419. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19420. // That means, if the mutation is applied within a transaction with an isolation level such
  19421. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19422. // or updated by the mutation.
  19423. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  19424. switch {
  19425. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19426. id, exists := m.ID()
  19427. if exists {
  19428. return []uint64{id}, nil
  19429. }
  19430. fallthrough
  19431. case m.op.Is(OpUpdate | OpDelete):
  19432. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  19433. default:
  19434. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19435. }
  19436. }
  19437. // SetCreatedAt sets the "created_at" field.
  19438. func (m *WxMutation) SetCreatedAt(t time.Time) {
  19439. m.created_at = &t
  19440. }
  19441. // CreatedAt returns the value of the "created_at" field in the mutation.
  19442. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  19443. v := m.created_at
  19444. if v == nil {
  19445. return
  19446. }
  19447. return *v, true
  19448. }
  19449. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  19450. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19452. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19453. if !m.op.Is(OpUpdateOne) {
  19454. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19455. }
  19456. if m.id == nil || m.oldValue == nil {
  19457. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19458. }
  19459. oldValue, err := m.oldValue(ctx)
  19460. if err != nil {
  19461. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19462. }
  19463. return oldValue.CreatedAt, nil
  19464. }
  19465. // ResetCreatedAt resets all changes to the "created_at" field.
  19466. func (m *WxMutation) ResetCreatedAt() {
  19467. m.created_at = nil
  19468. }
  19469. // SetUpdatedAt sets the "updated_at" field.
  19470. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  19471. m.updated_at = &t
  19472. }
  19473. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19474. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  19475. v := m.updated_at
  19476. if v == nil {
  19477. return
  19478. }
  19479. return *v, true
  19480. }
  19481. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  19482. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19484. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19485. if !m.op.Is(OpUpdateOne) {
  19486. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19487. }
  19488. if m.id == nil || m.oldValue == nil {
  19489. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19490. }
  19491. oldValue, err := m.oldValue(ctx)
  19492. if err != nil {
  19493. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19494. }
  19495. return oldValue.UpdatedAt, nil
  19496. }
  19497. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19498. func (m *WxMutation) ResetUpdatedAt() {
  19499. m.updated_at = nil
  19500. }
  19501. // SetStatus sets the "status" field.
  19502. func (m *WxMutation) SetStatus(u uint8) {
  19503. m.status = &u
  19504. m.addstatus = nil
  19505. }
  19506. // Status returns the value of the "status" field in the mutation.
  19507. func (m *WxMutation) Status() (r uint8, exists bool) {
  19508. v := m.status
  19509. if v == nil {
  19510. return
  19511. }
  19512. return *v, true
  19513. }
  19514. // OldStatus returns the old "status" field's value of the Wx entity.
  19515. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19517. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19518. if !m.op.Is(OpUpdateOne) {
  19519. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19520. }
  19521. if m.id == nil || m.oldValue == nil {
  19522. return v, errors.New("OldStatus requires an ID field in the mutation")
  19523. }
  19524. oldValue, err := m.oldValue(ctx)
  19525. if err != nil {
  19526. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19527. }
  19528. return oldValue.Status, nil
  19529. }
  19530. // AddStatus adds u to the "status" field.
  19531. func (m *WxMutation) AddStatus(u int8) {
  19532. if m.addstatus != nil {
  19533. *m.addstatus += u
  19534. } else {
  19535. m.addstatus = &u
  19536. }
  19537. }
  19538. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19539. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  19540. v := m.addstatus
  19541. if v == nil {
  19542. return
  19543. }
  19544. return *v, true
  19545. }
  19546. // ClearStatus clears the value of the "status" field.
  19547. func (m *WxMutation) ClearStatus() {
  19548. m.status = nil
  19549. m.addstatus = nil
  19550. m.clearedFields[wx.FieldStatus] = struct{}{}
  19551. }
  19552. // StatusCleared returns if the "status" field was cleared in this mutation.
  19553. func (m *WxMutation) StatusCleared() bool {
  19554. _, ok := m.clearedFields[wx.FieldStatus]
  19555. return ok
  19556. }
  19557. // ResetStatus resets all changes to the "status" field.
  19558. func (m *WxMutation) ResetStatus() {
  19559. m.status = nil
  19560. m.addstatus = nil
  19561. delete(m.clearedFields, wx.FieldStatus)
  19562. }
  19563. // SetDeletedAt sets the "deleted_at" field.
  19564. func (m *WxMutation) SetDeletedAt(t time.Time) {
  19565. m.deleted_at = &t
  19566. }
  19567. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19568. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  19569. v := m.deleted_at
  19570. if v == nil {
  19571. return
  19572. }
  19573. return *v, true
  19574. }
  19575. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  19576. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19578. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19579. if !m.op.Is(OpUpdateOne) {
  19580. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19581. }
  19582. if m.id == nil || m.oldValue == nil {
  19583. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19584. }
  19585. oldValue, err := m.oldValue(ctx)
  19586. if err != nil {
  19587. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19588. }
  19589. return oldValue.DeletedAt, nil
  19590. }
  19591. // ClearDeletedAt clears the value of the "deleted_at" field.
  19592. func (m *WxMutation) ClearDeletedAt() {
  19593. m.deleted_at = nil
  19594. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  19595. }
  19596. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19597. func (m *WxMutation) DeletedAtCleared() bool {
  19598. _, ok := m.clearedFields[wx.FieldDeletedAt]
  19599. return ok
  19600. }
  19601. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19602. func (m *WxMutation) ResetDeletedAt() {
  19603. m.deleted_at = nil
  19604. delete(m.clearedFields, wx.FieldDeletedAt)
  19605. }
  19606. // SetServerID sets the "server_id" field.
  19607. func (m *WxMutation) SetServerID(u uint64) {
  19608. m.server = &u
  19609. }
  19610. // ServerID returns the value of the "server_id" field in the mutation.
  19611. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  19612. v := m.server
  19613. if v == nil {
  19614. return
  19615. }
  19616. return *v, true
  19617. }
  19618. // OldServerID returns the old "server_id" field's value of the Wx entity.
  19619. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19621. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  19622. if !m.op.Is(OpUpdateOne) {
  19623. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  19624. }
  19625. if m.id == nil || m.oldValue == nil {
  19626. return v, errors.New("OldServerID requires an ID field in the mutation")
  19627. }
  19628. oldValue, err := m.oldValue(ctx)
  19629. if err != nil {
  19630. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  19631. }
  19632. return oldValue.ServerID, nil
  19633. }
  19634. // ClearServerID clears the value of the "server_id" field.
  19635. func (m *WxMutation) ClearServerID() {
  19636. m.server = nil
  19637. m.clearedFields[wx.FieldServerID] = struct{}{}
  19638. }
  19639. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  19640. func (m *WxMutation) ServerIDCleared() bool {
  19641. _, ok := m.clearedFields[wx.FieldServerID]
  19642. return ok
  19643. }
  19644. // ResetServerID resets all changes to the "server_id" field.
  19645. func (m *WxMutation) ResetServerID() {
  19646. m.server = nil
  19647. delete(m.clearedFields, wx.FieldServerID)
  19648. }
  19649. // SetPort sets the "port" field.
  19650. func (m *WxMutation) SetPort(s string) {
  19651. m.port = &s
  19652. }
  19653. // Port returns the value of the "port" field in the mutation.
  19654. func (m *WxMutation) Port() (r string, exists bool) {
  19655. v := m.port
  19656. if v == nil {
  19657. return
  19658. }
  19659. return *v, true
  19660. }
  19661. // OldPort returns the old "port" field's value of the Wx entity.
  19662. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19664. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  19665. if !m.op.Is(OpUpdateOne) {
  19666. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  19667. }
  19668. if m.id == nil || m.oldValue == nil {
  19669. return v, errors.New("OldPort requires an ID field in the mutation")
  19670. }
  19671. oldValue, err := m.oldValue(ctx)
  19672. if err != nil {
  19673. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  19674. }
  19675. return oldValue.Port, nil
  19676. }
  19677. // ResetPort resets all changes to the "port" field.
  19678. func (m *WxMutation) ResetPort() {
  19679. m.port = nil
  19680. }
  19681. // SetProcessID sets the "process_id" field.
  19682. func (m *WxMutation) SetProcessID(s string) {
  19683. m.process_id = &s
  19684. }
  19685. // ProcessID returns the value of the "process_id" field in the mutation.
  19686. func (m *WxMutation) ProcessID() (r string, exists bool) {
  19687. v := m.process_id
  19688. if v == nil {
  19689. return
  19690. }
  19691. return *v, true
  19692. }
  19693. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  19694. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19696. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  19697. if !m.op.Is(OpUpdateOne) {
  19698. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  19699. }
  19700. if m.id == nil || m.oldValue == nil {
  19701. return v, errors.New("OldProcessID requires an ID field in the mutation")
  19702. }
  19703. oldValue, err := m.oldValue(ctx)
  19704. if err != nil {
  19705. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  19706. }
  19707. return oldValue.ProcessID, nil
  19708. }
  19709. // ResetProcessID resets all changes to the "process_id" field.
  19710. func (m *WxMutation) ResetProcessID() {
  19711. m.process_id = nil
  19712. }
  19713. // SetCallback sets the "callback" field.
  19714. func (m *WxMutation) SetCallback(s string) {
  19715. m.callback = &s
  19716. }
  19717. // Callback returns the value of the "callback" field in the mutation.
  19718. func (m *WxMutation) Callback() (r string, exists bool) {
  19719. v := m.callback
  19720. if v == nil {
  19721. return
  19722. }
  19723. return *v, true
  19724. }
  19725. // OldCallback returns the old "callback" field's value of the Wx entity.
  19726. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19728. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  19729. if !m.op.Is(OpUpdateOne) {
  19730. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  19731. }
  19732. if m.id == nil || m.oldValue == nil {
  19733. return v, errors.New("OldCallback requires an ID field in the mutation")
  19734. }
  19735. oldValue, err := m.oldValue(ctx)
  19736. if err != nil {
  19737. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  19738. }
  19739. return oldValue.Callback, nil
  19740. }
  19741. // ResetCallback resets all changes to the "callback" field.
  19742. func (m *WxMutation) ResetCallback() {
  19743. m.callback = nil
  19744. }
  19745. // SetWxid sets the "wxid" field.
  19746. func (m *WxMutation) SetWxid(s string) {
  19747. m.wxid = &s
  19748. }
  19749. // Wxid returns the value of the "wxid" field in the mutation.
  19750. func (m *WxMutation) Wxid() (r string, exists bool) {
  19751. v := m.wxid
  19752. if v == nil {
  19753. return
  19754. }
  19755. return *v, true
  19756. }
  19757. // OldWxid returns the old "wxid" field's value of the Wx entity.
  19758. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19760. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  19761. if !m.op.Is(OpUpdateOne) {
  19762. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  19763. }
  19764. if m.id == nil || m.oldValue == nil {
  19765. return v, errors.New("OldWxid requires an ID field in the mutation")
  19766. }
  19767. oldValue, err := m.oldValue(ctx)
  19768. if err != nil {
  19769. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  19770. }
  19771. return oldValue.Wxid, nil
  19772. }
  19773. // ResetWxid resets all changes to the "wxid" field.
  19774. func (m *WxMutation) ResetWxid() {
  19775. m.wxid = nil
  19776. }
  19777. // SetAccount sets the "account" field.
  19778. func (m *WxMutation) SetAccount(s string) {
  19779. m.account = &s
  19780. }
  19781. // Account returns the value of the "account" field in the mutation.
  19782. func (m *WxMutation) Account() (r string, exists bool) {
  19783. v := m.account
  19784. if v == nil {
  19785. return
  19786. }
  19787. return *v, true
  19788. }
  19789. // OldAccount returns the old "account" field's value of the Wx entity.
  19790. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19792. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  19793. if !m.op.Is(OpUpdateOne) {
  19794. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  19795. }
  19796. if m.id == nil || m.oldValue == nil {
  19797. return v, errors.New("OldAccount requires an ID field in the mutation")
  19798. }
  19799. oldValue, err := m.oldValue(ctx)
  19800. if err != nil {
  19801. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  19802. }
  19803. return oldValue.Account, nil
  19804. }
  19805. // ResetAccount resets all changes to the "account" field.
  19806. func (m *WxMutation) ResetAccount() {
  19807. m.account = nil
  19808. }
  19809. // SetNickname sets the "nickname" field.
  19810. func (m *WxMutation) SetNickname(s string) {
  19811. m.nickname = &s
  19812. }
  19813. // Nickname returns the value of the "nickname" field in the mutation.
  19814. func (m *WxMutation) Nickname() (r string, exists bool) {
  19815. v := m.nickname
  19816. if v == nil {
  19817. return
  19818. }
  19819. return *v, true
  19820. }
  19821. // OldNickname returns the old "nickname" field's value of the Wx entity.
  19822. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19824. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  19825. if !m.op.Is(OpUpdateOne) {
  19826. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  19827. }
  19828. if m.id == nil || m.oldValue == nil {
  19829. return v, errors.New("OldNickname requires an ID field in the mutation")
  19830. }
  19831. oldValue, err := m.oldValue(ctx)
  19832. if err != nil {
  19833. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  19834. }
  19835. return oldValue.Nickname, nil
  19836. }
  19837. // ResetNickname resets all changes to the "nickname" field.
  19838. func (m *WxMutation) ResetNickname() {
  19839. m.nickname = nil
  19840. }
  19841. // SetTel sets the "tel" field.
  19842. func (m *WxMutation) SetTel(s string) {
  19843. m.tel = &s
  19844. }
  19845. // Tel returns the value of the "tel" field in the mutation.
  19846. func (m *WxMutation) Tel() (r string, exists bool) {
  19847. v := m.tel
  19848. if v == nil {
  19849. return
  19850. }
  19851. return *v, true
  19852. }
  19853. // OldTel returns the old "tel" field's value of the Wx entity.
  19854. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19856. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  19857. if !m.op.Is(OpUpdateOne) {
  19858. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  19859. }
  19860. if m.id == nil || m.oldValue == nil {
  19861. return v, errors.New("OldTel requires an ID field in the mutation")
  19862. }
  19863. oldValue, err := m.oldValue(ctx)
  19864. if err != nil {
  19865. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  19866. }
  19867. return oldValue.Tel, nil
  19868. }
  19869. // ResetTel resets all changes to the "tel" field.
  19870. func (m *WxMutation) ResetTel() {
  19871. m.tel = nil
  19872. }
  19873. // SetHeadBig sets the "head_big" field.
  19874. func (m *WxMutation) SetHeadBig(s string) {
  19875. m.head_big = &s
  19876. }
  19877. // HeadBig returns the value of the "head_big" field in the mutation.
  19878. func (m *WxMutation) HeadBig() (r string, exists bool) {
  19879. v := m.head_big
  19880. if v == nil {
  19881. return
  19882. }
  19883. return *v, true
  19884. }
  19885. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  19886. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19888. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  19889. if !m.op.Is(OpUpdateOne) {
  19890. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  19891. }
  19892. if m.id == nil || m.oldValue == nil {
  19893. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  19894. }
  19895. oldValue, err := m.oldValue(ctx)
  19896. if err != nil {
  19897. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  19898. }
  19899. return oldValue.HeadBig, nil
  19900. }
  19901. // ResetHeadBig resets all changes to the "head_big" field.
  19902. func (m *WxMutation) ResetHeadBig() {
  19903. m.head_big = nil
  19904. }
  19905. // SetOrganizationID sets the "organization_id" field.
  19906. func (m *WxMutation) SetOrganizationID(u uint64) {
  19907. m.organization_id = &u
  19908. m.addorganization_id = nil
  19909. }
  19910. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19911. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  19912. v := m.organization_id
  19913. if v == nil {
  19914. return
  19915. }
  19916. return *v, true
  19917. }
  19918. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  19919. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19921. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19922. if !m.op.Is(OpUpdateOne) {
  19923. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19924. }
  19925. if m.id == nil || m.oldValue == nil {
  19926. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19927. }
  19928. oldValue, err := m.oldValue(ctx)
  19929. if err != nil {
  19930. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19931. }
  19932. return oldValue.OrganizationID, nil
  19933. }
  19934. // AddOrganizationID adds u to the "organization_id" field.
  19935. func (m *WxMutation) AddOrganizationID(u int64) {
  19936. if m.addorganization_id != nil {
  19937. *m.addorganization_id += u
  19938. } else {
  19939. m.addorganization_id = &u
  19940. }
  19941. }
  19942. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19943. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  19944. v := m.addorganization_id
  19945. if v == nil {
  19946. return
  19947. }
  19948. return *v, true
  19949. }
  19950. // ClearOrganizationID clears the value of the "organization_id" field.
  19951. func (m *WxMutation) ClearOrganizationID() {
  19952. m.organization_id = nil
  19953. m.addorganization_id = nil
  19954. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  19955. }
  19956. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19957. func (m *WxMutation) OrganizationIDCleared() bool {
  19958. _, ok := m.clearedFields[wx.FieldOrganizationID]
  19959. return ok
  19960. }
  19961. // ResetOrganizationID resets all changes to the "organization_id" field.
  19962. func (m *WxMutation) ResetOrganizationID() {
  19963. m.organization_id = nil
  19964. m.addorganization_id = nil
  19965. delete(m.clearedFields, wx.FieldOrganizationID)
  19966. }
  19967. // SetAgentID sets the "agent_id" field.
  19968. func (m *WxMutation) SetAgentID(u uint64) {
  19969. m.agent = &u
  19970. }
  19971. // AgentID returns the value of the "agent_id" field in the mutation.
  19972. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  19973. v := m.agent
  19974. if v == nil {
  19975. return
  19976. }
  19977. return *v, true
  19978. }
  19979. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  19980. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  19981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19982. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  19983. if !m.op.Is(OpUpdateOne) {
  19984. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  19985. }
  19986. if m.id == nil || m.oldValue == nil {
  19987. return v, errors.New("OldAgentID requires an ID field in the mutation")
  19988. }
  19989. oldValue, err := m.oldValue(ctx)
  19990. if err != nil {
  19991. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  19992. }
  19993. return oldValue.AgentID, nil
  19994. }
  19995. // ResetAgentID resets all changes to the "agent_id" field.
  19996. func (m *WxMutation) ResetAgentID() {
  19997. m.agent = nil
  19998. }
  19999. // SetAPIBase sets the "api_base" field.
  20000. func (m *WxMutation) SetAPIBase(s string) {
  20001. m.api_base = &s
  20002. }
  20003. // APIBase returns the value of the "api_base" field in the mutation.
  20004. func (m *WxMutation) APIBase() (r string, exists bool) {
  20005. v := m.api_base
  20006. if v == nil {
  20007. return
  20008. }
  20009. return *v, true
  20010. }
  20011. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  20012. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  20013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20014. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  20015. if !m.op.Is(OpUpdateOne) {
  20016. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  20017. }
  20018. if m.id == nil || m.oldValue == nil {
  20019. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  20020. }
  20021. oldValue, err := m.oldValue(ctx)
  20022. if err != nil {
  20023. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  20024. }
  20025. return oldValue.APIBase, nil
  20026. }
  20027. // ClearAPIBase clears the value of the "api_base" field.
  20028. func (m *WxMutation) ClearAPIBase() {
  20029. m.api_base = nil
  20030. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  20031. }
  20032. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  20033. func (m *WxMutation) APIBaseCleared() bool {
  20034. _, ok := m.clearedFields[wx.FieldAPIBase]
  20035. return ok
  20036. }
  20037. // ResetAPIBase resets all changes to the "api_base" field.
  20038. func (m *WxMutation) ResetAPIBase() {
  20039. m.api_base = nil
  20040. delete(m.clearedFields, wx.FieldAPIBase)
  20041. }
  20042. // SetAPIKey sets the "api_key" field.
  20043. func (m *WxMutation) SetAPIKey(s string) {
  20044. m.api_key = &s
  20045. }
  20046. // APIKey returns the value of the "api_key" field in the mutation.
  20047. func (m *WxMutation) APIKey() (r string, exists bool) {
  20048. v := m.api_key
  20049. if v == nil {
  20050. return
  20051. }
  20052. return *v, true
  20053. }
  20054. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  20055. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  20056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20057. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  20058. if !m.op.Is(OpUpdateOne) {
  20059. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  20060. }
  20061. if m.id == nil || m.oldValue == nil {
  20062. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  20063. }
  20064. oldValue, err := m.oldValue(ctx)
  20065. if err != nil {
  20066. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  20067. }
  20068. return oldValue.APIKey, nil
  20069. }
  20070. // ClearAPIKey clears the value of the "api_key" field.
  20071. func (m *WxMutation) ClearAPIKey() {
  20072. m.api_key = nil
  20073. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  20074. }
  20075. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  20076. func (m *WxMutation) APIKeyCleared() bool {
  20077. _, ok := m.clearedFields[wx.FieldAPIKey]
  20078. return ok
  20079. }
  20080. // ResetAPIKey resets all changes to the "api_key" field.
  20081. func (m *WxMutation) ResetAPIKey() {
  20082. m.api_key = nil
  20083. delete(m.clearedFields, wx.FieldAPIKey)
  20084. }
  20085. // SetAllowList sets the "allow_list" field.
  20086. func (m *WxMutation) SetAllowList(s []string) {
  20087. m.allow_list = &s
  20088. m.appendallow_list = nil
  20089. }
  20090. // AllowList returns the value of the "allow_list" field in the mutation.
  20091. func (m *WxMutation) AllowList() (r []string, exists bool) {
  20092. v := m.allow_list
  20093. if v == nil {
  20094. return
  20095. }
  20096. return *v, true
  20097. }
  20098. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  20099. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  20100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20101. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  20102. if !m.op.Is(OpUpdateOne) {
  20103. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  20104. }
  20105. if m.id == nil || m.oldValue == nil {
  20106. return v, errors.New("OldAllowList requires an ID field in the mutation")
  20107. }
  20108. oldValue, err := m.oldValue(ctx)
  20109. if err != nil {
  20110. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  20111. }
  20112. return oldValue.AllowList, nil
  20113. }
  20114. // AppendAllowList adds s to the "allow_list" field.
  20115. func (m *WxMutation) AppendAllowList(s []string) {
  20116. m.appendallow_list = append(m.appendallow_list, s...)
  20117. }
  20118. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  20119. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  20120. if len(m.appendallow_list) == 0 {
  20121. return nil, false
  20122. }
  20123. return m.appendallow_list, true
  20124. }
  20125. // ResetAllowList resets all changes to the "allow_list" field.
  20126. func (m *WxMutation) ResetAllowList() {
  20127. m.allow_list = nil
  20128. m.appendallow_list = nil
  20129. }
  20130. // SetGroupAllowList sets the "group_allow_list" field.
  20131. func (m *WxMutation) SetGroupAllowList(s []string) {
  20132. m.group_allow_list = &s
  20133. m.appendgroup_allow_list = nil
  20134. }
  20135. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  20136. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  20137. v := m.group_allow_list
  20138. if v == nil {
  20139. return
  20140. }
  20141. return *v, true
  20142. }
  20143. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  20144. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  20145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20146. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  20147. if !m.op.Is(OpUpdateOne) {
  20148. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  20149. }
  20150. if m.id == nil || m.oldValue == nil {
  20151. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  20152. }
  20153. oldValue, err := m.oldValue(ctx)
  20154. if err != nil {
  20155. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  20156. }
  20157. return oldValue.GroupAllowList, nil
  20158. }
  20159. // AppendGroupAllowList adds s to the "group_allow_list" field.
  20160. func (m *WxMutation) AppendGroupAllowList(s []string) {
  20161. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  20162. }
  20163. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  20164. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  20165. if len(m.appendgroup_allow_list) == 0 {
  20166. return nil, false
  20167. }
  20168. return m.appendgroup_allow_list, true
  20169. }
  20170. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  20171. func (m *WxMutation) ResetGroupAllowList() {
  20172. m.group_allow_list = nil
  20173. m.appendgroup_allow_list = nil
  20174. }
  20175. // SetBlockList sets the "block_list" field.
  20176. func (m *WxMutation) SetBlockList(s []string) {
  20177. m.block_list = &s
  20178. m.appendblock_list = nil
  20179. }
  20180. // BlockList returns the value of the "block_list" field in the mutation.
  20181. func (m *WxMutation) BlockList() (r []string, exists bool) {
  20182. v := m.block_list
  20183. if v == nil {
  20184. return
  20185. }
  20186. return *v, true
  20187. }
  20188. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  20189. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  20190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20191. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  20192. if !m.op.Is(OpUpdateOne) {
  20193. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  20194. }
  20195. if m.id == nil || m.oldValue == nil {
  20196. return v, errors.New("OldBlockList requires an ID field in the mutation")
  20197. }
  20198. oldValue, err := m.oldValue(ctx)
  20199. if err != nil {
  20200. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  20201. }
  20202. return oldValue.BlockList, nil
  20203. }
  20204. // AppendBlockList adds s to the "block_list" field.
  20205. func (m *WxMutation) AppendBlockList(s []string) {
  20206. m.appendblock_list = append(m.appendblock_list, s...)
  20207. }
  20208. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  20209. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  20210. if len(m.appendblock_list) == 0 {
  20211. return nil, false
  20212. }
  20213. return m.appendblock_list, true
  20214. }
  20215. // ResetBlockList resets all changes to the "block_list" field.
  20216. func (m *WxMutation) ResetBlockList() {
  20217. m.block_list = nil
  20218. m.appendblock_list = nil
  20219. }
  20220. // SetGroupBlockList sets the "group_block_list" field.
  20221. func (m *WxMutation) SetGroupBlockList(s []string) {
  20222. m.group_block_list = &s
  20223. m.appendgroup_block_list = nil
  20224. }
  20225. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  20226. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  20227. v := m.group_block_list
  20228. if v == nil {
  20229. return
  20230. }
  20231. return *v, true
  20232. }
  20233. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  20234. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  20235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20236. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  20237. if !m.op.Is(OpUpdateOne) {
  20238. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  20239. }
  20240. if m.id == nil || m.oldValue == nil {
  20241. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  20242. }
  20243. oldValue, err := m.oldValue(ctx)
  20244. if err != nil {
  20245. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  20246. }
  20247. return oldValue.GroupBlockList, nil
  20248. }
  20249. // AppendGroupBlockList adds s to the "group_block_list" field.
  20250. func (m *WxMutation) AppendGroupBlockList(s []string) {
  20251. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  20252. }
  20253. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  20254. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  20255. if len(m.appendgroup_block_list) == 0 {
  20256. return nil, false
  20257. }
  20258. return m.appendgroup_block_list, true
  20259. }
  20260. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  20261. func (m *WxMutation) ResetGroupBlockList() {
  20262. m.group_block_list = nil
  20263. m.appendgroup_block_list = nil
  20264. }
  20265. // ClearServer clears the "server" edge to the Server entity.
  20266. func (m *WxMutation) ClearServer() {
  20267. m.clearedserver = true
  20268. m.clearedFields[wx.FieldServerID] = struct{}{}
  20269. }
  20270. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  20271. func (m *WxMutation) ServerCleared() bool {
  20272. return m.ServerIDCleared() || m.clearedserver
  20273. }
  20274. // ServerIDs returns the "server" edge IDs in the mutation.
  20275. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20276. // ServerID instead. It exists only for internal usage by the builders.
  20277. func (m *WxMutation) ServerIDs() (ids []uint64) {
  20278. if id := m.server; id != nil {
  20279. ids = append(ids, *id)
  20280. }
  20281. return
  20282. }
  20283. // ResetServer resets all changes to the "server" edge.
  20284. func (m *WxMutation) ResetServer() {
  20285. m.server = nil
  20286. m.clearedserver = false
  20287. }
  20288. // ClearAgent clears the "agent" edge to the Agent entity.
  20289. func (m *WxMutation) ClearAgent() {
  20290. m.clearedagent = true
  20291. m.clearedFields[wx.FieldAgentID] = struct{}{}
  20292. }
  20293. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  20294. func (m *WxMutation) AgentCleared() bool {
  20295. return m.clearedagent
  20296. }
  20297. // AgentIDs returns the "agent" edge IDs in the mutation.
  20298. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20299. // AgentID instead. It exists only for internal usage by the builders.
  20300. func (m *WxMutation) AgentIDs() (ids []uint64) {
  20301. if id := m.agent; id != nil {
  20302. ids = append(ids, *id)
  20303. }
  20304. return
  20305. }
  20306. // ResetAgent resets all changes to the "agent" edge.
  20307. func (m *WxMutation) ResetAgent() {
  20308. m.agent = nil
  20309. m.clearedagent = false
  20310. }
  20311. // Where appends a list predicates to the WxMutation builder.
  20312. func (m *WxMutation) Where(ps ...predicate.Wx) {
  20313. m.predicates = append(m.predicates, ps...)
  20314. }
  20315. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  20316. // users can use type-assertion to append predicates that do not depend on any generated package.
  20317. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  20318. p := make([]predicate.Wx, len(ps))
  20319. for i := range ps {
  20320. p[i] = ps[i]
  20321. }
  20322. m.Where(p...)
  20323. }
  20324. // Op returns the operation name.
  20325. func (m *WxMutation) Op() Op {
  20326. return m.op
  20327. }
  20328. // SetOp allows setting the mutation operation.
  20329. func (m *WxMutation) SetOp(op Op) {
  20330. m.op = op
  20331. }
  20332. // Type returns the node type of this mutation (Wx).
  20333. func (m *WxMutation) Type() string {
  20334. return m.typ
  20335. }
  20336. // Fields returns all fields that were changed during this mutation. Note that in
  20337. // order to get all numeric fields that were incremented/decremented, call
  20338. // AddedFields().
  20339. func (m *WxMutation) Fields() []string {
  20340. fields := make([]string, 0, 21)
  20341. if m.created_at != nil {
  20342. fields = append(fields, wx.FieldCreatedAt)
  20343. }
  20344. if m.updated_at != nil {
  20345. fields = append(fields, wx.FieldUpdatedAt)
  20346. }
  20347. if m.status != nil {
  20348. fields = append(fields, wx.FieldStatus)
  20349. }
  20350. if m.deleted_at != nil {
  20351. fields = append(fields, wx.FieldDeletedAt)
  20352. }
  20353. if m.server != nil {
  20354. fields = append(fields, wx.FieldServerID)
  20355. }
  20356. if m.port != nil {
  20357. fields = append(fields, wx.FieldPort)
  20358. }
  20359. if m.process_id != nil {
  20360. fields = append(fields, wx.FieldProcessID)
  20361. }
  20362. if m.callback != nil {
  20363. fields = append(fields, wx.FieldCallback)
  20364. }
  20365. if m.wxid != nil {
  20366. fields = append(fields, wx.FieldWxid)
  20367. }
  20368. if m.account != nil {
  20369. fields = append(fields, wx.FieldAccount)
  20370. }
  20371. if m.nickname != nil {
  20372. fields = append(fields, wx.FieldNickname)
  20373. }
  20374. if m.tel != nil {
  20375. fields = append(fields, wx.FieldTel)
  20376. }
  20377. if m.head_big != nil {
  20378. fields = append(fields, wx.FieldHeadBig)
  20379. }
  20380. if m.organization_id != nil {
  20381. fields = append(fields, wx.FieldOrganizationID)
  20382. }
  20383. if m.agent != nil {
  20384. fields = append(fields, wx.FieldAgentID)
  20385. }
  20386. if m.api_base != nil {
  20387. fields = append(fields, wx.FieldAPIBase)
  20388. }
  20389. if m.api_key != nil {
  20390. fields = append(fields, wx.FieldAPIKey)
  20391. }
  20392. if m.allow_list != nil {
  20393. fields = append(fields, wx.FieldAllowList)
  20394. }
  20395. if m.group_allow_list != nil {
  20396. fields = append(fields, wx.FieldGroupAllowList)
  20397. }
  20398. if m.block_list != nil {
  20399. fields = append(fields, wx.FieldBlockList)
  20400. }
  20401. if m.group_block_list != nil {
  20402. fields = append(fields, wx.FieldGroupBlockList)
  20403. }
  20404. return fields
  20405. }
  20406. // Field returns the value of a field with the given name. The second boolean
  20407. // return value indicates that this field was not set, or was not defined in the
  20408. // schema.
  20409. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  20410. switch name {
  20411. case wx.FieldCreatedAt:
  20412. return m.CreatedAt()
  20413. case wx.FieldUpdatedAt:
  20414. return m.UpdatedAt()
  20415. case wx.FieldStatus:
  20416. return m.Status()
  20417. case wx.FieldDeletedAt:
  20418. return m.DeletedAt()
  20419. case wx.FieldServerID:
  20420. return m.ServerID()
  20421. case wx.FieldPort:
  20422. return m.Port()
  20423. case wx.FieldProcessID:
  20424. return m.ProcessID()
  20425. case wx.FieldCallback:
  20426. return m.Callback()
  20427. case wx.FieldWxid:
  20428. return m.Wxid()
  20429. case wx.FieldAccount:
  20430. return m.Account()
  20431. case wx.FieldNickname:
  20432. return m.Nickname()
  20433. case wx.FieldTel:
  20434. return m.Tel()
  20435. case wx.FieldHeadBig:
  20436. return m.HeadBig()
  20437. case wx.FieldOrganizationID:
  20438. return m.OrganizationID()
  20439. case wx.FieldAgentID:
  20440. return m.AgentID()
  20441. case wx.FieldAPIBase:
  20442. return m.APIBase()
  20443. case wx.FieldAPIKey:
  20444. return m.APIKey()
  20445. case wx.FieldAllowList:
  20446. return m.AllowList()
  20447. case wx.FieldGroupAllowList:
  20448. return m.GroupAllowList()
  20449. case wx.FieldBlockList:
  20450. return m.BlockList()
  20451. case wx.FieldGroupBlockList:
  20452. return m.GroupBlockList()
  20453. }
  20454. return nil, false
  20455. }
  20456. // OldField returns the old value of the field from the database. An error is
  20457. // returned if the mutation operation is not UpdateOne, or the query to the
  20458. // database failed.
  20459. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20460. switch name {
  20461. case wx.FieldCreatedAt:
  20462. return m.OldCreatedAt(ctx)
  20463. case wx.FieldUpdatedAt:
  20464. return m.OldUpdatedAt(ctx)
  20465. case wx.FieldStatus:
  20466. return m.OldStatus(ctx)
  20467. case wx.FieldDeletedAt:
  20468. return m.OldDeletedAt(ctx)
  20469. case wx.FieldServerID:
  20470. return m.OldServerID(ctx)
  20471. case wx.FieldPort:
  20472. return m.OldPort(ctx)
  20473. case wx.FieldProcessID:
  20474. return m.OldProcessID(ctx)
  20475. case wx.FieldCallback:
  20476. return m.OldCallback(ctx)
  20477. case wx.FieldWxid:
  20478. return m.OldWxid(ctx)
  20479. case wx.FieldAccount:
  20480. return m.OldAccount(ctx)
  20481. case wx.FieldNickname:
  20482. return m.OldNickname(ctx)
  20483. case wx.FieldTel:
  20484. return m.OldTel(ctx)
  20485. case wx.FieldHeadBig:
  20486. return m.OldHeadBig(ctx)
  20487. case wx.FieldOrganizationID:
  20488. return m.OldOrganizationID(ctx)
  20489. case wx.FieldAgentID:
  20490. return m.OldAgentID(ctx)
  20491. case wx.FieldAPIBase:
  20492. return m.OldAPIBase(ctx)
  20493. case wx.FieldAPIKey:
  20494. return m.OldAPIKey(ctx)
  20495. case wx.FieldAllowList:
  20496. return m.OldAllowList(ctx)
  20497. case wx.FieldGroupAllowList:
  20498. return m.OldGroupAllowList(ctx)
  20499. case wx.FieldBlockList:
  20500. return m.OldBlockList(ctx)
  20501. case wx.FieldGroupBlockList:
  20502. return m.OldGroupBlockList(ctx)
  20503. }
  20504. return nil, fmt.Errorf("unknown Wx field %s", name)
  20505. }
  20506. // SetField sets the value of a field with the given name. It returns an error if
  20507. // the field is not defined in the schema, or if the type mismatched the field
  20508. // type.
  20509. func (m *WxMutation) SetField(name string, value ent.Value) error {
  20510. switch name {
  20511. case wx.FieldCreatedAt:
  20512. v, ok := value.(time.Time)
  20513. if !ok {
  20514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20515. }
  20516. m.SetCreatedAt(v)
  20517. return nil
  20518. case wx.FieldUpdatedAt:
  20519. v, ok := value.(time.Time)
  20520. if !ok {
  20521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20522. }
  20523. m.SetUpdatedAt(v)
  20524. return nil
  20525. case wx.FieldStatus:
  20526. v, ok := value.(uint8)
  20527. if !ok {
  20528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20529. }
  20530. m.SetStatus(v)
  20531. return nil
  20532. case wx.FieldDeletedAt:
  20533. v, ok := value.(time.Time)
  20534. if !ok {
  20535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20536. }
  20537. m.SetDeletedAt(v)
  20538. return nil
  20539. case wx.FieldServerID:
  20540. v, ok := value.(uint64)
  20541. if !ok {
  20542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20543. }
  20544. m.SetServerID(v)
  20545. return nil
  20546. case wx.FieldPort:
  20547. v, ok := value.(string)
  20548. if !ok {
  20549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20550. }
  20551. m.SetPort(v)
  20552. return nil
  20553. case wx.FieldProcessID:
  20554. v, ok := value.(string)
  20555. if !ok {
  20556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20557. }
  20558. m.SetProcessID(v)
  20559. return nil
  20560. case wx.FieldCallback:
  20561. v, ok := value.(string)
  20562. if !ok {
  20563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20564. }
  20565. m.SetCallback(v)
  20566. return nil
  20567. case wx.FieldWxid:
  20568. v, ok := value.(string)
  20569. if !ok {
  20570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20571. }
  20572. m.SetWxid(v)
  20573. return nil
  20574. case wx.FieldAccount:
  20575. v, ok := value.(string)
  20576. if !ok {
  20577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20578. }
  20579. m.SetAccount(v)
  20580. return nil
  20581. case wx.FieldNickname:
  20582. v, ok := value.(string)
  20583. if !ok {
  20584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20585. }
  20586. m.SetNickname(v)
  20587. return nil
  20588. case wx.FieldTel:
  20589. v, ok := value.(string)
  20590. if !ok {
  20591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20592. }
  20593. m.SetTel(v)
  20594. return nil
  20595. case wx.FieldHeadBig:
  20596. v, ok := value.(string)
  20597. if !ok {
  20598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20599. }
  20600. m.SetHeadBig(v)
  20601. return nil
  20602. case wx.FieldOrganizationID:
  20603. v, ok := value.(uint64)
  20604. if !ok {
  20605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20606. }
  20607. m.SetOrganizationID(v)
  20608. return nil
  20609. case wx.FieldAgentID:
  20610. v, ok := value.(uint64)
  20611. if !ok {
  20612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20613. }
  20614. m.SetAgentID(v)
  20615. return nil
  20616. case wx.FieldAPIBase:
  20617. v, ok := value.(string)
  20618. if !ok {
  20619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20620. }
  20621. m.SetAPIBase(v)
  20622. return nil
  20623. case wx.FieldAPIKey:
  20624. v, ok := value.(string)
  20625. if !ok {
  20626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20627. }
  20628. m.SetAPIKey(v)
  20629. return nil
  20630. case wx.FieldAllowList:
  20631. v, ok := value.([]string)
  20632. if !ok {
  20633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20634. }
  20635. m.SetAllowList(v)
  20636. return nil
  20637. case wx.FieldGroupAllowList:
  20638. v, ok := value.([]string)
  20639. if !ok {
  20640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20641. }
  20642. m.SetGroupAllowList(v)
  20643. return nil
  20644. case wx.FieldBlockList:
  20645. v, ok := value.([]string)
  20646. if !ok {
  20647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20648. }
  20649. m.SetBlockList(v)
  20650. return nil
  20651. case wx.FieldGroupBlockList:
  20652. v, ok := value.([]string)
  20653. if !ok {
  20654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20655. }
  20656. m.SetGroupBlockList(v)
  20657. return nil
  20658. }
  20659. return fmt.Errorf("unknown Wx field %s", name)
  20660. }
  20661. // AddedFields returns all numeric fields that were incremented/decremented during
  20662. // this mutation.
  20663. func (m *WxMutation) AddedFields() []string {
  20664. var fields []string
  20665. if m.addstatus != nil {
  20666. fields = append(fields, wx.FieldStatus)
  20667. }
  20668. if m.addorganization_id != nil {
  20669. fields = append(fields, wx.FieldOrganizationID)
  20670. }
  20671. return fields
  20672. }
  20673. // AddedField returns the numeric value that was incremented/decremented on a field
  20674. // with the given name. The second boolean return value indicates that this field
  20675. // was not set, or was not defined in the schema.
  20676. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  20677. switch name {
  20678. case wx.FieldStatus:
  20679. return m.AddedStatus()
  20680. case wx.FieldOrganizationID:
  20681. return m.AddedOrganizationID()
  20682. }
  20683. return nil, false
  20684. }
  20685. // AddField adds the value to the field with the given name. It returns an error if
  20686. // the field is not defined in the schema, or if the type mismatched the field
  20687. // type.
  20688. func (m *WxMutation) AddField(name string, value ent.Value) error {
  20689. switch name {
  20690. case wx.FieldStatus:
  20691. v, ok := value.(int8)
  20692. if !ok {
  20693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20694. }
  20695. m.AddStatus(v)
  20696. return nil
  20697. case wx.FieldOrganizationID:
  20698. v, ok := value.(int64)
  20699. if !ok {
  20700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20701. }
  20702. m.AddOrganizationID(v)
  20703. return nil
  20704. }
  20705. return fmt.Errorf("unknown Wx numeric field %s", name)
  20706. }
  20707. // ClearedFields returns all nullable fields that were cleared during this
  20708. // mutation.
  20709. func (m *WxMutation) ClearedFields() []string {
  20710. var fields []string
  20711. if m.FieldCleared(wx.FieldStatus) {
  20712. fields = append(fields, wx.FieldStatus)
  20713. }
  20714. if m.FieldCleared(wx.FieldDeletedAt) {
  20715. fields = append(fields, wx.FieldDeletedAt)
  20716. }
  20717. if m.FieldCleared(wx.FieldServerID) {
  20718. fields = append(fields, wx.FieldServerID)
  20719. }
  20720. if m.FieldCleared(wx.FieldOrganizationID) {
  20721. fields = append(fields, wx.FieldOrganizationID)
  20722. }
  20723. if m.FieldCleared(wx.FieldAPIBase) {
  20724. fields = append(fields, wx.FieldAPIBase)
  20725. }
  20726. if m.FieldCleared(wx.FieldAPIKey) {
  20727. fields = append(fields, wx.FieldAPIKey)
  20728. }
  20729. return fields
  20730. }
  20731. // FieldCleared returns a boolean indicating if a field with the given name was
  20732. // cleared in this mutation.
  20733. func (m *WxMutation) FieldCleared(name string) bool {
  20734. _, ok := m.clearedFields[name]
  20735. return ok
  20736. }
  20737. // ClearField clears the value of the field with the given name. It returns an
  20738. // error if the field is not defined in the schema.
  20739. func (m *WxMutation) ClearField(name string) error {
  20740. switch name {
  20741. case wx.FieldStatus:
  20742. m.ClearStatus()
  20743. return nil
  20744. case wx.FieldDeletedAt:
  20745. m.ClearDeletedAt()
  20746. return nil
  20747. case wx.FieldServerID:
  20748. m.ClearServerID()
  20749. return nil
  20750. case wx.FieldOrganizationID:
  20751. m.ClearOrganizationID()
  20752. return nil
  20753. case wx.FieldAPIBase:
  20754. m.ClearAPIBase()
  20755. return nil
  20756. case wx.FieldAPIKey:
  20757. m.ClearAPIKey()
  20758. return nil
  20759. }
  20760. return fmt.Errorf("unknown Wx nullable field %s", name)
  20761. }
  20762. // ResetField resets all changes in the mutation for the field with the given name.
  20763. // It returns an error if the field is not defined in the schema.
  20764. func (m *WxMutation) ResetField(name string) error {
  20765. switch name {
  20766. case wx.FieldCreatedAt:
  20767. m.ResetCreatedAt()
  20768. return nil
  20769. case wx.FieldUpdatedAt:
  20770. m.ResetUpdatedAt()
  20771. return nil
  20772. case wx.FieldStatus:
  20773. m.ResetStatus()
  20774. return nil
  20775. case wx.FieldDeletedAt:
  20776. m.ResetDeletedAt()
  20777. return nil
  20778. case wx.FieldServerID:
  20779. m.ResetServerID()
  20780. return nil
  20781. case wx.FieldPort:
  20782. m.ResetPort()
  20783. return nil
  20784. case wx.FieldProcessID:
  20785. m.ResetProcessID()
  20786. return nil
  20787. case wx.FieldCallback:
  20788. m.ResetCallback()
  20789. return nil
  20790. case wx.FieldWxid:
  20791. m.ResetWxid()
  20792. return nil
  20793. case wx.FieldAccount:
  20794. m.ResetAccount()
  20795. return nil
  20796. case wx.FieldNickname:
  20797. m.ResetNickname()
  20798. return nil
  20799. case wx.FieldTel:
  20800. m.ResetTel()
  20801. return nil
  20802. case wx.FieldHeadBig:
  20803. m.ResetHeadBig()
  20804. return nil
  20805. case wx.FieldOrganizationID:
  20806. m.ResetOrganizationID()
  20807. return nil
  20808. case wx.FieldAgentID:
  20809. m.ResetAgentID()
  20810. return nil
  20811. case wx.FieldAPIBase:
  20812. m.ResetAPIBase()
  20813. return nil
  20814. case wx.FieldAPIKey:
  20815. m.ResetAPIKey()
  20816. return nil
  20817. case wx.FieldAllowList:
  20818. m.ResetAllowList()
  20819. return nil
  20820. case wx.FieldGroupAllowList:
  20821. m.ResetGroupAllowList()
  20822. return nil
  20823. case wx.FieldBlockList:
  20824. m.ResetBlockList()
  20825. return nil
  20826. case wx.FieldGroupBlockList:
  20827. m.ResetGroupBlockList()
  20828. return nil
  20829. }
  20830. return fmt.Errorf("unknown Wx field %s", name)
  20831. }
  20832. // AddedEdges returns all edge names that were set/added in this mutation.
  20833. func (m *WxMutation) AddedEdges() []string {
  20834. edges := make([]string, 0, 2)
  20835. if m.server != nil {
  20836. edges = append(edges, wx.EdgeServer)
  20837. }
  20838. if m.agent != nil {
  20839. edges = append(edges, wx.EdgeAgent)
  20840. }
  20841. return edges
  20842. }
  20843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20844. // name in this mutation.
  20845. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  20846. switch name {
  20847. case wx.EdgeServer:
  20848. if id := m.server; id != nil {
  20849. return []ent.Value{*id}
  20850. }
  20851. case wx.EdgeAgent:
  20852. if id := m.agent; id != nil {
  20853. return []ent.Value{*id}
  20854. }
  20855. }
  20856. return nil
  20857. }
  20858. // RemovedEdges returns all edge names that were removed in this mutation.
  20859. func (m *WxMutation) RemovedEdges() []string {
  20860. edges := make([]string, 0, 2)
  20861. return edges
  20862. }
  20863. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20864. // the given name in this mutation.
  20865. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  20866. return nil
  20867. }
  20868. // ClearedEdges returns all edge names that were cleared in this mutation.
  20869. func (m *WxMutation) ClearedEdges() []string {
  20870. edges := make([]string, 0, 2)
  20871. if m.clearedserver {
  20872. edges = append(edges, wx.EdgeServer)
  20873. }
  20874. if m.clearedagent {
  20875. edges = append(edges, wx.EdgeAgent)
  20876. }
  20877. return edges
  20878. }
  20879. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20880. // was cleared in this mutation.
  20881. func (m *WxMutation) EdgeCleared(name string) bool {
  20882. switch name {
  20883. case wx.EdgeServer:
  20884. return m.clearedserver
  20885. case wx.EdgeAgent:
  20886. return m.clearedagent
  20887. }
  20888. return false
  20889. }
  20890. // ClearEdge clears the value of the edge with the given name. It returns an error
  20891. // if that edge is not defined in the schema.
  20892. func (m *WxMutation) ClearEdge(name string) error {
  20893. switch name {
  20894. case wx.EdgeServer:
  20895. m.ClearServer()
  20896. return nil
  20897. case wx.EdgeAgent:
  20898. m.ClearAgent()
  20899. return nil
  20900. }
  20901. return fmt.Errorf("unknown Wx unique edge %s", name)
  20902. }
  20903. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20904. // It returns an error if the edge is not defined in the schema.
  20905. func (m *WxMutation) ResetEdge(name string) error {
  20906. switch name {
  20907. case wx.EdgeServer:
  20908. m.ResetServer()
  20909. return nil
  20910. case wx.EdgeAgent:
  20911. m.ResetAgent()
  20912. return nil
  20913. }
  20914. return fmt.Errorf("unknown Wx edge %s", name)
  20915. }