mutation.go 604 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/contact"
  12. "wechat-api/ent/custom_types"
  13. "wechat-api/ent/employee"
  14. "wechat-api/ent/employeeconfig"
  15. "wechat-api/ent/label"
  16. "wechat-api/ent/labelrelationship"
  17. "wechat-api/ent/message"
  18. "wechat-api/ent/messagerecords"
  19. "wechat-api/ent/msg"
  20. "wechat-api/ent/predicate"
  21. "wechat-api/ent/server"
  22. "wechat-api/ent/sopnode"
  23. "wechat-api/ent/sopstage"
  24. "wechat-api/ent/soptask"
  25. "wechat-api/ent/token"
  26. "wechat-api/ent/tutorial"
  27. "wechat-api/ent/workexperience"
  28. "wechat-api/ent/wx"
  29. "entgo.io/ent"
  30. "entgo.io/ent/dialect/sql"
  31. )
  32. const (
  33. // Operation types.
  34. OpCreate = ent.OpCreate
  35. OpDelete = ent.OpDelete
  36. OpDeleteOne = ent.OpDeleteOne
  37. OpUpdate = ent.OpUpdate
  38. OpUpdateOne = ent.OpUpdateOne
  39. // Node types.
  40. TypeAgent = "Agent"
  41. TypeBatchMsg = "BatchMsg"
  42. TypeContact = "Contact"
  43. TypeEmployee = "Employee"
  44. TypeEmployeeConfig = "EmployeeConfig"
  45. TypeLabel = "Label"
  46. TypeLabelRelationship = "LabelRelationship"
  47. TypeMessage = "Message"
  48. TypeMessageRecords = "MessageRecords"
  49. TypeMsg = "Msg"
  50. TypeServer = "Server"
  51. TypeSopNode = "SopNode"
  52. TypeSopStage = "SopStage"
  53. TypeSopTask = "SopTask"
  54. TypeToken = "Token"
  55. TypeTutorial = "Tutorial"
  56. TypeWorkExperience = "WorkExperience"
  57. TypeWx = "Wx"
  58. )
  59. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  60. type AgentMutation struct {
  61. config
  62. op Op
  63. typ string
  64. id *uint64
  65. created_at *time.Time
  66. updated_at *time.Time
  67. deleted_at *time.Time
  68. name *string
  69. role *string
  70. status *int
  71. addstatus *int
  72. background *string
  73. examples *string
  74. organization_id *uint64
  75. addorganization_id *int64
  76. clearedFields map[string]struct{}
  77. wx_agent map[uint64]struct{}
  78. removedwx_agent map[uint64]struct{}
  79. clearedwx_agent bool
  80. done bool
  81. oldValue func(context.Context) (*Agent, error)
  82. predicates []predicate.Agent
  83. }
  84. var _ ent.Mutation = (*AgentMutation)(nil)
  85. // agentOption allows management of the mutation configuration using functional options.
  86. type agentOption func(*AgentMutation)
  87. // newAgentMutation creates new mutation for the Agent entity.
  88. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  89. m := &AgentMutation{
  90. config: c,
  91. op: op,
  92. typ: TypeAgent,
  93. clearedFields: make(map[string]struct{}),
  94. }
  95. for _, opt := range opts {
  96. opt(m)
  97. }
  98. return m
  99. }
  100. // withAgentID sets the ID field of the mutation.
  101. func withAgentID(id uint64) agentOption {
  102. return func(m *AgentMutation) {
  103. var (
  104. err error
  105. once sync.Once
  106. value *Agent
  107. )
  108. m.oldValue = func(ctx context.Context) (*Agent, error) {
  109. once.Do(func() {
  110. if m.done {
  111. err = errors.New("querying old values post mutation is not allowed")
  112. } else {
  113. value, err = m.Client().Agent.Get(ctx, id)
  114. }
  115. })
  116. return value, err
  117. }
  118. m.id = &id
  119. }
  120. }
  121. // withAgent sets the old Agent of the mutation.
  122. func withAgent(node *Agent) agentOption {
  123. return func(m *AgentMutation) {
  124. m.oldValue = func(context.Context) (*Agent, error) {
  125. return node, nil
  126. }
  127. m.id = &node.ID
  128. }
  129. }
  130. // Client returns a new `ent.Client` from the mutation. If the mutation was
  131. // executed in a transaction (ent.Tx), a transactional client is returned.
  132. func (m AgentMutation) Client() *Client {
  133. client := &Client{config: m.config}
  134. client.init()
  135. return client
  136. }
  137. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  138. // it returns an error otherwise.
  139. func (m AgentMutation) Tx() (*Tx, error) {
  140. if _, ok := m.driver.(*txDriver); !ok {
  141. return nil, errors.New("ent: mutation is not running in a transaction")
  142. }
  143. tx := &Tx{config: m.config}
  144. tx.init()
  145. return tx, nil
  146. }
  147. // SetID sets the value of the id field. Note that this
  148. // operation is only accepted on creation of Agent entities.
  149. func (m *AgentMutation) SetID(id uint64) {
  150. m.id = &id
  151. }
  152. // ID returns the ID value in the mutation. Note that the ID is only available
  153. // if it was provided to the builder or after it was returned from the database.
  154. func (m *AgentMutation) ID() (id uint64, exists bool) {
  155. if m.id == nil {
  156. return
  157. }
  158. return *m.id, true
  159. }
  160. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  161. // That means, if the mutation is applied within a transaction with an isolation level such
  162. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  163. // or updated by the mutation.
  164. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  165. switch {
  166. case m.op.Is(OpUpdateOne | OpDeleteOne):
  167. id, exists := m.ID()
  168. if exists {
  169. return []uint64{id}, nil
  170. }
  171. fallthrough
  172. case m.op.Is(OpUpdate | OpDelete):
  173. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  174. default:
  175. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  176. }
  177. }
  178. // SetCreatedAt sets the "created_at" field.
  179. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  180. m.created_at = &t
  181. }
  182. // CreatedAt returns the value of the "created_at" field in the mutation.
  183. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  184. v := m.created_at
  185. if v == nil {
  186. return
  187. }
  188. return *v, true
  189. }
  190. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  191. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  193. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  194. if !m.op.Is(OpUpdateOne) {
  195. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  196. }
  197. if m.id == nil || m.oldValue == nil {
  198. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  199. }
  200. oldValue, err := m.oldValue(ctx)
  201. if err != nil {
  202. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  203. }
  204. return oldValue.CreatedAt, nil
  205. }
  206. // ResetCreatedAt resets all changes to the "created_at" field.
  207. func (m *AgentMutation) ResetCreatedAt() {
  208. m.created_at = nil
  209. }
  210. // SetUpdatedAt sets the "updated_at" field.
  211. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  212. m.updated_at = &t
  213. }
  214. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  215. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  216. v := m.updated_at
  217. if v == nil {
  218. return
  219. }
  220. return *v, true
  221. }
  222. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  223. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  225. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  226. if !m.op.Is(OpUpdateOne) {
  227. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  228. }
  229. if m.id == nil || m.oldValue == nil {
  230. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  231. }
  232. oldValue, err := m.oldValue(ctx)
  233. if err != nil {
  234. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  235. }
  236. return oldValue.UpdatedAt, nil
  237. }
  238. // ResetUpdatedAt resets all changes to the "updated_at" field.
  239. func (m *AgentMutation) ResetUpdatedAt() {
  240. m.updated_at = nil
  241. }
  242. // SetDeletedAt sets the "deleted_at" field.
  243. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  244. m.deleted_at = &t
  245. }
  246. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  247. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  248. v := m.deleted_at
  249. if v == nil {
  250. return
  251. }
  252. return *v, true
  253. }
  254. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  255. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  257. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  258. if !m.op.Is(OpUpdateOne) {
  259. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  260. }
  261. if m.id == nil || m.oldValue == nil {
  262. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  263. }
  264. oldValue, err := m.oldValue(ctx)
  265. if err != nil {
  266. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  267. }
  268. return oldValue.DeletedAt, nil
  269. }
  270. // ClearDeletedAt clears the value of the "deleted_at" field.
  271. func (m *AgentMutation) ClearDeletedAt() {
  272. m.deleted_at = nil
  273. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  274. }
  275. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  276. func (m *AgentMutation) DeletedAtCleared() bool {
  277. _, ok := m.clearedFields[agent.FieldDeletedAt]
  278. return ok
  279. }
  280. // ResetDeletedAt resets all changes to the "deleted_at" field.
  281. func (m *AgentMutation) ResetDeletedAt() {
  282. m.deleted_at = nil
  283. delete(m.clearedFields, agent.FieldDeletedAt)
  284. }
  285. // SetName sets the "name" field.
  286. func (m *AgentMutation) SetName(s string) {
  287. m.name = &s
  288. }
  289. // Name returns the value of the "name" field in the mutation.
  290. func (m *AgentMutation) Name() (r string, exists bool) {
  291. v := m.name
  292. if v == nil {
  293. return
  294. }
  295. return *v, true
  296. }
  297. // OldName returns the old "name" field's value of the Agent entity.
  298. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  300. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  301. if !m.op.Is(OpUpdateOne) {
  302. return v, errors.New("OldName is only allowed on UpdateOne operations")
  303. }
  304. if m.id == nil || m.oldValue == nil {
  305. return v, errors.New("OldName requires an ID field in the mutation")
  306. }
  307. oldValue, err := m.oldValue(ctx)
  308. if err != nil {
  309. return v, fmt.Errorf("querying old value for OldName: %w", err)
  310. }
  311. return oldValue.Name, nil
  312. }
  313. // ResetName resets all changes to the "name" field.
  314. func (m *AgentMutation) ResetName() {
  315. m.name = nil
  316. }
  317. // SetRole sets the "role" field.
  318. func (m *AgentMutation) SetRole(s string) {
  319. m.role = &s
  320. }
  321. // Role returns the value of the "role" field in the mutation.
  322. func (m *AgentMutation) Role() (r string, exists bool) {
  323. v := m.role
  324. if v == nil {
  325. return
  326. }
  327. return *v, true
  328. }
  329. // OldRole returns the old "role" field's value of the Agent entity.
  330. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  332. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  333. if !m.op.Is(OpUpdateOne) {
  334. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  335. }
  336. if m.id == nil || m.oldValue == nil {
  337. return v, errors.New("OldRole requires an ID field in the mutation")
  338. }
  339. oldValue, err := m.oldValue(ctx)
  340. if err != nil {
  341. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  342. }
  343. return oldValue.Role, nil
  344. }
  345. // ResetRole resets all changes to the "role" field.
  346. func (m *AgentMutation) ResetRole() {
  347. m.role = nil
  348. }
  349. // SetStatus sets the "status" field.
  350. func (m *AgentMutation) SetStatus(i int) {
  351. m.status = &i
  352. m.addstatus = nil
  353. }
  354. // Status returns the value of the "status" field in the mutation.
  355. func (m *AgentMutation) Status() (r int, exists bool) {
  356. v := m.status
  357. if v == nil {
  358. return
  359. }
  360. return *v, true
  361. }
  362. // OldStatus returns the old "status" field's value of the Agent entity.
  363. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  365. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  366. if !m.op.Is(OpUpdateOne) {
  367. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  368. }
  369. if m.id == nil || m.oldValue == nil {
  370. return v, errors.New("OldStatus requires an ID field in the mutation")
  371. }
  372. oldValue, err := m.oldValue(ctx)
  373. if err != nil {
  374. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  375. }
  376. return oldValue.Status, nil
  377. }
  378. // AddStatus adds i to the "status" field.
  379. func (m *AgentMutation) AddStatus(i int) {
  380. if m.addstatus != nil {
  381. *m.addstatus += i
  382. } else {
  383. m.addstatus = &i
  384. }
  385. }
  386. // AddedStatus returns the value that was added to the "status" field in this mutation.
  387. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  388. v := m.addstatus
  389. if v == nil {
  390. return
  391. }
  392. return *v, true
  393. }
  394. // ClearStatus clears the value of the "status" field.
  395. func (m *AgentMutation) ClearStatus() {
  396. m.status = nil
  397. m.addstatus = nil
  398. m.clearedFields[agent.FieldStatus] = struct{}{}
  399. }
  400. // StatusCleared returns if the "status" field was cleared in this mutation.
  401. func (m *AgentMutation) StatusCleared() bool {
  402. _, ok := m.clearedFields[agent.FieldStatus]
  403. return ok
  404. }
  405. // ResetStatus resets all changes to the "status" field.
  406. func (m *AgentMutation) ResetStatus() {
  407. m.status = nil
  408. m.addstatus = nil
  409. delete(m.clearedFields, agent.FieldStatus)
  410. }
  411. // SetBackground sets the "background" field.
  412. func (m *AgentMutation) SetBackground(s string) {
  413. m.background = &s
  414. }
  415. // Background returns the value of the "background" field in the mutation.
  416. func (m *AgentMutation) Background() (r string, exists bool) {
  417. v := m.background
  418. if v == nil {
  419. return
  420. }
  421. return *v, true
  422. }
  423. // OldBackground returns the old "background" field's value of the Agent entity.
  424. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  426. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  427. if !m.op.Is(OpUpdateOne) {
  428. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  429. }
  430. if m.id == nil || m.oldValue == nil {
  431. return v, errors.New("OldBackground requires an ID field in the mutation")
  432. }
  433. oldValue, err := m.oldValue(ctx)
  434. if err != nil {
  435. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  436. }
  437. return oldValue.Background, nil
  438. }
  439. // ClearBackground clears the value of the "background" field.
  440. func (m *AgentMutation) ClearBackground() {
  441. m.background = nil
  442. m.clearedFields[agent.FieldBackground] = struct{}{}
  443. }
  444. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  445. func (m *AgentMutation) BackgroundCleared() bool {
  446. _, ok := m.clearedFields[agent.FieldBackground]
  447. return ok
  448. }
  449. // ResetBackground resets all changes to the "background" field.
  450. func (m *AgentMutation) ResetBackground() {
  451. m.background = nil
  452. delete(m.clearedFields, agent.FieldBackground)
  453. }
  454. // SetExamples sets the "examples" field.
  455. func (m *AgentMutation) SetExamples(s string) {
  456. m.examples = &s
  457. }
  458. // Examples returns the value of the "examples" field in the mutation.
  459. func (m *AgentMutation) Examples() (r string, exists bool) {
  460. v := m.examples
  461. if v == nil {
  462. return
  463. }
  464. return *v, true
  465. }
  466. // OldExamples returns the old "examples" field's value of the Agent entity.
  467. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  469. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  470. if !m.op.Is(OpUpdateOne) {
  471. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  472. }
  473. if m.id == nil || m.oldValue == nil {
  474. return v, errors.New("OldExamples requires an ID field in the mutation")
  475. }
  476. oldValue, err := m.oldValue(ctx)
  477. if err != nil {
  478. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  479. }
  480. return oldValue.Examples, nil
  481. }
  482. // ClearExamples clears the value of the "examples" field.
  483. func (m *AgentMutation) ClearExamples() {
  484. m.examples = nil
  485. m.clearedFields[agent.FieldExamples] = struct{}{}
  486. }
  487. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  488. func (m *AgentMutation) ExamplesCleared() bool {
  489. _, ok := m.clearedFields[agent.FieldExamples]
  490. return ok
  491. }
  492. // ResetExamples resets all changes to the "examples" field.
  493. func (m *AgentMutation) ResetExamples() {
  494. m.examples = nil
  495. delete(m.clearedFields, agent.FieldExamples)
  496. }
  497. // SetOrganizationID sets the "organization_id" field.
  498. func (m *AgentMutation) SetOrganizationID(u uint64) {
  499. m.organization_id = &u
  500. m.addorganization_id = nil
  501. }
  502. // OrganizationID returns the value of the "organization_id" field in the mutation.
  503. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  504. v := m.organization_id
  505. if v == nil {
  506. return
  507. }
  508. return *v, true
  509. }
  510. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  511. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  513. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  514. if !m.op.Is(OpUpdateOne) {
  515. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  516. }
  517. if m.id == nil || m.oldValue == nil {
  518. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  519. }
  520. oldValue, err := m.oldValue(ctx)
  521. if err != nil {
  522. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  523. }
  524. return oldValue.OrganizationID, nil
  525. }
  526. // AddOrganizationID adds u to the "organization_id" field.
  527. func (m *AgentMutation) AddOrganizationID(u int64) {
  528. if m.addorganization_id != nil {
  529. *m.addorganization_id += u
  530. } else {
  531. m.addorganization_id = &u
  532. }
  533. }
  534. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  535. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  536. v := m.addorganization_id
  537. if v == nil {
  538. return
  539. }
  540. return *v, true
  541. }
  542. // ResetOrganizationID resets all changes to the "organization_id" field.
  543. func (m *AgentMutation) ResetOrganizationID() {
  544. m.organization_id = nil
  545. m.addorganization_id = nil
  546. }
  547. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  548. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  549. if m.wx_agent == nil {
  550. m.wx_agent = make(map[uint64]struct{})
  551. }
  552. for i := range ids {
  553. m.wx_agent[ids[i]] = struct{}{}
  554. }
  555. }
  556. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  557. func (m *AgentMutation) ClearWxAgent() {
  558. m.clearedwx_agent = true
  559. }
  560. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  561. func (m *AgentMutation) WxAgentCleared() bool {
  562. return m.clearedwx_agent
  563. }
  564. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  565. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  566. if m.removedwx_agent == nil {
  567. m.removedwx_agent = make(map[uint64]struct{})
  568. }
  569. for i := range ids {
  570. delete(m.wx_agent, ids[i])
  571. m.removedwx_agent[ids[i]] = struct{}{}
  572. }
  573. }
  574. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  575. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  576. for id := range m.removedwx_agent {
  577. ids = append(ids, id)
  578. }
  579. return
  580. }
  581. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  582. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  583. for id := range m.wx_agent {
  584. ids = append(ids, id)
  585. }
  586. return
  587. }
  588. // ResetWxAgent resets all changes to the "wx_agent" edge.
  589. func (m *AgentMutation) ResetWxAgent() {
  590. m.wx_agent = nil
  591. m.clearedwx_agent = false
  592. m.removedwx_agent = nil
  593. }
  594. // Where appends a list predicates to the AgentMutation builder.
  595. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  596. m.predicates = append(m.predicates, ps...)
  597. }
  598. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  599. // users can use type-assertion to append predicates that do not depend on any generated package.
  600. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  601. p := make([]predicate.Agent, len(ps))
  602. for i := range ps {
  603. p[i] = ps[i]
  604. }
  605. m.Where(p...)
  606. }
  607. // Op returns the operation name.
  608. func (m *AgentMutation) Op() Op {
  609. return m.op
  610. }
  611. // SetOp allows setting the mutation operation.
  612. func (m *AgentMutation) SetOp(op Op) {
  613. m.op = op
  614. }
  615. // Type returns the node type of this mutation (Agent).
  616. func (m *AgentMutation) Type() string {
  617. return m.typ
  618. }
  619. // Fields returns all fields that were changed during this mutation. Note that in
  620. // order to get all numeric fields that were incremented/decremented, call
  621. // AddedFields().
  622. func (m *AgentMutation) Fields() []string {
  623. fields := make([]string, 0, 9)
  624. if m.created_at != nil {
  625. fields = append(fields, agent.FieldCreatedAt)
  626. }
  627. if m.updated_at != nil {
  628. fields = append(fields, agent.FieldUpdatedAt)
  629. }
  630. if m.deleted_at != nil {
  631. fields = append(fields, agent.FieldDeletedAt)
  632. }
  633. if m.name != nil {
  634. fields = append(fields, agent.FieldName)
  635. }
  636. if m.role != nil {
  637. fields = append(fields, agent.FieldRole)
  638. }
  639. if m.status != nil {
  640. fields = append(fields, agent.FieldStatus)
  641. }
  642. if m.background != nil {
  643. fields = append(fields, agent.FieldBackground)
  644. }
  645. if m.examples != nil {
  646. fields = append(fields, agent.FieldExamples)
  647. }
  648. if m.organization_id != nil {
  649. fields = append(fields, agent.FieldOrganizationID)
  650. }
  651. return fields
  652. }
  653. // Field returns the value of a field with the given name. The second boolean
  654. // return value indicates that this field was not set, or was not defined in the
  655. // schema.
  656. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  657. switch name {
  658. case agent.FieldCreatedAt:
  659. return m.CreatedAt()
  660. case agent.FieldUpdatedAt:
  661. return m.UpdatedAt()
  662. case agent.FieldDeletedAt:
  663. return m.DeletedAt()
  664. case agent.FieldName:
  665. return m.Name()
  666. case agent.FieldRole:
  667. return m.Role()
  668. case agent.FieldStatus:
  669. return m.Status()
  670. case agent.FieldBackground:
  671. return m.Background()
  672. case agent.FieldExamples:
  673. return m.Examples()
  674. case agent.FieldOrganizationID:
  675. return m.OrganizationID()
  676. }
  677. return nil, false
  678. }
  679. // OldField returns the old value of the field from the database. An error is
  680. // returned if the mutation operation is not UpdateOne, or the query to the
  681. // database failed.
  682. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  683. switch name {
  684. case agent.FieldCreatedAt:
  685. return m.OldCreatedAt(ctx)
  686. case agent.FieldUpdatedAt:
  687. return m.OldUpdatedAt(ctx)
  688. case agent.FieldDeletedAt:
  689. return m.OldDeletedAt(ctx)
  690. case agent.FieldName:
  691. return m.OldName(ctx)
  692. case agent.FieldRole:
  693. return m.OldRole(ctx)
  694. case agent.FieldStatus:
  695. return m.OldStatus(ctx)
  696. case agent.FieldBackground:
  697. return m.OldBackground(ctx)
  698. case agent.FieldExamples:
  699. return m.OldExamples(ctx)
  700. case agent.FieldOrganizationID:
  701. return m.OldOrganizationID(ctx)
  702. }
  703. return nil, fmt.Errorf("unknown Agent field %s", name)
  704. }
  705. // SetField sets the value of a field with the given name. It returns an error if
  706. // the field is not defined in the schema, or if the type mismatched the field
  707. // type.
  708. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  709. switch name {
  710. case agent.FieldCreatedAt:
  711. v, ok := value.(time.Time)
  712. if !ok {
  713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  714. }
  715. m.SetCreatedAt(v)
  716. return nil
  717. case agent.FieldUpdatedAt:
  718. v, ok := value.(time.Time)
  719. if !ok {
  720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  721. }
  722. m.SetUpdatedAt(v)
  723. return nil
  724. case agent.FieldDeletedAt:
  725. v, ok := value.(time.Time)
  726. if !ok {
  727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  728. }
  729. m.SetDeletedAt(v)
  730. return nil
  731. case agent.FieldName:
  732. v, ok := value.(string)
  733. if !ok {
  734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  735. }
  736. m.SetName(v)
  737. return nil
  738. case agent.FieldRole:
  739. v, ok := value.(string)
  740. if !ok {
  741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  742. }
  743. m.SetRole(v)
  744. return nil
  745. case agent.FieldStatus:
  746. v, ok := value.(int)
  747. if !ok {
  748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  749. }
  750. m.SetStatus(v)
  751. return nil
  752. case agent.FieldBackground:
  753. v, ok := value.(string)
  754. if !ok {
  755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  756. }
  757. m.SetBackground(v)
  758. return nil
  759. case agent.FieldExamples:
  760. v, ok := value.(string)
  761. if !ok {
  762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  763. }
  764. m.SetExamples(v)
  765. return nil
  766. case agent.FieldOrganizationID:
  767. v, ok := value.(uint64)
  768. if !ok {
  769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  770. }
  771. m.SetOrganizationID(v)
  772. return nil
  773. }
  774. return fmt.Errorf("unknown Agent field %s", name)
  775. }
  776. // AddedFields returns all numeric fields that were incremented/decremented during
  777. // this mutation.
  778. func (m *AgentMutation) AddedFields() []string {
  779. var fields []string
  780. if m.addstatus != nil {
  781. fields = append(fields, agent.FieldStatus)
  782. }
  783. if m.addorganization_id != nil {
  784. fields = append(fields, agent.FieldOrganizationID)
  785. }
  786. return fields
  787. }
  788. // AddedField returns the numeric value that was incremented/decremented on a field
  789. // with the given name. The second boolean return value indicates that this field
  790. // was not set, or was not defined in the schema.
  791. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  792. switch name {
  793. case agent.FieldStatus:
  794. return m.AddedStatus()
  795. case agent.FieldOrganizationID:
  796. return m.AddedOrganizationID()
  797. }
  798. return nil, false
  799. }
  800. // AddField adds the value to the field with the given name. It returns an error if
  801. // the field is not defined in the schema, or if the type mismatched the field
  802. // type.
  803. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  804. switch name {
  805. case agent.FieldStatus:
  806. v, ok := value.(int)
  807. if !ok {
  808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  809. }
  810. m.AddStatus(v)
  811. return nil
  812. case agent.FieldOrganizationID:
  813. v, ok := value.(int64)
  814. if !ok {
  815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  816. }
  817. m.AddOrganizationID(v)
  818. return nil
  819. }
  820. return fmt.Errorf("unknown Agent numeric field %s", name)
  821. }
  822. // ClearedFields returns all nullable fields that were cleared during this
  823. // mutation.
  824. func (m *AgentMutation) ClearedFields() []string {
  825. var fields []string
  826. if m.FieldCleared(agent.FieldDeletedAt) {
  827. fields = append(fields, agent.FieldDeletedAt)
  828. }
  829. if m.FieldCleared(agent.FieldStatus) {
  830. fields = append(fields, agent.FieldStatus)
  831. }
  832. if m.FieldCleared(agent.FieldBackground) {
  833. fields = append(fields, agent.FieldBackground)
  834. }
  835. if m.FieldCleared(agent.FieldExamples) {
  836. fields = append(fields, agent.FieldExamples)
  837. }
  838. return fields
  839. }
  840. // FieldCleared returns a boolean indicating if a field with the given name was
  841. // cleared in this mutation.
  842. func (m *AgentMutation) FieldCleared(name string) bool {
  843. _, ok := m.clearedFields[name]
  844. return ok
  845. }
  846. // ClearField clears the value of the field with the given name. It returns an
  847. // error if the field is not defined in the schema.
  848. func (m *AgentMutation) ClearField(name string) error {
  849. switch name {
  850. case agent.FieldDeletedAt:
  851. m.ClearDeletedAt()
  852. return nil
  853. case agent.FieldStatus:
  854. m.ClearStatus()
  855. return nil
  856. case agent.FieldBackground:
  857. m.ClearBackground()
  858. return nil
  859. case agent.FieldExamples:
  860. m.ClearExamples()
  861. return nil
  862. }
  863. return fmt.Errorf("unknown Agent nullable field %s", name)
  864. }
  865. // ResetField resets all changes in the mutation for the field with the given name.
  866. // It returns an error if the field is not defined in the schema.
  867. func (m *AgentMutation) ResetField(name string) error {
  868. switch name {
  869. case agent.FieldCreatedAt:
  870. m.ResetCreatedAt()
  871. return nil
  872. case agent.FieldUpdatedAt:
  873. m.ResetUpdatedAt()
  874. return nil
  875. case agent.FieldDeletedAt:
  876. m.ResetDeletedAt()
  877. return nil
  878. case agent.FieldName:
  879. m.ResetName()
  880. return nil
  881. case agent.FieldRole:
  882. m.ResetRole()
  883. return nil
  884. case agent.FieldStatus:
  885. m.ResetStatus()
  886. return nil
  887. case agent.FieldBackground:
  888. m.ResetBackground()
  889. return nil
  890. case agent.FieldExamples:
  891. m.ResetExamples()
  892. return nil
  893. case agent.FieldOrganizationID:
  894. m.ResetOrganizationID()
  895. return nil
  896. }
  897. return fmt.Errorf("unknown Agent field %s", name)
  898. }
  899. // AddedEdges returns all edge names that were set/added in this mutation.
  900. func (m *AgentMutation) AddedEdges() []string {
  901. edges := make([]string, 0, 1)
  902. if m.wx_agent != nil {
  903. edges = append(edges, agent.EdgeWxAgent)
  904. }
  905. return edges
  906. }
  907. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  908. // name in this mutation.
  909. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  910. switch name {
  911. case agent.EdgeWxAgent:
  912. ids := make([]ent.Value, 0, len(m.wx_agent))
  913. for id := range m.wx_agent {
  914. ids = append(ids, id)
  915. }
  916. return ids
  917. }
  918. return nil
  919. }
  920. // RemovedEdges returns all edge names that were removed in this mutation.
  921. func (m *AgentMutation) RemovedEdges() []string {
  922. edges := make([]string, 0, 1)
  923. if m.removedwx_agent != nil {
  924. edges = append(edges, agent.EdgeWxAgent)
  925. }
  926. return edges
  927. }
  928. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  929. // the given name in this mutation.
  930. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  931. switch name {
  932. case agent.EdgeWxAgent:
  933. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  934. for id := range m.removedwx_agent {
  935. ids = append(ids, id)
  936. }
  937. return ids
  938. }
  939. return nil
  940. }
  941. // ClearedEdges returns all edge names that were cleared in this mutation.
  942. func (m *AgentMutation) ClearedEdges() []string {
  943. edges := make([]string, 0, 1)
  944. if m.clearedwx_agent {
  945. edges = append(edges, agent.EdgeWxAgent)
  946. }
  947. return edges
  948. }
  949. // EdgeCleared returns a boolean which indicates if the edge with the given name
  950. // was cleared in this mutation.
  951. func (m *AgentMutation) EdgeCleared(name string) bool {
  952. switch name {
  953. case agent.EdgeWxAgent:
  954. return m.clearedwx_agent
  955. }
  956. return false
  957. }
  958. // ClearEdge clears the value of the edge with the given name. It returns an error
  959. // if that edge is not defined in the schema.
  960. func (m *AgentMutation) ClearEdge(name string) error {
  961. switch name {
  962. }
  963. return fmt.Errorf("unknown Agent unique edge %s", name)
  964. }
  965. // ResetEdge resets all changes to the edge with the given name in this mutation.
  966. // It returns an error if the edge is not defined in the schema.
  967. func (m *AgentMutation) ResetEdge(name string) error {
  968. switch name {
  969. case agent.EdgeWxAgent:
  970. m.ResetWxAgent()
  971. return nil
  972. }
  973. return fmt.Errorf("unknown Agent edge %s", name)
  974. }
  975. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  976. type BatchMsgMutation struct {
  977. config
  978. op Op
  979. typ string
  980. id *uint64
  981. created_at *time.Time
  982. updated_at *time.Time
  983. deleted_at *time.Time
  984. status *uint8
  985. addstatus *int8
  986. batch_no *string
  987. task_name *string
  988. fromwxid *string
  989. msg *string
  990. tag *string
  991. total *int32
  992. addtotal *int32
  993. success *int32
  994. addsuccess *int32
  995. fail *int32
  996. addfail *int32
  997. start_time *time.Time
  998. stop_time *time.Time
  999. _type *int32
  1000. add_type *int32
  1001. organization_id *uint64
  1002. addorganization_id *int64
  1003. clearedFields map[string]struct{}
  1004. done bool
  1005. oldValue func(context.Context) (*BatchMsg, error)
  1006. predicates []predicate.BatchMsg
  1007. }
  1008. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  1009. // batchmsgOption allows management of the mutation configuration using functional options.
  1010. type batchmsgOption func(*BatchMsgMutation)
  1011. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  1012. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1013. m := &BatchMsgMutation{
  1014. config: c,
  1015. op: op,
  1016. typ: TypeBatchMsg,
  1017. clearedFields: make(map[string]struct{}),
  1018. }
  1019. for _, opt := range opts {
  1020. opt(m)
  1021. }
  1022. return m
  1023. }
  1024. // withBatchMsgID sets the ID field of the mutation.
  1025. func withBatchMsgID(id uint64) batchmsgOption {
  1026. return func(m *BatchMsgMutation) {
  1027. var (
  1028. err error
  1029. once sync.Once
  1030. value *BatchMsg
  1031. )
  1032. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1033. once.Do(func() {
  1034. if m.done {
  1035. err = errors.New("querying old values post mutation is not allowed")
  1036. } else {
  1037. value, err = m.Client().BatchMsg.Get(ctx, id)
  1038. }
  1039. })
  1040. return value, err
  1041. }
  1042. m.id = &id
  1043. }
  1044. }
  1045. // withBatchMsg sets the old BatchMsg of the mutation.
  1046. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1047. return func(m *BatchMsgMutation) {
  1048. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1049. return node, nil
  1050. }
  1051. m.id = &node.ID
  1052. }
  1053. }
  1054. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1055. // executed in a transaction (ent.Tx), a transactional client is returned.
  1056. func (m BatchMsgMutation) Client() *Client {
  1057. client := &Client{config: m.config}
  1058. client.init()
  1059. return client
  1060. }
  1061. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1062. // it returns an error otherwise.
  1063. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1064. if _, ok := m.driver.(*txDriver); !ok {
  1065. return nil, errors.New("ent: mutation is not running in a transaction")
  1066. }
  1067. tx := &Tx{config: m.config}
  1068. tx.init()
  1069. return tx, nil
  1070. }
  1071. // SetID sets the value of the id field. Note that this
  1072. // operation is only accepted on creation of BatchMsg entities.
  1073. func (m *BatchMsgMutation) SetID(id uint64) {
  1074. m.id = &id
  1075. }
  1076. // ID returns the ID value in the mutation. Note that the ID is only available
  1077. // if it was provided to the builder or after it was returned from the database.
  1078. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1079. if m.id == nil {
  1080. return
  1081. }
  1082. return *m.id, true
  1083. }
  1084. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1085. // That means, if the mutation is applied within a transaction with an isolation level such
  1086. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1087. // or updated by the mutation.
  1088. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1089. switch {
  1090. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1091. id, exists := m.ID()
  1092. if exists {
  1093. return []uint64{id}, nil
  1094. }
  1095. fallthrough
  1096. case m.op.Is(OpUpdate | OpDelete):
  1097. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1098. default:
  1099. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1100. }
  1101. }
  1102. // SetCreatedAt sets the "created_at" field.
  1103. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1104. m.created_at = &t
  1105. }
  1106. // CreatedAt returns the value of the "created_at" field in the mutation.
  1107. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1108. v := m.created_at
  1109. if v == nil {
  1110. return
  1111. }
  1112. return *v, true
  1113. }
  1114. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1115. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1117. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1118. if !m.op.Is(OpUpdateOne) {
  1119. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1120. }
  1121. if m.id == nil || m.oldValue == nil {
  1122. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1123. }
  1124. oldValue, err := m.oldValue(ctx)
  1125. if err != nil {
  1126. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1127. }
  1128. return oldValue.CreatedAt, nil
  1129. }
  1130. // ResetCreatedAt resets all changes to the "created_at" field.
  1131. func (m *BatchMsgMutation) ResetCreatedAt() {
  1132. m.created_at = nil
  1133. }
  1134. // SetUpdatedAt sets the "updated_at" field.
  1135. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1136. m.updated_at = &t
  1137. }
  1138. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1139. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1140. v := m.updated_at
  1141. if v == nil {
  1142. return
  1143. }
  1144. return *v, true
  1145. }
  1146. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1147. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1149. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1150. if !m.op.Is(OpUpdateOne) {
  1151. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1152. }
  1153. if m.id == nil || m.oldValue == nil {
  1154. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1155. }
  1156. oldValue, err := m.oldValue(ctx)
  1157. if err != nil {
  1158. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1159. }
  1160. return oldValue.UpdatedAt, nil
  1161. }
  1162. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1163. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1164. m.updated_at = nil
  1165. }
  1166. // SetDeletedAt sets the "deleted_at" field.
  1167. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1168. m.deleted_at = &t
  1169. }
  1170. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1171. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1172. v := m.deleted_at
  1173. if v == nil {
  1174. return
  1175. }
  1176. return *v, true
  1177. }
  1178. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1179. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1181. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1182. if !m.op.Is(OpUpdateOne) {
  1183. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1184. }
  1185. if m.id == nil || m.oldValue == nil {
  1186. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1187. }
  1188. oldValue, err := m.oldValue(ctx)
  1189. if err != nil {
  1190. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1191. }
  1192. return oldValue.DeletedAt, nil
  1193. }
  1194. // ClearDeletedAt clears the value of the "deleted_at" field.
  1195. func (m *BatchMsgMutation) ClearDeletedAt() {
  1196. m.deleted_at = nil
  1197. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1198. }
  1199. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1200. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1201. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1202. return ok
  1203. }
  1204. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1205. func (m *BatchMsgMutation) ResetDeletedAt() {
  1206. m.deleted_at = nil
  1207. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1208. }
  1209. // SetStatus sets the "status" field.
  1210. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1211. m.status = &u
  1212. m.addstatus = nil
  1213. }
  1214. // Status returns the value of the "status" field in the mutation.
  1215. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1216. v := m.status
  1217. if v == nil {
  1218. return
  1219. }
  1220. return *v, true
  1221. }
  1222. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1223. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1225. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1226. if !m.op.Is(OpUpdateOne) {
  1227. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1228. }
  1229. if m.id == nil || m.oldValue == nil {
  1230. return v, errors.New("OldStatus requires an ID field in the mutation")
  1231. }
  1232. oldValue, err := m.oldValue(ctx)
  1233. if err != nil {
  1234. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1235. }
  1236. return oldValue.Status, nil
  1237. }
  1238. // AddStatus adds u to the "status" field.
  1239. func (m *BatchMsgMutation) AddStatus(u int8) {
  1240. if m.addstatus != nil {
  1241. *m.addstatus += u
  1242. } else {
  1243. m.addstatus = &u
  1244. }
  1245. }
  1246. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1247. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1248. v := m.addstatus
  1249. if v == nil {
  1250. return
  1251. }
  1252. return *v, true
  1253. }
  1254. // ClearStatus clears the value of the "status" field.
  1255. func (m *BatchMsgMutation) ClearStatus() {
  1256. m.status = nil
  1257. m.addstatus = nil
  1258. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1259. }
  1260. // StatusCleared returns if the "status" field was cleared in this mutation.
  1261. func (m *BatchMsgMutation) StatusCleared() bool {
  1262. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1263. return ok
  1264. }
  1265. // ResetStatus resets all changes to the "status" field.
  1266. func (m *BatchMsgMutation) ResetStatus() {
  1267. m.status = nil
  1268. m.addstatus = nil
  1269. delete(m.clearedFields, batchmsg.FieldStatus)
  1270. }
  1271. // SetBatchNo sets the "batch_no" field.
  1272. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1273. m.batch_no = &s
  1274. }
  1275. // BatchNo returns the value of the "batch_no" field in the mutation.
  1276. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1277. v := m.batch_no
  1278. if v == nil {
  1279. return
  1280. }
  1281. return *v, true
  1282. }
  1283. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1284. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1286. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1287. if !m.op.Is(OpUpdateOne) {
  1288. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1289. }
  1290. if m.id == nil || m.oldValue == nil {
  1291. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1292. }
  1293. oldValue, err := m.oldValue(ctx)
  1294. if err != nil {
  1295. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1296. }
  1297. return oldValue.BatchNo, nil
  1298. }
  1299. // ClearBatchNo clears the value of the "batch_no" field.
  1300. func (m *BatchMsgMutation) ClearBatchNo() {
  1301. m.batch_no = nil
  1302. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1303. }
  1304. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1305. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1306. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1307. return ok
  1308. }
  1309. // ResetBatchNo resets all changes to the "batch_no" field.
  1310. func (m *BatchMsgMutation) ResetBatchNo() {
  1311. m.batch_no = nil
  1312. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1313. }
  1314. // SetTaskName sets the "task_name" field.
  1315. func (m *BatchMsgMutation) SetTaskName(s string) {
  1316. m.task_name = &s
  1317. }
  1318. // TaskName returns the value of the "task_name" field in the mutation.
  1319. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1320. v := m.task_name
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1327. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1329. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1335. }
  1336. oldValue, err := m.oldValue(ctx)
  1337. if err != nil {
  1338. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1339. }
  1340. return oldValue.TaskName, nil
  1341. }
  1342. // ClearTaskName clears the value of the "task_name" field.
  1343. func (m *BatchMsgMutation) ClearTaskName() {
  1344. m.task_name = nil
  1345. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1346. }
  1347. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1348. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1349. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1350. return ok
  1351. }
  1352. // ResetTaskName resets all changes to the "task_name" field.
  1353. func (m *BatchMsgMutation) ResetTaskName() {
  1354. m.task_name = nil
  1355. delete(m.clearedFields, batchmsg.FieldTaskName)
  1356. }
  1357. // SetFromwxid sets the "fromwxid" field.
  1358. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1359. m.fromwxid = &s
  1360. }
  1361. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1362. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1363. v := m.fromwxid
  1364. if v == nil {
  1365. return
  1366. }
  1367. return *v, true
  1368. }
  1369. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1370. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1372. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1373. if !m.op.Is(OpUpdateOne) {
  1374. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1375. }
  1376. if m.id == nil || m.oldValue == nil {
  1377. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1378. }
  1379. oldValue, err := m.oldValue(ctx)
  1380. if err != nil {
  1381. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1382. }
  1383. return oldValue.Fromwxid, nil
  1384. }
  1385. // ClearFromwxid clears the value of the "fromwxid" field.
  1386. func (m *BatchMsgMutation) ClearFromwxid() {
  1387. m.fromwxid = nil
  1388. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1389. }
  1390. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1391. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1392. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1393. return ok
  1394. }
  1395. // ResetFromwxid resets all changes to the "fromwxid" field.
  1396. func (m *BatchMsgMutation) ResetFromwxid() {
  1397. m.fromwxid = nil
  1398. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1399. }
  1400. // SetMsg sets the "msg" field.
  1401. func (m *BatchMsgMutation) SetMsg(s string) {
  1402. m.msg = &s
  1403. }
  1404. // Msg returns the value of the "msg" field in the mutation.
  1405. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1406. v := m.msg
  1407. if v == nil {
  1408. return
  1409. }
  1410. return *v, true
  1411. }
  1412. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1413. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1415. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1416. if !m.op.Is(OpUpdateOne) {
  1417. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1418. }
  1419. if m.id == nil || m.oldValue == nil {
  1420. return v, errors.New("OldMsg requires an ID field in the mutation")
  1421. }
  1422. oldValue, err := m.oldValue(ctx)
  1423. if err != nil {
  1424. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1425. }
  1426. return oldValue.Msg, nil
  1427. }
  1428. // ClearMsg clears the value of the "msg" field.
  1429. func (m *BatchMsgMutation) ClearMsg() {
  1430. m.msg = nil
  1431. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1432. }
  1433. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1434. func (m *BatchMsgMutation) MsgCleared() bool {
  1435. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1436. return ok
  1437. }
  1438. // ResetMsg resets all changes to the "msg" field.
  1439. func (m *BatchMsgMutation) ResetMsg() {
  1440. m.msg = nil
  1441. delete(m.clearedFields, batchmsg.FieldMsg)
  1442. }
  1443. // SetTag sets the "tag" field.
  1444. func (m *BatchMsgMutation) SetTag(s string) {
  1445. m.tag = &s
  1446. }
  1447. // Tag returns the value of the "tag" field in the mutation.
  1448. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1449. v := m.tag
  1450. if v == nil {
  1451. return
  1452. }
  1453. return *v, true
  1454. }
  1455. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1456. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1458. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1459. if !m.op.Is(OpUpdateOne) {
  1460. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1461. }
  1462. if m.id == nil || m.oldValue == nil {
  1463. return v, errors.New("OldTag requires an ID field in the mutation")
  1464. }
  1465. oldValue, err := m.oldValue(ctx)
  1466. if err != nil {
  1467. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1468. }
  1469. return oldValue.Tag, nil
  1470. }
  1471. // ClearTag clears the value of the "tag" field.
  1472. func (m *BatchMsgMutation) ClearTag() {
  1473. m.tag = nil
  1474. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1475. }
  1476. // TagCleared returns if the "tag" field was cleared in this mutation.
  1477. func (m *BatchMsgMutation) TagCleared() bool {
  1478. _, ok := m.clearedFields[batchmsg.FieldTag]
  1479. return ok
  1480. }
  1481. // ResetTag resets all changes to the "tag" field.
  1482. func (m *BatchMsgMutation) ResetTag() {
  1483. m.tag = nil
  1484. delete(m.clearedFields, batchmsg.FieldTag)
  1485. }
  1486. // SetTotal sets the "total" field.
  1487. func (m *BatchMsgMutation) SetTotal(i int32) {
  1488. m.total = &i
  1489. m.addtotal = nil
  1490. }
  1491. // Total returns the value of the "total" field in the mutation.
  1492. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1493. v := m.total
  1494. if v == nil {
  1495. return
  1496. }
  1497. return *v, true
  1498. }
  1499. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1500. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1502. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1503. if !m.op.Is(OpUpdateOne) {
  1504. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1505. }
  1506. if m.id == nil || m.oldValue == nil {
  1507. return v, errors.New("OldTotal requires an ID field in the mutation")
  1508. }
  1509. oldValue, err := m.oldValue(ctx)
  1510. if err != nil {
  1511. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1512. }
  1513. return oldValue.Total, nil
  1514. }
  1515. // AddTotal adds i to the "total" field.
  1516. func (m *BatchMsgMutation) AddTotal(i int32) {
  1517. if m.addtotal != nil {
  1518. *m.addtotal += i
  1519. } else {
  1520. m.addtotal = &i
  1521. }
  1522. }
  1523. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1524. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1525. v := m.addtotal
  1526. if v == nil {
  1527. return
  1528. }
  1529. return *v, true
  1530. }
  1531. // ClearTotal clears the value of the "total" field.
  1532. func (m *BatchMsgMutation) ClearTotal() {
  1533. m.total = nil
  1534. m.addtotal = nil
  1535. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1536. }
  1537. // TotalCleared returns if the "total" field was cleared in this mutation.
  1538. func (m *BatchMsgMutation) TotalCleared() bool {
  1539. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1540. return ok
  1541. }
  1542. // ResetTotal resets all changes to the "total" field.
  1543. func (m *BatchMsgMutation) ResetTotal() {
  1544. m.total = nil
  1545. m.addtotal = nil
  1546. delete(m.clearedFields, batchmsg.FieldTotal)
  1547. }
  1548. // SetSuccess sets the "success" field.
  1549. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1550. m.success = &i
  1551. m.addsuccess = nil
  1552. }
  1553. // Success returns the value of the "success" field in the mutation.
  1554. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1555. v := m.success
  1556. if v == nil {
  1557. return
  1558. }
  1559. return *v, true
  1560. }
  1561. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1562. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1564. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1565. if !m.op.Is(OpUpdateOne) {
  1566. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1567. }
  1568. if m.id == nil || m.oldValue == nil {
  1569. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1570. }
  1571. oldValue, err := m.oldValue(ctx)
  1572. if err != nil {
  1573. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1574. }
  1575. return oldValue.Success, nil
  1576. }
  1577. // AddSuccess adds i to the "success" field.
  1578. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1579. if m.addsuccess != nil {
  1580. *m.addsuccess += i
  1581. } else {
  1582. m.addsuccess = &i
  1583. }
  1584. }
  1585. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1586. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1587. v := m.addsuccess
  1588. if v == nil {
  1589. return
  1590. }
  1591. return *v, true
  1592. }
  1593. // ClearSuccess clears the value of the "success" field.
  1594. func (m *BatchMsgMutation) ClearSuccess() {
  1595. m.success = nil
  1596. m.addsuccess = nil
  1597. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1598. }
  1599. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1600. func (m *BatchMsgMutation) SuccessCleared() bool {
  1601. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1602. return ok
  1603. }
  1604. // ResetSuccess resets all changes to the "success" field.
  1605. func (m *BatchMsgMutation) ResetSuccess() {
  1606. m.success = nil
  1607. m.addsuccess = nil
  1608. delete(m.clearedFields, batchmsg.FieldSuccess)
  1609. }
  1610. // SetFail sets the "fail" field.
  1611. func (m *BatchMsgMutation) SetFail(i int32) {
  1612. m.fail = &i
  1613. m.addfail = nil
  1614. }
  1615. // Fail returns the value of the "fail" field in the mutation.
  1616. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1617. v := m.fail
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1624. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1626. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldFail requires an ID field in the mutation")
  1632. }
  1633. oldValue, err := m.oldValue(ctx)
  1634. if err != nil {
  1635. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1636. }
  1637. return oldValue.Fail, nil
  1638. }
  1639. // AddFail adds i to the "fail" field.
  1640. func (m *BatchMsgMutation) AddFail(i int32) {
  1641. if m.addfail != nil {
  1642. *m.addfail += i
  1643. } else {
  1644. m.addfail = &i
  1645. }
  1646. }
  1647. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1648. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1649. v := m.addfail
  1650. if v == nil {
  1651. return
  1652. }
  1653. return *v, true
  1654. }
  1655. // ClearFail clears the value of the "fail" field.
  1656. func (m *BatchMsgMutation) ClearFail() {
  1657. m.fail = nil
  1658. m.addfail = nil
  1659. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1660. }
  1661. // FailCleared returns if the "fail" field was cleared in this mutation.
  1662. func (m *BatchMsgMutation) FailCleared() bool {
  1663. _, ok := m.clearedFields[batchmsg.FieldFail]
  1664. return ok
  1665. }
  1666. // ResetFail resets all changes to the "fail" field.
  1667. func (m *BatchMsgMutation) ResetFail() {
  1668. m.fail = nil
  1669. m.addfail = nil
  1670. delete(m.clearedFields, batchmsg.FieldFail)
  1671. }
  1672. // SetStartTime sets the "start_time" field.
  1673. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1674. m.start_time = &t
  1675. }
  1676. // StartTime returns the value of the "start_time" field in the mutation.
  1677. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1678. v := m.start_time
  1679. if v == nil {
  1680. return
  1681. }
  1682. return *v, true
  1683. }
  1684. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1685. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1687. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1688. if !m.op.Is(OpUpdateOne) {
  1689. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1690. }
  1691. if m.id == nil || m.oldValue == nil {
  1692. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1693. }
  1694. oldValue, err := m.oldValue(ctx)
  1695. if err != nil {
  1696. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1697. }
  1698. return oldValue.StartTime, nil
  1699. }
  1700. // ClearStartTime clears the value of the "start_time" field.
  1701. func (m *BatchMsgMutation) ClearStartTime() {
  1702. m.start_time = nil
  1703. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1704. }
  1705. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1706. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1707. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1708. return ok
  1709. }
  1710. // ResetStartTime resets all changes to the "start_time" field.
  1711. func (m *BatchMsgMutation) ResetStartTime() {
  1712. m.start_time = nil
  1713. delete(m.clearedFields, batchmsg.FieldStartTime)
  1714. }
  1715. // SetStopTime sets the "stop_time" field.
  1716. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1717. m.stop_time = &t
  1718. }
  1719. // StopTime returns the value of the "stop_time" field in the mutation.
  1720. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1721. v := m.stop_time
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1728. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1740. }
  1741. return oldValue.StopTime, nil
  1742. }
  1743. // ClearStopTime clears the value of the "stop_time" field.
  1744. func (m *BatchMsgMutation) ClearStopTime() {
  1745. m.stop_time = nil
  1746. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1747. }
  1748. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1749. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1750. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1751. return ok
  1752. }
  1753. // ResetStopTime resets all changes to the "stop_time" field.
  1754. func (m *BatchMsgMutation) ResetStopTime() {
  1755. m.stop_time = nil
  1756. delete(m.clearedFields, batchmsg.FieldStopTime)
  1757. }
  1758. // SetType sets the "type" field.
  1759. func (m *BatchMsgMutation) SetType(i int32) {
  1760. m._type = &i
  1761. m.add_type = nil
  1762. }
  1763. // GetType returns the value of the "type" field in the mutation.
  1764. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  1765. v := m._type
  1766. if v == nil {
  1767. return
  1768. }
  1769. return *v, true
  1770. }
  1771. // OldType returns the old "type" field's value of the BatchMsg entity.
  1772. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1774. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  1775. if !m.op.Is(OpUpdateOne) {
  1776. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1777. }
  1778. if m.id == nil || m.oldValue == nil {
  1779. return v, errors.New("OldType requires an ID field in the mutation")
  1780. }
  1781. oldValue, err := m.oldValue(ctx)
  1782. if err != nil {
  1783. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1784. }
  1785. return oldValue.Type, nil
  1786. }
  1787. // AddType adds i to the "type" field.
  1788. func (m *BatchMsgMutation) AddType(i int32) {
  1789. if m.add_type != nil {
  1790. *m.add_type += i
  1791. } else {
  1792. m.add_type = &i
  1793. }
  1794. }
  1795. // AddedType returns the value that was added to the "type" field in this mutation.
  1796. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  1797. v := m.add_type
  1798. if v == nil {
  1799. return
  1800. }
  1801. return *v, true
  1802. }
  1803. // ClearType clears the value of the "type" field.
  1804. func (m *BatchMsgMutation) ClearType() {
  1805. m._type = nil
  1806. m.add_type = nil
  1807. m.clearedFields[batchmsg.FieldType] = struct{}{}
  1808. }
  1809. // TypeCleared returns if the "type" field was cleared in this mutation.
  1810. func (m *BatchMsgMutation) TypeCleared() bool {
  1811. _, ok := m.clearedFields[batchmsg.FieldType]
  1812. return ok
  1813. }
  1814. // ResetType resets all changes to the "type" field.
  1815. func (m *BatchMsgMutation) ResetType() {
  1816. m._type = nil
  1817. m.add_type = nil
  1818. delete(m.clearedFields, batchmsg.FieldType)
  1819. }
  1820. // SetOrganizationID sets the "organization_id" field.
  1821. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  1822. m.organization_id = &u
  1823. m.addorganization_id = nil
  1824. }
  1825. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1826. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  1827. v := m.organization_id
  1828. if v == nil {
  1829. return
  1830. }
  1831. return *v, true
  1832. }
  1833. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  1834. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1836. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1837. if !m.op.Is(OpUpdateOne) {
  1838. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1839. }
  1840. if m.id == nil || m.oldValue == nil {
  1841. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1842. }
  1843. oldValue, err := m.oldValue(ctx)
  1844. if err != nil {
  1845. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1846. }
  1847. return oldValue.OrganizationID, nil
  1848. }
  1849. // AddOrganizationID adds u to the "organization_id" field.
  1850. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  1851. if m.addorganization_id != nil {
  1852. *m.addorganization_id += u
  1853. } else {
  1854. m.addorganization_id = &u
  1855. }
  1856. }
  1857. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1858. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  1859. v := m.addorganization_id
  1860. if v == nil {
  1861. return
  1862. }
  1863. return *v, true
  1864. }
  1865. // ResetOrganizationID resets all changes to the "organization_id" field.
  1866. func (m *BatchMsgMutation) ResetOrganizationID() {
  1867. m.organization_id = nil
  1868. m.addorganization_id = nil
  1869. }
  1870. // Where appends a list predicates to the BatchMsgMutation builder.
  1871. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1872. m.predicates = append(m.predicates, ps...)
  1873. }
  1874. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1875. // users can use type-assertion to append predicates that do not depend on any generated package.
  1876. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1877. p := make([]predicate.BatchMsg, len(ps))
  1878. for i := range ps {
  1879. p[i] = ps[i]
  1880. }
  1881. m.Where(p...)
  1882. }
  1883. // Op returns the operation name.
  1884. func (m *BatchMsgMutation) Op() Op {
  1885. return m.op
  1886. }
  1887. // SetOp allows setting the mutation operation.
  1888. func (m *BatchMsgMutation) SetOp(op Op) {
  1889. m.op = op
  1890. }
  1891. // Type returns the node type of this mutation (BatchMsg).
  1892. func (m *BatchMsgMutation) Type() string {
  1893. return m.typ
  1894. }
  1895. // Fields returns all fields that were changed during this mutation. Note that in
  1896. // order to get all numeric fields that were incremented/decremented, call
  1897. // AddedFields().
  1898. func (m *BatchMsgMutation) Fields() []string {
  1899. fields := make([]string, 0, 16)
  1900. if m.created_at != nil {
  1901. fields = append(fields, batchmsg.FieldCreatedAt)
  1902. }
  1903. if m.updated_at != nil {
  1904. fields = append(fields, batchmsg.FieldUpdatedAt)
  1905. }
  1906. if m.deleted_at != nil {
  1907. fields = append(fields, batchmsg.FieldDeletedAt)
  1908. }
  1909. if m.status != nil {
  1910. fields = append(fields, batchmsg.FieldStatus)
  1911. }
  1912. if m.batch_no != nil {
  1913. fields = append(fields, batchmsg.FieldBatchNo)
  1914. }
  1915. if m.task_name != nil {
  1916. fields = append(fields, batchmsg.FieldTaskName)
  1917. }
  1918. if m.fromwxid != nil {
  1919. fields = append(fields, batchmsg.FieldFromwxid)
  1920. }
  1921. if m.msg != nil {
  1922. fields = append(fields, batchmsg.FieldMsg)
  1923. }
  1924. if m.tag != nil {
  1925. fields = append(fields, batchmsg.FieldTag)
  1926. }
  1927. if m.total != nil {
  1928. fields = append(fields, batchmsg.FieldTotal)
  1929. }
  1930. if m.success != nil {
  1931. fields = append(fields, batchmsg.FieldSuccess)
  1932. }
  1933. if m.fail != nil {
  1934. fields = append(fields, batchmsg.FieldFail)
  1935. }
  1936. if m.start_time != nil {
  1937. fields = append(fields, batchmsg.FieldStartTime)
  1938. }
  1939. if m.stop_time != nil {
  1940. fields = append(fields, batchmsg.FieldStopTime)
  1941. }
  1942. if m._type != nil {
  1943. fields = append(fields, batchmsg.FieldType)
  1944. }
  1945. if m.organization_id != nil {
  1946. fields = append(fields, batchmsg.FieldOrganizationID)
  1947. }
  1948. return fields
  1949. }
  1950. // Field returns the value of a field with the given name. The second boolean
  1951. // return value indicates that this field was not set, or was not defined in the
  1952. // schema.
  1953. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1954. switch name {
  1955. case batchmsg.FieldCreatedAt:
  1956. return m.CreatedAt()
  1957. case batchmsg.FieldUpdatedAt:
  1958. return m.UpdatedAt()
  1959. case batchmsg.FieldDeletedAt:
  1960. return m.DeletedAt()
  1961. case batchmsg.FieldStatus:
  1962. return m.Status()
  1963. case batchmsg.FieldBatchNo:
  1964. return m.BatchNo()
  1965. case batchmsg.FieldTaskName:
  1966. return m.TaskName()
  1967. case batchmsg.FieldFromwxid:
  1968. return m.Fromwxid()
  1969. case batchmsg.FieldMsg:
  1970. return m.Msg()
  1971. case batchmsg.FieldTag:
  1972. return m.Tag()
  1973. case batchmsg.FieldTotal:
  1974. return m.Total()
  1975. case batchmsg.FieldSuccess:
  1976. return m.Success()
  1977. case batchmsg.FieldFail:
  1978. return m.Fail()
  1979. case batchmsg.FieldStartTime:
  1980. return m.StartTime()
  1981. case batchmsg.FieldStopTime:
  1982. return m.StopTime()
  1983. case batchmsg.FieldType:
  1984. return m.GetType()
  1985. case batchmsg.FieldOrganizationID:
  1986. return m.OrganizationID()
  1987. }
  1988. return nil, false
  1989. }
  1990. // OldField returns the old value of the field from the database. An error is
  1991. // returned if the mutation operation is not UpdateOne, or the query to the
  1992. // database failed.
  1993. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1994. switch name {
  1995. case batchmsg.FieldCreatedAt:
  1996. return m.OldCreatedAt(ctx)
  1997. case batchmsg.FieldUpdatedAt:
  1998. return m.OldUpdatedAt(ctx)
  1999. case batchmsg.FieldDeletedAt:
  2000. return m.OldDeletedAt(ctx)
  2001. case batchmsg.FieldStatus:
  2002. return m.OldStatus(ctx)
  2003. case batchmsg.FieldBatchNo:
  2004. return m.OldBatchNo(ctx)
  2005. case batchmsg.FieldTaskName:
  2006. return m.OldTaskName(ctx)
  2007. case batchmsg.FieldFromwxid:
  2008. return m.OldFromwxid(ctx)
  2009. case batchmsg.FieldMsg:
  2010. return m.OldMsg(ctx)
  2011. case batchmsg.FieldTag:
  2012. return m.OldTag(ctx)
  2013. case batchmsg.FieldTotal:
  2014. return m.OldTotal(ctx)
  2015. case batchmsg.FieldSuccess:
  2016. return m.OldSuccess(ctx)
  2017. case batchmsg.FieldFail:
  2018. return m.OldFail(ctx)
  2019. case batchmsg.FieldStartTime:
  2020. return m.OldStartTime(ctx)
  2021. case batchmsg.FieldStopTime:
  2022. return m.OldStopTime(ctx)
  2023. case batchmsg.FieldType:
  2024. return m.OldType(ctx)
  2025. case batchmsg.FieldOrganizationID:
  2026. return m.OldOrganizationID(ctx)
  2027. }
  2028. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  2029. }
  2030. // SetField sets the value of a field with the given name. It returns an error if
  2031. // the field is not defined in the schema, or if the type mismatched the field
  2032. // type.
  2033. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  2034. switch name {
  2035. case batchmsg.FieldCreatedAt:
  2036. v, ok := value.(time.Time)
  2037. if !ok {
  2038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2039. }
  2040. m.SetCreatedAt(v)
  2041. return nil
  2042. case batchmsg.FieldUpdatedAt:
  2043. v, ok := value.(time.Time)
  2044. if !ok {
  2045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2046. }
  2047. m.SetUpdatedAt(v)
  2048. return nil
  2049. case batchmsg.FieldDeletedAt:
  2050. v, ok := value.(time.Time)
  2051. if !ok {
  2052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2053. }
  2054. m.SetDeletedAt(v)
  2055. return nil
  2056. case batchmsg.FieldStatus:
  2057. v, ok := value.(uint8)
  2058. if !ok {
  2059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2060. }
  2061. m.SetStatus(v)
  2062. return nil
  2063. case batchmsg.FieldBatchNo:
  2064. v, ok := value.(string)
  2065. if !ok {
  2066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2067. }
  2068. m.SetBatchNo(v)
  2069. return nil
  2070. case batchmsg.FieldTaskName:
  2071. v, ok := value.(string)
  2072. if !ok {
  2073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2074. }
  2075. m.SetTaskName(v)
  2076. return nil
  2077. case batchmsg.FieldFromwxid:
  2078. v, ok := value.(string)
  2079. if !ok {
  2080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2081. }
  2082. m.SetFromwxid(v)
  2083. return nil
  2084. case batchmsg.FieldMsg:
  2085. v, ok := value.(string)
  2086. if !ok {
  2087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2088. }
  2089. m.SetMsg(v)
  2090. return nil
  2091. case batchmsg.FieldTag:
  2092. v, ok := value.(string)
  2093. if !ok {
  2094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2095. }
  2096. m.SetTag(v)
  2097. return nil
  2098. case batchmsg.FieldTotal:
  2099. v, ok := value.(int32)
  2100. if !ok {
  2101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2102. }
  2103. m.SetTotal(v)
  2104. return nil
  2105. case batchmsg.FieldSuccess:
  2106. v, ok := value.(int32)
  2107. if !ok {
  2108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2109. }
  2110. m.SetSuccess(v)
  2111. return nil
  2112. case batchmsg.FieldFail:
  2113. v, ok := value.(int32)
  2114. if !ok {
  2115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2116. }
  2117. m.SetFail(v)
  2118. return nil
  2119. case batchmsg.FieldStartTime:
  2120. v, ok := value.(time.Time)
  2121. if !ok {
  2122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2123. }
  2124. m.SetStartTime(v)
  2125. return nil
  2126. case batchmsg.FieldStopTime:
  2127. v, ok := value.(time.Time)
  2128. if !ok {
  2129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2130. }
  2131. m.SetStopTime(v)
  2132. return nil
  2133. case batchmsg.FieldType:
  2134. v, ok := value.(int32)
  2135. if !ok {
  2136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2137. }
  2138. m.SetType(v)
  2139. return nil
  2140. case batchmsg.FieldOrganizationID:
  2141. v, ok := value.(uint64)
  2142. if !ok {
  2143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2144. }
  2145. m.SetOrganizationID(v)
  2146. return nil
  2147. }
  2148. return fmt.Errorf("unknown BatchMsg field %s", name)
  2149. }
  2150. // AddedFields returns all numeric fields that were incremented/decremented during
  2151. // this mutation.
  2152. func (m *BatchMsgMutation) AddedFields() []string {
  2153. var fields []string
  2154. if m.addstatus != nil {
  2155. fields = append(fields, batchmsg.FieldStatus)
  2156. }
  2157. if m.addtotal != nil {
  2158. fields = append(fields, batchmsg.FieldTotal)
  2159. }
  2160. if m.addsuccess != nil {
  2161. fields = append(fields, batchmsg.FieldSuccess)
  2162. }
  2163. if m.addfail != nil {
  2164. fields = append(fields, batchmsg.FieldFail)
  2165. }
  2166. if m.add_type != nil {
  2167. fields = append(fields, batchmsg.FieldType)
  2168. }
  2169. if m.addorganization_id != nil {
  2170. fields = append(fields, batchmsg.FieldOrganizationID)
  2171. }
  2172. return fields
  2173. }
  2174. // AddedField returns the numeric value that was incremented/decremented on a field
  2175. // with the given name. The second boolean return value indicates that this field
  2176. // was not set, or was not defined in the schema.
  2177. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2178. switch name {
  2179. case batchmsg.FieldStatus:
  2180. return m.AddedStatus()
  2181. case batchmsg.FieldTotal:
  2182. return m.AddedTotal()
  2183. case batchmsg.FieldSuccess:
  2184. return m.AddedSuccess()
  2185. case batchmsg.FieldFail:
  2186. return m.AddedFail()
  2187. case batchmsg.FieldType:
  2188. return m.AddedType()
  2189. case batchmsg.FieldOrganizationID:
  2190. return m.AddedOrganizationID()
  2191. }
  2192. return nil, false
  2193. }
  2194. // AddField adds the value to the field with the given name. It returns an error if
  2195. // the field is not defined in the schema, or if the type mismatched the field
  2196. // type.
  2197. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2198. switch name {
  2199. case batchmsg.FieldStatus:
  2200. v, ok := value.(int8)
  2201. if !ok {
  2202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2203. }
  2204. m.AddStatus(v)
  2205. return nil
  2206. case batchmsg.FieldTotal:
  2207. v, ok := value.(int32)
  2208. if !ok {
  2209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2210. }
  2211. m.AddTotal(v)
  2212. return nil
  2213. case batchmsg.FieldSuccess:
  2214. v, ok := value.(int32)
  2215. if !ok {
  2216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2217. }
  2218. m.AddSuccess(v)
  2219. return nil
  2220. case batchmsg.FieldFail:
  2221. v, ok := value.(int32)
  2222. if !ok {
  2223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2224. }
  2225. m.AddFail(v)
  2226. return nil
  2227. case batchmsg.FieldType:
  2228. v, ok := value.(int32)
  2229. if !ok {
  2230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2231. }
  2232. m.AddType(v)
  2233. return nil
  2234. case batchmsg.FieldOrganizationID:
  2235. v, ok := value.(int64)
  2236. if !ok {
  2237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2238. }
  2239. m.AddOrganizationID(v)
  2240. return nil
  2241. }
  2242. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2243. }
  2244. // ClearedFields returns all nullable fields that were cleared during this
  2245. // mutation.
  2246. func (m *BatchMsgMutation) ClearedFields() []string {
  2247. var fields []string
  2248. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2249. fields = append(fields, batchmsg.FieldDeletedAt)
  2250. }
  2251. if m.FieldCleared(batchmsg.FieldStatus) {
  2252. fields = append(fields, batchmsg.FieldStatus)
  2253. }
  2254. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2255. fields = append(fields, batchmsg.FieldBatchNo)
  2256. }
  2257. if m.FieldCleared(batchmsg.FieldTaskName) {
  2258. fields = append(fields, batchmsg.FieldTaskName)
  2259. }
  2260. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2261. fields = append(fields, batchmsg.FieldFromwxid)
  2262. }
  2263. if m.FieldCleared(batchmsg.FieldMsg) {
  2264. fields = append(fields, batchmsg.FieldMsg)
  2265. }
  2266. if m.FieldCleared(batchmsg.FieldTag) {
  2267. fields = append(fields, batchmsg.FieldTag)
  2268. }
  2269. if m.FieldCleared(batchmsg.FieldTotal) {
  2270. fields = append(fields, batchmsg.FieldTotal)
  2271. }
  2272. if m.FieldCleared(batchmsg.FieldSuccess) {
  2273. fields = append(fields, batchmsg.FieldSuccess)
  2274. }
  2275. if m.FieldCleared(batchmsg.FieldFail) {
  2276. fields = append(fields, batchmsg.FieldFail)
  2277. }
  2278. if m.FieldCleared(batchmsg.FieldStartTime) {
  2279. fields = append(fields, batchmsg.FieldStartTime)
  2280. }
  2281. if m.FieldCleared(batchmsg.FieldStopTime) {
  2282. fields = append(fields, batchmsg.FieldStopTime)
  2283. }
  2284. if m.FieldCleared(batchmsg.FieldType) {
  2285. fields = append(fields, batchmsg.FieldType)
  2286. }
  2287. return fields
  2288. }
  2289. // FieldCleared returns a boolean indicating if a field with the given name was
  2290. // cleared in this mutation.
  2291. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2292. _, ok := m.clearedFields[name]
  2293. return ok
  2294. }
  2295. // ClearField clears the value of the field with the given name. It returns an
  2296. // error if the field is not defined in the schema.
  2297. func (m *BatchMsgMutation) ClearField(name string) error {
  2298. switch name {
  2299. case batchmsg.FieldDeletedAt:
  2300. m.ClearDeletedAt()
  2301. return nil
  2302. case batchmsg.FieldStatus:
  2303. m.ClearStatus()
  2304. return nil
  2305. case batchmsg.FieldBatchNo:
  2306. m.ClearBatchNo()
  2307. return nil
  2308. case batchmsg.FieldTaskName:
  2309. m.ClearTaskName()
  2310. return nil
  2311. case batchmsg.FieldFromwxid:
  2312. m.ClearFromwxid()
  2313. return nil
  2314. case batchmsg.FieldMsg:
  2315. m.ClearMsg()
  2316. return nil
  2317. case batchmsg.FieldTag:
  2318. m.ClearTag()
  2319. return nil
  2320. case batchmsg.FieldTotal:
  2321. m.ClearTotal()
  2322. return nil
  2323. case batchmsg.FieldSuccess:
  2324. m.ClearSuccess()
  2325. return nil
  2326. case batchmsg.FieldFail:
  2327. m.ClearFail()
  2328. return nil
  2329. case batchmsg.FieldStartTime:
  2330. m.ClearStartTime()
  2331. return nil
  2332. case batchmsg.FieldStopTime:
  2333. m.ClearStopTime()
  2334. return nil
  2335. case batchmsg.FieldType:
  2336. m.ClearType()
  2337. return nil
  2338. }
  2339. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2340. }
  2341. // ResetField resets all changes in the mutation for the field with the given name.
  2342. // It returns an error if the field is not defined in the schema.
  2343. func (m *BatchMsgMutation) ResetField(name string) error {
  2344. switch name {
  2345. case batchmsg.FieldCreatedAt:
  2346. m.ResetCreatedAt()
  2347. return nil
  2348. case batchmsg.FieldUpdatedAt:
  2349. m.ResetUpdatedAt()
  2350. return nil
  2351. case batchmsg.FieldDeletedAt:
  2352. m.ResetDeletedAt()
  2353. return nil
  2354. case batchmsg.FieldStatus:
  2355. m.ResetStatus()
  2356. return nil
  2357. case batchmsg.FieldBatchNo:
  2358. m.ResetBatchNo()
  2359. return nil
  2360. case batchmsg.FieldTaskName:
  2361. m.ResetTaskName()
  2362. return nil
  2363. case batchmsg.FieldFromwxid:
  2364. m.ResetFromwxid()
  2365. return nil
  2366. case batchmsg.FieldMsg:
  2367. m.ResetMsg()
  2368. return nil
  2369. case batchmsg.FieldTag:
  2370. m.ResetTag()
  2371. return nil
  2372. case batchmsg.FieldTotal:
  2373. m.ResetTotal()
  2374. return nil
  2375. case batchmsg.FieldSuccess:
  2376. m.ResetSuccess()
  2377. return nil
  2378. case batchmsg.FieldFail:
  2379. m.ResetFail()
  2380. return nil
  2381. case batchmsg.FieldStartTime:
  2382. m.ResetStartTime()
  2383. return nil
  2384. case batchmsg.FieldStopTime:
  2385. m.ResetStopTime()
  2386. return nil
  2387. case batchmsg.FieldType:
  2388. m.ResetType()
  2389. return nil
  2390. case batchmsg.FieldOrganizationID:
  2391. m.ResetOrganizationID()
  2392. return nil
  2393. }
  2394. return fmt.Errorf("unknown BatchMsg field %s", name)
  2395. }
  2396. // AddedEdges returns all edge names that were set/added in this mutation.
  2397. func (m *BatchMsgMutation) AddedEdges() []string {
  2398. edges := make([]string, 0, 0)
  2399. return edges
  2400. }
  2401. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2402. // name in this mutation.
  2403. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2404. return nil
  2405. }
  2406. // RemovedEdges returns all edge names that were removed in this mutation.
  2407. func (m *BatchMsgMutation) RemovedEdges() []string {
  2408. edges := make([]string, 0, 0)
  2409. return edges
  2410. }
  2411. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2412. // the given name in this mutation.
  2413. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2414. return nil
  2415. }
  2416. // ClearedEdges returns all edge names that were cleared in this mutation.
  2417. func (m *BatchMsgMutation) ClearedEdges() []string {
  2418. edges := make([]string, 0, 0)
  2419. return edges
  2420. }
  2421. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2422. // was cleared in this mutation.
  2423. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2424. return false
  2425. }
  2426. // ClearEdge clears the value of the edge with the given name. It returns an error
  2427. // if that edge is not defined in the schema.
  2428. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2429. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2430. }
  2431. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2432. // It returns an error if the edge is not defined in the schema.
  2433. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2434. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2435. }
  2436. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2437. type ContactMutation struct {
  2438. config
  2439. op Op
  2440. typ string
  2441. id *uint64
  2442. created_at *time.Time
  2443. updated_at *time.Time
  2444. status *uint8
  2445. addstatus *int8
  2446. deleted_at *time.Time
  2447. wx_wxid *string
  2448. _type *int
  2449. add_type *int
  2450. wxid *string
  2451. account *string
  2452. nickname *string
  2453. markname *string
  2454. headimg *string
  2455. sex *int
  2456. addsex *int
  2457. starrole *string
  2458. dontseeit *int
  2459. adddontseeit *int
  2460. dontseeme *int
  2461. adddontseeme *int
  2462. lag *string
  2463. gid *string
  2464. gname *string
  2465. v3 *string
  2466. organization_id *uint64
  2467. addorganization_id *int64
  2468. clearedFields map[string]struct{}
  2469. contact_relationships map[uint64]struct{}
  2470. removedcontact_relationships map[uint64]struct{}
  2471. clearedcontact_relationships bool
  2472. contact_messages map[uint64]struct{}
  2473. removedcontact_messages map[uint64]struct{}
  2474. clearedcontact_messages bool
  2475. done bool
  2476. oldValue func(context.Context) (*Contact, error)
  2477. predicates []predicate.Contact
  2478. }
  2479. var _ ent.Mutation = (*ContactMutation)(nil)
  2480. // contactOption allows management of the mutation configuration using functional options.
  2481. type contactOption func(*ContactMutation)
  2482. // newContactMutation creates new mutation for the Contact entity.
  2483. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2484. m := &ContactMutation{
  2485. config: c,
  2486. op: op,
  2487. typ: TypeContact,
  2488. clearedFields: make(map[string]struct{}),
  2489. }
  2490. for _, opt := range opts {
  2491. opt(m)
  2492. }
  2493. return m
  2494. }
  2495. // withContactID sets the ID field of the mutation.
  2496. func withContactID(id uint64) contactOption {
  2497. return func(m *ContactMutation) {
  2498. var (
  2499. err error
  2500. once sync.Once
  2501. value *Contact
  2502. )
  2503. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2504. once.Do(func() {
  2505. if m.done {
  2506. err = errors.New("querying old values post mutation is not allowed")
  2507. } else {
  2508. value, err = m.Client().Contact.Get(ctx, id)
  2509. }
  2510. })
  2511. return value, err
  2512. }
  2513. m.id = &id
  2514. }
  2515. }
  2516. // withContact sets the old Contact of the mutation.
  2517. func withContact(node *Contact) contactOption {
  2518. return func(m *ContactMutation) {
  2519. m.oldValue = func(context.Context) (*Contact, error) {
  2520. return node, nil
  2521. }
  2522. m.id = &node.ID
  2523. }
  2524. }
  2525. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2526. // executed in a transaction (ent.Tx), a transactional client is returned.
  2527. func (m ContactMutation) Client() *Client {
  2528. client := &Client{config: m.config}
  2529. client.init()
  2530. return client
  2531. }
  2532. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2533. // it returns an error otherwise.
  2534. func (m ContactMutation) Tx() (*Tx, error) {
  2535. if _, ok := m.driver.(*txDriver); !ok {
  2536. return nil, errors.New("ent: mutation is not running in a transaction")
  2537. }
  2538. tx := &Tx{config: m.config}
  2539. tx.init()
  2540. return tx, nil
  2541. }
  2542. // SetID sets the value of the id field. Note that this
  2543. // operation is only accepted on creation of Contact entities.
  2544. func (m *ContactMutation) SetID(id uint64) {
  2545. m.id = &id
  2546. }
  2547. // ID returns the ID value in the mutation. Note that the ID is only available
  2548. // if it was provided to the builder or after it was returned from the database.
  2549. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2550. if m.id == nil {
  2551. return
  2552. }
  2553. return *m.id, true
  2554. }
  2555. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2556. // That means, if the mutation is applied within a transaction with an isolation level such
  2557. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2558. // or updated by the mutation.
  2559. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2560. switch {
  2561. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2562. id, exists := m.ID()
  2563. if exists {
  2564. return []uint64{id}, nil
  2565. }
  2566. fallthrough
  2567. case m.op.Is(OpUpdate | OpDelete):
  2568. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2569. default:
  2570. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2571. }
  2572. }
  2573. // SetCreatedAt sets the "created_at" field.
  2574. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2575. m.created_at = &t
  2576. }
  2577. // CreatedAt returns the value of the "created_at" field in the mutation.
  2578. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2579. v := m.created_at
  2580. if v == nil {
  2581. return
  2582. }
  2583. return *v, true
  2584. }
  2585. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2586. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2588. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2589. if !m.op.Is(OpUpdateOne) {
  2590. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2591. }
  2592. if m.id == nil || m.oldValue == nil {
  2593. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2594. }
  2595. oldValue, err := m.oldValue(ctx)
  2596. if err != nil {
  2597. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2598. }
  2599. return oldValue.CreatedAt, nil
  2600. }
  2601. // ResetCreatedAt resets all changes to the "created_at" field.
  2602. func (m *ContactMutation) ResetCreatedAt() {
  2603. m.created_at = nil
  2604. }
  2605. // SetUpdatedAt sets the "updated_at" field.
  2606. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2607. m.updated_at = &t
  2608. }
  2609. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2610. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2611. v := m.updated_at
  2612. if v == nil {
  2613. return
  2614. }
  2615. return *v, true
  2616. }
  2617. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2618. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2620. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2621. if !m.op.Is(OpUpdateOne) {
  2622. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2623. }
  2624. if m.id == nil || m.oldValue == nil {
  2625. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2626. }
  2627. oldValue, err := m.oldValue(ctx)
  2628. if err != nil {
  2629. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2630. }
  2631. return oldValue.UpdatedAt, nil
  2632. }
  2633. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2634. func (m *ContactMutation) ResetUpdatedAt() {
  2635. m.updated_at = nil
  2636. }
  2637. // SetStatus sets the "status" field.
  2638. func (m *ContactMutation) SetStatus(u uint8) {
  2639. m.status = &u
  2640. m.addstatus = nil
  2641. }
  2642. // Status returns the value of the "status" field in the mutation.
  2643. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2644. v := m.status
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // OldStatus returns the old "status" field's value of the Contact entity.
  2651. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2653. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2654. if !m.op.Is(OpUpdateOne) {
  2655. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2656. }
  2657. if m.id == nil || m.oldValue == nil {
  2658. return v, errors.New("OldStatus requires an ID field in the mutation")
  2659. }
  2660. oldValue, err := m.oldValue(ctx)
  2661. if err != nil {
  2662. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2663. }
  2664. return oldValue.Status, nil
  2665. }
  2666. // AddStatus adds u to the "status" field.
  2667. func (m *ContactMutation) AddStatus(u int8) {
  2668. if m.addstatus != nil {
  2669. *m.addstatus += u
  2670. } else {
  2671. m.addstatus = &u
  2672. }
  2673. }
  2674. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2675. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2676. v := m.addstatus
  2677. if v == nil {
  2678. return
  2679. }
  2680. return *v, true
  2681. }
  2682. // ClearStatus clears the value of the "status" field.
  2683. func (m *ContactMutation) ClearStatus() {
  2684. m.status = nil
  2685. m.addstatus = nil
  2686. m.clearedFields[contact.FieldStatus] = struct{}{}
  2687. }
  2688. // StatusCleared returns if the "status" field was cleared in this mutation.
  2689. func (m *ContactMutation) StatusCleared() bool {
  2690. _, ok := m.clearedFields[contact.FieldStatus]
  2691. return ok
  2692. }
  2693. // ResetStatus resets all changes to the "status" field.
  2694. func (m *ContactMutation) ResetStatus() {
  2695. m.status = nil
  2696. m.addstatus = nil
  2697. delete(m.clearedFields, contact.FieldStatus)
  2698. }
  2699. // SetDeletedAt sets the "deleted_at" field.
  2700. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2701. m.deleted_at = &t
  2702. }
  2703. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2704. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2705. v := m.deleted_at
  2706. if v == nil {
  2707. return
  2708. }
  2709. return *v, true
  2710. }
  2711. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2712. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2714. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2715. if !m.op.Is(OpUpdateOne) {
  2716. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2717. }
  2718. if m.id == nil || m.oldValue == nil {
  2719. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2720. }
  2721. oldValue, err := m.oldValue(ctx)
  2722. if err != nil {
  2723. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2724. }
  2725. return oldValue.DeletedAt, nil
  2726. }
  2727. // ClearDeletedAt clears the value of the "deleted_at" field.
  2728. func (m *ContactMutation) ClearDeletedAt() {
  2729. m.deleted_at = nil
  2730. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2731. }
  2732. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2733. func (m *ContactMutation) DeletedAtCleared() bool {
  2734. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2735. return ok
  2736. }
  2737. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2738. func (m *ContactMutation) ResetDeletedAt() {
  2739. m.deleted_at = nil
  2740. delete(m.clearedFields, contact.FieldDeletedAt)
  2741. }
  2742. // SetWxWxid sets the "wx_wxid" field.
  2743. func (m *ContactMutation) SetWxWxid(s string) {
  2744. m.wx_wxid = &s
  2745. }
  2746. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2747. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2748. v := m.wx_wxid
  2749. if v == nil {
  2750. return
  2751. }
  2752. return *v, true
  2753. }
  2754. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2755. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2757. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2758. if !m.op.Is(OpUpdateOne) {
  2759. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2760. }
  2761. if m.id == nil || m.oldValue == nil {
  2762. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2763. }
  2764. oldValue, err := m.oldValue(ctx)
  2765. if err != nil {
  2766. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2767. }
  2768. return oldValue.WxWxid, nil
  2769. }
  2770. // ClearWxWxid clears the value of the "wx_wxid" field.
  2771. func (m *ContactMutation) ClearWxWxid() {
  2772. m.wx_wxid = nil
  2773. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2774. }
  2775. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2776. func (m *ContactMutation) WxWxidCleared() bool {
  2777. _, ok := m.clearedFields[contact.FieldWxWxid]
  2778. return ok
  2779. }
  2780. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2781. func (m *ContactMutation) ResetWxWxid() {
  2782. m.wx_wxid = nil
  2783. delete(m.clearedFields, contact.FieldWxWxid)
  2784. }
  2785. // SetType sets the "type" field.
  2786. func (m *ContactMutation) SetType(i int) {
  2787. m._type = &i
  2788. m.add_type = nil
  2789. }
  2790. // GetType returns the value of the "type" field in the mutation.
  2791. func (m *ContactMutation) GetType() (r int, exists bool) {
  2792. v := m._type
  2793. if v == nil {
  2794. return
  2795. }
  2796. return *v, true
  2797. }
  2798. // OldType returns the old "type" field's value of the Contact entity.
  2799. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2801. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2802. if !m.op.Is(OpUpdateOne) {
  2803. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2804. }
  2805. if m.id == nil || m.oldValue == nil {
  2806. return v, errors.New("OldType requires an ID field in the mutation")
  2807. }
  2808. oldValue, err := m.oldValue(ctx)
  2809. if err != nil {
  2810. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2811. }
  2812. return oldValue.Type, nil
  2813. }
  2814. // AddType adds i to the "type" field.
  2815. func (m *ContactMutation) AddType(i int) {
  2816. if m.add_type != nil {
  2817. *m.add_type += i
  2818. } else {
  2819. m.add_type = &i
  2820. }
  2821. }
  2822. // AddedType returns the value that was added to the "type" field in this mutation.
  2823. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2824. v := m.add_type
  2825. if v == nil {
  2826. return
  2827. }
  2828. return *v, true
  2829. }
  2830. // ClearType clears the value of the "type" field.
  2831. func (m *ContactMutation) ClearType() {
  2832. m._type = nil
  2833. m.add_type = nil
  2834. m.clearedFields[contact.FieldType] = struct{}{}
  2835. }
  2836. // TypeCleared returns if the "type" field was cleared in this mutation.
  2837. func (m *ContactMutation) TypeCleared() bool {
  2838. _, ok := m.clearedFields[contact.FieldType]
  2839. return ok
  2840. }
  2841. // ResetType resets all changes to the "type" field.
  2842. func (m *ContactMutation) ResetType() {
  2843. m._type = nil
  2844. m.add_type = nil
  2845. delete(m.clearedFields, contact.FieldType)
  2846. }
  2847. // SetWxid sets the "wxid" field.
  2848. func (m *ContactMutation) SetWxid(s string) {
  2849. m.wxid = &s
  2850. }
  2851. // Wxid returns the value of the "wxid" field in the mutation.
  2852. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2853. v := m.wxid
  2854. if v == nil {
  2855. return
  2856. }
  2857. return *v, true
  2858. }
  2859. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2860. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2862. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2863. if !m.op.Is(OpUpdateOne) {
  2864. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2865. }
  2866. if m.id == nil || m.oldValue == nil {
  2867. return v, errors.New("OldWxid requires an ID field in the mutation")
  2868. }
  2869. oldValue, err := m.oldValue(ctx)
  2870. if err != nil {
  2871. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2872. }
  2873. return oldValue.Wxid, nil
  2874. }
  2875. // ResetWxid resets all changes to the "wxid" field.
  2876. func (m *ContactMutation) ResetWxid() {
  2877. m.wxid = nil
  2878. }
  2879. // SetAccount sets the "account" field.
  2880. func (m *ContactMutation) SetAccount(s string) {
  2881. m.account = &s
  2882. }
  2883. // Account returns the value of the "account" field in the mutation.
  2884. func (m *ContactMutation) Account() (r string, exists bool) {
  2885. v := m.account
  2886. if v == nil {
  2887. return
  2888. }
  2889. return *v, true
  2890. }
  2891. // OldAccount returns the old "account" field's value of the Contact entity.
  2892. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2894. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2895. if !m.op.Is(OpUpdateOne) {
  2896. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2897. }
  2898. if m.id == nil || m.oldValue == nil {
  2899. return v, errors.New("OldAccount requires an ID field in the mutation")
  2900. }
  2901. oldValue, err := m.oldValue(ctx)
  2902. if err != nil {
  2903. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2904. }
  2905. return oldValue.Account, nil
  2906. }
  2907. // ResetAccount resets all changes to the "account" field.
  2908. func (m *ContactMutation) ResetAccount() {
  2909. m.account = nil
  2910. }
  2911. // SetNickname sets the "nickname" field.
  2912. func (m *ContactMutation) SetNickname(s string) {
  2913. m.nickname = &s
  2914. }
  2915. // Nickname returns the value of the "nickname" field in the mutation.
  2916. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2917. v := m.nickname
  2918. if v == nil {
  2919. return
  2920. }
  2921. return *v, true
  2922. }
  2923. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2924. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2926. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2927. if !m.op.Is(OpUpdateOne) {
  2928. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2929. }
  2930. if m.id == nil || m.oldValue == nil {
  2931. return v, errors.New("OldNickname requires an ID field in the mutation")
  2932. }
  2933. oldValue, err := m.oldValue(ctx)
  2934. if err != nil {
  2935. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2936. }
  2937. return oldValue.Nickname, nil
  2938. }
  2939. // ResetNickname resets all changes to the "nickname" field.
  2940. func (m *ContactMutation) ResetNickname() {
  2941. m.nickname = nil
  2942. }
  2943. // SetMarkname sets the "markname" field.
  2944. func (m *ContactMutation) SetMarkname(s string) {
  2945. m.markname = &s
  2946. }
  2947. // Markname returns the value of the "markname" field in the mutation.
  2948. func (m *ContactMutation) Markname() (r string, exists bool) {
  2949. v := m.markname
  2950. if v == nil {
  2951. return
  2952. }
  2953. return *v, true
  2954. }
  2955. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2958. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2959. if !m.op.Is(OpUpdateOne) {
  2960. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2961. }
  2962. if m.id == nil || m.oldValue == nil {
  2963. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2964. }
  2965. oldValue, err := m.oldValue(ctx)
  2966. if err != nil {
  2967. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2968. }
  2969. return oldValue.Markname, nil
  2970. }
  2971. // ResetMarkname resets all changes to the "markname" field.
  2972. func (m *ContactMutation) ResetMarkname() {
  2973. m.markname = nil
  2974. }
  2975. // SetHeadimg sets the "headimg" field.
  2976. func (m *ContactMutation) SetHeadimg(s string) {
  2977. m.headimg = &s
  2978. }
  2979. // Headimg returns the value of the "headimg" field in the mutation.
  2980. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2981. v := m.headimg
  2982. if v == nil {
  2983. return
  2984. }
  2985. return *v, true
  2986. }
  2987. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2988. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2990. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2991. if !m.op.Is(OpUpdateOne) {
  2992. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2993. }
  2994. if m.id == nil || m.oldValue == nil {
  2995. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2996. }
  2997. oldValue, err := m.oldValue(ctx)
  2998. if err != nil {
  2999. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  3000. }
  3001. return oldValue.Headimg, nil
  3002. }
  3003. // ResetHeadimg resets all changes to the "headimg" field.
  3004. func (m *ContactMutation) ResetHeadimg() {
  3005. m.headimg = nil
  3006. }
  3007. // SetSex sets the "sex" field.
  3008. func (m *ContactMutation) SetSex(i int) {
  3009. m.sex = &i
  3010. m.addsex = nil
  3011. }
  3012. // Sex returns the value of the "sex" field in the mutation.
  3013. func (m *ContactMutation) Sex() (r int, exists bool) {
  3014. v := m.sex
  3015. if v == nil {
  3016. return
  3017. }
  3018. return *v, true
  3019. }
  3020. // OldSex returns the old "sex" field's value of the Contact entity.
  3021. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3023. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  3024. if !m.op.Is(OpUpdateOne) {
  3025. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  3026. }
  3027. if m.id == nil || m.oldValue == nil {
  3028. return v, errors.New("OldSex requires an ID field in the mutation")
  3029. }
  3030. oldValue, err := m.oldValue(ctx)
  3031. if err != nil {
  3032. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  3033. }
  3034. return oldValue.Sex, nil
  3035. }
  3036. // AddSex adds i to the "sex" field.
  3037. func (m *ContactMutation) AddSex(i int) {
  3038. if m.addsex != nil {
  3039. *m.addsex += i
  3040. } else {
  3041. m.addsex = &i
  3042. }
  3043. }
  3044. // AddedSex returns the value that was added to the "sex" field in this mutation.
  3045. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  3046. v := m.addsex
  3047. if v == nil {
  3048. return
  3049. }
  3050. return *v, true
  3051. }
  3052. // ResetSex resets all changes to the "sex" field.
  3053. func (m *ContactMutation) ResetSex() {
  3054. m.sex = nil
  3055. m.addsex = nil
  3056. }
  3057. // SetStarrole sets the "starrole" field.
  3058. func (m *ContactMutation) SetStarrole(s string) {
  3059. m.starrole = &s
  3060. }
  3061. // Starrole returns the value of the "starrole" field in the mutation.
  3062. func (m *ContactMutation) Starrole() (r string, exists bool) {
  3063. v := m.starrole
  3064. if v == nil {
  3065. return
  3066. }
  3067. return *v, true
  3068. }
  3069. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  3070. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3072. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  3073. if !m.op.Is(OpUpdateOne) {
  3074. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  3075. }
  3076. if m.id == nil || m.oldValue == nil {
  3077. return v, errors.New("OldStarrole requires an ID field in the mutation")
  3078. }
  3079. oldValue, err := m.oldValue(ctx)
  3080. if err != nil {
  3081. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  3082. }
  3083. return oldValue.Starrole, nil
  3084. }
  3085. // ResetStarrole resets all changes to the "starrole" field.
  3086. func (m *ContactMutation) ResetStarrole() {
  3087. m.starrole = nil
  3088. }
  3089. // SetDontseeit sets the "dontseeit" field.
  3090. func (m *ContactMutation) SetDontseeit(i int) {
  3091. m.dontseeit = &i
  3092. m.adddontseeit = nil
  3093. }
  3094. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  3095. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  3096. v := m.dontseeit
  3097. if v == nil {
  3098. return
  3099. }
  3100. return *v, true
  3101. }
  3102. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  3103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3105. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  3106. if !m.op.Is(OpUpdateOne) {
  3107. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  3108. }
  3109. if m.id == nil || m.oldValue == nil {
  3110. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  3111. }
  3112. oldValue, err := m.oldValue(ctx)
  3113. if err != nil {
  3114. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  3115. }
  3116. return oldValue.Dontseeit, nil
  3117. }
  3118. // AddDontseeit adds i to the "dontseeit" field.
  3119. func (m *ContactMutation) AddDontseeit(i int) {
  3120. if m.adddontseeit != nil {
  3121. *m.adddontseeit += i
  3122. } else {
  3123. m.adddontseeit = &i
  3124. }
  3125. }
  3126. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3127. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3128. v := m.adddontseeit
  3129. if v == nil {
  3130. return
  3131. }
  3132. return *v, true
  3133. }
  3134. // ResetDontseeit resets all changes to the "dontseeit" field.
  3135. func (m *ContactMutation) ResetDontseeit() {
  3136. m.dontseeit = nil
  3137. m.adddontseeit = nil
  3138. }
  3139. // SetDontseeme sets the "dontseeme" field.
  3140. func (m *ContactMutation) SetDontseeme(i int) {
  3141. m.dontseeme = &i
  3142. m.adddontseeme = nil
  3143. }
  3144. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3145. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3146. v := m.dontseeme
  3147. if v == nil {
  3148. return
  3149. }
  3150. return *v, true
  3151. }
  3152. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3153. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3155. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3156. if !m.op.Is(OpUpdateOne) {
  3157. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3158. }
  3159. if m.id == nil || m.oldValue == nil {
  3160. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3161. }
  3162. oldValue, err := m.oldValue(ctx)
  3163. if err != nil {
  3164. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3165. }
  3166. return oldValue.Dontseeme, nil
  3167. }
  3168. // AddDontseeme adds i to the "dontseeme" field.
  3169. func (m *ContactMutation) AddDontseeme(i int) {
  3170. if m.adddontseeme != nil {
  3171. *m.adddontseeme += i
  3172. } else {
  3173. m.adddontseeme = &i
  3174. }
  3175. }
  3176. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3177. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3178. v := m.adddontseeme
  3179. if v == nil {
  3180. return
  3181. }
  3182. return *v, true
  3183. }
  3184. // ResetDontseeme resets all changes to the "dontseeme" field.
  3185. func (m *ContactMutation) ResetDontseeme() {
  3186. m.dontseeme = nil
  3187. m.adddontseeme = nil
  3188. }
  3189. // SetLag sets the "lag" field.
  3190. func (m *ContactMutation) SetLag(s string) {
  3191. m.lag = &s
  3192. }
  3193. // Lag returns the value of the "lag" field in the mutation.
  3194. func (m *ContactMutation) Lag() (r string, exists bool) {
  3195. v := m.lag
  3196. if v == nil {
  3197. return
  3198. }
  3199. return *v, true
  3200. }
  3201. // OldLag returns the old "lag" field's value of the Contact entity.
  3202. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3204. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3205. if !m.op.Is(OpUpdateOne) {
  3206. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3207. }
  3208. if m.id == nil || m.oldValue == nil {
  3209. return v, errors.New("OldLag requires an ID field in the mutation")
  3210. }
  3211. oldValue, err := m.oldValue(ctx)
  3212. if err != nil {
  3213. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3214. }
  3215. return oldValue.Lag, nil
  3216. }
  3217. // ResetLag resets all changes to the "lag" field.
  3218. func (m *ContactMutation) ResetLag() {
  3219. m.lag = nil
  3220. }
  3221. // SetGid sets the "gid" field.
  3222. func (m *ContactMutation) SetGid(s string) {
  3223. m.gid = &s
  3224. }
  3225. // Gid returns the value of the "gid" field in the mutation.
  3226. func (m *ContactMutation) Gid() (r string, exists bool) {
  3227. v := m.gid
  3228. if v == nil {
  3229. return
  3230. }
  3231. return *v, true
  3232. }
  3233. // OldGid returns the old "gid" field's value of the Contact entity.
  3234. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3236. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3237. if !m.op.Is(OpUpdateOne) {
  3238. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3239. }
  3240. if m.id == nil || m.oldValue == nil {
  3241. return v, errors.New("OldGid requires an ID field in the mutation")
  3242. }
  3243. oldValue, err := m.oldValue(ctx)
  3244. if err != nil {
  3245. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3246. }
  3247. return oldValue.Gid, nil
  3248. }
  3249. // ResetGid resets all changes to the "gid" field.
  3250. func (m *ContactMutation) ResetGid() {
  3251. m.gid = nil
  3252. }
  3253. // SetGname sets the "gname" field.
  3254. func (m *ContactMutation) SetGname(s string) {
  3255. m.gname = &s
  3256. }
  3257. // Gname returns the value of the "gname" field in the mutation.
  3258. func (m *ContactMutation) Gname() (r string, exists bool) {
  3259. v := m.gname
  3260. if v == nil {
  3261. return
  3262. }
  3263. return *v, true
  3264. }
  3265. // OldGname returns the old "gname" field's value of the Contact entity.
  3266. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3268. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3269. if !m.op.Is(OpUpdateOne) {
  3270. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3271. }
  3272. if m.id == nil || m.oldValue == nil {
  3273. return v, errors.New("OldGname requires an ID field in the mutation")
  3274. }
  3275. oldValue, err := m.oldValue(ctx)
  3276. if err != nil {
  3277. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3278. }
  3279. return oldValue.Gname, nil
  3280. }
  3281. // ResetGname resets all changes to the "gname" field.
  3282. func (m *ContactMutation) ResetGname() {
  3283. m.gname = nil
  3284. }
  3285. // SetV3 sets the "v3" field.
  3286. func (m *ContactMutation) SetV3(s string) {
  3287. m.v3 = &s
  3288. }
  3289. // V3 returns the value of the "v3" field in the mutation.
  3290. func (m *ContactMutation) V3() (r string, exists bool) {
  3291. v := m.v3
  3292. if v == nil {
  3293. return
  3294. }
  3295. return *v, true
  3296. }
  3297. // OldV3 returns the old "v3" field's value of the Contact entity.
  3298. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3300. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3301. if !m.op.Is(OpUpdateOne) {
  3302. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3303. }
  3304. if m.id == nil || m.oldValue == nil {
  3305. return v, errors.New("OldV3 requires an ID field in the mutation")
  3306. }
  3307. oldValue, err := m.oldValue(ctx)
  3308. if err != nil {
  3309. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3310. }
  3311. return oldValue.V3, nil
  3312. }
  3313. // ResetV3 resets all changes to the "v3" field.
  3314. func (m *ContactMutation) ResetV3() {
  3315. m.v3 = nil
  3316. }
  3317. // SetOrganizationID sets the "organization_id" field.
  3318. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3319. m.organization_id = &u
  3320. m.addorganization_id = nil
  3321. }
  3322. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3323. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3324. v := m.organization_id
  3325. if v == nil {
  3326. return
  3327. }
  3328. return *v, true
  3329. }
  3330. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3331. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3333. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3334. if !m.op.Is(OpUpdateOne) {
  3335. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3336. }
  3337. if m.id == nil || m.oldValue == nil {
  3338. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3339. }
  3340. oldValue, err := m.oldValue(ctx)
  3341. if err != nil {
  3342. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3343. }
  3344. return oldValue.OrganizationID, nil
  3345. }
  3346. // AddOrganizationID adds u to the "organization_id" field.
  3347. func (m *ContactMutation) AddOrganizationID(u int64) {
  3348. if m.addorganization_id != nil {
  3349. *m.addorganization_id += u
  3350. } else {
  3351. m.addorganization_id = &u
  3352. }
  3353. }
  3354. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3355. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3356. v := m.addorganization_id
  3357. if v == nil {
  3358. return
  3359. }
  3360. return *v, true
  3361. }
  3362. // ClearOrganizationID clears the value of the "organization_id" field.
  3363. func (m *ContactMutation) ClearOrganizationID() {
  3364. m.organization_id = nil
  3365. m.addorganization_id = nil
  3366. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3367. }
  3368. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3369. func (m *ContactMutation) OrganizationIDCleared() bool {
  3370. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3371. return ok
  3372. }
  3373. // ResetOrganizationID resets all changes to the "organization_id" field.
  3374. func (m *ContactMutation) ResetOrganizationID() {
  3375. m.organization_id = nil
  3376. m.addorganization_id = nil
  3377. delete(m.clearedFields, contact.FieldOrganizationID)
  3378. }
  3379. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3380. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3381. if m.contact_relationships == nil {
  3382. m.contact_relationships = make(map[uint64]struct{})
  3383. }
  3384. for i := range ids {
  3385. m.contact_relationships[ids[i]] = struct{}{}
  3386. }
  3387. }
  3388. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3389. func (m *ContactMutation) ClearContactRelationships() {
  3390. m.clearedcontact_relationships = true
  3391. }
  3392. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3393. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3394. return m.clearedcontact_relationships
  3395. }
  3396. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3397. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3398. if m.removedcontact_relationships == nil {
  3399. m.removedcontact_relationships = make(map[uint64]struct{})
  3400. }
  3401. for i := range ids {
  3402. delete(m.contact_relationships, ids[i])
  3403. m.removedcontact_relationships[ids[i]] = struct{}{}
  3404. }
  3405. }
  3406. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3407. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3408. for id := range m.removedcontact_relationships {
  3409. ids = append(ids, id)
  3410. }
  3411. return
  3412. }
  3413. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3414. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3415. for id := range m.contact_relationships {
  3416. ids = append(ids, id)
  3417. }
  3418. return
  3419. }
  3420. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3421. func (m *ContactMutation) ResetContactRelationships() {
  3422. m.contact_relationships = nil
  3423. m.clearedcontact_relationships = false
  3424. m.removedcontact_relationships = nil
  3425. }
  3426. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3427. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3428. if m.contact_messages == nil {
  3429. m.contact_messages = make(map[uint64]struct{})
  3430. }
  3431. for i := range ids {
  3432. m.contact_messages[ids[i]] = struct{}{}
  3433. }
  3434. }
  3435. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3436. func (m *ContactMutation) ClearContactMessages() {
  3437. m.clearedcontact_messages = true
  3438. }
  3439. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3440. func (m *ContactMutation) ContactMessagesCleared() bool {
  3441. return m.clearedcontact_messages
  3442. }
  3443. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3444. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3445. if m.removedcontact_messages == nil {
  3446. m.removedcontact_messages = make(map[uint64]struct{})
  3447. }
  3448. for i := range ids {
  3449. delete(m.contact_messages, ids[i])
  3450. m.removedcontact_messages[ids[i]] = struct{}{}
  3451. }
  3452. }
  3453. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3454. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3455. for id := range m.removedcontact_messages {
  3456. ids = append(ids, id)
  3457. }
  3458. return
  3459. }
  3460. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3461. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3462. for id := range m.contact_messages {
  3463. ids = append(ids, id)
  3464. }
  3465. return
  3466. }
  3467. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3468. func (m *ContactMutation) ResetContactMessages() {
  3469. m.contact_messages = nil
  3470. m.clearedcontact_messages = false
  3471. m.removedcontact_messages = nil
  3472. }
  3473. // Where appends a list predicates to the ContactMutation builder.
  3474. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3475. m.predicates = append(m.predicates, ps...)
  3476. }
  3477. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3478. // users can use type-assertion to append predicates that do not depend on any generated package.
  3479. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3480. p := make([]predicate.Contact, len(ps))
  3481. for i := range ps {
  3482. p[i] = ps[i]
  3483. }
  3484. m.Where(p...)
  3485. }
  3486. // Op returns the operation name.
  3487. func (m *ContactMutation) Op() Op {
  3488. return m.op
  3489. }
  3490. // SetOp allows setting the mutation operation.
  3491. func (m *ContactMutation) SetOp(op Op) {
  3492. m.op = op
  3493. }
  3494. // Type returns the node type of this mutation (Contact).
  3495. func (m *ContactMutation) Type() string {
  3496. return m.typ
  3497. }
  3498. // Fields returns all fields that were changed during this mutation. Note that in
  3499. // order to get all numeric fields that were incremented/decremented, call
  3500. // AddedFields().
  3501. func (m *ContactMutation) Fields() []string {
  3502. fields := make([]string, 0, 20)
  3503. if m.created_at != nil {
  3504. fields = append(fields, contact.FieldCreatedAt)
  3505. }
  3506. if m.updated_at != nil {
  3507. fields = append(fields, contact.FieldUpdatedAt)
  3508. }
  3509. if m.status != nil {
  3510. fields = append(fields, contact.FieldStatus)
  3511. }
  3512. if m.deleted_at != nil {
  3513. fields = append(fields, contact.FieldDeletedAt)
  3514. }
  3515. if m.wx_wxid != nil {
  3516. fields = append(fields, contact.FieldWxWxid)
  3517. }
  3518. if m._type != nil {
  3519. fields = append(fields, contact.FieldType)
  3520. }
  3521. if m.wxid != nil {
  3522. fields = append(fields, contact.FieldWxid)
  3523. }
  3524. if m.account != nil {
  3525. fields = append(fields, contact.FieldAccount)
  3526. }
  3527. if m.nickname != nil {
  3528. fields = append(fields, contact.FieldNickname)
  3529. }
  3530. if m.markname != nil {
  3531. fields = append(fields, contact.FieldMarkname)
  3532. }
  3533. if m.headimg != nil {
  3534. fields = append(fields, contact.FieldHeadimg)
  3535. }
  3536. if m.sex != nil {
  3537. fields = append(fields, contact.FieldSex)
  3538. }
  3539. if m.starrole != nil {
  3540. fields = append(fields, contact.FieldStarrole)
  3541. }
  3542. if m.dontseeit != nil {
  3543. fields = append(fields, contact.FieldDontseeit)
  3544. }
  3545. if m.dontseeme != nil {
  3546. fields = append(fields, contact.FieldDontseeme)
  3547. }
  3548. if m.lag != nil {
  3549. fields = append(fields, contact.FieldLag)
  3550. }
  3551. if m.gid != nil {
  3552. fields = append(fields, contact.FieldGid)
  3553. }
  3554. if m.gname != nil {
  3555. fields = append(fields, contact.FieldGname)
  3556. }
  3557. if m.v3 != nil {
  3558. fields = append(fields, contact.FieldV3)
  3559. }
  3560. if m.organization_id != nil {
  3561. fields = append(fields, contact.FieldOrganizationID)
  3562. }
  3563. return fields
  3564. }
  3565. // Field returns the value of a field with the given name. The second boolean
  3566. // return value indicates that this field was not set, or was not defined in the
  3567. // schema.
  3568. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3569. switch name {
  3570. case contact.FieldCreatedAt:
  3571. return m.CreatedAt()
  3572. case contact.FieldUpdatedAt:
  3573. return m.UpdatedAt()
  3574. case contact.FieldStatus:
  3575. return m.Status()
  3576. case contact.FieldDeletedAt:
  3577. return m.DeletedAt()
  3578. case contact.FieldWxWxid:
  3579. return m.WxWxid()
  3580. case contact.FieldType:
  3581. return m.GetType()
  3582. case contact.FieldWxid:
  3583. return m.Wxid()
  3584. case contact.FieldAccount:
  3585. return m.Account()
  3586. case contact.FieldNickname:
  3587. return m.Nickname()
  3588. case contact.FieldMarkname:
  3589. return m.Markname()
  3590. case contact.FieldHeadimg:
  3591. return m.Headimg()
  3592. case contact.FieldSex:
  3593. return m.Sex()
  3594. case contact.FieldStarrole:
  3595. return m.Starrole()
  3596. case contact.FieldDontseeit:
  3597. return m.Dontseeit()
  3598. case contact.FieldDontseeme:
  3599. return m.Dontseeme()
  3600. case contact.FieldLag:
  3601. return m.Lag()
  3602. case contact.FieldGid:
  3603. return m.Gid()
  3604. case contact.FieldGname:
  3605. return m.Gname()
  3606. case contact.FieldV3:
  3607. return m.V3()
  3608. case contact.FieldOrganizationID:
  3609. return m.OrganizationID()
  3610. }
  3611. return nil, false
  3612. }
  3613. // OldField returns the old value of the field from the database. An error is
  3614. // returned if the mutation operation is not UpdateOne, or the query to the
  3615. // database failed.
  3616. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3617. switch name {
  3618. case contact.FieldCreatedAt:
  3619. return m.OldCreatedAt(ctx)
  3620. case contact.FieldUpdatedAt:
  3621. return m.OldUpdatedAt(ctx)
  3622. case contact.FieldStatus:
  3623. return m.OldStatus(ctx)
  3624. case contact.FieldDeletedAt:
  3625. return m.OldDeletedAt(ctx)
  3626. case contact.FieldWxWxid:
  3627. return m.OldWxWxid(ctx)
  3628. case contact.FieldType:
  3629. return m.OldType(ctx)
  3630. case contact.FieldWxid:
  3631. return m.OldWxid(ctx)
  3632. case contact.FieldAccount:
  3633. return m.OldAccount(ctx)
  3634. case contact.FieldNickname:
  3635. return m.OldNickname(ctx)
  3636. case contact.FieldMarkname:
  3637. return m.OldMarkname(ctx)
  3638. case contact.FieldHeadimg:
  3639. return m.OldHeadimg(ctx)
  3640. case contact.FieldSex:
  3641. return m.OldSex(ctx)
  3642. case contact.FieldStarrole:
  3643. return m.OldStarrole(ctx)
  3644. case contact.FieldDontseeit:
  3645. return m.OldDontseeit(ctx)
  3646. case contact.FieldDontseeme:
  3647. return m.OldDontseeme(ctx)
  3648. case contact.FieldLag:
  3649. return m.OldLag(ctx)
  3650. case contact.FieldGid:
  3651. return m.OldGid(ctx)
  3652. case contact.FieldGname:
  3653. return m.OldGname(ctx)
  3654. case contact.FieldV3:
  3655. return m.OldV3(ctx)
  3656. case contact.FieldOrganizationID:
  3657. return m.OldOrganizationID(ctx)
  3658. }
  3659. return nil, fmt.Errorf("unknown Contact field %s", name)
  3660. }
  3661. // SetField sets the value of a field with the given name. It returns an error if
  3662. // the field is not defined in the schema, or if the type mismatched the field
  3663. // type.
  3664. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3665. switch name {
  3666. case contact.FieldCreatedAt:
  3667. v, ok := value.(time.Time)
  3668. if !ok {
  3669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3670. }
  3671. m.SetCreatedAt(v)
  3672. return nil
  3673. case contact.FieldUpdatedAt:
  3674. v, ok := value.(time.Time)
  3675. if !ok {
  3676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3677. }
  3678. m.SetUpdatedAt(v)
  3679. return nil
  3680. case contact.FieldStatus:
  3681. v, ok := value.(uint8)
  3682. if !ok {
  3683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3684. }
  3685. m.SetStatus(v)
  3686. return nil
  3687. case contact.FieldDeletedAt:
  3688. v, ok := value.(time.Time)
  3689. if !ok {
  3690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3691. }
  3692. m.SetDeletedAt(v)
  3693. return nil
  3694. case contact.FieldWxWxid:
  3695. v, ok := value.(string)
  3696. if !ok {
  3697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3698. }
  3699. m.SetWxWxid(v)
  3700. return nil
  3701. case contact.FieldType:
  3702. v, ok := value.(int)
  3703. if !ok {
  3704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3705. }
  3706. m.SetType(v)
  3707. return nil
  3708. case contact.FieldWxid:
  3709. v, ok := value.(string)
  3710. if !ok {
  3711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3712. }
  3713. m.SetWxid(v)
  3714. return nil
  3715. case contact.FieldAccount:
  3716. v, ok := value.(string)
  3717. if !ok {
  3718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3719. }
  3720. m.SetAccount(v)
  3721. return nil
  3722. case contact.FieldNickname:
  3723. v, ok := value.(string)
  3724. if !ok {
  3725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3726. }
  3727. m.SetNickname(v)
  3728. return nil
  3729. case contact.FieldMarkname:
  3730. v, ok := value.(string)
  3731. if !ok {
  3732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3733. }
  3734. m.SetMarkname(v)
  3735. return nil
  3736. case contact.FieldHeadimg:
  3737. v, ok := value.(string)
  3738. if !ok {
  3739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3740. }
  3741. m.SetHeadimg(v)
  3742. return nil
  3743. case contact.FieldSex:
  3744. v, ok := value.(int)
  3745. if !ok {
  3746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3747. }
  3748. m.SetSex(v)
  3749. return nil
  3750. case contact.FieldStarrole:
  3751. v, ok := value.(string)
  3752. if !ok {
  3753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3754. }
  3755. m.SetStarrole(v)
  3756. return nil
  3757. case contact.FieldDontseeit:
  3758. v, ok := value.(int)
  3759. if !ok {
  3760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3761. }
  3762. m.SetDontseeit(v)
  3763. return nil
  3764. case contact.FieldDontseeme:
  3765. v, ok := value.(int)
  3766. if !ok {
  3767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3768. }
  3769. m.SetDontseeme(v)
  3770. return nil
  3771. case contact.FieldLag:
  3772. v, ok := value.(string)
  3773. if !ok {
  3774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3775. }
  3776. m.SetLag(v)
  3777. return nil
  3778. case contact.FieldGid:
  3779. v, ok := value.(string)
  3780. if !ok {
  3781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3782. }
  3783. m.SetGid(v)
  3784. return nil
  3785. case contact.FieldGname:
  3786. v, ok := value.(string)
  3787. if !ok {
  3788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3789. }
  3790. m.SetGname(v)
  3791. return nil
  3792. case contact.FieldV3:
  3793. v, ok := value.(string)
  3794. if !ok {
  3795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3796. }
  3797. m.SetV3(v)
  3798. return nil
  3799. case contact.FieldOrganizationID:
  3800. v, ok := value.(uint64)
  3801. if !ok {
  3802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3803. }
  3804. m.SetOrganizationID(v)
  3805. return nil
  3806. }
  3807. return fmt.Errorf("unknown Contact field %s", name)
  3808. }
  3809. // AddedFields returns all numeric fields that were incremented/decremented during
  3810. // this mutation.
  3811. func (m *ContactMutation) AddedFields() []string {
  3812. var fields []string
  3813. if m.addstatus != nil {
  3814. fields = append(fields, contact.FieldStatus)
  3815. }
  3816. if m.add_type != nil {
  3817. fields = append(fields, contact.FieldType)
  3818. }
  3819. if m.addsex != nil {
  3820. fields = append(fields, contact.FieldSex)
  3821. }
  3822. if m.adddontseeit != nil {
  3823. fields = append(fields, contact.FieldDontseeit)
  3824. }
  3825. if m.adddontseeme != nil {
  3826. fields = append(fields, contact.FieldDontseeme)
  3827. }
  3828. if m.addorganization_id != nil {
  3829. fields = append(fields, contact.FieldOrganizationID)
  3830. }
  3831. return fields
  3832. }
  3833. // AddedField returns the numeric value that was incremented/decremented on a field
  3834. // with the given name. The second boolean return value indicates that this field
  3835. // was not set, or was not defined in the schema.
  3836. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3837. switch name {
  3838. case contact.FieldStatus:
  3839. return m.AddedStatus()
  3840. case contact.FieldType:
  3841. return m.AddedType()
  3842. case contact.FieldSex:
  3843. return m.AddedSex()
  3844. case contact.FieldDontseeit:
  3845. return m.AddedDontseeit()
  3846. case contact.FieldDontseeme:
  3847. return m.AddedDontseeme()
  3848. case contact.FieldOrganizationID:
  3849. return m.AddedOrganizationID()
  3850. }
  3851. return nil, false
  3852. }
  3853. // AddField adds the value to the field with the given name. It returns an error if
  3854. // the field is not defined in the schema, or if the type mismatched the field
  3855. // type.
  3856. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3857. switch name {
  3858. case contact.FieldStatus:
  3859. v, ok := value.(int8)
  3860. if !ok {
  3861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3862. }
  3863. m.AddStatus(v)
  3864. return nil
  3865. case contact.FieldType:
  3866. v, ok := value.(int)
  3867. if !ok {
  3868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3869. }
  3870. m.AddType(v)
  3871. return nil
  3872. case contact.FieldSex:
  3873. v, ok := value.(int)
  3874. if !ok {
  3875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3876. }
  3877. m.AddSex(v)
  3878. return nil
  3879. case contact.FieldDontseeit:
  3880. v, ok := value.(int)
  3881. if !ok {
  3882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3883. }
  3884. m.AddDontseeit(v)
  3885. return nil
  3886. case contact.FieldDontseeme:
  3887. v, ok := value.(int)
  3888. if !ok {
  3889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3890. }
  3891. m.AddDontseeme(v)
  3892. return nil
  3893. case contact.FieldOrganizationID:
  3894. v, ok := value.(int64)
  3895. if !ok {
  3896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3897. }
  3898. m.AddOrganizationID(v)
  3899. return nil
  3900. }
  3901. return fmt.Errorf("unknown Contact numeric field %s", name)
  3902. }
  3903. // ClearedFields returns all nullable fields that were cleared during this
  3904. // mutation.
  3905. func (m *ContactMutation) ClearedFields() []string {
  3906. var fields []string
  3907. if m.FieldCleared(contact.FieldStatus) {
  3908. fields = append(fields, contact.FieldStatus)
  3909. }
  3910. if m.FieldCleared(contact.FieldDeletedAt) {
  3911. fields = append(fields, contact.FieldDeletedAt)
  3912. }
  3913. if m.FieldCleared(contact.FieldWxWxid) {
  3914. fields = append(fields, contact.FieldWxWxid)
  3915. }
  3916. if m.FieldCleared(contact.FieldType) {
  3917. fields = append(fields, contact.FieldType)
  3918. }
  3919. if m.FieldCleared(contact.FieldOrganizationID) {
  3920. fields = append(fields, contact.FieldOrganizationID)
  3921. }
  3922. return fields
  3923. }
  3924. // FieldCleared returns a boolean indicating if a field with the given name was
  3925. // cleared in this mutation.
  3926. func (m *ContactMutation) FieldCleared(name string) bool {
  3927. _, ok := m.clearedFields[name]
  3928. return ok
  3929. }
  3930. // ClearField clears the value of the field with the given name. It returns an
  3931. // error if the field is not defined in the schema.
  3932. func (m *ContactMutation) ClearField(name string) error {
  3933. switch name {
  3934. case contact.FieldStatus:
  3935. m.ClearStatus()
  3936. return nil
  3937. case contact.FieldDeletedAt:
  3938. m.ClearDeletedAt()
  3939. return nil
  3940. case contact.FieldWxWxid:
  3941. m.ClearWxWxid()
  3942. return nil
  3943. case contact.FieldType:
  3944. m.ClearType()
  3945. return nil
  3946. case contact.FieldOrganizationID:
  3947. m.ClearOrganizationID()
  3948. return nil
  3949. }
  3950. return fmt.Errorf("unknown Contact nullable field %s", name)
  3951. }
  3952. // ResetField resets all changes in the mutation for the field with the given name.
  3953. // It returns an error if the field is not defined in the schema.
  3954. func (m *ContactMutation) ResetField(name string) error {
  3955. switch name {
  3956. case contact.FieldCreatedAt:
  3957. m.ResetCreatedAt()
  3958. return nil
  3959. case contact.FieldUpdatedAt:
  3960. m.ResetUpdatedAt()
  3961. return nil
  3962. case contact.FieldStatus:
  3963. m.ResetStatus()
  3964. return nil
  3965. case contact.FieldDeletedAt:
  3966. m.ResetDeletedAt()
  3967. return nil
  3968. case contact.FieldWxWxid:
  3969. m.ResetWxWxid()
  3970. return nil
  3971. case contact.FieldType:
  3972. m.ResetType()
  3973. return nil
  3974. case contact.FieldWxid:
  3975. m.ResetWxid()
  3976. return nil
  3977. case contact.FieldAccount:
  3978. m.ResetAccount()
  3979. return nil
  3980. case contact.FieldNickname:
  3981. m.ResetNickname()
  3982. return nil
  3983. case contact.FieldMarkname:
  3984. m.ResetMarkname()
  3985. return nil
  3986. case contact.FieldHeadimg:
  3987. m.ResetHeadimg()
  3988. return nil
  3989. case contact.FieldSex:
  3990. m.ResetSex()
  3991. return nil
  3992. case contact.FieldStarrole:
  3993. m.ResetStarrole()
  3994. return nil
  3995. case contact.FieldDontseeit:
  3996. m.ResetDontseeit()
  3997. return nil
  3998. case contact.FieldDontseeme:
  3999. m.ResetDontseeme()
  4000. return nil
  4001. case contact.FieldLag:
  4002. m.ResetLag()
  4003. return nil
  4004. case contact.FieldGid:
  4005. m.ResetGid()
  4006. return nil
  4007. case contact.FieldGname:
  4008. m.ResetGname()
  4009. return nil
  4010. case contact.FieldV3:
  4011. m.ResetV3()
  4012. return nil
  4013. case contact.FieldOrganizationID:
  4014. m.ResetOrganizationID()
  4015. return nil
  4016. }
  4017. return fmt.Errorf("unknown Contact field %s", name)
  4018. }
  4019. // AddedEdges returns all edge names that were set/added in this mutation.
  4020. func (m *ContactMutation) AddedEdges() []string {
  4021. edges := make([]string, 0, 2)
  4022. if m.contact_relationships != nil {
  4023. edges = append(edges, contact.EdgeContactRelationships)
  4024. }
  4025. if m.contact_messages != nil {
  4026. edges = append(edges, contact.EdgeContactMessages)
  4027. }
  4028. return edges
  4029. }
  4030. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4031. // name in this mutation.
  4032. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  4033. switch name {
  4034. case contact.EdgeContactRelationships:
  4035. ids := make([]ent.Value, 0, len(m.contact_relationships))
  4036. for id := range m.contact_relationships {
  4037. ids = append(ids, id)
  4038. }
  4039. return ids
  4040. case contact.EdgeContactMessages:
  4041. ids := make([]ent.Value, 0, len(m.contact_messages))
  4042. for id := range m.contact_messages {
  4043. ids = append(ids, id)
  4044. }
  4045. return ids
  4046. }
  4047. return nil
  4048. }
  4049. // RemovedEdges returns all edge names that were removed in this mutation.
  4050. func (m *ContactMutation) RemovedEdges() []string {
  4051. edges := make([]string, 0, 2)
  4052. if m.removedcontact_relationships != nil {
  4053. edges = append(edges, contact.EdgeContactRelationships)
  4054. }
  4055. if m.removedcontact_messages != nil {
  4056. edges = append(edges, contact.EdgeContactMessages)
  4057. }
  4058. return edges
  4059. }
  4060. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4061. // the given name in this mutation.
  4062. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  4063. switch name {
  4064. case contact.EdgeContactRelationships:
  4065. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  4066. for id := range m.removedcontact_relationships {
  4067. ids = append(ids, id)
  4068. }
  4069. return ids
  4070. case contact.EdgeContactMessages:
  4071. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  4072. for id := range m.removedcontact_messages {
  4073. ids = append(ids, id)
  4074. }
  4075. return ids
  4076. }
  4077. return nil
  4078. }
  4079. // ClearedEdges returns all edge names that were cleared in this mutation.
  4080. func (m *ContactMutation) ClearedEdges() []string {
  4081. edges := make([]string, 0, 2)
  4082. if m.clearedcontact_relationships {
  4083. edges = append(edges, contact.EdgeContactRelationships)
  4084. }
  4085. if m.clearedcontact_messages {
  4086. edges = append(edges, contact.EdgeContactMessages)
  4087. }
  4088. return edges
  4089. }
  4090. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4091. // was cleared in this mutation.
  4092. func (m *ContactMutation) EdgeCleared(name string) bool {
  4093. switch name {
  4094. case contact.EdgeContactRelationships:
  4095. return m.clearedcontact_relationships
  4096. case contact.EdgeContactMessages:
  4097. return m.clearedcontact_messages
  4098. }
  4099. return false
  4100. }
  4101. // ClearEdge clears the value of the edge with the given name. It returns an error
  4102. // if that edge is not defined in the schema.
  4103. func (m *ContactMutation) ClearEdge(name string) error {
  4104. switch name {
  4105. }
  4106. return fmt.Errorf("unknown Contact unique edge %s", name)
  4107. }
  4108. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4109. // It returns an error if the edge is not defined in the schema.
  4110. func (m *ContactMutation) ResetEdge(name string) error {
  4111. switch name {
  4112. case contact.EdgeContactRelationships:
  4113. m.ResetContactRelationships()
  4114. return nil
  4115. case contact.EdgeContactMessages:
  4116. m.ResetContactMessages()
  4117. return nil
  4118. }
  4119. return fmt.Errorf("unknown Contact edge %s", name)
  4120. }
  4121. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  4122. type EmployeeMutation struct {
  4123. config
  4124. op Op
  4125. typ string
  4126. id *uint64
  4127. created_at *time.Time
  4128. updated_at *time.Time
  4129. deleted_at *time.Time
  4130. title *string
  4131. avatar *string
  4132. tags *string
  4133. hire_count *int
  4134. addhire_count *int
  4135. service_count *int
  4136. addservice_count *int
  4137. achievement_count *int
  4138. addachievement_count *int
  4139. intro *string
  4140. estimate *string
  4141. skill *string
  4142. ability_type *string
  4143. scene *string
  4144. switch_in *string
  4145. video_url *string
  4146. organization_id *uint64
  4147. addorganization_id *int64
  4148. clearedFields map[string]struct{}
  4149. em_work_experiences map[uint64]struct{}
  4150. removedem_work_experiences map[uint64]struct{}
  4151. clearedem_work_experiences bool
  4152. em_tutorial map[uint64]struct{}
  4153. removedem_tutorial map[uint64]struct{}
  4154. clearedem_tutorial bool
  4155. done bool
  4156. oldValue func(context.Context) (*Employee, error)
  4157. predicates []predicate.Employee
  4158. }
  4159. var _ ent.Mutation = (*EmployeeMutation)(nil)
  4160. // employeeOption allows management of the mutation configuration using functional options.
  4161. type employeeOption func(*EmployeeMutation)
  4162. // newEmployeeMutation creates new mutation for the Employee entity.
  4163. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  4164. m := &EmployeeMutation{
  4165. config: c,
  4166. op: op,
  4167. typ: TypeEmployee,
  4168. clearedFields: make(map[string]struct{}),
  4169. }
  4170. for _, opt := range opts {
  4171. opt(m)
  4172. }
  4173. return m
  4174. }
  4175. // withEmployeeID sets the ID field of the mutation.
  4176. func withEmployeeID(id uint64) employeeOption {
  4177. return func(m *EmployeeMutation) {
  4178. var (
  4179. err error
  4180. once sync.Once
  4181. value *Employee
  4182. )
  4183. m.oldValue = func(ctx context.Context) (*Employee, error) {
  4184. once.Do(func() {
  4185. if m.done {
  4186. err = errors.New("querying old values post mutation is not allowed")
  4187. } else {
  4188. value, err = m.Client().Employee.Get(ctx, id)
  4189. }
  4190. })
  4191. return value, err
  4192. }
  4193. m.id = &id
  4194. }
  4195. }
  4196. // withEmployee sets the old Employee of the mutation.
  4197. func withEmployee(node *Employee) employeeOption {
  4198. return func(m *EmployeeMutation) {
  4199. m.oldValue = func(context.Context) (*Employee, error) {
  4200. return node, nil
  4201. }
  4202. m.id = &node.ID
  4203. }
  4204. }
  4205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4206. // executed in a transaction (ent.Tx), a transactional client is returned.
  4207. func (m EmployeeMutation) Client() *Client {
  4208. client := &Client{config: m.config}
  4209. client.init()
  4210. return client
  4211. }
  4212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4213. // it returns an error otherwise.
  4214. func (m EmployeeMutation) Tx() (*Tx, error) {
  4215. if _, ok := m.driver.(*txDriver); !ok {
  4216. return nil, errors.New("ent: mutation is not running in a transaction")
  4217. }
  4218. tx := &Tx{config: m.config}
  4219. tx.init()
  4220. return tx, nil
  4221. }
  4222. // SetID sets the value of the id field. Note that this
  4223. // operation is only accepted on creation of Employee entities.
  4224. func (m *EmployeeMutation) SetID(id uint64) {
  4225. m.id = &id
  4226. }
  4227. // ID returns the ID value in the mutation. Note that the ID is only available
  4228. // if it was provided to the builder or after it was returned from the database.
  4229. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  4230. if m.id == nil {
  4231. return
  4232. }
  4233. return *m.id, true
  4234. }
  4235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4236. // That means, if the mutation is applied within a transaction with an isolation level such
  4237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4238. // or updated by the mutation.
  4239. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  4240. switch {
  4241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4242. id, exists := m.ID()
  4243. if exists {
  4244. return []uint64{id}, nil
  4245. }
  4246. fallthrough
  4247. case m.op.Is(OpUpdate | OpDelete):
  4248. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  4249. default:
  4250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4251. }
  4252. }
  4253. // SetCreatedAt sets the "created_at" field.
  4254. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  4255. m.created_at = &t
  4256. }
  4257. // CreatedAt returns the value of the "created_at" field in the mutation.
  4258. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  4259. v := m.created_at
  4260. if v == nil {
  4261. return
  4262. }
  4263. return *v, true
  4264. }
  4265. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  4266. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4268. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4269. if !m.op.Is(OpUpdateOne) {
  4270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4271. }
  4272. if m.id == nil || m.oldValue == nil {
  4273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4274. }
  4275. oldValue, err := m.oldValue(ctx)
  4276. if err != nil {
  4277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4278. }
  4279. return oldValue.CreatedAt, nil
  4280. }
  4281. // ResetCreatedAt resets all changes to the "created_at" field.
  4282. func (m *EmployeeMutation) ResetCreatedAt() {
  4283. m.created_at = nil
  4284. }
  4285. // SetUpdatedAt sets the "updated_at" field.
  4286. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  4287. m.updated_at = &t
  4288. }
  4289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4290. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  4291. v := m.updated_at
  4292. if v == nil {
  4293. return
  4294. }
  4295. return *v, true
  4296. }
  4297. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  4298. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4300. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4301. if !m.op.Is(OpUpdateOne) {
  4302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4303. }
  4304. if m.id == nil || m.oldValue == nil {
  4305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4306. }
  4307. oldValue, err := m.oldValue(ctx)
  4308. if err != nil {
  4309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4310. }
  4311. return oldValue.UpdatedAt, nil
  4312. }
  4313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4314. func (m *EmployeeMutation) ResetUpdatedAt() {
  4315. m.updated_at = nil
  4316. }
  4317. // SetDeletedAt sets the "deleted_at" field.
  4318. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  4319. m.deleted_at = &t
  4320. }
  4321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4322. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  4323. v := m.deleted_at
  4324. if v == nil {
  4325. return
  4326. }
  4327. return *v, true
  4328. }
  4329. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  4330. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4332. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4333. if !m.op.Is(OpUpdateOne) {
  4334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4335. }
  4336. if m.id == nil || m.oldValue == nil {
  4337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4338. }
  4339. oldValue, err := m.oldValue(ctx)
  4340. if err != nil {
  4341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4342. }
  4343. return oldValue.DeletedAt, nil
  4344. }
  4345. // ClearDeletedAt clears the value of the "deleted_at" field.
  4346. func (m *EmployeeMutation) ClearDeletedAt() {
  4347. m.deleted_at = nil
  4348. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  4349. }
  4350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4351. func (m *EmployeeMutation) DeletedAtCleared() bool {
  4352. _, ok := m.clearedFields[employee.FieldDeletedAt]
  4353. return ok
  4354. }
  4355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4356. func (m *EmployeeMutation) ResetDeletedAt() {
  4357. m.deleted_at = nil
  4358. delete(m.clearedFields, employee.FieldDeletedAt)
  4359. }
  4360. // SetTitle sets the "title" field.
  4361. func (m *EmployeeMutation) SetTitle(s string) {
  4362. m.title = &s
  4363. }
  4364. // Title returns the value of the "title" field in the mutation.
  4365. func (m *EmployeeMutation) Title() (r string, exists bool) {
  4366. v := m.title
  4367. if v == nil {
  4368. return
  4369. }
  4370. return *v, true
  4371. }
  4372. // OldTitle returns the old "title" field's value of the Employee entity.
  4373. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4375. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  4376. if !m.op.Is(OpUpdateOne) {
  4377. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4378. }
  4379. if m.id == nil || m.oldValue == nil {
  4380. return v, errors.New("OldTitle requires an ID field in the mutation")
  4381. }
  4382. oldValue, err := m.oldValue(ctx)
  4383. if err != nil {
  4384. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4385. }
  4386. return oldValue.Title, nil
  4387. }
  4388. // ResetTitle resets all changes to the "title" field.
  4389. func (m *EmployeeMutation) ResetTitle() {
  4390. m.title = nil
  4391. }
  4392. // SetAvatar sets the "avatar" field.
  4393. func (m *EmployeeMutation) SetAvatar(s string) {
  4394. m.avatar = &s
  4395. }
  4396. // Avatar returns the value of the "avatar" field in the mutation.
  4397. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  4398. v := m.avatar
  4399. if v == nil {
  4400. return
  4401. }
  4402. return *v, true
  4403. }
  4404. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  4405. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4407. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  4408. if !m.op.Is(OpUpdateOne) {
  4409. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  4410. }
  4411. if m.id == nil || m.oldValue == nil {
  4412. return v, errors.New("OldAvatar requires an ID field in the mutation")
  4413. }
  4414. oldValue, err := m.oldValue(ctx)
  4415. if err != nil {
  4416. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  4417. }
  4418. return oldValue.Avatar, nil
  4419. }
  4420. // ResetAvatar resets all changes to the "avatar" field.
  4421. func (m *EmployeeMutation) ResetAvatar() {
  4422. m.avatar = nil
  4423. }
  4424. // SetTags sets the "tags" field.
  4425. func (m *EmployeeMutation) SetTags(s string) {
  4426. m.tags = &s
  4427. }
  4428. // Tags returns the value of the "tags" field in the mutation.
  4429. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  4430. v := m.tags
  4431. if v == nil {
  4432. return
  4433. }
  4434. return *v, true
  4435. }
  4436. // OldTags returns the old "tags" field's value of the Employee entity.
  4437. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4439. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  4440. if !m.op.Is(OpUpdateOne) {
  4441. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  4442. }
  4443. if m.id == nil || m.oldValue == nil {
  4444. return v, errors.New("OldTags requires an ID field in the mutation")
  4445. }
  4446. oldValue, err := m.oldValue(ctx)
  4447. if err != nil {
  4448. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  4449. }
  4450. return oldValue.Tags, nil
  4451. }
  4452. // ResetTags resets all changes to the "tags" field.
  4453. func (m *EmployeeMutation) ResetTags() {
  4454. m.tags = nil
  4455. }
  4456. // SetHireCount sets the "hire_count" field.
  4457. func (m *EmployeeMutation) SetHireCount(i int) {
  4458. m.hire_count = &i
  4459. m.addhire_count = nil
  4460. }
  4461. // HireCount returns the value of the "hire_count" field in the mutation.
  4462. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  4463. v := m.hire_count
  4464. if v == nil {
  4465. return
  4466. }
  4467. return *v, true
  4468. }
  4469. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  4470. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4472. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  4473. if !m.op.Is(OpUpdateOne) {
  4474. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  4475. }
  4476. if m.id == nil || m.oldValue == nil {
  4477. return v, errors.New("OldHireCount requires an ID field in the mutation")
  4478. }
  4479. oldValue, err := m.oldValue(ctx)
  4480. if err != nil {
  4481. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  4482. }
  4483. return oldValue.HireCount, nil
  4484. }
  4485. // AddHireCount adds i to the "hire_count" field.
  4486. func (m *EmployeeMutation) AddHireCount(i int) {
  4487. if m.addhire_count != nil {
  4488. *m.addhire_count += i
  4489. } else {
  4490. m.addhire_count = &i
  4491. }
  4492. }
  4493. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  4494. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  4495. v := m.addhire_count
  4496. if v == nil {
  4497. return
  4498. }
  4499. return *v, true
  4500. }
  4501. // ResetHireCount resets all changes to the "hire_count" field.
  4502. func (m *EmployeeMutation) ResetHireCount() {
  4503. m.hire_count = nil
  4504. m.addhire_count = nil
  4505. }
  4506. // SetServiceCount sets the "service_count" field.
  4507. func (m *EmployeeMutation) SetServiceCount(i int) {
  4508. m.service_count = &i
  4509. m.addservice_count = nil
  4510. }
  4511. // ServiceCount returns the value of the "service_count" field in the mutation.
  4512. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  4513. v := m.service_count
  4514. if v == nil {
  4515. return
  4516. }
  4517. return *v, true
  4518. }
  4519. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  4520. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4522. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  4523. if !m.op.Is(OpUpdateOne) {
  4524. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  4525. }
  4526. if m.id == nil || m.oldValue == nil {
  4527. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  4528. }
  4529. oldValue, err := m.oldValue(ctx)
  4530. if err != nil {
  4531. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  4532. }
  4533. return oldValue.ServiceCount, nil
  4534. }
  4535. // AddServiceCount adds i to the "service_count" field.
  4536. func (m *EmployeeMutation) AddServiceCount(i int) {
  4537. if m.addservice_count != nil {
  4538. *m.addservice_count += i
  4539. } else {
  4540. m.addservice_count = &i
  4541. }
  4542. }
  4543. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  4544. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  4545. v := m.addservice_count
  4546. if v == nil {
  4547. return
  4548. }
  4549. return *v, true
  4550. }
  4551. // ResetServiceCount resets all changes to the "service_count" field.
  4552. func (m *EmployeeMutation) ResetServiceCount() {
  4553. m.service_count = nil
  4554. m.addservice_count = nil
  4555. }
  4556. // SetAchievementCount sets the "achievement_count" field.
  4557. func (m *EmployeeMutation) SetAchievementCount(i int) {
  4558. m.achievement_count = &i
  4559. m.addachievement_count = nil
  4560. }
  4561. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  4562. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  4563. v := m.achievement_count
  4564. if v == nil {
  4565. return
  4566. }
  4567. return *v, true
  4568. }
  4569. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  4570. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4572. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  4573. if !m.op.Is(OpUpdateOne) {
  4574. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  4575. }
  4576. if m.id == nil || m.oldValue == nil {
  4577. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  4578. }
  4579. oldValue, err := m.oldValue(ctx)
  4580. if err != nil {
  4581. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  4582. }
  4583. return oldValue.AchievementCount, nil
  4584. }
  4585. // AddAchievementCount adds i to the "achievement_count" field.
  4586. func (m *EmployeeMutation) AddAchievementCount(i int) {
  4587. if m.addachievement_count != nil {
  4588. *m.addachievement_count += i
  4589. } else {
  4590. m.addachievement_count = &i
  4591. }
  4592. }
  4593. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  4594. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  4595. v := m.addachievement_count
  4596. if v == nil {
  4597. return
  4598. }
  4599. return *v, true
  4600. }
  4601. // ResetAchievementCount resets all changes to the "achievement_count" field.
  4602. func (m *EmployeeMutation) ResetAchievementCount() {
  4603. m.achievement_count = nil
  4604. m.addachievement_count = nil
  4605. }
  4606. // SetIntro sets the "intro" field.
  4607. func (m *EmployeeMutation) SetIntro(s string) {
  4608. m.intro = &s
  4609. }
  4610. // Intro returns the value of the "intro" field in the mutation.
  4611. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  4612. v := m.intro
  4613. if v == nil {
  4614. return
  4615. }
  4616. return *v, true
  4617. }
  4618. // OldIntro returns the old "intro" field's value of the Employee entity.
  4619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4621. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  4622. if !m.op.Is(OpUpdateOne) {
  4623. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  4624. }
  4625. if m.id == nil || m.oldValue == nil {
  4626. return v, errors.New("OldIntro requires an ID field in the mutation")
  4627. }
  4628. oldValue, err := m.oldValue(ctx)
  4629. if err != nil {
  4630. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  4631. }
  4632. return oldValue.Intro, nil
  4633. }
  4634. // ResetIntro resets all changes to the "intro" field.
  4635. func (m *EmployeeMutation) ResetIntro() {
  4636. m.intro = nil
  4637. }
  4638. // SetEstimate sets the "estimate" field.
  4639. func (m *EmployeeMutation) SetEstimate(s string) {
  4640. m.estimate = &s
  4641. }
  4642. // Estimate returns the value of the "estimate" field in the mutation.
  4643. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  4644. v := m.estimate
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  4651. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldEstimate requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  4663. }
  4664. return oldValue.Estimate, nil
  4665. }
  4666. // ResetEstimate resets all changes to the "estimate" field.
  4667. func (m *EmployeeMutation) ResetEstimate() {
  4668. m.estimate = nil
  4669. }
  4670. // SetSkill sets the "skill" field.
  4671. func (m *EmployeeMutation) SetSkill(s string) {
  4672. m.skill = &s
  4673. }
  4674. // Skill returns the value of the "skill" field in the mutation.
  4675. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  4676. v := m.skill
  4677. if v == nil {
  4678. return
  4679. }
  4680. return *v, true
  4681. }
  4682. // OldSkill returns the old "skill" field's value of the Employee entity.
  4683. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4685. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  4686. if !m.op.Is(OpUpdateOne) {
  4687. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  4688. }
  4689. if m.id == nil || m.oldValue == nil {
  4690. return v, errors.New("OldSkill requires an ID field in the mutation")
  4691. }
  4692. oldValue, err := m.oldValue(ctx)
  4693. if err != nil {
  4694. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  4695. }
  4696. return oldValue.Skill, nil
  4697. }
  4698. // ResetSkill resets all changes to the "skill" field.
  4699. func (m *EmployeeMutation) ResetSkill() {
  4700. m.skill = nil
  4701. }
  4702. // SetAbilityType sets the "ability_type" field.
  4703. func (m *EmployeeMutation) SetAbilityType(s string) {
  4704. m.ability_type = &s
  4705. }
  4706. // AbilityType returns the value of the "ability_type" field in the mutation.
  4707. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  4708. v := m.ability_type
  4709. if v == nil {
  4710. return
  4711. }
  4712. return *v, true
  4713. }
  4714. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  4715. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4717. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  4718. if !m.op.Is(OpUpdateOne) {
  4719. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  4720. }
  4721. if m.id == nil || m.oldValue == nil {
  4722. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  4723. }
  4724. oldValue, err := m.oldValue(ctx)
  4725. if err != nil {
  4726. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  4727. }
  4728. return oldValue.AbilityType, nil
  4729. }
  4730. // ResetAbilityType resets all changes to the "ability_type" field.
  4731. func (m *EmployeeMutation) ResetAbilityType() {
  4732. m.ability_type = nil
  4733. }
  4734. // SetScene sets the "scene" field.
  4735. func (m *EmployeeMutation) SetScene(s string) {
  4736. m.scene = &s
  4737. }
  4738. // Scene returns the value of the "scene" field in the mutation.
  4739. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  4740. v := m.scene
  4741. if v == nil {
  4742. return
  4743. }
  4744. return *v, true
  4745. }
  4746. // OldScene returns the old "scene" field's value of the Employee entity.
  4747. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4749. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  4750. if !m.op.Is(OpUpdateOne) {
  4751. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  4752. }
  4753. if m.id == nil || m.oldValue == nil {
  4754. return v, errors.New("OldScene requires an ID field in the mutation")
  4755. }
  4756. oldValue, err := m.oldValue(ctx)
  4757. if err != nil {
  4758. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  4759. }
  4760. return oldValue.Scene, nil
  4761. }
  4762. // ResetScene resets all changes to the "scene" field.
  4763. func (m *EmployeeMutation) ResetScene() {
  4764. m.scene = nil
  4765. }
  4766. // SetSwitchIn sets the "switch_in" field.
  4767. func (m *EmployeeMutation) SetSwitchIn(s string) {
  4768. m.switch_in = &s
  4769. }
  4770. // SwitchIn returns the value of the "switch_in" field in the mutation.
  4771. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  4772. v := m.switch_in
  4773. if v == nil {
  4774. return
  4775. }
  4776. return *v, true
  4777. }
  4778. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  4779. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4781. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  4782. if !m.op.Is(OpUpdateOne) {
  4783. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  4784. }
  4785. if m.id == nil || m.oldValue == nil {
  4786. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  4787. }
  4788. oldValue, err := m.oldValue(ctx)
  4789. if err != nil {
  4790. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  4791. }
  4792. return oldValue.SwitchIn, nil
  4793. }
  4794. // ResetSwitchIn resets all changes to the "switch_in" field.
  4795. func (m *EmployeeMutation) ResetSwitchIn() {
  4796. m.switch_in = nil
  4797. }
  4798. // SetVideoURL sets the "video_url" field.
  4799. func (m *EmployeeMutation) SetVideoURL(s string) {
  4800. m.video_url = &s
  4801. }
  4802. // VideoURL returns the value of the "video_url" field in the mutation.
  4803. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  4804. v := m.video_url
  4805. if v == nil {
  4806. return
  4807. }
  4808. return *v, true
  4809. }
  4810. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  4811. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4813. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  4814. if !m.op.Is(OpUpdateOne) {
  4815. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  4816. }
  4817. if m.id == nil || m.oldValue == nil {
  4818. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  4819. }
  4820. oldValue, err := m.oldValue(ctx)
  4821. if err != nil {
  4822. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  4823. }
  4824. return oldValue.VideoURL, nil
  4825. }
  4826. // ResetVideoURL resets all changes to the "video_url" field.
  4827. func (m *EmployeeMutation) ResetVideoURL() {
  4828. m.video_url = nil
  4829. }
  4830. // SetOrganizationID sets the "organization_id" field.
  4831. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  4832. m.organization_id = &u
  4833. m.addorganization_id = nil
  4834. }
  4835. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4836. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  4837. v := m.organization_id
  4838. if v == nil {
  4839. return
  4840. }
  4841. return *v, true
  4842. }
  4843. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  4844. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  4845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4846. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4847. if !m.op.Is(OpUpdateOne) {
  4848. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4849. }
  4850. if m.id == nil || m.oldValue == nil {
  4851. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4852. }
  4853. oldValue, err := m.oldValue(ctx)
  4854. if err != nil {
  4855. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4856. }
  4857. return oldValue.OrganizationID, nil
  4858. }
  4859. // AddOrganizationID adds u to the "organization_id" field.
  4860. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  4861. if m.addorganization_id != nil {
  4862. *m.addorganization_id += u
  4863. } else {
  4864. m.addorganization_id = &u
  4865. }
  4866. }
  4867. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4868. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  4869. v := m.addorganization_id
  4870. if v == nil {
  4871. return
  4872. }
  4873. return *v, true
  4874. }
  4875. // ResetOrganizationID resets all changes to the "organization_id" field.
  4876. func (m *EmployeeMutation) ResetOrganizationID() {
  4877. m.organization_id = nil
  4878. m.addorganization_id = nil
  4879. }
  4880. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  4881. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  4882. if m.em_work_experiences == nil {
  4883. m.em_work_experiences = make(map[uint64]struct{})
  4884. }
  4885. for i := range ids {
  4886. m.em_work_experiences[ids[i]] = struct{}{}
  4887. }
  4888. }
  4889. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  4890. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  4891. m.clearedem_work_experiences = true
  4892. }
  4893. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  4894. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  4895. return m.clearedem_work_experiences
  4896. }
  4897. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  4898. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  4899. if m.removedem_work_experiences == nil {
  4900. m.removedem_work_experiences = make(map[uint64]struct{})
  4901. }
  4902. for i := range ids {
  4903. delete(m.em_work_experiences, ids[i])
  4904. m.removedem_work_experiences[ids[i]] = struct{}{}
  4905. }
  4906. }
  4907. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  4908. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  4909. for id := range m.removedem_work_experiences {
  4910. ids = append(ids, id)
  4911. }
  4912. return
  4913. }
  4914. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  4915. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  4916. for id := range m.em_work_experiences {
  4917. ids = append(ids, id)
  4918. }
  4919. return
  4920. }
  4921. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  4922. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  4923. m.em_work_experiences = nil
  4924. m.clearedem_work_experiences = false
  4925. m.removedem_work_experiences = nil
  4926. }
  4927. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  4928. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  4929. if m.em_tutorial == nil {
  4930. m.em_tutorial = make(map[uint64]struct{})
  4931. }
  4932. for i := range ids {
  4933. m.em_tutorial[ids[i]] = struct{}{}
  4934. }
  4935. }
  4936. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  4937. func (m *EmployeeMutation) ClearEmTutorial() {
  4938. m.clearedem_tutorial = true
  4939. }
  4940. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  4941. func (m *EmployeeMutation) EmTutorialCleared() bool {
  4942. return m.clearedem_tutorial
  4943. }
  4944. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  4945. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  4946. if m.removedem_tutorial == nil {
  4947. m.removedem_tutorial = make(map[uint64]struct{})
  4948. }
  4949. for i := range ids {
  4950. delete(m.em_tutorial, ids[i])
  4951. m.removedem_tutorial[ids[i]] = struct{}{}
  4952. }
  4953. }
  4954. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  4955. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  4956. for id := range m.removedem_tutorial {
  4957. ids = append(ids, id)
  4958. }
  4959. return
  4960. }
  4961. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  4962. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  4963. for id := range m.em_tutorial {
  4964. ids = append(ids, id)
  4965. }
  4966. return
  4967. }
  4968. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  4969. func (m *EmployeeMutation) ResetEmTutorial() {
  4970. m.em_tutorial = nil
  4971. m.clearedem_tutorial = false
  4972. m.removedem_tutorial = nil
  4973. }
  4974. // Where appends a list predicates to the EmployeeMutation builder.
  4975. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  4976. m.predicates = append(m.predicates, ps...)
  4977. }
  4978. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  4979. // users can use type-assertion to append predicates that do not depend on any generated package.
  4980. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  4981. p := make([]predicate.Employee, len(ps))
  4982. for i := range ps {
  4983. p[i] = ps[i]
  4984. }
  4985. m.Where(p...)
  4986. }
  4987. // Op returns the operation name.
  4988. func (m *EmployeeMutation) Op() Op {
  4989. return m.op
  4990. }
  4991. // SetOp allows setting the mutation operation.
  4992. func (m *EmployeeMutation) SetOp(op Op) {
  4993. m.op = op
  4994. }
  4995. // Type returns the node type of this mutation (Employee).
  4996. func (m *EmployeeMutation) Type() string {
  4997. return m.typ
  4998. }
  4999. // Fields returns all fields that were changed during this mutation. Note that in
  5000. // order to get all numeric fields that were incremented/decremented, call
  5001. // AddedFields().
  5002. func (m *EmployeeMutation) Fields() []string {
  5003. fields := make([]string, 0, 17)
  5004. if m.created_at != nil {
  5005. fields = append(fields, employee.FieldCreatedAt)
  5006. }
  5007. if m.updated_at != nil {
  5008. fields = append(fields, employee.FieldUpdatedAt)
  5009. }
  5010. if m.deleted_at != nil {
  5011. fields = append(fields, employee.FieldDeletedAt)
  5012. }
  5013. if m.title != nil {
  5014. fields = append(fields, employee.FieldTitle)
  5015. }
  5016. if m.avatar != nil {
  5017. fields = append(fields, employee.FieldAvatar)
  5018. }
  5019. if m.tags != nil {
  5020. fields = append(fields, employee.FieldTags)
  5021. }
  5022. if m.hire_count != nil {
  5023. fields = append(fields, employee.FieldHireCount)
  5024. }
  5025. if m.service_count != nil {
  5026. fields = append(fields, employee.FieldServiceCount)
  5027. }
  5028. if m.achievement_count != nil {
  5029. fields = append(fields, employee.FieldAchievementCount)
  5030. }
  5031. if m.intro != nil {
  5032. fields = append(fields, employee.FieldIntro)
  5033. }
  5034. if m.estimate != nil {
  5035. fields = append(fields, employee.FieldEstimate)
  5036. }
  5037. if m.skill != nil {
  5038. fields = append(fields, employee.FieldSkill)
  5039. }
  5040. if m.ability_type != nil {
  5041. fields = append(fields, employee.FieldAbilityType)
  5042. }
  5043. if m.scene != nil {
  5044. fields = append(fields, employee.FieldScene)
  5045. }
  5046. if m.switch_in != nil {
  5047. fields = append(fields, employee.FieldSwitchIn)
  5048. }
  5049. if m.video_url != nil {
  5050. fields = append(fields, employee.FieldVideoURL)
  5051. }
  5052. if m.organization_id != nil {
  5053. fields = append(fields, employee.FieldOrganizationID)
  5054. }
  5055. return fields
  5056. }
  5057. // Field returns the value of a field with the given name. The second boolean
  5058. // return value indicates that this field was not set, or was not defined in the
  5059. // schema.
  5060. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  5061. switch name {
  5062. case employee.FieldCreatedAt:
  5063. return m.CreatedAt()
  5064. case employee.FieldUpdatedAt:
  5065. return m.UpdatedAt()
  5066. case employee.FieldDeletedAt:
  5067. return m.DeletedAt()
  5068. case employee.FieldTitle:
  5069. return m.Title()
  5070. case employee.FieldAvatar:
  5071. return m.Avatar()
  5072. case employee.FieldTags:
  5073. return m.Tags()
  5074. case employee.FieldHireCount:
  5075. return m.HireCount()
  5076. case employee.FieldServiceCount:
  5077. return m.ServiceCount()
  5078. case employee.FieldAchievementCount:
  5079. return m.AchievementCount()
  5080. case employee.FieldIntro:
  5081. return m.Intro()
  5082. case employee.FieldEstimate:
  5083. return m.Estimate()
  5084. case employee.FieldSkill:
  5085. return m.Skill()
  5086. case employee.FieldAbilityType:
  5087. return m.AbilityType()
  5088. case employee.FieldScene:
  5089. return m.Scene()
  5090. case employee.FieldSwitchIn:
  5091. return m.SwitchIn()
  5092. case employee.FieldVideoURL:
  5093. return m.VideoURL()
  5094. case employee.FieldOrganizationID:
  5095. return m.OrganizationID()
  5096. }
  5097. return nil, false
  5098. }
  5099. // OldField returns the old value of the field from the database. An error is
  5100. // returned if the mutation operation is not UpdateOne, or the query to the
  5101. // database failed.
  5102. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5103. switch name {
  5104. case employee.FieldCreatedAt:
  5105. return m.OldCreatedAt(ctx)
  5106. case employee.FieldUpdatedAt:
  5107. return m.OldUpdatedAt(ctx)
  5108. case employee.FieldDeletedAt:
  5109. return m.OldDeletedAt(ctx)
  5110. case employee.FieldTitle:
  5111. return m.OldTitle(ctx)
  5112. case employee.FieldAvatar:
  5113. return m.OldAvatar(ctx)
  5114. case employee.FieldTags:
  5115. return m.OldTags(ctx)
  5116. case employee.FieldHireCount:
  5117. return m.OldHireCount(ctx)
  5118. case employee.FieldServiceCount:
  5119. return m.OldServiceCount(ctx)
  5120. case employee.FieldAchievementCount:
  5121. return m.OldAchievementCount(ctx)
  5122. case employee.FieldIntro:
  5123. return m.OldIntro(ctx)
  5124. case employee.FieldEstimate:
  5125. return m.OldEstimate(ctx)
  5126. case employee.FieldSkill:
  5127. return m.OldSkill(ctx)
  5128. case employee.FieldAbilityType:
  5129. return m.OldAbilityType(ctx)
  5130. case employee.FieldScene:
  5131. return m.OldScene(ctx)
  5132. case employee.FieldSwitchIn:
  5133. return m.OldSwitchIn(ctx)
  5134. case employee.FieldVideoURL:
  5135. return m.OldVideoURL(ctx)
  5136. case employee.FieldOrganizationID:
  5137. return m.OldOrganizationID(ctx)
  5138. }
  5139. return nil, fmt.Errorf("unknown Employee field %s", name)
  5140. }
  5141. // SetField sets the value of a field with the given name. It returns an error if
  5142. // the field is not defined in the schema, or if the type mismatched the field
  5143. // type.
  5144. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  5145. switch name {
  5146. case employee.FieldCreatedAt:
  5147. v, ok := value.(time.Time)
  5148. if !ok {
  5149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5150. }
  5151. m.SetCreatedAt(v)
  5152. return nil
  5153. case employee.FieldUpdatedAt:
  5154. v, ok := value.(time.Time)
  5155. if !ok {
  5156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5157. }
  5158. m.SetUpdatedAt(v)
  5159. return nil
  5160. case employee.FieldDeletedAt:
  5161. v, ok := value.(time.Time)
  5162. if !ok {
  5163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5164. }
  5165. m.SetDeletedAt(v)
  5166. return nil
  5167. case employee.FieldTitle:
  5168. v, ok := value.(string)
  5169. if !ok {
  5170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5171. }
  5172. m.SetTitle(v)
  5173. return nil
  5174. case employee.FieldAvatar:
  5175. v, ok := value.(string)
  5176. if !ok {
  5177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5178. }
  5179. m.SetAvatar(v)
  5180. return nil
  5181. case employee.FieldTags:
  5182. v, ok := value.(string)
  5183. if !ok {
  5184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5185. }
  5186. m.SetTags(v)
  5187. return nil
  5188. case employee.FieldHireCount:
  5189. v, ok := value.(int)
  5190. if !ok {
  5191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5192. }
  5193. m.SetHireCount(v)
  5194. return nil
  5195. case employee.FieldServiceCount:
  5196. v, ok := value.(int)
  5197. if !ok {
  5198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5199. }
  5200. m.SetServiceCount(v)
  5201. return nil
  5202. case employee.FieldAchievementCount:
  5203. v, ok := value.(int)
  5204. if !ok {
  5205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5206. }
  5207. m.SetAchievementCount(v)
  5208. return nil
  5209. case employee.FieldIntro:
  5210. v, ok := value.(string)
  5211. if !ok {
  5212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5213. }
  5214. m.SetIntro(v)
  5215. return nil
  5216. case employee.FieldEstimate:
  5217. v, ok := value.(string)
  5218. if !ok {
  5219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5220. }
  5221. m.SetEstimate(v)
  5222. return nil
  5223. case employee.FieldSkill:
  5224. v, ok := value.(string)
  5225. if !ok {
  5226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5227. }
  5228. m.SetSkill(v)
  5229. return nil
  5230. case employee.FieldAbilityType:
  5231. v, ok := value.(string)
  5232. if !ok {
  5233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5234. }
  5235. m.SetAbilityType(v)
  5236. return nil
  5237. case employee.FieldScene:
  5238. v, ok := value.(string)
  5239. if !ok {
  5240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5241. }
  5242. m.SetScene(v)
  5243. return nil
  5244. case employee.FieldSwitchIn:
  5245. v, ok := value.(string)
  5246. if !ok {
  5247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5248. }
  5249. m.SetSwitchIn(v)
  5250. return nil
  5251. case employee.FieldVideoURL:
  5252. v, ok := value.(string)
  5253. if !ok {
  5254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5255. }
  5256. m.SetVideoURL(v)
  5257. return nil
  5258. case employee.FieldOrganizationID:
  5259. v, ok := value.(uint64)
  5260. if !ok {
  5261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5262. }
  5263. m.SetOrganizationID(v)
  5264. return nil
  5265. }
  5266. return fmt.Errorf("unknown Employee field %s", name)
  5267. }
  5268. // AddedFields returns all numeric fields that were incremented/decremented during
  5269. // this mutation.
  5270. func (m *EmployeeMutation) AddedFields() []string {
  5271. var fields []string
  5272. if m.addhire_count != nil {
  5273. fields = append(fields, employee.FieldHireCount)
  5274. }
  5275. if m.addservice_count != nil {
  5276. fields = append(fields, employee.FieldServiceCount)
  5277. }
  5278. if m.addachievement_count != nil {
  5279. fields = append(fields, employee.FieldAchievementCount)
  5280. }
  5281. if m.addorganization_id != nil {
  5282. fields = append(fields, employee.FieldOrganizationID)
  5283. }
  5284. return fields
  5285. }
  5286. // AddedField returns the numeric value that was incremented/decremented on a field
  5287. // with the given name. The second boolean return value indicates that this field
  5288. // was not set, or was not defined in the schema.
  5289. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  5290. switch name {
  5291. case employee.FieldHireCount:
  5292. return m.AddedHireCount()
  5293. case employee.FieldServiceCount:
  5294. return m.AddedServiceCount()
  5295. case employee.FieldAchievementCount:
  5296. return m.AddedAchievementCount()
  5297. case employee.FieldOrganizationID:
  5298. return m.AddedOrganizationID()
  5299. }
  5300. return nil, false
  5301. }
  5302. // AddField adds the value to the field with the given name. It returns an error if
  5303. // the field is not defined in the schema, or if the type mismatched the field
  5304. // type.
  5305. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  5306. switch name {
  5307. case employee.FieldHireCount:
  5308. v, ok := value.(int)
  5309. if !ok {
  5310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5311. }
  5312. m.AddHireCount(v)
  5313. return nil
  5314. case employee.FieldServiceCount:
  5315. v, ok := value.(int)
  5316. if !ok {
  5317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5318. }
  5319. m.AddServiceCount(v)
  5320. return nil
  5321. case employee.FieldAchievementCount:
  5322. v, ok := value.(int)
  5323. if !ok {
  5324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5325. }
  5326. m.AddAchievementCount(v)
  5327. return nil
  5328. case employee.FieldOrganizationID:
  5329. v, ok := value.(int64)
  5330. if !ok {
  5331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5332. }
  5333. m.AddOrganizationID(v)
  5334. return nil
  5335. }
  5336. return fmt.Errorf("unknown Employee numeric field %s", name)
  5337. }
  5338. // ClearedFields returns all nullable fields that were cleared during this
  5339. // mutation.
  5340. func (m *EmployeeMutation) ClearedFields() []string {
  5341. var fields []string
  5342. if m.FieldCleared(employee.FieldDeletedAt) {
  5343. fields = append(fields, employee.FieldDeletedAt)
  5344. }
  5345. return fields
  5346. }
  5347. // FieldCleared returns a boolean indicating if a field with the given name was
  5348. // cleared in this mutation.
  5349. func (m *EmployeeMutation) FieldCleared(name string) bool {
  5350. _, ok := m.clearedFields[name]
  5351. return ok
  5352. }
  5353. // ClearField clears the value of the field with the given name. It returns an
  5354. // error if the field is not defined in the schema.
  5355. func (m *EmployeeMutation) ClearField(name string) error {
  5356. switch name {
  5357. case employee.FieldDeletedAt:
  5358. m.ClearDeletedAt()
  5359. return nil
  5360. }
  5361. return fmt.Errorf("unknown Employee nullable field %s", name)
  5362. }
  5363. // ResetField resets all changes in the mutation for the field with the given name.
  5364. // It returns an error if the field is not defined in the schema.
  5365. func (m *EmployeeMutation) ResetField(name string) error {
  5366. switch name {
  5367. case employee.FieldCreatedAt:
  5368. m.ResetCreatedAt()
  5369. return nil
  5370. case employee.FieldUpdatedAt:
  5371. m.ResetUpdatedAt()
  5372. return nil
  5373. case employee.FieldDeletedAt:
  5374. m.ResetDeletedAt()
  5375. return nil
  5376. case employee.FieldTitle:
  5377. m.ResetTitle()
  5378. return nil
  5379. case employee.FieldAvatar:
  5380. m.ResetAvatar()
  5381. return nil
  5382. case employee.FieldTags:
  5383. m.ResetTags()
  5384. return nil
  5385. case employee.FieldHireCount:
  5386. m.ResetHireCount()
  5387. return nil
  5388. case employee.FieldServiceCount:
  5389. m.ResetServiceCount()
  5390. return nil
  5391. case employee.FieldAchievementCount:
  5392. m.ResetAchievementCount()
  5393. return nil
  5394. case employee.FieldIntro:
  5395. m.ResetIntro()
  5396. return nil
  5397. case employee.FieldEstimate:
  5398. m.ResetEstimate()
  5399. return nil
  5400. case employee.FieldSkill:
  5401. m.ResetSkill()
  5402. return nil
  5403. case employee.FieldAbilityType:
  5404. m.ResetAbilityType()
  5405. return nil
  5406. case employee.FieldScene:
  5407. m.ResetScene()
  5408. return nil
  5409. case employee.FieldSwitchIn:
  5410. m.ResetSwitchIn()
  5411. return nil
  5412. case employee.FieldVideoURL:
  5413. m.ResetVideoURL()
  5414. return nil
  5415. case employee.FieldOrganizationID:
  5416. m.ResetOrganizationID()
  5417. return nil
  5418. }
  5419. return fmt.Errorf("unknown Employee field %s", name)
  5420. }
  5421. // AddedEdges returns all edge names that were set/added in this mutation.
  5422. func (m *EmployeeMutation) AddedEdges() []string {
  5423. edges := make([]string, 0, 2)
  5424. if m.em_work_experiences != nil {
  5425. edges = append(edges, employee.EdgeEmWorkExperiences)
  5426. }
  5427. if m.em_tutorial != nil {
  5428. edges = append(edges, employee.EdgeEmTutorial)
  5429. }
  5430. return edges
  5431. }
  5432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5433. // name in this mutation.
  5434. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  5435. switch name {
  5436. case employee.EdgeEmWorkExperiences:
  5437. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  5438. for id := range m.em_work_experiences {
  5439. ids = append(ids, id)
  5440. }
  5441. return ids
  5442. case employee.EdgeEmTutorial:
  5443. ids := make([]ent.Value, 0, len(m.em_tutorial))
  5444. for id := range m.em_tutorial {
  5445. ids = append(ids, id)
  5446. }
  5447. return ids
  5448. }
  5449. return nil
  5450. }
  5451. // RemovedEdges returns all edge names that were removed in this mutation.
  5452. func (m *EmployeeMutation) RemovedEdges() []string {
  5453. edges := make([]string, 0, 2)
  5454. if m.removedem_work_experiences != nil {
  5455. edges = append(edges, employee.EdgeEmWorkExperiences)
  5456. }
  5457. if m.removedem_tutorial != nil {
  5458. edges = append(edges, employee.EdgeEmTutorial)
  5459. }
  5460. return edges
  5461. }
  5462. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5463. // the given name in this mutation.
  5464. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  5465. switch name {
  5466. case employee.EdgeEmWorkExperiences:
  5467. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  5468. for id := range m.removedem_work_experiences {
  5469. ids = append(ids, id)
  5470. }
  5471. return ids
  5472. case employee.EdgeEmTutorial:
  5473. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  5474. for id := range m.removedem_tutorial {
  5475. ids = append(ids, id)
  5476. }
  5477. return ids
  5478. }
  5479. return nil
  5480. }
  5481. // ClearedEdges returns all edge names that were cleared in this mutation.
  5482. func (m *EmployeeMutation) ClearedEdges() []string {
  5483. edges := make([]string, 0, 2)
  5484. if m.clearedem_work_experiences {
  5485. edges = append(edges, employee.EdgeEmWorkExperiences)
  5486. }
  5487. if m.clearedem_tutorial {
  5488. edges = append(edges, employee.EdgeEmTutorial)
  5489. }
  5490. return edges
  5491. }
  5492. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5493. // was cleared in this mutation.
  5494. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  5495. switch name {
  5496. case employee.EdgeEmWorkExperiences:
  5497. return m.clearedem_work_experiences
  5498. case employee.EdgeEmTutorial:
  5499. return m.clearedem_tutorial
  5500. }
  5501. return false
  5502. }
  5503. // ClearEdge clears the value of the edge with the given name. It returns an error
  5504. // if that edge is not defined in the schema.
  5505. func (m *EmployeeMutation) ClearEdge(name string) error {
  5506. switch name {
  5507. }
  5508. return fmt.Errorf("unknown Employee unique edge %s", name)
  5509. }
  5510. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5511. // It returns an error if the edge is not defined in the schema.
  5512. func (m *EmployeeMutation) ResetEdge(name string) error {
  5513. switch name {
  5514. case employee.EdgeEmWorkExperiences:
  5515. m.ResetEmWorkExperiences()
  5516. return nil
  5517. case employee.EdgeEmTutorial:
  5518. m.ResetEmTutorial()
  5519. return nil
  5520. }
  5521. return fmt.Errorf("unknown Employee edge %s", name)
  5522. }
  5523. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  5524. type EmployeeConfigMutation struct {
  5525. config
  5526. op Op
  5527. typ string
  5528. id *uint64
  5529. created_at *time.Time
  5530. updated_at *time.Time
  5531. deleted_at *time.Time
  5532. stype *string
  5533. title *string
  5534. photo *string
  5535. organization_id *uint64
  5536. addorganization_id *int64
  5537. clearedFields map[string]struct{}
  5538. done bool
  5539. oldValue func(context.Context) (*EmployeeConfig, error)
  5540. predicates []predicate.EmployeeConfig
  5541. }
  5542. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  5543. // employeeconfigOption allows management of the mutation configuration using functional options.
  5544. type employeeconfigOption func(*EmployeeConfigMutation)
  5545. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  5546. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  5547. m := &EmployeeConfigMutation{
  5548. config: c,
  5549. op: op,
  5550. typ: TypeEmployeeConfig,
  5551. clearedFields: make(map[string]struct{}),
  5552. }
  5553. for _, opt := range opts {
  5554. opt(m)
  5555. }
  5556. return m
  5557. }
  5558. // withEmployeeConfigID sets the ID field of the mutation.
  5559. func withEmployeeConfigID(id uint64) employeeconfigOption {
  5560. return func(m *EmployeeConfigMutation) {
  5561. var (
  5562. err error
  5563. once sync.Once
  5564. value *EmployeeConfig
  5565. )
  5566. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  5567. once.Do(func() {
  5568. if m.done {
  5569. err = errors.New("querying old values post mutation is not allowed")
  5570. } else {
  5571. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  5572. }
  5573. })
  5574. return value, err
  5575. }
  5576. m.id = &id
  5577. }
  5578. }
  5579. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  5580. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  5581. return func(m *EmployeeConfigMutation) {
  5582. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  5583. return node, nil
  5584. }
  5585. m.id = &node.ID
  5586. }
  5587. }
  5588. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5589. // executed in a transaction (ent.Tx), a transactional client is returned.
  5590. func (m EmployeeConfigMutation) Client() *Client {
  5591. client := &Client{config: m.config}
  5592. client.init()
  5593. return client
  5594. }
  5595. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5596. // it returns an error otherwise.
  5597. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  5598. if _, ok := m.driver.(*txDriver); !ok {
  5599. return nil, errors.New("ent: mutation is not running in a transaction")
  5600. }
  5601. tx := &Tx{config: m.config}
  5602. tx.init()
  5603. return tx, nil
  5604. }
  5605. // SetID sets the value of the id field. Note that this
  5606. // operation is only accepted on creation of EmployeeConfig entities.
  5607. func (m *EmployeeConfigMutation) SetID(id uint64) {
  5608. m.id = &id
  5609. }
  5610. // ID returns the ID value in the mutation. Note that the ID is only available
  5611. // if it was provided to the builder or after it was returned from the database.
  5612. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  5613. if m.id == nil {
  5614. return
  5615. }
  5616. return *m.id, true
  5617. }
  5618. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5619. // That means, if the mutation is applied within a transaction with an isolation level such
  5620. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5621. // or updated by the mutation.
  5622. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  5623. switch {
  5624. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5625. id, exists := m.ID()
  5626. if exists {
  5627. return []uint64{id}, nil
  5628. }
  5629. fallthrough
  5630. case m.op.Is(OpUpdate | OpDelete):
  5631. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  5632. default:
  5633. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5634. }
  5635. }
  5636. // SetCreatedAt sets the "created_at" field.
  5637. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  5638. m.created_at = &t
  5639. }
  5640. // CreatedAt returns the value of the "created_at" field in the mutation.
  5641. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  5642. v := m.created_at
  5643. if v == nil {
  5644. return
  5645. }
  5646. return *v, true
  5647. }
  5648. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  5649. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5651. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5652. if !m.op.Is(OpUpdateOne) {
  5653. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5654. }
  5655. if m.id == nil || m.oldValue == nil {
  5656. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5657. }
  5658. oldValue, err := m.oldValue(ctx)
  5659. if err != nil {
  5660. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5661. }
  5662. return oldValue.CreatedAt, nil
  5663. }
  5664. // ResetCreatedAt resets all changes to the "created_at" field.
  5665. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  5666. m.created_at = nil
  5667. }
  5668. // SetUpdatedAt sets the "updated_at" field.
  5669. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  5670. m.updated_at = &t
  5671. }
  5672. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5673. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  5674. v := m.updated_at
  5675. if v == nil {
  5676. return
  5677. }
  5678. return *v, true
  5679. }
  5680. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  5681. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5683. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5684. if !m.op.Is(OpUpdateOne) {
  5685. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5686. }
  5687. if m.id == nil || m.oldValue == nil {
  5688. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5689. }
  5690. oldValue, err := m.oldValue(ctx)
  5691. if err != nil {
  5692. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5693. }
  5694. return oldValue.UpdatedAt, nil
  5695. }
  5696. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5697. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  5698. m.updated_at = nil
  5699. }
  5700. // SetDeletedAt sets the "deleted_at" field.
  5701. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  5702. m.deleted_at = &t
  5703. }
  5704. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5705. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  5706. v := m.deleted_at
  5707. if v == nil {
  5708. return
  5709. }
  5710. return *v, true
  5711. }
  5712. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  5713. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5715. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5716. if !m.op.Is(OpUpdateOne) {
  5717. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5718. }
  5719. if m.id == nil || m.oldValue == nil {
  5720. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5721. }
  5722. oldValue, err := m.oldValue(ctx)
  5723. if err != nil {
  5724. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5725. }
  5726. return oldValue.DeletedAt, nil
  5727. }
  5728. // ClearDeletedAt clears the value of the "deleted_at" field.
  5729. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  5730. m.deleted_at = nil
  5731. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  5732. }
  5733. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5734. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  5735. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  5736. return ok
  5737. }
  5738. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5739. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  5740. m.deleted_at = nil
  5741. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  5742. }
  5743. // SetStype sets the "stype" field.
  5744. func (m *EmployeeConfigMutation) SetStype(s string) {
  5745. m.stype = &s
  5746. }
  5747. // Stype returns the value of the "stype" field in the mutation.
  5748. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  5749. v := m.stype
  5750. if v == nil {
  5751. return
  5752. }
  5753. return *v, true
  5754. }
  5755. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  5756. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5758. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  5759. if !m.op.Is(OpUpdateOne) {
  5760. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  5761. }
  5762. if m.id == nil || m.oldValue == nil {
  5763. return v, errors.New("OldStype requires an ID field in the mutation")
  5764. }
  5765. oldValue, err := m.oldValue(ctx)
  5766. if err != nil {
  5767. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  5768. }
  5769. return oldValue.Stype, nil
  5770. }
  5771. // ResetStype resets all changes to the "stype" field.
  5772. func (m *EmployeeConfigMutation) ResetStype() {
  5773. m.stype = nil
  5774. }
  5775. // SetTitle sets the "title" field.
  5776. func (m *EmployeeConfigMutation) SetTitle(s string) {
  5777. m.title = &s
  5778. }
  5779. // Title returns the value of the "title" field in the mutation.
  5780. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  5781. v := m.title
  5782. if v == nil {
  5783. return
  5784. }
  5785. return *v, true
  5786. }
  5787. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  5788. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5790. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  5791. if !m.op.Is(OpUpdateOne) {
  5792. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5793. }
  5794. if m.id == nil || m.oldValue == nil {
  5795. return v, errors.New("OldTitle requires an ID field in the mutation")
  5796. }
  5797. oldValue, err := m.oldValue(ctx)
  5798. if err != nil {
  5799. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5800. }
  5801. return oldValue.Title, nil
  5802. }
  5803. // ResetTitle resets all changes to the "title" field.
  5804. func (m *EmployeeConfigMutation) ResetTitle() {
  5805. m.title = nil
  5806. }
  5807. // SetPhoto sets the "photo" field.
  5808. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  5809. m.photo = &s
  5810. }
  5811. // Photo returns the value of the "photo" field in the mutation.
  5812. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  5813. v := m.photo
  5814. if v == nil {
  5815. return
  5816. }
  5817. return *v, true
  5818. }
  5819. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  5820. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5822. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  5823. if !m.op.Is(OpUpdateOne) {
  5824. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  5825. }
  5826. if m.id == nil || m.oldValue == nil {
  5827. return v, errors.New("OldPhoto requires an ID field in the mutation")
  5828. }
  5829. oldValue, err := m.oldValue(ctx)
  5830. if err != nil {
  5831. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  5832. }
  5833. return oldValue.Photo, nil
  5834. }
  5835. // ResetPhoto resets all changes to the "photo" field.
  5836. func (m *EmployeeConfigMutation) ResetPhoto() {
  5837. m.photo = nil
  5838. }
  5839. // SetOrganizationID sets the "organization_id" field.
  5840. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  5841. m.organization_id = &u
  5842. m.addorganization_id = nil
  5843. }
  5844. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5845. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  5846. v := m.organization_id
  5847. if v == nil {
  5848. return
  5849. }
  5850. return *v, true
  5851. }
  5852. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  5853. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  5854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5855. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5856. if !m.op.Is(OpUpdateOne) {
  5857. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5858. }
  5859. if m.id == nil || m.oldValue == nil {
  5860. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5861. }
  5862. oldValue, err := m.oldValue(ctx)
  5863. if err != nil {
  5864. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5865. }
  5866. return oldValue.OrganizationID, nil
  5867. }
  5868. // AddOrganizationID adds u to the "organization_id" field.
  5869. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  5870. if m.addorganization_id != nil {
  5871. *m.addorganization_id += u
  5872. } else {
  5873. m.addorganization_id = &u
  5874. }
  5875. }
  5876. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5877. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  5878. v := m.addorganization_id
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // ClearOrganizationID clears the value of the "organization_id" field.
  5885. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  5886. m.organization_id = nil
  5887. m.addorganization_id = nil
  5888. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  5889. }
  5890. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5891. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  5892. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  5893. return ok
  5894. }
  5895. // ResetOrganizationID resets all changes to the "organization_id" field.
  5896. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  5897. m.organization_id = nil
  5898. m.addorganization_id = nil
  5899. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  5900. }
  5901. // Where appends a list predicates to the EmployeeConfigMutation builder.
  5902. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  5903. m.predicates = append(m.predicates, ps...)
  5904. }
  5905. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  5906. // users can use type-assertion to append predicates that do not depend on any generated package.
  5907. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  5908. p := make([]predicate.EmployeeConfig, len(ps))
  5909. for i := range ps {
  5910. p[i] = ps[i]
  5911. }
  5912. m.Where(p...)
  5913. }
  5914. // Op returns the operation name.
  5915. func (m *EmployeeConfigMutation) Op() Op {
  5916. return m.op
  5917. }
  5918. // SetOp allows setting the mutation operation.
  5919. func (m *EmployeeConfigMutation) SetOp(op Op) {
  5920. m.op = op
  5921. }
  5922. // Type returns the node type of this mutation (EmployeeConfig).
  5923. func (m *EmployeeConfigMutation) Type() string {
  5924. return m.typ
  5925. }
  5926. // Fields returns all fields that were changed during this mutation. Note that in
  5927. // order to get all numeric fields that were incremented/decremented, call
  5928. // AddedFields().
  5929. func (m *EmployeeConfigMutation) Fields() []string {
  5930. fields := make([]string, 0, 7)
  5931. if m.created_at != nil {
  5932. fields = append(fields, employeeconfig.FieldCreatedAt)
  5933. }
  5934. if m.updated_at != nil {
  5935. fields = append(fields, employeeconfig.FieldUpdatedAt)
  5936. }
  5937. if m.deleted_at != nil {
  5938. fields = append(fields, employeeconfig.FieldDeletedAt)
  5939. }
  5940. if m.stype != nil {
  5941. fields = append(fields, employeeconfig.FieldStype)
  5942. }
  5943. if m.title != nil {
  5944. fields = append(fields, employeeconfig.FieldTitle)
  5945. }
  5946. if m.photo != nil {
  5947. fields = append(fields, employeeconfig.FieldPhoto)
  5948. }
  5949. if m.organization_id != nil {
  5950. fields = append(fields, employeeconfig.FieldOrganizationID)
  5951. }
  5952. return fields
  5953. }
  5954. // Field returns the value of a field with the given name. The second boolean
  5955. // return value indicates that this field was not set, or was not defined in the
  5956. // schema.
  5957. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  5958. switch name {
  5959. case employeeconfig.FieldCreatedAt:
  5960. return m.CreatedAt()
  5961. case employeeconfig.FieldUpdatedAt:
  5962. return m.UpdatedAt()
  5963. case employeeconfig.FieldDeletedAt:
  5964. return m.DeletedAt()
  5965. case employeeconfig.FieldStype:
  5966. return m.Stype()
  5967. case employeeconfig.FieldTitle:
  5968. return m.Title()
  5969. case employeeconfig.FieldPhoto:
  5970. return m.Photo()
  5971. case employeeconfig.FieldOrganizationID:
  5972. return m.OrganizationID()
  5973. }
  5974. return nil, false
  5975. }
  5976. // OldField returns the old value of the field from the database. An error is
  5977. // returned if the mutation operation is not UpdateOne, or the query to the
  5978. // database failed.
  5979. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5980. switch name {
  5981. case employeeconfig.FieldCreatedAt:
  5982. return m.OldCreatedAt(ctx)
  5983. case employeeconfig.FieldUpdatedAt:
  5984. return m.OldUpdatedAt(ctx)
  5985. case employeeconfig.FieldDeletedAt:
  5986. return m.OldDeletedAt(ctx)
  5987. case employeeconfig.FieldStype:
  5988. return m.OldStype(ctx)
  5989. case employeeconfig.FieldTitle:
  5990. return m.OldTitle(ctx)
  5991. case employeeconfig.FieldPhoto:
  5992. return m.OldPhoto(ctx)
  5993. case employeeconfig.FieldOrganizationID:
  5994. return m.OldOrganizationID(ctx)
  5995. }
  5996. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  5997. }
  5998. // SetField sets the value of a field with the given name. It returns an error if
  5999. // the field is not defined in the schema, or if the type mismatched the field
  6000. // type.
  6001. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  6002. switch name {
  6003. case employeeconfig.FieldCreatedAt:
  6004. v, ok := value.(time.Time)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.SetCreatedAt(v)
  6009. return nil
  6010. case employeeconfig.FieldUpdatedAt:
  6011. v, ok := value.(time.Time)
  6012. if !ok {
  6013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6014. }
  6015. m.SetUpdatedAt(v)
  6016. return nil
  6017. case employeeconfig.FieldDeletedAt:
  6018. v, ok := value.(time.Time)
  6019. if !ok {
  6020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6021. }
  6022. m.SetDeletedAt(v)
  6023. return nil
  6024. case employeeconfig.FieldStype:
  6025. v, ok := value.(string)
  6026. if !ok {
  6027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6028. }
  6029. m.SetStype(v)
  6030. return nil
  6031. case employeeconfig.FieldTitle:
  6032. v, ok := value.(string)
  6033. if !ok {
  6034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6035. }
  6036. m.SetTitle(v)
  6037. return nil
  6038. case employeeconfig.FieldPhoto:
  6039. v, ok := value.(string)
  6040. if !ok {
  6041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6042. }
  6043. m.SetPhoto(v)
  6044. return nil
  6045. case employeeconfig.FieldOrganizationID:
  6046. v, ok := value.(uint64)
  6047. if !ok {
  6048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6049. }
  6050. m.SetOrganizationID(v)
  6051. return nil
  6052. }
  6053. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6054. }
  6055. // AddedFields returns all numeric fields that were incremented/decremented during
  6056. // this mutation.
  6057. func (m *EmployeeConfigMutation) AddedFields() []string {
  6058. var fields []string
  6059. if m.addorganization_id != nil {
  6060. fields = append(fields, employeeconfig.FieldOrganizationID)
  6061. }
  6062. return fields
  6063. }
  6064. // AddedField returns the numeric value that was incremented/decremented on a field
  6065. // with the given name. The second boolean return value indicates that this field
  6066. // was not set, or was not defined in the schema.
  6067. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  6068. switch name {
  6069. case employeeconfig.FieldOrganizationID:
  6070. return m.AddedOrganizationID()
  6071. }
  6072. return nil, false
  6073. }
  6074. // AddField adds the value to the field with the given name. It returns an error if
  6075. // the field is not defined in the schema, or if the type mismatched the field
  6076. // type.
  6077. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  6078. switch name {
  6079. case employeeconfig.FieldOrganizationID:
  6080. v, ok := value.(int64)
  6081. if !ok {
  6082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6083. }
  6084. m.AddOrganizationID(v)
  6085. return nil
  6086. }
  6087. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  6088. }
  6089. // ClearedFields returns all nullable fields that were cleared during this
  6090. // mutation.
  6091. func (m *EmployeeConfigMutation) ClearedFields() []string {
  6092. var fields []string
  6093. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  6094. fields = append(fields, employeeconfig.FieldDeletedAt)
  6095. }
  6096. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  6097. fields = append(fields, employeeconfig.FieldOrganizationID)
  6098. }
  6099. return fields
  6100. }
  6101. // FieldCleared returns a boolean indicating if a field with the given name was
  6102. // cleared in this mutation.
  6103. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  6104. _, ok := m.clearedFields[name]
  6105. return ok
  6106. }
  6107. // ClearField clears the value of the field with the given name. It returns an
  6108. // error if the field is not defined in the schema.
  6109. func (m *EmployeeConfigMutation) ClearField(name string) error {
  6110. switch name {
  6111. case employeeconfig.FieldDeletedAt:
  6112. m.ClearDeletedAt()
  6113. return nil
  6114. case employeeconfig.FieldOrganizationID:
  6115. m.ClearOrganizationID()
  6116. return nil
  6117. }
  6118. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  6119. }
  6120. // ResetField resets all changes in the mutation for the field with the given name.
  6121. // It returns an error if the field is not defined in the schema.
  6122. func (m *EmployeeConfigMutation) ResetField(name string) error {
  6123. switch name {
  6124. case employeeconfig.FieldCreatedAt:
  6125. m.ResetCreatedAt()
  6126. return nil
  6127. case employeeconfig.FieldUpdatedAt:
  6128. m.ResetUpdatedAt()
  6129. return nil
  6130. case employeeconfig.FieldDeletedAt:
  6131. m.ResetDeletedAt()
  6132. return nil
  6133. case employeeconfig.FieldStype:
  6134. m.ResetStype()
  6135. return nil
  6136. case employeeconfig.FieldTitle:
  6137. m.ResetTitle()
  6138. return nil
  6139. case employeeconfig.FieldPhoto:
  6140. m.ResetPhoto()
  6141. return nil
  6142. case employeeconfig.FieldOrganizationID:
  6143. m.ResetOrganizationID()
  6144. return nil
  6145. }
  6146. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  6147. }
  6148. // AddedEdges returns all edge names that were set/added in this mutation.
  6149. func (m *EmployeeConfigMutation) AddedEdges() []string {
  6150. edges := make([]string, 0, 0)
  6151. return edges
  6152. }
  6153. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6154. // name in this mutation.
  6155. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  6156. return nil
  6157. }
  6158. // RemovedEdges returns all edge names that were removed in this mutation.
  6159. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  6160. edges := make([]string, 0, 0)
  6161. return edges
  6162. }
  6163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6164. // the given name in this mutation.
  6165. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  6166. return nil
  6167. }
  6168. // ClearedEdges returns all edge names that were cleared in this mutation.
  6169. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  6170. edges := make([]string, 0, 0)
  6171. return edges
  6172. }
  6173. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6174. // was cleared in this mutation.
  6175. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  6176. return false
  6177. }
  6178. // ClearEdge clears the value of the edge with the given name. It returns an error
  6179. // if that edge is not defined in the schema.
  6180. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  6181. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  6182. }
  6183. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6184. // It returns an error if the edge is not defined in the schema.
  6185. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  6186. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  6187. }
  6188. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  6189. type LabelMutation struct {
  6190. config
  6191. op Op
  6192. typ string
  6193. id *uint64
  6194. created_at *time.Time
  6195. updated_at *time.Time
  6196. status *uint8
  6197. addstatus *int8
  6198. _type *int
  6199. add_type *int
  6200. name *string
  6201. from *int
  6202. addfrom *int
  6203. mode *int
  6204. addmode *int
  6205. conditions *string
  6206. organization_id *uint64
  6207. addorganization_id *int64
  6208. clearedFields map[string]struct{}
  6209. label_relationships map[uint64]struct{}
  6210. removedlabel_relationships map[uint64]struct{}
  6211. clearedlabel_relationships bool
  6212. done bool
  6213. oldValue func(context.Context) (*Label, error)
  6214. predicates []predicate.Label
  6215. }
  6216. var _ ent.Mutation = (*LabelMutation)(nil)
  6217. // labelOption allows management of the mutation configuration using functional options.
  6218. type labelOption func(*LabelMutation)
  6219. // newLabelMutation creates new mutation for the Label entity.
  6220. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  6221. m := &LabelMutation{
  6222. config: c,
  6223. op: op,
  6224. typ: TypeLabel,
  6225. clearedFields: make(map[string]struct{}),
  6226. }
  6227. for _, opt := range opts {
  6228. opt(m)
  6229. }
  6230. return m
  6231. }
  6232. // withLabelID sets the ID field of the mutation.
  6233. func withLabelID(id uint64) labelOption {
  6234. return func(m *LabelMutation) {
  6235. var (
  6236. err error
  6237. once sync.Once
  6238. value *Label
  6239. )
  6240. m.oldValue = func(ctx context.Context) (*Label, error) {
  6241. once.Do(func() {
  6242. if m.done {
  6243. err = errors.New("querying old values post mutation is not allowed")
  6244. } else {
  6245. value, err = m.Client().Label.Get(ctx, id)
  6246. }
  6247. })
  6248. return value, err
  6249. }
  6250. m.id = &id
  6251. }
  6252. }
  6253. // withLabel sets the old Label of the mutation.
  6254. func withLabel(node *Label) labelOption {
  6255. return func(m *LabelMutation) {
  6256. m.oldValue = func(context.Context) (*Label, error) {
  6257. return node, nil
  6258. }
  6259. m.id = &node.ID
  6260. }
  6261. }
  6262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6263. // executed in a transaction (ent.Tx), a transactional client is returned.
  6264. func (m LabelMutation) Client() *Client {
  6265. client := &Client{config: m.config}
  6266. client.init()
  6267. return client
  6268. }
  6269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6270. // it returns an error otherwise.
  6271. func (m LabelMutation) Tx() (*Tx, error) {
  6272. if _, ok := m.driver.(*txDriver); !ok {
  6273. return nil, errors.New("ent: mutation is not running in a transaction")
  6274. }
  6275. tx := &Tx{config: m.config}
  6276. tx.init()
  6277. return tx, nil
  6278. }
  6279. // SetID sets the value of the id field. Note that this
  6280. // operation is only accepted on creation of Label entities.
  6281. func (m *LabelMutation) SetID(id uint64) {
  6282. m.id = &id
  6283. }
  6284. // ID returns the ID value in the mutation. Note that the ID is only available
  6285. // if it was provided to the builder or after it was returned from the database.
  6286. func (m *LabelMutation) ID() (id uint64, exists bool) {
  6287. if m.id == nil {
  6288. return
  6289. }
  6290. return *m.id, true
  6291. }
  6292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6293. // That means, if the mutation is applied within a transaction with an isolation level such
  6294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6295. // or updated by the mutation.
  6296. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  6297. switch {
  6298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6299. id, exists := m.ID()
  6300. if exists {
  6301. return []uint64{id}, nil
  6302. }
  6303. fallthrough
  6304. case m.op.Is(OpUpdate | OpDelete):
  6305. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  6306. default:
  6307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6308. }
  6309. }
  6310. // SetCreatedAt sets the "created_at" field.
  6311. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  6312. m.created_at = &t
  6313. }
  6314. // CreatedAt returns the value of the "created_at" field in the mutation.
  6315. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  6316. v := m.created_at
  6317. if v == nil {
  6318. return
  6319. }
  6320. return *v, true
  6321. }
  6322. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  6323. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6325. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6326. if !m.op.Is(OpUpdateOne) {
  6327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6328. }
  6329. if m.id == nil || m.oldValue == nil {
  6330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6331. }
  6332. oldValue, err := m.oldValue(ctx)
  6333. if err != nil {
  6334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6335. }
  6336. return oldValue.CreatedAt, nil
  6337. }
  6338. // ResetCreatedAt resets all changes to the "created_at" field.
  6339. func (m *LabelMutation) ResetCreatedAt() {
  6340. m.created_at = nil
  6341. }
  6342. // SetUpdatedAt sets the "updated_at" field.
  6343. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  6344. m.updated_at = &t
  6345. }
  6346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6347. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  6348. v := m.updated_at
  6349. if v == nil {
  6350. return
  6351. }
  6352. return *v, true
  6353. }
  6354. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  6355. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6357. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6358. if !m.op.Is(OpUpdateOne) {
  6359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6360. }
  6361. if m.id == nil || m.oldValue == nil {
  6362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6363. }
  6364. oldValue, err := m.oldValue(ctx)
  6365. if err != nil {
  6366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6367. }
  6368. return oldValue.UpdatedAt, nil
  6369. }
  6370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6371. func (m *LabelMutation) ResetUpdatedAt() {
  6372. m.updated_at = nil
  6373. }
  6374. // SetStatus sets the "status" field.
  6375. func (m *LabelMutation) SetStatus(u uint8) {
  6376. m.status = &u
  6377. m.addstatus = nil
  6378. }
  6379. // Status returns the value of the "status" field in the mutation.
  6380. func (m *LabelMutation) Status() (r uint8, exists bool) {
  6381. v := m.status
  6382. if v == nil {
  6383. return
  6384. }
  6385. return *v, true
  6386. }
  6387. // OldStatus returns the old "status" field's value of the Label entity.
  6388. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6390. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6391. if !m.op.Is(OpUpdateOne) {
  6392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6393. }
  6394. if m.id == nil || m.oldValue == nil {
  6395. return v, errors.New("OldStatus requires an ID field in the mutation")
  6396. }
  6397. oldValue, err := m.oldValue(ctx)
  6398. if err != nil {
  6399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6400. }
  6401. return oldValue.Status, nil
  6402. }
  6403. // AddStatus adds u to the "status" field.
  6404. func (m *LabelMutation) AddStatus(u int8) {
  6405. if m.addstatus != nil {
  6406. *m.addstatus += u
  6407. } else {
  6408. m.addstatus = &u
  6409. }
  6410. }
  6411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6412. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  6413. v := m.addstatus
  6414. if v == nil {
  6415. return
  6416. }
  6417. return *v, true
  6418. }
  6419. // ClearStatus clears the value of the "status" field.
  6420. func (m *LabelMutation) ClearStatus() {
  6421. m.status = nil
  6422. m.addstatus = nil
  6423. m.clearedFields[label.FieldStatus] = struct{}{}
  6424. }
  6425. // StatusCleared returns if the "status" field was cleared in this mutation.
  6426. func (m *LabelMutation) StatusCleared() bool {
  6427. _, ok := m.clearedFields[label.FieldStatus]
  6428. return ok
  6429. }
  6430. // ResetStatus resets all changes to the "status" field.
  6431. func (m *LabelMutation) ResetStatus() {
  6432. m.status = nil
  6433. m.addstatus = nil
  6434. delete(m.clearedFields, label.FieldStatus)
  6435. }
  6436. // SetType sets the "type" field.
  6437. func (m *LabelMutation) SetType(i int) {
  6438. m._type = &i
  6439. m.add_type = nil
  6440. }
  6441. // GetType returns the value of the "type" field in the mutation.
  6442. func (m *LabelMutation) GetType() (r int, exists bool) {
  6443. v := m._type
  6444. if v == nil {
  6445. return
  6446. }
  6447. return *v, true
  6448. }
  6449. // OldType returns the old "type" field's value of the Label entity.
  6450. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6452. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  6453. if !m.op.Is(OpUpdateOne) {
  6454. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6455. }
  6456. if m.id == nil || m.oldValue == nil {
  6457. return v, errors.New("OldType requires an ID field in the mutation")
  6458. }
  6459. oldValue, err := m.oldValue(ctx)
  6460. if err != nil {
  6461. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6462. }
  6463. return oldValue.Type, nil
  6464. }
  6465. // AddType adds i to the "type" field.
  6466. func (m *LabelMutation) AddType(i int) {
  6467. if m.add_type != nil {
  6468. *m.add_type += i
  6469. } else {
  6470. m.add_type = &i
  6471. }
  6472. }
  6473. // AddedType returns the value that was added to the "type" field in this mutation.
  6474. func (m *LabelMutation) AddedType() (r int, exists bool) {
  6475. v := m.add_type
  6476. if v == nil {
  6477. return
  6478. }
  6479. return *v, true
  6480. }
  6481. // ResetType resets all changes to the "type" field.
  6482. func (m *LabelMutation) ResetType() {
  6483. m._type = nil
  6484. m.add_type = nil
  6485. }
  6486. // SetName sets the "name" field.
  6487. func (m *LabelMutation) SetName(s string) {
  6488. m.name = &s
  6489. }
  6490. // Name returns the value of the "name" field in the mutation.
  6491. func (m *LabelMutation) Name() (r string, exists bool) {
  6492. v := m.name
  6493. if v == nil {
  6494. return
  6495. }
  6496. return *v, true
  6497. }
  6498. // OldName returns the old "name" field's value of the Label entity.
  6499. // If the Label 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 *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  6502. if !m.op.Is(OpUpdateOne) {
  6503. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6504. }
  6505. if m.id == nil || m.oldValue == nil {
  6506. return v, errors.New("OldName 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 OldName: %w", err)
  6511. }
  6512. return oldValue.Name, nil
  6513. }
  6514. // ResetName resets all changes to the "name" field.
  6515. func (m *LabelMutation) ResetName() {
  6516. m.name = nil
  6517. }
  6518. // SetFrom sets the "from" field.
  6519. func (m *LabelMutation) SetFrom(i int) {
  6520. m.from = &i
  6521. m.addfrom = nil
  6522. }
  6523. // From returns the value of the "from" field in the mutation.
  6524. func (m *LabelMutation) From() (r int, exists bool) {
  6525. v := m.from
  6526. if v == nil {
  6527. return
  6528. }
  6529. return *v, true
  6530. }
  6531. // OldFrom returns the old "from" field's value of the Label entity.
  6532. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6534. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  6535. if !m.op.Is(OpUpdateOne) {
  6536. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  6537. }
  6538. if m.id == nil || m.oldValue == nil {
  6539. return v, errors.New("OldFrom requires an ID field in the mutation")
  6540. }
  6541. oldValue, err := m.oldValue(ctx)
  6542. if err != nil {
  6543. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  6544. }
  6545. return oldValue.From, nil
  6546. }
  6547. // AddFrom adds i to the "from" field.
  6548. func (m *LabelMutation) AddFrom(i int) {
  6549. if m.addfrom != nil {
  6550. *m.addfrom += i
  6551. } else {
  6552. m.addfrom = &i
  6553. }
  6554. }
  6555. // AddedFrom returns the value that was added to the "from" field in this mutation.
  6556. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  6557. v := m.addfrom
  6558. if v == nil {
  6559. return
  6560. }
  6561. return *v, true
  6562. }
  6563. // ResetFrom resets all changes to the "from" field.
  6564. func (m *LabelMutation) ResetFrom() {
  6565. m.from = nil
  6566. m.addfrom = nil
  6567. }
  6568. // SetMode sets the "mode" field.
  6569. func (m *LabelMutation) SetMode(i int) {
  6570. m.mode = &i
  6571. m.addmode = nil
  6572. }
  6573. // Mode returns the value of the "mode" field in the mutation.
  6574. func (m *LabelMutation) Mode() (r int, exists bool) {
  6575. v := m.mode
  6576. if v == nil {
  6577. return
  6578. }
  6579. return *v, true
  6580. }
  6581. // OldMode returns the old "mode" field's value of the Label entity.
  6582. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6584. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  6585. if !m.op.Is(OpUpdateOne) {
  6586. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  6587. }
  6588. if m.id == nil || m.oldValue == nil {
  6589. return v, errors.New("OldMode requires an ID field in the mutation")
  6590. }
  6591. oldValue, err := m.oldValue(ctx)
  6592. if err != nil {
  6593. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  6594. }
  6595. return oldValue.Mode, nil
  6596. }
  6597. // AddMode adds i to the "mode" field.
  6598. func (m *LabelMutation) AddMode(i int) {
  6599. if m.addmode != nil {
  6600. *m.addmode += i
  6601. } else {
  6602. m.addmode = &i
  6603. }
  6604. }
  6605. // AddedMode returns the value that was added to the "mode" field in this mutation.
  6606. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  6607. v := m.addmode
  6608. if v == nil {
  6609. return
  6610. }
  6611. return *v, true
  6612. }
  6613. // ResetMode resets all changes to the "mode" field.
  6614. func (m *LabelMutation) ResetMode() {
  6615. m.mode = nil
  6616. m.addmode = nil
  6617. }
  6618. // SetConditions sets the "conditions" field.
  6619. func (m *LabelMutation) SetConditions(s string) {
  6620. m.conditions = &s
  6621. }
  6622. // Conditions returns the value of the "conditions" field in the mutation.
  6623. func (m *LabelMutation) Conditions() (r string, exists bool) {
  6624. v := m.conditions
  6625. if v == nil {
  6626. return
  6627. }
  6628. return *v, true
  6629. }
  6630. // OldConditions returns the old "conditions" field's value of the Label entity.
  6631. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6633. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  6634. if !m.op.Is(OpUpdateOne) {
  6635. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  6636. }
  6637. if m.id == nil || m.oldValue == nil {
  6638. return v, errors.New("OldConditions requires an ID field in the mutation")
  6639. }
  6640. oldValue, err := m.oldValue(ctx)
  6641. if err != nil {
  6642. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  6643. }
  6644. return oldValue.Conditions, nil
  6645. }
  6646. // ClearConditions clears the value of the "conditions" field.
  6647. func (m *LabelMutation) ClearConditions() {
  6648. m.conditions = nil
  6649. m.clearedFields[label.FieldConditions] = struct{}{}
  6650. }
  6651. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  6652. func (m *LabelMutation) ConditionsCleared() bool {
  6653. _, ok := m.clearedFields[label.FieldConditions]
  6654. return ok
  6655. }
  6656. // ResetConditions resets all changes to the "conditions" field.
  6657. func (m *LabelMutation) ResetConditions() {
  6658. m.conditions = nil
  6659. delete(m.clearedFields, label.FieldConditions)
  6660. }
  6661. // SetOrganizationID sets the "organization_id" field.
  6662. func (m *LabelMutation) SetOrganizationID(u uint64) {
  6663. m.organization_id = &u
  6664. m.addorganization_id = nil
  6665. }
  6666. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6667. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  6668. v := m.organization_id
  6669. if v == nil {
  6670. return
  6671. }
  6672. return *v, true
  6673. }
  6674. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  6675. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  6676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6677. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6678. if !m.op.Is(OpUpdateOne) {
  6679. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6680. }
  6681. if m.id == nil || m.oldValue == nil {
  6682. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6683. }
  6684. oldValue, err := m.oldValue(ctx)
  6685. if err != nil {
  6686. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6687. }
  6688. return oldValue.OrganizationID, nil
  6689. }
  6690. // AddOrganizationID adds u to the "organization_id" field.
  6691. func (m *LabelMutation) AddOrganizationID(u int64) {
  6692. if m.addorganization_id != nil {
  6693. *m.addorganization_id += u
  6694. } else {
  6695. m.addorganization_id = &u
  6696. }
  6697. }
  6698. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6699. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  6700. v := m.addorganization_id
  6701. if v == nil {
  6702. return
  6703. }
  6704. return *v, true
  6705. }
  6706. // ClearOrganizationID clears the value of the "organization_id" field.
  6707. func (m *LabelMutation) ClearOrganizationID() {
  6708. m.organization_id = nil
  6709. m.addorganization_id = nil
  6710. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  6711. }
  6712. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6713. func (m *LabelMutation) OrganizationIDCleared() bool {
  6714. _, ok := m.clearedFields[label.FieldOrganizationID]
  6715. return ok
  6716. }
  6717. // ResetOrganizationID resets all changes to the "organization_id" field.
  6718. func (m *LabelMutation) ResetOrganizationID() {
  6719. m.organization_id = nil
  6720. m.addorganization_id = nil
  6721. delete(m.clearedFields, label.FieldOrganizationID)
  6722. }
  6723. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  6724. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  6725. if m.label_relationships == nil {
  6726. m.label_relationships = make(map[uint64]struct{})
  6727. }
  6728. for i := range ids {
  6729. m.label_relationships[ids[i]] = struct{}{}
  6730. }
  6731. }
  6732. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  6733. func (m *LabelMutation) ClearLabelRelationships() {
  6734. m.clearedlabel_relationships = true
  6735. }
  6736. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  6737. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  6738. return m.clearedlabel_relationships
  6739. }
  6740. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  6741. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  6742. if m.removedlabel_relationships == nil {
  6743. m.removedlabel_relationships = make(map[uint64]struct{})
  6744. }
  6745. for i := range ids {
  6746. delete(m.label_relationships, ids[i])
  6747. m.removedlabel_relationships[ids[i]] = struct{}{}
  6748. }
  6749. }
  6750. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  6751. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  6752. for id := range m.removedlabel_relationships {
  6753. ids = append(ids, id)
  6754. }
  6755. return
  6756. }
  6757. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  6758. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  6759. for id := range m.label_relationships {
  6760. ids = append(ids, id)
  6761. }
  6762. return
  6763. }
  6764. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  6765. func (m *LabelMutation) ResetLabelRelationships() {
  6766. m.label_relationships = nil
  6767. m.clearedlabel_relationships = false
  6768. m.removedlabel_relationships = nil
  6769. }
  6770. // Where appends a list predicates to the LabelMutation builder.
  6771. func (m *LabelMutation) Where(ps ...predicate.Label) {
  6772. m.predicates = append(m.predicates, ps...)
  6773. }
  6774. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  6775. // users can use type-assertion to append predicates that do not depend on any generated package.
  6776. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  6777. p := make([]predicate.Label, len(ps))
  6778. for i := range ps {
  6779. p[i] = ps[i]
  6780. }
  6781. m.Where(p...)
  6782. }
  6783. // Op returns the operation name.
  6784. func (m *LabelMutation) Op() Op {
  6785. return m.op
  6786. }
  6787. // SetOp allows setting the mutation operation.
  6788. func (m *LabelMutation) SetOp(op Op) {
  6789. m.op = op
  6790. }
  6791. // Type returns the node type of this mutation (Label).
  6792. func (m *LabelMutation) Type() string {
  6793. return m.typ
  6794. }
  6795. // Fields returns all fields that were changed during this mutation. Note that in
  6796. // order to get all numeric fields that were incremented/decremented, call
  6797. // AddedFields().
  6798. func (m *LabelMutation) Fields() []string {
  6799. fields := make([]string, 0, 9)
  6800. if m.created_at != nil {
  6801. fields = append(fields, label.FieldCreatedAt)
  6802. }
  6803. if m.updated_at != nil {
  6804. fields = append(fields, label.FieldUpdatedAt)
  6805. }
  6806. if m.status != nil {
  6807. fields = append(fields, label.FieldStatus)
  6808. }
  6809. if m._type != nil {
  6810. fields = append(fields, label.FieldType)
  6811. }
  6812. if m.name != nil {
  6813. fields = append(fields, label.FieldName)
  6814. }
  6815. if m.from != nil {
  6816. fields = append(fields, label.FieldFrom)
  6817. }
  6818. if m.mode != nil {
  6819. fields = append(fields, label.FieldMode)
  6820. }
  6821. if m.conditions != nil {
  6822. fields = append(fields, label.FieldConditions)
  6823. }
  6824. if m.organization_id != nil {
  6825. fields = append(fields, label.FieldOrganizationID)
  6826. }
  6827. return fields
  6828. }
  6829. // Field returns the value of a field with the given name. The second boolean
  6830. // return value indicates that this field was not set, or was not defined in the
  6831. // schema.
  6832. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  6833. switch name {
  6834. case label.FieldCreatedAt:
  6835. return m.CreatedAt()
  6836. case label.FieldUpdatedAt:
  6837. return m.UpdatedAt()
  6838. case label.FieldStatus:
  6839. return m.Status()
  6840. case label.FieldType:
  6841. return m.GetType()
  6842. case label.FieldName:
  6843. return m.Name()
  6844. case label.FieldFrom:
  6845. return m.From()
  6846. case label.FieldMode:
  6847. return m.Mode()
  6848. case label.FieldConditions:
  6849. return m.Conditions()
  6850. case label.FieldOrganizationID:
  6851. return m.OrganizationID()
  6852. }
  6853. return nil, false
  6854. }
  6855. // OldField returns the old value of the field from the database. An error is
  6856. // returned if the mutation operation is not UpdateOne, or the query to the
  6857. // database failed.
  6858. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6859. switch name {
  6860. case label.FieldCreatedAt:
  6861. return m.OldCreatedAt(ctx)
  6862. case label.FieldUpdatedAt:
  6863. return m.OldUpdatedAt(ctx)
  6864. case label.FieldStatus:
  6865. return m.OldStatus(ctx)
  6866. case label.FieldType:
  6867. return m.OldType(ctx)
  6868. case label.FieldName:
  6869. return m.OldName(ctx)
  6870. case label.FieldFrom:
  6871. return m.OldFrom(ctx)
  6872. case label.FieldMode:
  6873. return m.OldMode(ctx)
  6874. case label.FieldConditions:
  6875. return m.OldConditions(ctx)
  6876. case label.FieldOrganizationID:
  6877. return m.OldOrganizationID(ctx)
  6878. }
  6879. return nil, fmt.Errorf("unknown Label field %s", name)
  6880. }
  6881. // SetField sets the value of a field with the given name. It returns an error if
  6882. // the field is not defined in the schema, or if the type mismatched the field
  6883. // type.
  6884. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  6885. switch name {
  6886. case label.FieldCreatedAt:
  6887. v, ok := value.(time.Time)
  6888. if !ok {
  6889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6890. }
  6891. m.SetCreatedAt(v)
  6892. return nil
  6893. case label.FieldUpdatedAt:
  6894. v, ok := value.(time.Time)
  6895. if !ok {
  6896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6897. }
  6898. m.SetUpdatedAt(v)
  6899. return nil
  6900. case label.FieldStatus:
  6901. v, ok := value.(uint8)
  6902. if !ok {
  6903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6904. }
  6905. m.SetStatus(v)
  6906. return nil
  6907. case label.FieldType:
  6908. v, ok := value.(int)
  6909. if !ok {
  6910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6911. }
  6912. m.SetType(v)
  6913. return nil
  6914. case label.FieldName:
  6915. v, ok := value.(string)
  6916. if !ok {
  6917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6918. }
  6919. m.SetName(v)
  6920. return nil
  6921. case label.FieldFrom:
  6922. v, ok := value.(int)
  6923. if !ok {
  6924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6925. }
  6926. m.SetFrom(v)
  6927. return nil
  6928. case label.FieldMode:
  6929. v, ok := value.(int)
  6930. if !ok {
  6931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6932. }
  6933. m.SetMode(v)
  6934. return nil
  6935. case label.FieldConditions:
  6936. v, ok := value.(string)
  6937. if !ok {
  6938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6939. }
  6940. m.SetConditions(v)
  6941. return nil
  6942. case label.FieldOrganizationID:
  6943. v, ok := value.(uint64)
  6944. if !ok {
  6945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6946. }
  6947. m.SetOrganizationID(v)
  6948. return nil
  6949. }
  6950. return fmt.Errorf("unknown Label field %s", name)
  6951. }
  6952. // AddedFields returns all numeric fields that were incremented/decremented during
  6953. // this mutation.
  6954. func (m *LabelMutation) AddedFields() []string {
  6955. var fields []string
  6956. if m.addstatus != nil {
  6957. fields = append(fields, label.FieldStatus)
  6958. }
  6959. if m.add_type != nil {
  6960. fields = append(fields, label.FieldType)
  6961. }
  6962. if m.addfrom != nil {
  6963. fields = append(fields, label.FieldFrom)
  6964. }
  6965. if m.addmode != nil {
  6966. fields = append(fields, label.FieldMode)
  6967. }
  6968. if m.addorganization_id != nil {
  6969. fields = append(fields, label.FieldOrganizationID)
  6970. }
  6971. return fields
  6972. }
  6973. // AddedField returns the numeric value that was incremented/decremented on a field
  6974. // with the given name. The second boolean return value indicates that this field
  6975. // was not set, or was not defined in the schema.
  6976. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  6977. switch name {
  6978. case label.FieldStatus:
  6979. return m.AddedStatus()
  6980. case label.FieldType:
  6981. return m.AddedType()
  6982. case label.FieldFrom:
  6983. return m.AddedFrom()
  6984. case label.FieldMode:
  6985. return m.AddedMode()
  6986. case label.FieldOrganizationID:
  6987. return m.AddedOrganizationID()
  6988. }
  6989. return nil, false
  6990. }
  6991. // AddField adds the value to the field with the given name. It returns an error if
  6992. // the field is not defined in the schema, or if the type mismatched the field
  6993. // type.
  6994. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  6995. switch name {
  6996. case label.FieldStatus:
  6997. v, ok := value.(int8)
  6998. if !ok {
  6999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7000. }
  7001. m.AddStatus(v)
  7002. return nil
  7003. case label.FieldType:
  7004. v, ok := value.(int)
  7005. if !ok {
  7006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7007. }
  7008. m.AddType(v)
  7009. return nil
  7010. case label.FieldFrom:
  7011. v, ok := value.(int)
  7012. if !ok {
  7013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7014. }
  7015. m.AddFrom(v)
  7016. return nil
  7017. case label.FieldMode:
  7018. v, ok := value.(int)
  7019. if !ok {
  7020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7021. }
  7022. m.AddMode(v)
  7023. return nil
  7024. case label.FieldOrganizationID:
  7025. v, ok := value.(int64)
  7026. if !ok {
  7027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7028. }
  7029. m.AddOrganizationID(v)
  7030. return nil
  7031. }
  7032. return fmt.Errorf("unknown Label numeric field %s", name)
  7033. }
  7034. // ClearedFields returns all nullable fields that were cleared during this
  7035. // mutation.
  7036. func (m *LabelMutation) ClearedFields() []string {
  7037. var fields []string
  7038. if m.FieldCleared(label.FieldStatus) {
  7039. fields = append(fields, label.FieldStatus)
  7040. }
  7041. if m.FieldCleared(label.FieldConditions) {
  7042. fields = append(fields, label.FieldConditions)
  7043. }
  7044. if m.FieldCleared(label.FieldOrganizationID) {
  7045. fields = append(fields, label.FieldOrganizationID)
  7046. }
  7047. return fields
  7048. }
  7049. // FieldCleared returns a boolean indicating if a field with the given name was
  7050. // cleared in this mutation.
  7051. func (m *LabelMutation) FieldCleared(name string) bool {
  7052. _, ok := m.clearedFields[name]
  7053. return ok
  7054. }
  7055. // ClearField clears the value of the field with the given name. It returns an
  7056. // error if the field is not defined in the schema.
  7057. func (m *LabelMutation) ClearField(name string) error {
  7058. switch name {
  7059. case label.FieldStatus:
  7060. m.ClearStatus()
  7061. return nil
  7062. case label.FieldConditions:
  7063. m.ClearConditions()
  7064. return nil
  7065. case label.FieldOrganizationID:
  7066. m.ClearOrganizationID()
  7067. return nil
  7068. }
  7069. return fmt.Errorf("unknown Label nullable field %s", name)
  7070. }
  7071. // ResetField resets all changes in the mutation for the field with the given name.
  7072. // It returns an error if the field is not defined in the schema.
  7073. func (m *LabelMutation) ResetField(name string) error {
  7074. switch name {
  7075. case label.FieldCreatedAt:
  7076. m.ResetCreatedAt()
  7077. return nil
  7078. case label.FieldUpdatedAt:
  7079. m.ResetUpdatedAt()
  7080. return nil
  7081. case label.FieldStatus:
  7082. m.ResetStatus()
  7083. return nil
  7084. case label.FieldType:
  7085. m.ResetType()
  7086. return nil
  7087. case label.FieldName:
  7088. m.ResetName()
  7089. return nil
  7090. case label.FieldFrom:
  7091. m.ResetFrom()
  7092. return nil
  7093. case label.FieldMode:
  7094. m.ResetMode()
  7095. return nil
  7096. case label.FieldConditions:
  7097. m.ResetConditions()
  7098. return nil
  7099. case label.FieldOrganizationID:
  7100. m.ResetOrganizationID()
  7101. return nil
  7102. }
  7103. return fmt.Errorf("unknown Label field %s", name)
  7104. }
  7105. // AddedEdges returns all edge names that were set/added in this mutation.
  7106. func (m *LabelMutation) AddedEdges() []string {
  7107. edges := make([]string, 0, 1)
  7108. if m.label_relationships != nil {
  7109. edges = append(edges, label.EdgeLabelRelationships)
  7110. }
  7111. return edges
  7112. }
  7113. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7114. // name in this mutation.
  7115. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  7116. switch name {
  7117. case label.EdgeLabelRelationships:
  7118. ids := make([]ent.Value, 0, len(m.label_relationships))
  7119. for id := range m.label_relationships {
  7120. ids = append(ids, id)
  7121. }
  7122. return ids
  7123. }
  7124. return nil
  7125. }
  7126. // RemovedEdges returns all edge names that were removed in this mutation.
  7127. func (m *LabelMutation) RemovedEdges() []string {
  7128. edges := make([]string, 0, 1)
  7129. if m.removedlabel_relationships != nil {
  7130. edges = append(edges, label.EdgeLabelRelationships)
  7131. }
  7132. return edges
  7133. }
  7134. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7135. // the given name in this mutation.
  7136. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  7137. switch name {
  7138. case label.EdgeLabelRelationships:
  7139. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  7140. for id := range m.removedlabel_relationships {
  7141. ids = append(ids, id)
  7142. }
  7143. return ids
  7144. }
  7145. return nil
  7146. }
  7147. // ClearedEdges returns all edge names that were cleared in this mutation.
  7148. func (m *LabelMutation) ClearedEdges() []string {
  7149. edges := make([]string, 0, 1)
  7150. if m.clearedlabel_relationships {
  7151. edges = append(edges, label.EdgeLabelRelationships)
  7152. }
  7153. return edges
  7154. }
  7155. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7156. // was cleared in this mutation.
  7157. func (m *LabelMutation) EdgeCleared(name string) bool {
  7158. switch name {
  7159. case label.EdgeLabelRelationships:
  7160. return m.clearedlabel_relationships
  7161. }
  7162. return false
  7163. }
  7164. // ClearEdge clears the value of the edge with the given name. It returns an error
  7165. // if that edge is not defined in the schema.
  7166. func (m *LabelMutation) ClearEdge(name string) error {
  7167. switch name {
  7168. }
  7169. return fmt.Errorf("unknown Label unique edge %s", name)
  7170. }
  7171. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7172. // It returns an error if the edge is not defined in the schema.
  7173. func (m *LabelMutation) ResetEdge(name string) error {
  7174. switch name {
  7175. case label.EdgeLabelRelationships:
  7176. m.ResetLabelRelationships()
  7177. return nil
  7178. }
  7179. return fmt.Errorf("unknown Label edge %s", name)
  7180. }
  7181. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  7182. type LabelRelationshipMutation struct {
  7183. config
  7184. op Op
  7185. typ string
  7186. id *uint64
  7187. created_at *time.Time
  7188. updated_at *time.Time
  7189. status *uint8
  7190. addstatus *int8
  7191. deleted_at *time.Time
  7192. organization_id *uint64
  7193. addorganization_id *int64
  7194. clearedFields map[string]struct{}
  7195. contacts *uint64
  7196. clearedcontacts bool
  7197. labels *uint64
  7198. clearedlabels bool
  7199. done bool
  7200. oldValue func(context.Context) (*LabelRelationship, error)
  7201. predicates []predicate.LabelRelationship
  7202. }
  7203. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  7204. // labelrelationshipOption allows management of the mutation configuration using functional options.
  7205. type labelrelationshipOption func(*LabelRelationshipMutation)
  7206. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  7207. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  7208. m := &LabelRelationshipMutation{
  7209. config: c,
  7210. op: op,
  7211. typ: TypeLabelRelationship,
  7212. clearedFields: make(map[string]struct{}),
  7213. }
  7214. for _, opt := range opts {
  7215. opt(m)
  7216. }
  7217. return m
  7218. }
  7219. // withLabelRelationshipID sets the ID field of the mutation.
  7220. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  7221. return func(m *LabelRelationshipMutation) {
  7222. var (
  7223. err error
  7224. once sync.Once
  7225. value *LabelRelationship
  7226. )
  7227. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  7228. once.Do(func() {
  7229. if m.done {
  7230. err = errors.New("querying old values post mutation is not allowed")
  7231. } else {
  7232. value, err = m.Client().LabelRelationship.Get(ctx, id)
  7233. }
  7234. })
  7235. return value, err
  7236. }
  7237. m.id = &id
  7238. }
  7239. }
  7240. // withLabelRelationship sets the old LabelRelationship of the mutation.
  7241. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  7242. return func(m *LabelRelationshipMutation) {
  7243. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  7244. return node, nil
  7245. }
  7246. m.id = &node.ID
  7247. }
  7248. }
  7249. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7250. // executed in a transaction (ent.Tx), a transactional client is returned.
  7251. func (m LabelRelationshipMutation) Client() *Client {
  7252. client := &Client{config: m.config}
  7253. client.init()
  7254. return client
  7255. }
  7256. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7257. // it returns an error otherwise.
  7258. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  7259. if _, ok := m.driver.(*txDriver); !ok {
  7260. return nil, errors.New("ent: mutation is not running in a transaction")
  7261. }
  7262. tx := &Tx{config: m.config}
  7263. tx.init()
  7264. return tx, nil
  7265. }
  7266. // SetID sets the value of the id field. Note that this
  7267. // operation is only accepted on creation of LabelRelationship entities.
  7268. func (m *LabelRelationshipMutation) SetID(id uint64) {
  7269. m.id = &id
  7270. }
  7271. // ID returns the ID value in the mutation. Note that the ID is only available
  7272. // if it was provided to the builder or after it was returned from the database.
  7273. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  7274. if m.id == nil {
  7275. return
  7276. }
  7277. return *m.id, true
  7278. }
  7279. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7280. // That means, if the mutation is applied within a transaction with an isolation level such
  7281. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7282. // or updated by the mutation.
  7283. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  7284. switch {
  7285. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7286. id, exists := m.ID()
  7287. if exists {
  7288. return []uint64{id}, nil
  7289. }
  7290. fallthrough
  7291. case m.op.Is(OpUpdate | OpDelete):
  7292. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  7293. default:
  7294. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7295. }
  7296. }
  7297. // SetCreatedAt sets the "created_at" field.
  7298. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  7299. m.created_at = &t
  7300. }
  7301. // CreatedAt returns the value of the "created_at" field in the mutation.
  7302. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  7303. v := m.created_at
  7304. if v == nil {
  7305. return
  7306. }
  7307. return *v, true
  7308. }
  7309. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  7310. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7312. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7313. if !m.op.Is(OpUpdateOne) {
  7314. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7315. }
  7316. if m.id == nil || m.oldValue == nil {
  7317. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7318. }
  7319. oldValue, err := m.oldValue(ctx)
  7320. if err != nil {
  7321. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7322. }
  7323. return oldValue.CreatedAt, nil
  7324. }
  7325. // ResetCreatedAt resets all changes to the "created_at" field.
  7326. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  7327. m.created_at = nil
  7328. }
  7329. // SetUpdatedAt sets the "updated_at" field.
  7330. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  7331. m.updated_at = &t
  7332. }
  7333. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7334. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  7335. v := m.updated_at
  7336. if v == nil {
  7337. return
  7338. }
  7339. return *v, true
  7340. }
  7341. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  7342. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7344. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7345. if !m.op.Is(OpUpdateOne) {
  7346. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7347. }
  7348. if m.id == nil || m.oldValue == nil {
  7349. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7350. }
  7351. oldValue, err := m.oldValue(ctx)
  7352. if err != nil {
  7353. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7354. }
  7355. return oldValue.UpdatedAt, nil
  7356. }
  7357. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7358. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  7359. m.updated_at = nil
  7360. }
  7361. // SetStatus sets the "status" field.
  7362. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  7363. m.status = &u
  7364. m.addstatus = nil
  7365. }
  7366. // Status returns the value of the "status" field in the mutation.
  7367. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  7368. v := m.status
  7369. if v == nil {
  7370. return
  7371. }
  7372. return *v, true
  7373. }
  7374. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  7375. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7377. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7378. if !m.op.Is(OpUpdateOne) {
  7379. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7380. }
  7381. if m.id == nil || m.oldValue == nil {
  7382. return v, errors.New("OldStatus requires an ID field in the mutation")
  7383. }
  7384. oldValue, err := m.oldValue(ctx)
  7385. if err != nil {
  7386. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7387. }
  7388. return oldValue.Status, nil
  7389. }
  7390. // AddStatus adds u to the "status" field.
  7391. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  7392. if m.addstatus != nil {
  7393. *m.addstatus += u
  7394. } else {
  7395. m.addstatus = &u
  7396. }
  7397. }
  7398. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7399. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  7400. v := m.addstatus
  7401. if v == nil {
  7402. return
  7403. }
  7404. return *v, true
  7405. }
  7406. // ClearStatus clears the value of the "status" field.
  7407. func (m *LabelRelationshipMutation) ClearStatus() {
  7408. m.status = nil
  7409. m.addstatus = nil
  7410. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  7411. }
  7412. // StatusCleared returns if the "status" field was cleared in this mutation.
  7413. func (m *LabelRelationshipMutation) StatusCleared() bool {
  7414. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  7415. return ok
  7416. }
  7417. // ResetStatus resets all changes to the "status" field.
  7418. func (m *LabelRelationshipMutation) ResetStatus() {
  7419. m.status = nil
  7420. m.addstatus = nil
  7421. delete(m.clearedFields, labelrelationship.FieldStatus)
  7422. }
  7423. // SetDeletedAt sets the "deleted_at" field.
  7424. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  7425. m.deleted_at = &t
  7426. }
  7427. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7428. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  7429. v := m.deleted_at
  7430. if v == nil {
  7431. return
  7432. }
  7433. return *v, true
  7434. }
  7435. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  7436. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7438. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7439. if !m.op.Is(OpUpdateOne) {
  7440. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7441. }
  7442. if m.id == nil || m.oldValue == nil {
  7443. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7444. }
  7445. oldValue, err := m.oldValue(ctx)
  7446. if err != nil {
  7447. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7448. }
  7449. return oldValue.DeletedAt, nil
  7450. }
  7451. // ClearDeletedAt clears the value of the "deleted_at" field.
  7452. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  7453. m.deleted_at = nil
  7454. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  7455. }
  7456. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7457. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  7458. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  7459. return ok
  7460. }
  7461. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7462. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  7463. m.deleted_at = nil
  7464. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  7465. }
  7466. // SetLabelID sets the "label_id" field.
  7467. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  7468. m.labels = &u
  7469. }
  7470. // LabelID returns the value of the "label_id" field in the mutation.
  7471. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  7472. v := m.labels
  7473. if v == nil {
  7474. return
  7475. }
  7476. return *v, true
  7477. }
  7478. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  7479. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7481. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  7482. if !m.op.Is(OpUpdateOne) {
  7483. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  7484. }
  7485. if m.id == nil || m.oldValue == nil {
  7486. return v, errors.New("OldLabelID requires an ID field in the mutation")
  7487. }
  7488. oldValue, err := m.oldValue(ctx)
  7489. if err != nil {
  7490. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  7491. }
  7492. return oldValue.LabelID, nil
  7493. }
  7494. // ResetLabelID resets all changes to the "label_id" field.
  7495. func (m *LabelRelationshipMutation) ResetLabelID() {
  7496. m.labels = nil
  7497. }
  7498. // SetContactID sets the "contact_id" field.
  7499. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  7500. m.contacts = &u
  7501. }
  7502. // ContactID returns the value of the "contact_id" field in the mutation.
  7503. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  7504. v := m.contacts
  7505. if v == nil {
  7506. return
  7507. }
  7508. return *v, true
  7509. }
  7510. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  7511. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  7512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7513. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  7514. if !m.op.Is(OpUpdateOne) {
  7515. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  7516. }
  7517. if m.id == nil || m.oldValue == nil {
  7518. return v, errors.New("OldContactID requires an ID field in the mutation")
  7519. }
  7520. oldValue, err := m.oldValue(ctx)
  7521. if err != nil {
  7522. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  7523. }
  7524. return oldValue.ContactID, nil
  7525. }
  7526. // ResetContactID resets all changes to the "contact_id" field.
  7527. func (m *LabelRelationshipMutation) ResetContactID() {
  7528. m.contacts = nil
  7529. }
  7530. // SetOrganizationID sets the "organization_id" field.
  7531. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  7532. m.organization_id = &u
  7533. m.addorganization_id = nil
  7534. }
  7535. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7536. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  7537. v := m.organization_id
  7538. if v == nil {
  7539. return
  7540. }
  7541. return *v, true
  7542. }
  7543. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  7544. // If the LabelRelationship 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 *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7547. if !m.op.Is(OpUpdateOne) {
  7548. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7549. }
  7550. if m.id == nil || m.oldValue == nil {
  7551. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  7556. }
  7557. return oldValue.OrganizationID, nil
  7558. }
  7559. // AddOrganizationID adds u to the "organization_id" field.
  7560. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  7561. if m.addorganization_id != nil {
  7562. *m.addorganization_id += u
  7563. } else {
  7564. m.addorganization_id = &u
  7565. }
  7566. }
  7567. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7568. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  7569. v := m.addorganization_id
  7570. if v == nil {
  7571. return
  7572. }
  7573. return *v, true
  7574. }
  7575. // ClearOrganizationID clears the value of the "organization_id" field.
  7576. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  7577. m.organization_id = nil
  7578. m.addorganization_id = nil
  7579. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  7580. }
  7581. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7582. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  7583. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  7584. return ok
  7585. }
  7586. // ResetOrganizationID resets all changes to the "organization_id" field.
  7587. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  7588. m.organization_id = nil
  7589. m.addorganization_id = nil
  7590. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  7591. }
  7592. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  7593. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  7594. m.contacts = &id
  7595. }
  7596. // ClearContacts clears the "contacts" edge to the Contact entity.
  7597. func (m *LabelRelationshipMutation) ClearContacts() {
  7598. m.clearedcontacts = true
  7599. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  7600. }
  7601. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  7602. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  7603. return m.clearedcontacts
  7604. }
  7605. // ContactsID returns the "contacts" edge ID in the mutation.
  7606. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  7607. if m.contacts != nil {
  7608. return *m.contacts, true
  7609. }
  7610. return
  7611. }
  7612. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  7613. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7614. // ContactsID instead. It exists only for internal usage by the builders.
  7615. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  7616. if id := m.contacts; id != nil {
  7617. ids = append(ids, *id)
  7618. }
  7619. return
  7620. }
  7621. // ResetContacts resets all changes to the "contacts" edge.
  7622. func (m *LabelRelationshipMutation) ResetContacts() {
  7623. m.contacts = nil
  7624. m.clearedcontacts = false
  7625. }
  7626. // SetLabelsID sets the "labels" edge to the Label entity by id.
  7627. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  7628. m.labels = &id
  7629. }
  7630. // ClearLabels clears the "labels" edge to the Label entity.
  7631. func (m *LabelRelationshipMutation) ClearLabels() {
  7632. m.clearedlabels = true
  7633. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  7634. }
  7635. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  7636. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  7637. return m.clearedlabels
  7638. }
  7639. // LabelsID returns the "labels" edge ID in the mutation.
  7640. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  7641. if m.labels != nil {
  7642. return *m.labels, true
  7643. }
  7644. return
  7645. }
  7646. // LabelsIDs returns the "labels" edge IDs in the mutation.
  7647. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7648. // LabelsID instead. It exists only for internal usage by the builders.
  7649. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  7650. if id := m.labels; id != nil {
  7651. ids = append(ids, *id)
  7652. }
  7653. return
  7654. }
  7655. // ResetLabels resets all changes to the "labels" edge.
  7656. func (m *LabelRelationshipMutation) ResetLabels() {
  7657. m.labels = nil
  7658. m.clearedlabels = false
  7659. }
  7660. // Where appends a list predicates to the LabelRelationshipMutation builder.
  7661. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  7662. m.predicates = append(m.predicates, ps...)
  7663. }
  7664. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  7665. // users can use type-assertion to append predicates that do not depend on any generated package.
  7666. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  7667. p := make([]predicate.LabelRelationship, len(ps))
  7668. for i := range ps {
  7669. p[i] = ps[i]
  7670. }
  7671. m.Where(p...)
  7672. }
  7673. // Op returns the operation name.
  7674. func (m *LabelRelationshipMutation) Op() Op {
  7675. return m.op
  7676. }
  7677. // SetOp allows setting the mutation operation.
  7678. func (m *LabelRelationshipMutation) SetOp(op Op) {
  7679. m.op = op
  7680. }
  7681. // Type returns the node type of this mutation (LabelRelationship).
  7682. func (m *LabelRelationshipMutation) Type() string {
  7683. return m.typ
  7684. }
  7685. // Fields returns all fields that were changed during this mutation. Note that in
  7686. // order to get all numeric fields that were incremented/decremented, call
  7687. // AddedFields().
  7688. func (m *LabelRelationshipMutation) Fields() []string {
  7689. fields := make([]string, 0, 7)
  7690. if m.created_at != nil {
  7691. fields = append(fields, labelrelationship.FieldCreatedAt)
  7692. }
  7693. if m.updated_at != nil {
  7694. fields = append(fields, labelrelationship.FieldUpdatedAt)
  7695. }
  7696. if m.status != nil {
  7697. fields = append(fields, labelrelationship.FieldStatus)
  7698. }
  7699. if m.deleted_at != nil {
  7700. fields = append(fields, labelrelationship.FieldDeletedAt)
  7701. }
  7702. if m.labels != nil {
  7703. fields = append(fields, labelrelationship.FieldLabelID)
  7704. }
  7705. if m.contacts != nil {
  7706. fields = append(fields, labelrelationship.FieldContactID)
  7707. }
  7708. if m.organization_id != nil {
  7709. fields = append(fields, labelrelationship.FieldOrganizationID)
  7710. }
  7711. return fields
  7712. }
  7713. // Field returns the value of a field with the given name. The second boolean
  7714. // return value indicates that this field was not set, or was not defined in the
  7715. // schema.
  7716. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  7717. switch name {
  7718. case labelrelationship.FieldCreatedAt:
  7719. return m.CreatedAt()
  7720. case labelrelationship.FieldUpdatedAt:
  7721. return m.UpdatedAt()
  7722. case labelrelationship.FieldStatus:
  7723. return m.Status()
  7724. case labelrelationship.FieldDeletedAt:
  7725. return m.DeletedAt()
  7726. case labelrelationship.FieldLabelID:
  7727. return m.LabelID()
  7728. case labelrelationship.FieldContactID:
  7729. return m.ContactID()
  7730. case labelrelationship.FieldOrganizationID:
  7731. return m.OrganizationID()
  7732. }
  7733. return nil, false
  7734. }
  7735. // OldField returns the old value of the field from the database. An error is
  7736. // returned if the mutation operation is not UpdateOne, or the query to the
  7737. // database failed.
  7738. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7739. switch name {
  7740. case labelrelationship.FieldCreatedAt:
  7741. return m.OldCreatedAt(ctx)
  7742. case labelrelationship.FieldUpdatedAt:
  7743. return m.OldUpdatedAt(ctx)
  7744. case labelrelationship.FieldStatus:
  7745. return m.OldStatus(ctx)
  7746. case labelrelationship.FieldDeletedAt:
  7747. return m.OldDeletedAt(ctx)
  7748. case labelrelationship.FieldLabelID:
  7749. return m.OldLabelID(ctx)
  7750. case labelrelationship.FieldContactID:
  7751. return m.OldContactID(ctx)
  7752. case labelrelationship.FieldOrganizationID:
  7753. return m.OldOrganizationID(ctx)
  7754. }
  7755. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  7756. }
  7757. // SetField sets the value of a field with the given name. It returns an error if
  7758. // the field is not defined in the schema, or if the type mismatched the field
  7759. // type.
  7760. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  7761. switch name {
  7762. case labelrelationship.FieldCreatedAt:
  7763. v, ok := value.(time.Time)
  7764. if !ok {
  7765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7766. }
  7767. m.SetCreatedAt(v)
  7768. return nil
  7769. case labelrelationship.FieldUpdatedAt:
  7770. v, ok := value.(time.Time)
  7771. if !ok {
  7772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7773. }
  7774. m.SetUpdatedAt(v)
  7775. return nil
  7776. case labelrelationship.FieldStatus:
  7777. v, ok := value.(uint8)
  7778. if !ok {
  7779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7780. }
  7781. m.SetStatus(v)
  7782. return nil
  7783. case labelrelationship.FieldDeletedAt:
  7784. v, ok := value.(time.Time)
  7785. if !ok {
  7786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7787. }
  7788. m.SetDeletedAt(v)
  7789. return nil
  7790. case labelrelationship.FieldLabelID:
  7791. v, ok := value.(uint64)
  7792. if !ok {
  7793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7794. }
  7795. m.SetLabelID(v)
  7796. return nil
  7797. case labelrelationship.FieldContactID:
  7798. v, ok := value.(uint64)
  7799. if !ok {
  7800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7801. }
  7802. m.SetContactID(v)
  7803. return nil
  7804. case labelrelationship.FieldOrganizationID:
  7805. v, ok := value.(uint64)
  7806. if !ok {
  7807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7808. }
  7809. m.SetOrganizationID(v)
  7810. return nil
  7811. }
  7812. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7813. }
  7814. // AddedFields returns all numeric fields that were incremented/decremented during
  7815. // this mutation.
  7816. func (m *LabelRelationshipMutation) AddedFields() []string {
  7817. var fields []string
  7818. if m.addstatus != nil {
  7819. fields = append(fields, labelrelationship.FieldStatus)
  7820. }
  7821. if m.addorganization_id != nil {
  7822. fields = append(fields, labelrelationship.FieldOrganizationID)
  7823. }
  7824. return fields
  7825. }
  7826. // AddedField returns the numeric value that was incremented/decremented on a field
  7827. // with the given name. The second boolean return value indicates that this field
  7828. // was not set, or was not defined in the schema.
  7829. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  7830. switch name {
  7831. case labelrelationship.FieldStatus:
  7832. return m.AddedStatus()
  7833. case labelrelationship.FieldOrganizationID:
  7834. return m.AddedOrganizationID()
  7835. }
  7836. return nil, false
  7837. }
  7838. // AddField adds the value to the field with the given name. It returns an error if
  7839. // the field is not defined in the schema, or if the type mismatched the field
  7840. // type.
  7841. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  7842. switch name {
  7843. case labelrelationship.FieldStatus:
  7844. v, ok := value.(int8)
  7845. if !ok {
  7846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7847. }
  7848. m.AddStatus(v)
  7849. return nil
  7850. case labelrelationship.FieldOrganizationID:
  7851. v, ok := value.(int64)
  7852. if !ok {
  7853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7854. }
  7855. m.AddOrganizationID(v)
  7856. return nil
  7857. }
  7858. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  7859. }
  7860. // ClearedFields returns all nullable fields that were cleared during this
  7861. // mutation.
  7862. func (m *LabelRelationshipMutation) ClearedFields() []string {
  7863. var fields []string
  7864. if m.FieldCleared(labelrelationship.FieldStatus) {
  7865. fields = append(fields, labelrelationship.FieldStatus)
  7866. }
  7867. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  7868. fields = append(fields, labelrelationship.FieldDeletedAt)
  7869. }
  7870. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  7871. fields = append(fields, labelrelationship.FieldOrganizationID)
  7872. }
  7873. return fields
  7874. }
  7875. // FieldCleared returns a boolean indicating if a field with the given name was
  7876. // cleared in this mutation.
  7877. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  7878. _, ok := m.clearedFields[name]
  7879. return ok
  7880. }
  7881. // ClearField clears the value of the field with the given name. It returns an
  7882. // error if the field is not defined in the schema.
  7883. func (m *LabelRelationshipMutation) ClearField(name string) error {
  7884. switch name {
  7885. case labelrelationship.FieldStatus:
  7886. m.ClearStatus()
  7887. return nil
  7888. case labelrelationship.FieldDeletedAt:
  7889. m.ClearDeletedAt()
  7890. return nil
  7891. case labelrelationship.FieldOrganizationID:
  7892. m.ClearOrganizationID()
  7893. return nil
  7894. }
  7895. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  7896. }
  7897. // ResetField resets all changes in the mutation for the field with the given name.
  7898. // It returns an error if the field is not defined in the schema.
  7899. func (m *LabelRelationshipMutation) ResetField(name string) error {
  7900. switch name {
  7901. case labelrelationship.FieldCreatedAt:
  7902. m.ResetCreatedAt()
  7903. return nil
  7904. case labelrelationship.FieldUpdatedAt:
  7905. m.ResetUpdatedAt()
  7906. return nil
  7907. case labelrelationship.FieldStatus:
  7908. m.ResetStatus()
  7909. return nil
  7910. case labelrelationship.FieldDeletedAt:
  7911. m.ResetDeletedAt()
  7912. return nil
  7913. case labelrelationship.FieldLabelID:
  7914. m.ResetLabelID()
  7915. return nil
  7916. case labelrelationship.FieldContactID:
  7917. m.ResetContactID()
  7918. return nil
  7919. case labelrelationship.FieldOrganizationID:
  7920. m.ResetOrganizationID()
  7921. return nil
  7922. }
  7923. return fmt.Errorf("unknown LabelRelationship field %s", name)
  7924. }
  7925. // AddedEdges returns all edge names that were set/added in this mutation.
  7926. func (m *LabelRelationshipMutation) AddedEdges() []string {
  7927. edges := make([]string, 0, 2)
  7928. if m.contacts != nil {
  7929. edges = append(edges, labelrelationship.EdgeContacts)
  7930. }
  7931. if m.labels != nil {
  7932. edges = append(edges, labelrelationship.EdgeLabels)
  7933. }
  7934. return edges
  7935. }
  7936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7937. // name in this mutation.
  7938. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  7939. switch name {
  7940. case labelrelationship.EdgeContacts:
  7941. if id := m.contacts; id != nil {
  7942. return []ent.Value{*id}
  7943. }
  7944. case labelrelationship.EdgeLabels:
  7945. if id := m.labels; id != nil {
  7946. return []ent.Value{*id}
  7947. }
  7948. }
  7949. return nil
  7950. }
  7951. // RemovedEdges returns all edge names that were removed in this mutation.
  7952. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  7953. edges := make([]string, 0, 2)
  7954. return edges
  7955. }
  7956. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7957. // the given name in this mutation.
  7958. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  7959. return nil
  7960. }
  7961. // ClearedEdges returns all edge names that were cleared in this mutation.
  7962. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  7963. edges := make([]string, 0, 2)
  7964. if m.clearedcontacts {
  7965. edges = append(edges, labelrelationship.EdgeContacts)
  7966. }
  7967. if m.clearedlabels {
  7968. edges = append(edges, labelrelationship.EdgeLabels)
  7969. }
  7970. return edges
  7971. }
  7972. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7973. // was cleared in this mutation.
  7974. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  7975. switch name {
  7976. case labelrelationship.EdgeContacts:
  7977. return m.clearedcontacts
  7978. case labelrelationship.EdgeLabels:
  7979. return m.clearedlabels
  7980. }
  7981. return false
  7982. }
  7983. // ClearEdge clears the value of the edge with the given name. It returns an error
  7984. // if that edge is not defined in the schema.
  7985. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  7986. switch name {
  7987. case labelrelationship.EdgeContacts:
  7988. m.ClearContacts()
  7989. return nil
  7990. case labelrelationship.EdgeLabels:
  7991. m.ClearLabels()
  7992. return nil
  7993. }
  7994. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  7995. }
  7996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7997. // It returns an error if the edge is not defined in the schema.
  7998. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  7999. switch name {
  8000. case labelrelationship.EdgeContacts:
  8001. m.ResetContacts()
  8002. return nil
  8003. case labelrelationship.EdgeLabels:
  8004. m.ResetLabels()
  8005. return nil
  8006. }
  8007. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  8008. }
  8009. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  8010. type MessageMutation struct {
  8011. config
  8012. op Op
  8013. typ string
  8014. id *int
  8015. wx_wxid *string
  8016. wxid *string
  8017. content *string
  8018. clearedFields map[string]struct{}
  8019. done bool
  8020. oldValue func(context.Context) (*Message, error)
  8021. predicates []predicate.Message
  8022. }
  8023. var _ ent.Mutation = (*MessageMutation)(nil)
  8024. // messageOption allows management of the mutation configuration using functional options.
  8025. type messageOption func(*MessageMutation)
  8026. // newMessageMutation creates new mutation for the Message entity.
  8027. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  8028. m := &MessageMutation{
  8029. config: c,
  8030. op: op,
  8031. typ: TypeMessage,
  8032. clearedFields: make(map[string]struct{}),
  8033. }
  8034. for _, opt := range opts {
  8035. opt(m)
  8036. }
  8037. return m
  8038. }
  8039. // withMessageID sets the ID field of the mutation.
  8040. func withMessageID(id int) messageOption {
  8041. return func(m *MessageMutation) {
  8042. var (
  8043. err error
  8044. once sync.Once
  8045. value *Message
  8046. )
  8047. m.oldValue = func(ctx context.Context) (*Message, error) {
  8048. once.Do(func() {
  8049. if m.done {
  8050. err = errors.New("querying old values post mutation is not allowed")
  8051. } else {
  8052. value, err = m.Client().Message.Get(ctx, id)
  8053. }
  8054. })
  8055. return value, err
  8056. }
  8057. m.id = &id
  8058. }
  8059. }
  8060. // withMessage sets the old Message of the mutation.
  8061. func withMessage(node *Message) messageOption {
  8062. return func(m *MessageMutation) {
  8063. m.oldValue = func(context.Context) (*Message, error) {
  8064. return node, nil
  8065. }
  8066. m.id = &node.ID
  8067. }
  8068. }
  8069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8070. // executed in a transaction (ent.Tx), a transactional client is returned.
  8071. func (m MessageMutation) Client() *Client {
  8072. client := &Client{config: m.config}
  8073. client.init()
  8074. return client
  8075. }
  8076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8077. // it returns an error otherwise.
  8078. func (m MessageMutation) Tx() (*Tx, error) {
  8079. if _, ok := m.driver.(*txDriver); !ok {
  8080. return nil, errors.New("ent: mutation is not running in a transaction")
  8081. }
  8082. tx := &Tx{config: m.config}
  8083. tx.init()
  8084. return tx, nil
  8085. }
  8086. // ID returns the ID value in the mutation. Note that the ID is only available
  8087. // if it was provided to the builder or after it was returned from the database.
  8088. func (m *MessageMutation) ID() (id int, exists bool) {
  8089. if m.id == nil {
  8090. return
  8091. }
  8092. return *m.id, true
  8093. }
  8094. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8095. // That means, if the mutation is applied within a transaction with an isolation level such
  8096. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8097. // or updated by the mutation.
  8098. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  8099. switch {
  8100. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8101. id, exists := m.ID()
  8102. if exists {
  8103. return []int{id}, nil
  8104. }
  8105. fallthrough
  8106. case m.op.Is(OpUpdate | OpDelete):
  8107. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  8108. default:
  8109. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8110. }
  8111. }
  8112. // SetWxWxid sets the "wx_wxid" field.
  8113. func (m *MessageMutation) SetWxWxid(s string) {
  8114. m.wx_wxid = &s
  8115. }
  8116. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8117. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  8118. v := m.wx_wxid
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  8125. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8127. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8133. }
  8134. oldValue, err := m.oldValue(ctx)
  8135. if err != nil {
  8136. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8137. }
  8138. return oldValue.WxWxid, nil
  8139. }
  8140. // ClearWxWxid clears the value of the "wx_wxid" field.
  8141. func (m *MessageMutation) ClearWxWxid() {
  8142. m.wx_wxid = nil
  8143. m.clearedFields[message.FieldWxWxid] = struct{}{}
  8144. }
  8145. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  8146. func (m *MessageMutation) WxWxidCleared() bool {
  8147. _, ok := m.clearedFields[message.FieldWxWxid]
  8148. return ok
  8149. }
  8150. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8151. func (m *MessageMutation) ResetWxWxid() {
  8152. m.wx_wxid = nil
  8153. delete(m.clearedFields, message.FieldWxWxid)
  8154. }
  8155. // SetWxid sets the "wxid" field.
  8156. func (m *MessageMutation) SetWxid(s string) {
  8157. m.wxid = &s
  8158. }
  8159. // Wxid returns the value of the "wxid" field in the mutation.
  8160. func (m *MessageMutation) Wxid() (r string, exists bool) {
  8161. v := m.wxid
  8162. if v == nil {
  8163. return
  8164. }
  8165. return *v, true
  8166. }
  8167. // OldWxid returns the old "wxid" field's value of the Message entity.
  8168. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8170. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  8171. if !m.op.Is(OpUpdateOne) {
  8172. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8173. }
  8174. if m.id == nil || m.oldValue == nil {
  8175. return v, errors.New("OldWxid requires an ID field in the mutation")
  8176. }
  8177. oldValue, err := m.oldValue(ctx)
  8178. if err != nil {
  8179. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8180. }
  8181. return oldValue.Wxid, nil
  8182. }
  8183. // ResetWxid resets all changes to the "wxid" field.
  8184. func (m *MessageMutation) ResetWxid() {
  8185. m.wxid = nil
  8186. }
  8187. // SetContent sets the "content" field.
  8188. func (m *MessageMutation) SetContent(s string) {
  8189. m.content = &s
  8190. }
  8191. // Content returns the value of the "content" field in the mutation.
  8192. func (m *MessageMutation) Content() (r string, exists bool) {
  8193. v := m.content
  8194. if v == nil {
  8195. return
  8196. }
  8197. return *v, true
  8198. }
  8199. // OldContent returns the old "content" field's value of the Message entity.
  8200. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  8201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8202. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  8203. if !m.op.Is(OpUpdateOne) {
  8204. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8205. }
  8206. if m.id == nil || m.oldValue == nil {
  8207. return v, errors.New("OldContent requires an ID field in the mutation")
  8208. }
  8209. oldValue, err := m.oldValue(ctx)
  8210. if err != nil {
  8211. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8212. }
  8213. return oldValue.Content, nil
  8214. }
  8215. // ResetContent resets all changes to the "content" field.
  8216. func (m *MessageMutation) ResetContent() {
  8217. m.content = nil
  8218. }
  8219. // Where appends a list predicates to the MessageMutation builder.
  8220. func (m *MessageMutation) Where(ps ...predicate.Message) {
  8221. m.predicates = append(m.predicates, ps...)
  8222. }
  8223. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  8224. // users can use type-assertion to append predicates that do not depend on any generated package.
  8225. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  8226. p := make([]predicate.Message, len(ps))
  8227. for i := range ps {
  8228. p[i] = ps[i]
  8229. }
  8230. m.Where(p...)
  8231. }
  8232. // Op returns the operation name.
  8233. func (m *MessageMutation) Op() Op {
  8234. return m.op
  8235. }
  8236. // SetOp allows setting the mutation operation.
  8237. func (m *MessageMutation) SetOp(op Op) {
  8238. m.op = op
  8239. }
  8240. // Type returns the node type of this mutation (Message).
  8241. func (m *MessageMutation) Type() string {
  8242. return m.typ
  8243. }
  8244. // Fields returns all fields that were changed during this mutation. Note that in
  8245. // order to get all numeric fields that were incremented/decremented, call
  8246. // AddedFields().
  8247. func (m *MessageMutation) Fields() []string {
  8248. fields := make([]string, 0, 3)
  8249. if m.wx_wxid != nil {
  8250. fields = append(fields, message.FieldWxWxid)
  8251. }
  8252. if m.wxid != nil {
  8253. fields = append(fields, message.FieldWxid)
  8254. }
  8255. if m.content != nil {
  8256. fields = append(fields, message.FieldContent)
  8257. }
  8258. return fields
  8259. }
  8260. // Field returns the value of a field with the given name. The second boolean
  8261. // return value indicates that this field was not set, or was not defined in the
  8262. // schema.
  8263. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  8264. switch name {
  8265. case message.FieldWxWxid:
  8266. return m.WxWxid()
  8267. case message.FieldWxid:
  8268. return m.Wxid()
  8269. case message.FieldContent:
  8270. return m.Content()
  8271. }
  8272. return nil, false
  8273. }
  8274. // OldField returns the old value of the field from the database. An error is
  8275. // returned if the mutation operation is not UpdateOne, or the query to the
  8276. // database failed.
  8277. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8278. switch name {
  8279. case message.FieldWxWxid:
  8280. return m.OldWxWxid(ctx)
  8281. case message.FieldWxid:
  8282. return m.OldWxid(ctx)
  8283. case message.FieldContent:
  8284. return m.OldContent(ctx)
  8285. }
  8286. return nil, fmt.Errorf("unknown Message field %s", name)
  8287. }
  8288. // SetField sets the value of a field with the given name. It returns an error if
  8289. // the field is not defined in the schema, or if the type mismatched the field
  8290. // type.
  8291. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  8292. switch name {
  8293. case message.FieldWxWxid:
  8294. v, ok := value.(string)
  8295. if !ok {
  8296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8297. }
  8298. m.SetWxWxid(v)
  8299. return nil
  8300. case message.FieldWxid:
  8301. v, ok := value.(string)
  8302. if !ok {
  8303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8304. }
  8305. m.SetWxid(v)
  8306. return nil
  8307. case message.FieldContent:
  8308. v, ok := value.(string)
  8309. if !ok {
  8310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8311. }
  8312. m.SetContent(v)
  8313. return nil
  8314. }
  8315. return fmt.Errorf("unknown Message field %s", name)
  8316. }
  8317. // AddedFields returns all numeric fields that were incremented/decremented during
  8318. // this mutation.
  8319. func (m *MessageMutation) AddedFields() []string {
  8320. return nil
  8321. }
  8322. // AddedField returns the numeric value that was incremented/decremented on a field
  8323. // with the given name. The second boolean return value indicates that this field
  8324. // was not set, or was not defined in the schema.
  8325. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  8326. return nil, false
  8327. }
  8328. // AddField adds the value to the field with the given name. It returns an error if
  8329. // the field is not defined in the schema, or if the type mismatched the field
  8330. // type.
  8331. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  8332. switch name {
  8333. }
  8334. return fmt.Errorf("unknown Message numeric field %s", name)
  8335. }
  8336. // ClearedFields returns all nullable fields that were cleared during this
  8337. // mutation.
  8338. func (m *MessageMutation) ClearedFields() []string {
  8339. var fields []string
  8340. if m.FieldCleared(message.FieldWxWxid) {
  8341. fields = append(fields, message.FieldWxWxid)
  8342. }
  8343. return fields
  8344. }
  8345. // FieldCleared returns a boolean indicating if a field with the given name was
  8346. // cleared in this mutation.
  8347. func (m *MessageMutation) FieldCleared(name string) bool {
  8348. _, ok := m.clearedFields[name]
  8349. return ok
  8350. }
  8351. // ClearField clears the value of the field with the given name. It returns an
  8352. // error if the field is not defined in the schema.
  8353. func (m *MessageMutation) ClearField(name string) error {
  8354. switch name {
  8355. case message.FieldWxWxid:
  8356. m.ClearWxWxid()
  8357. return nil
  8358. }
  8359. return fmt.Errorf("unknown Message nullable field %s", name)
  8360. }
  8361. // ResetField resets all changes in the mutation for the field with the given name.
  8362. // It returns an error if the field is not defined in the schema.
  8363. func (m *MessageMutation) ResetField(name string) error {
  8364. switch name {
  8365. case message.FieldWxWxid:
  8366. m.ResetWxWxid()
  8367. return nil
  8368. case message.FieldWxid:
  8369. m.ResetWxid()
  8370. return nil
  8371. case message.FieldContent:
  8372. m.ResetContent()
  8373. return nil
  8374. }
  8375. return fmt.Errorf("unknown Message field %s", name)
  8376. }
  8377. // AddedEdges returns all edge names that were set/added in this mutation.
  8378. func (m *MessageMutation) AddedEdges() []string {
  8379. edges := make([]string, 0, 0)
  8380. return edges
  8381. }
  8382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8383. // name in this mutation.
  8384. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  8385. return nil
  8386. }
  8387. // RemovedEdges returns all edge names that were removed in this mutation.
  8388. func (m *MessageMutation) RemovedEdges() []string {
  8389. edges := make([]string, 0, 0)
  8390. return edges
  8391. }
  8392. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8393. // the given name in this mutation.
  8394. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  8395. return nil
  8396. }
  8397. // ClearedEdges returns all edge names that were cleared in this mutation.
  8398. func (m *MessageMutation) ClearedEdges() []string {
  8399. edges := make([]string, 0, 0)
  8400. return edges
  8401. }
  8402. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8403. // was cleared in this mutation.
  8404. func (m *MessageMutation) EdgeCleared(name string) bool {
  8405. return false
  8406. }
  8407. // ClearEdge clears the value of the edge with the given name. It returns an error
  8408. // if that edge is not defined in the schema.
  8409. func (m *MessageMutation) ClearEdge(name string) error {
  8410. return fmt.Errorf("unknown Message unique edge %s", name)
  8411. }
  8412. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8413. // It returns an error if the edge is not defined in the schema.
  8414. func (m *MessageMutation) ResetEdge(name string) error {
  8415. return fmt.Errorf("unknown Message edge %s", name)
  8416. }
  8417. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  8418. type MessageRecordsMutation struct {
  8419. config
  8420. op Op
  8421. typ string
  8422. id *uint64
  8423. created_at *time.Time
  8424. updated_at *time.Time
  8425. status *uint8
  8426. addstatus *int8
  8427. deleted_at *time.Time
  8428. bot_wxid *string
  8429. contact_type *int
  8430. addcontact_type *int
  8431. contact_wxid *string
  8432. content_type *int
  8433. addcontent_type *int
  8434. content *string
  8435. meta *custom_types.Meta
  8436. error_detail *string
  8437. send_time *time.Time
  8438. source_type *int
  8439. addsource_type *int
  8440. organization_id *uint64
  8441. addorganization_id *int64
  8442. clearedFields map[string]struct{}
  8443. sop_stage *uint64
  8444. clearedsop_stage bool
  8445. sop_node *uint64
  8446. clearedsop_node bool
  8447. message_contact *uint64
  8448. clearedmessage_contact bool
  8449. done bool
  8450. oldValue func(context.Context) (*MessageRecords, error)
  8451. predicates []predicate.MessageRecords
  8452. }
  8453. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  8454. // messagerecordsOption allows management of the mutation configuration using functional options.
  8455. type messagerecordsOption func(*MessageRecordsMutation)
  8456. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  8457. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  8458. m := &MessageRecordsMutation{
  8459. config: c,
  8460. op: op,
  8461. typ: TypeMessageRecords,
  8462. clearedFields: make(map[string]struct{}),
  8463. }
  8464. for _, opt := range opts {
  8465. opt(m)
  8466. }
  8467. return m
  8468. }
  8469. // withMessageRecordsID sets the ID field of the mutation.
  8470. func withMessageRecordsID(id uint64) messagerecordsOption {
  8471. return func(m *MessageRecordsMutation) {
  8472. var (
  8473. err error
  8474. once sync.Once
  8475. value *MessageRecords
  8476. )
  8477. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  8478. once.Do(func() {
  8479. if m.done {
  8480. err = errors.New("querying old values post mutation is not allowed")
  8481. } else {
  8482. value, err = m.Client().MessageRecords.Get(ctx, id)
  8483. }
  8484. })
  8485. return value, err
  8486. }
  8487. m.id = &id
  8488. }
  8489. }
  8490. // withMessageRecords sets the old MessageRecords of the mutation.
  8491. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  8492. return func(m *MessageRecordsMutation) {
  8493. m.oldValue = func(context.Context) (*MessageRecords, error) {
  8494. return node, nil
  8495. }
  8496. m.id = &node.ID
  8497. }
  8498. }
  8499. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8500. // executed in a transaction (ent.Tx), a transactional client is returned.
  8501. func (m MessageRecordsMutation) Client() *Client {
  8502. client := &Client{config: m.config}
  8503. client.init()
  8504. return client
  8505. }
  8506. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8507. // it returns an error otherwise.
  8508. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  8509. if _, ok := m.driver.(*txDriver); !ok {
  8510. return nil, errors.New("ent: mutation is not running in a transaction")
  8511. }
  8512. tx := &Tx{config: m.config}
  8513. tx.init()
  8514. return tx, nil
  8515. }
  8516. // SetID sets the value of the id field. Note that this
  8517. // operation is only accepted on creation of MessageRecords entities.
  8518. func (m *MessageRecordsMutation) SetID(id uint64) {
  8519. m.id = &id
  8520. }
  8521. // ID returns the ID value in the mutation. Note that the ID is only available
  8522. // if it was provided to the builder or after it was returned from the database.
  8523. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  8524. if m.id == nil {
  8525. return
  8526. }
  8527. return *m.id, true
  8528. }
  8529. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8530. // That means, if the mutation is applied within a transaction with an isolation level such
  8531. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8532. // or updated by the mutation.
  8533. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8534. switch {
  8535. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8536. id, exists := m.ID()
  8537. if exists {
  8538. return []uint64{id}, nil
  8539. }
  8540. fallthrough
  8541. case m.op.Is(OpUpdate | OpDelete):
  8542. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  8543. default:
  8544. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8545. }
  8546. }
  8547. // SetCreatedAt sets the "created_at" field.
  8548. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  8549. m.created_at = &t
  8550. }
  8551. // CreatedAt returns the value of the "created_at" field in the mutation.
  8552. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8553. v := m.created_at
  8554. if v == nil {
  8555. return
  8556. }
  8557. return *v, true
  8558. }
  8559. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  8560. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8562. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8563. if !m.op.Is(OpUpdateOne) {
  8564. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8565. }
  8566. if m.id == nil || m.oldValue == nil {
  8567. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8568. }
  8569. oldValue, err := m.oldValue(ctx)
  8570. if err != nil {
  8571. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8572. }
  8573. return oldValue.CreatedAt, nil
  8574. }
  8575. // ResetCreatedAt resets all changes to the "created_at" field.
  8576. func (m *MessageRecordsMutation) ResetCreatedAt() {
  8577. m.created_at = nil
  8578. }
  8579. // SetUpdatedAt sets the "updated_at" field.
  8580. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  8581. m.updated_at = &t
  8582. }
  8583. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8584. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8585. v := m.updated_at
  8586. if v == nil {
  8587. return
  8588. }
  8589. return *v, true
  8590. }
  8591. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  8592. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8594. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8595. if !m.op.Is(OpUpdateOne) {
  8596. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8597. }
  8598. if m.id == nil || m.oldValue == nil {
  8599. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8600. }
  8601. oldValue, err := m.oldValue(ctx)
  8602. if err != nil {
  8603. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8604. }
  8605. return oldValue.UpdatedAt, nil
  8606. }
  8607. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8608. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  8609. m.updated_at = nil
  8610. }
  8611. // SetStatus sets the "status" field.
  8612. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  8613. m.status = &u
  8614. m.addstatus = nil
  8615. }
  8616. // Status returns the value of the "status" field in the mutation.
  8617. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  8618. v := m.status
  8619. if v == nil {
  8620. return
  8621. }
  8622. return *v, true
  8623. }
  8624. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  8625. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8627. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8628. if !m.op.Is(OpUpdateOne) {
  8629. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8630. }
  8631. if m.id == nil || m.oldValue == nil {
  8632. return v, errors.New("OldStatus requires an ID field in the mutation")
  8633. }
  8634. oldValue, err := m.oldValue(ctx)
  8635. if err != nil {
  8636. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8637. }
  8638. return oldValue.Status, nil
  8639. }
  8640. // AddStatus adds u to the "status" field.
  8641. func (m *MessageRecordsMutation) AddStatus(u int8) {
  8642. if m.addstatus != nil {
  8643. *m.addstatus += u
  8644. } else {
  8645. m.addstatus = &u
  8646. }
  8647. }
  8648. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8649. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  8650. v := m.addstatus
  8651. if v == nil {
  8652. return
  8653. }
  8654. return *v, true
  8655. }
  8656. // ClearStatus clears the value of the "status" field.
  8657. func (m *MessageRecordsMutation) ClearStatus() {
  8658. m.status = nil
  8659. m.addstatus = nil
  8660. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  8661. }
  8662. // StatusCleared returns if the "status" field was cleared in this mutation.
  8663. func (m *MessageRecordsMutation) StatusCleared() bool {
  8664. _, ok := m.clearedFields[messagerecords.FieldStatus]
  8665. return ok
  8666. }
  8667. // ResetStatus resets all changes to the "status" field.
  8668. func (m *MessageRecordsMutation) ResetStatus() {
  8669. m.status = nil
  8670. m.addstatus = nil
  8671. delete(m.clearedFields, messagerecords.FieldStatus)
  8672. }
  8673. // SetDeletedAt sets the "deleted_at" field.
  8674. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  8675. m.deleted_at = &t
  8676. }
  8677. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8678. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8679. v := m.deleted_at
  8680. if v == nil {
  8681. return
  8682. }
  8683. return *v, true
  8684. }
  8685. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  8686. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8688. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8689. if !m.op.Is(OpUpdateOne) {
  8690. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8691. }
  8692. if m.id == nil || m.oldValue == nil {
  8693. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8694. }
  8695. oldValue, err := m.oldValue(ctx)
  8696. if err != nil {
  8697. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8698. }
  8699. return oldValue.DeletedAt, nil
  8700. }
  8701. // ClearDeletedAt clears the value of the "deleted_at" field.
  8702. func (m *MessageRecordsMutation) ClearDeletedAt() {
  8703. m.deleted_at = nil
  8704. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  8705. }
  8706. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8707. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  8708. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  8709. return ok
  8710. }
  8711. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8712. func (m *MessageRecordsMutation) ResetDeletedAt() {
  8713. m.deleted_at = nil
  8714. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  8715. }
  8716. // SetBotWxid sets the "bot_wxid" field.
  8717. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  8718. m.bot_wxid = &s
  8719. }
  8720. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  8721. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  8722. v := m.bot_wxid
  8723. if v == nil {
  8724. return
  8725. }
  8726. return *v, true
  8727. }
  8728. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  8729. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8731. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  8732. if !m.op.Is(OpUpdateOne) {
  8733. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  8734. }
  8735. if m.id == nil || m.oldValue == nil {
  8736. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  8737. }
  8738. oldValue, err := m.oldValue(ctx)
  8739. if err != nil {
  8740. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  8741. }
  8742. return oldValue.BotWxid, nil
  8743. }
  8744. // ResetBotWxid resets all changes to the "bot_wxid" field.
  8745. func (m *MessageRecordsMutation) ResetBotWxid() {
  8746. m.bot_wxid = nil
  8747. }
  8748. // SetContactID sets the "contact_id" field.
  8749. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  8750. m.message_contact = &u
  8751. }
  8752. // ContactID returns the value of the "contact_id" field in the mutation.
  8753. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  8754. v := m.message_contact
  8755. if v == nil {
  8756. return
  8757. }
  8758. return *v, true
  8759. }
  8760. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  8761. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8763. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  8764. if !m.op.Is(OpUpdateOne) {
  8765. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  8766. }
  8767. if m.id == nil || m.oldValue == nil {
  8768. return v, errors.New("OldContactID requires an ID field in the mutation")
  8769. }
  8770. oldValue, err := m.oldValue(ctx)
  8771. if err != nil {
  8772. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  8773. }
  8774. return oldValue.ContactID, nil
  8775. }
  8776. // ClearContactID clears the value of the "contact_id" field.
  8777. func (m *MessageRecordsMutation) ClearContactID() {
  8778. m.message_contact = nil
  8779. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  8780. }
  8781. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  8782. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  8783. _, ok := m.clearedFields[messagerecords.FieldContactID]
  8784. return ok
  8785. }
  8786. // ResetContactID resets all changes to the "contact_id" field.
  8787. func (m *MessageRecordsMutation) ResetContactID() {
  8788. m.message_contact = nil
  8789. delete(m.clearedFields, messagerecords.FieldContactID)
  8790. }
  8791. // SetContactType sets the "contact_type" field.
  8792. func (m *MessageRecordsMutation) SetContactType(i int) {
  8793. m.contact_type = &i
  8794. m.addcontact_type = nil
  8795. }
  8796. // ContactType returns the value of the "contact_type" field in the mutation.
  8797. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  8798. v := m.contact_type
  8799. if v == nil {
  8800. return
  8801. }
  8802. return *v, true
  8803. }
  8804. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  8805. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8807. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  8808. if !m.op.Is(OpUpdateOne) {
  8809. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  8810. }
  8811. if m.id == nil || m.oldValue == nil {
  8812. return v, errors.New("OldContactType requires an ID field in the mutation")
  8813. }
  8814. oldValue, err := m.oldValue(ctx)
  8815. if err != nil {
  8816. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  8817. }
  8818. return oldValue.ContactType, nil
  8819. }
  8820. // AddContactType adds i to the "contact_type" field.
  8821. func (m *MessageRecordsMutation) AddContactType(i int) {
  8822. if m.addcontact_type != nil {
  8823. *m.addcontact_type += i
  8824. } else {
  8825. m.addcontact_type = &i
  8826. }
  8827. }
  8828. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  8829. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  8830. v := m.addcontact_type
  8831. if v == nil {
  8832. return
  8833. }
  8834. return *v, true
  8835. }
  8836. // ResetContactType resets all changes to the "contact_type" field.
  8837. func (m *MessageRecordsMutation) ResetContactType() {
  8838. m.contact_type = nil
  8839. m.addcontact_type = nil
  8840. }
  8841. // SetContactWxid sets the "contact_wxid" field.
  8842. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  8843. m.contact_wxid = &s
  8844. }
  8845. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  8846. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  8847. v := m.contact_wxid
  8848. if v == nil {
  8849. return
  8850. }
  8851. return *v, true
  8852. }
  8853. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  8854. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8856. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  8857. if !m.op.Is(OpUpdateOne) {
  8858. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  8859. }
  8860. if m.id == nil || m.oldValue == nil {
  8861. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  8862. }
  8863. oldValue, err := m.oldValue(ctx)
  8864. if err != nil {
  8865. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  8866. }
  8867. return oldValue.ContactWxid, nil
  8868. }
  8869. // ResetContactWxid resets all changes to the "contact_wxid" field.
  8870. func (m *MessageRecordsMutation) ResetContactWxid() {
  8871. m.contact_wxid = nil
  8872. }
  8873. // SetContentType sets the "content_type" field.
  8874. func (m *MessageRecordsMutation) SetContentType(i int) {
  8875. m.content_type = &i
  8876. m.addcontent_type = nil
  8877. }
  8878. // ContentType returns the value of the "content_type" field in the mutation.
  8879. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  8880. v := m.content_type
  8881. if v == nil {
  8882. return
  8883. }
  8884. return *v, true
  8885. }
  8886. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  8887. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8889. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  8890. if !m.op.Is(OpUpdateOne) {
  8891. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8892. }
  8893. if m.id == nil || m.oldValue == nil {
  8894. return v, errors.New("OldContentType requires an ID field in the mutation")
  8895. }
  8896. oldValue, err := m.oldValue(ctx)
  8897. if err != nil {
  8898. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8899. }
  8900. return oldValue.ContentType, nil
  8901. }
  8902. // AddContentType adds i to the "content_type" field.
  8903. func (m *MessageRecordsMutation) AddContentType(i int) {
  8904. if m.addcontent_type != nil {
  8905. *m.addcontent_type += i
  8906. } else {
  8907. m.addcontent_type = &i
  8908. }
  8909. }
  8910. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8911. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  8912. v := m.addcontent_type
  8913. if v == nil {
  8914. return
  8915. }
  8916. return *v, true
  8917. }
  8918. // ResetContentType resets all changes to the "content_type" field.
  8919. func (m *MessageRecordsMutation) ResetContentType() {
  8920. m.content_type = nil
  8921. m.addcontent_type = nil
  8922. }
  8923. // SetContent sets the "content" field.
  8924. func (m *MessageRecordsMutation) SetContent(s string) {
  8925. m.content = &s
  8926. }
  8927. // Content returns the value of the "content" field in the mutation.
  8928. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  8929. v := m.content
  8930. if v == nil {
  8931. return
  8932. }
  8933. return *v, true
  8934. }
  8935. // OldContent returns the old "content" field's value of the MessageRecords entity.
  8936. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8938. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8939. if !m.op.Is(OpUpdateOne) {
  8940. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8941. }
  8942. if m.id == nil || m.oldValue == nil {
  8943. return v, errors.New("OldContent requires an ID field in the mutation")
  8944. }
  8945. oldValue, err := m.oldValue(ctx)
  8946. if err != nil {
  8947. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8948. }
  8949. return oldValue.Content, nil
  8950. }
  8951. // ResetContent resets all changes to the "content" field.
  8952. func (m *MessageRecordsMutation) ResetContent() {
  8953. m.content = nil
  8954. }
  8955. // SetMeta sets the "meta" field.
  8956. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  8957. m.meta = &ct
  8958. }
  8959. // Meta returns the value of the "meta" field in the mutation.
  8960. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  8961. v := m.meta
  8962. if v == nil {
  8963. return
  8964. }
  8965. return *v, true
  8966. }
  8967. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  8968. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  8969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8970. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  8971. if !m.op.Is(OpUpdateOne) {
  8972. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  8973. }
  8974. if m.id == nil || m.oldValue == nil {
  8975. return v, errors.New("OldMeta requires an ID field in the mutation")
  8976. }
  8977. oldValue, err := m.oldValue(ctx)
  8978. if err != nil {
  8979. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  8980. }
  8981. return oldValue.Meta, nil
  8982. }
  8983. // ClearMeta clears the value of the "meta" field.
  8984. func (m *MessageRecordsMutation) ClearMeta() {
  8985. m.meta = nil
  8986. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  8987. }
  8988. // MetaCleared returns if the "meta" field was cleared in this mutation.
  8989. func (m *MessageRecordsMutation) MetaCleared() bool {
  8990. _, ok := m.clearedFields[messagerecords.FieldMeta]
  8991. return ok
  8992. }
  8993. // ResetMeta resets all changes to the "meta" field.
  8994. func (m *MessageRecordsMutation) ResetMeta() {
  8995. m.meta = nil
  8996. delete(m.clearedFields, messagerecords.FieldMeta)
  8997. }
  8998. // SetErrorDetail sets the "error_detail" field.
  8999. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  9000. m.error_detail = &s
  9001. }
  9002. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  9003. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  9004. v := m.error_detail
  9005. if v == nil {
  9006. return
  9007. }
  9008. return *v, true
  9009. }
  9010. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  9011. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9013. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  9014. if !m.op.Is(OpUpdateOne) {
  9015. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  9016. }
  9017. if m.id == nil || m.oldValue == nil {
  9018. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  9019. }
  9020. oldValue, err := m.oldValue(ctx)
  9021. if err != nil {
  9022. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  9023. }
  9024. return oldValue.ErrorDetail, nil
  9025. }
  9026. // ResetErrorDetail resets all changes to the "error_detail" field.
  9027. func (m *MessageRecordsMutation) ResetErrorDetail() {
  9028. m.error_detail = nil
  9029. }
  9030. // SetSendTime sets the "send_time" field.
  9031. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  9032. m.send_time = &t
  9033. }
  9034. // SendTime returns the value of the "send_time" field in the mutation.
  9035. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  9036. v := m.send_time
  9037. if v == nil {
  9038. return
  9039. }
  9040. return *v, true
  9041. }
  9042. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  9043. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9045. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  9046. if !m.op.Is(OpUpdateOne) {
  9047. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  9048. }
  9049. if m.id == nil || m.oldValue == nil {
  9050. return v, errors.New("OldSendTime requires an ID field in the mutation")
  9051. }
  9052. oldValue, err := m.oldValue(ctx)
  9053. if err != nil {
  9054. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  9055. }
  9056. return oldValue.SendTime, nil
  9057. }
  9058. // ClearSendTime clears the value of the "send_time" field.
  9059. func (m *MessageRecordsMutation) ClearSendTime() {
  9060. m.send_time = nil
  9061. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  9062. }
  9063. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  9064. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  9065. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  9066. return ok
  9067. }
  9068. // ResetSendTime resets all changes to the "send_time" field.
  9069. func (m *MessageRecordsMutation) ResetSendTime() {
  9070. m.send_time = nil
  9071. delete(m.clearedFields, messagerecords.FieldSendTime)
  9072. }
  9073. // SetSourceType sets the "source_type" field.
  9074. func (m *MessageRecordsMutation) SetSourceType(i int) {
  9075. m.source_type = &i
  9076. m.addsource_type = nil
  9077. }
  9078. // SourceType returns the value of the "source_type" field in the mutation.
  9079. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  9080. v := m.source_type
  9081. if v == nil {
  9082. return
  9083. }
  9084. return *v, true
  9085. }
  9086. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  9087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9089. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  9090. if !m.op.Is(OpUpdateOne) {
  9091. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  9092. }
  9093. if m.id == nil || m.oldValue == nil {
  9094. return v, errors.New("OldSourceType requires an ID field in the mutation")
  9095. }
  9096. oldValue, err := m.oldValue(ctx)
  9097. if err != nil {
  9098. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  9099. }
  9100. return oldValue.SourceType, nil
  9101. }
  9102. // AddSourceType adds i to the "source_type" field.
  9103. func (m *MessageRecordsMutation) AddSourceType(i int) {
  9104. if m.addsource_type != nil {
  9105. *m.addsource_type += i
  9106. } else {
  9107. m.addsource_type = &i
  9108. }
  9109. }
  9110. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  9111. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  9112. v := m.addsource_type
  9113. if v == nil {
  9114. return
  9115. }
  9116. return *v, true
  9117. }
  9118. // ResetSourceType resets all changes to the "source_type" field.
  9119. func (m *MessageRecordsMutation) ResetSourceType() {
  9120. m.source_type = nil
  9121. m.addsource_type = nil
  9122. }
  9123. // SetSourceID sets the "source_id" field.
  9124. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  9125. m.sop_stage = &u
  9126. }
  9127. // SourceID returns the value of the "source_id" field in the mutation.
  9128. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  9129. v := m.sop_stage
  9130. if v == nil {
  9131. return
  9132. }
  9133. return *v, true
  9134. }
  9135. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  9136. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9138. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  9139. if !m.op.Is(OpUpdateOne) {
  9140. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  9141. }
  9142. if m.id == nil || m.oldValue == nil {
  9143. return v, errors.New("OldSourceID requires an ID field in the mutation")
  9144. }
  9145. oldValue, err := m.oldValue(ctx)
  9146. if err != nil {
  9147. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  9148. }
  9149. return oldValue.SourceID, nil
  9150. }
  9151. // ClearSourceID clears the value of the "source_id" field.
  9152. func (m *MessageRecordsMutation) ClearSourceID() {
  9153. m.sop_stage = nil
  9154. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9155. }
  9156. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  9157. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  9158. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  9159. return ok
  9160. }
  9161. // ResetSourceID resets all changes to the "source_id" field.
  9162. func (m *MessageRecordsMutation) ResetSourceID() {
  9163. m.sop_stage = nil
  9164. delete(m.clearedFields, messagerecords.FieldSourceID)
  9165. }
  9166. // SetSubSourceID sets the "sub_source_id" field.
  9167. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  9168. m.sop_node = &u
  9169. }
  9170. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  9171. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  9172. v := m.sop_node
  9173. if v == nil {
  9174. return
  9175. }
  9176. return *v, true
  9177. }
  9178. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  9179. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9181. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  9182. if !m.op.Is(OpUpdateOne) {
  9183. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  9184. }
  9185. if m.id == nil || m.oldValue == nil {
  9186. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  9187. }
  9188. oldValue, err := m.oldValue(ctx)
  9189. if err != nil {
  9190. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  9191. }
  9192. return oldValue.SubSourceID, nil
  9193. }
  9194. // ClearSubSourceID clears the value of the "sub_source_id" field.
  9195. func (m *MessageRecordsMutation) ClearSubSourceID() {
  9196. m.sop_node = nil
  9197. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9198. }
  9199. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  9200. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  9201. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  9202. return ok
  9203. }
  9204. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  9205. func (m *MessageRecordsMutation) ResetSubSourceID() {
  9206. m.sop_node = nil
  9207. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  9208. }
  9209. // SetOrganizationID sets the "organization_id" field.
  9210. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  9211. m.organization_id = &u
  9212. m.addorganization_id = nil
  9213. }
  9214. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9215. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  9216. v := m.organization_id
  9217. if v == nil {
  9218. return
  9219. }
  9220. return *v, true
  9221. }
  9222. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  9223. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  9224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9225. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9226. if !m.op.Is(OpUpdateOne) {
  9227. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9228. }
  9229. if m.id == nil || m.oldValue == nil {
  9230. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9231. }
  9232. oldValue, err := m.oldValue(ctx)
  9233. if err != nil {
  9234. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9235. }
  9236. return oldValue.OrganizationID, nil
  9237. }
  9238. // AddOrganizationID adds u to the "organization_id" field.
  9239. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  9240. if m.addorganization_id != nil {
  9241. *m.addorganization_id += u
  9242. } else {
  9243. m.addorganization_id = &u
  9244. }
  9245. }
  9246. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9247. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  9248. v := m.addorganization_id
  9249. if v == nil {
  9250. return
  9251. }
  9252. return *v, true
  9253. }
  9254. // ClearOrganizationID clears the value of the "organization_id" field.
  9255. func (m *MessageRecordsMutation) ClearOrganizationID() {
  9256. m.organization_id = nil
  9257. m.addorganization_id = nil
  9258. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  9259. }
  9260. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9261. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  9262. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  9263. return ok
  9264. }
  9265. // ResetOrganizationID resets all changes to the "organization_id" field.
  9266. func (m *MessageRecordsMutation) ResetOrganizationID() {
  9267. m.organization_id = nil
  9268. m.addorganization_id = nil
  9269. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  9270. }
  9271. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  9272. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  9273. m.sop_stage = &id
  9274. }
  9275. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  9276. func (m *MessageRecordsMutation) ClearSopStage() {
  9277. m.clearedsop_stage = true
  9278. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  9279. }
  9280. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  9281. func (m *MessageRecordsMutation) SopStageCleared() bool {
  9282. return m.SourceIDCleared() || m.clearedsop_stage
  9283. }
  9284. // SopStageID returns the "sop_stage" edge ID in the mutation.
  9285. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  9286. if m.sop_stage != nil {
  9287. return *m.sop_stage, true
  9288. }
  9289. return
  9290. }
  9291. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  9292. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9293. // SopStageID instead. It exists only for internal usage by the builders.
  9294. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  9295. if id := m.sop_stage; id != nil {
  9296. ids = append(ids, *id)
  9297. }
  9298. return
  9299. }
  9300. // ResetSopStage resets all changes to the "sop_stage" edge.
  9301. func (m *MessageRecordsMutation) ResetSopStage() {
  9302. m.sop_stage = nil
  9303. m.clearedsop_stage = false
  9304. }
  9305. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  9306. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  9307. m.sop_node = &id
  9308. }
  9309. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  9310. func (m *MessageRecordsMutation) ClearSopNode() {
  9311. m.clearedsop_node = true
  9312. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  9313. }
  9314. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  9315. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  9316. return m.SubSourceIDCleared() || m.clearedsop_node
  9317. }
  9318. // SopNodeID returns the "sop_node" edge ID in the mutation.
  9319. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  9320. if m.sop_node != nil {
  9321. return *m.sop_node, true
  9322. }
  9323. return
  9324. }
  9325. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  9326. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9327. // SopNodeID instead. It exists only for internal usage by the builders.
  9328. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  9329. if id := m.sop_node; id != nil {
  9330. ids = append(ids, *id)
  9331. }
  9332. return
  9333. }
  9334. // ResetSopNode resets all changes to the "sop_node" edge.
  9335. func (m *MessageRecordsMutation) ResetSopNode() {
  9336. m.sop_node = nil
  9337. m.clearedsop_node = false
  9338. }
  9339. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  9340. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  9341. m.message_contact = &id
  9342. }
  9343. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  9344. func (m *MessageRecordsMutation) ClearMessageContact() {
  9345. m.clearedmessage_contact = true
  9346. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  9347. }
  9348. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  9349. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  9350. return m.ContactIDCleared() || m.clearedmessage_contact
  9351. }
  9352. // MessageContactID returns the "message_contact" edge ID in the mutation.
  9353. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  9354. if m.message_contact != nil {
  9355. return *m.message_contact, true
  9356. }
  9357. return
  9358. }
  9359. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  9360. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9361. // MessageContactID instead. It exists only for internal usage by the builders.
  9362. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  9363. if id := m.message_contact; id != nil {
  9364. ids = append(ids, *id)
  9365. }
  9366. return
  9367. }
  9368. // ResetMessageContact resets all changes to the "message_contact" edge.
  9369. func (m *MessageRecordsMutation) ResetMessageContact() {
  9370. m.message_contact = nil
  9371. m.clearedmessage_contact = false
  9372. }
  9373. // Where appends a list predicates to the MessageRecordsMutation builder.
  9374. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  9375. m.predicates = append(m.predicates, ps...)
  9376. }
  9377. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  9378. // users can use type-assertion to append predicates that do not depend on any generated package.
  9379. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9380. p := make([]predicate.MessageRecords, len(ps))
  9381. for i := range ps {
  9382. p[i] = ps[i]
  9383. }
  9384. m.Where(p...)
  9385. }
  9386. // Op returns the operation name.
  9387. func (m *MessageRecordsMutation) Op() Op {
  9388. return m.op
  9389. }
  9390. // SetOp allows setting the mutation operation.
  9391. func (m *MessageRecordsMutation) SetOp(op Op) {
  9392. m.op = op
  9393. }
  9394. // Type returns the node type of this mutation (MessageRecords).
  9395. func (m *MessageRecordsMutation) Type() string {
  9396. return m.typ
  9397. }
  9398. // Fields returns all fields that were changed during this mutation. Note that in
  9399. // order to get all numeric fields that were incremented/decremented, call
  9400. // AddedFields().
  9401. func (m *MessageRecordsMutation) Fields() []string {
  9402. fields := make([]string, 0, 17)
  9403. if m.created_at != nil {
  9404. fields = append(fields, messagerecords.FieldCreatedAt)
  9405. }
  9406. if m.updated_at != nil {
  9407. fields = append(fields, messagerecords.FieldUpdatedAt)
  9408. }
  9409. if m.status != nil {
  9410. fields = append(fields, messagerecords.FieldStatus)
  9411. }
  9412. if m.deleted_at != nil {
  9413. fields = append(fields, messagerecords.FieldDeletedAt)
  9414. }
  9415. if m.bot_wxid != nil {
  9416. fields = append(fields, messagerecords.FieldBotWxid)
  9417. }
  9418. if m.message_contact != nil {
  9419. fields = append(fields, messagerecords.FieldContactID)
  9420. }
  9421. if m.contact_type != nil {
  9422. fields = append(fields, messagerecords.FieldContactType)
  9423. }
  9424. if m.contact_wxid != nil {
  9425. fields = append(fields, messagerecords.FieldContactWxid)
  9426. }
  9427. if m.content_type != nil {
  9428. fields = append(fields, messagerecords.FieldContentType)
  9429. }
  9430. if m.content != nil {
  9431. fields = append(fields, messagerecords.FieldContent)
  9432. }
  9433. if m.meta != nil {
  9434. fields = append(fields, messagerecords.FieldMeta)
  9435. }
  9436. if m.error_detail != nil {
  9437. fields = append(fields, messagerecords.FieldErrorDetail)
  9438. }
  9439. if m.send_time != nil {
  9440. fields = append(fields, messagerecords.FieldSendTime)
  9441. }
  9442. if m.source_type != nil {
  9443. fields = append(fields, messagerecords.FieldSourceType)
  9444. }
  9445. if m.sop_stage != nil {
  9446. fields = append(fields, messagerecords.FieldSourceID)
  9447. }
  9448. if m.sop_node != nil {
  9449. fields = append(fields, messagerecords.FieldSubSourceID)
  9450. }
  9451. if m.organization_id != nil {
  9452. fields = append(fields, messagerecords.FieldOrganizationID)
  9453. }
  9454. return fields
  9455. }
  9456. // Field returns the value of a field with the given name. The second boolean
  9457. // return value indicates that this field was not set, or was not defined in the
  9458. // schema.
  9459. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  9460. switch name {
  9461. case messagerecords.FieldCreatedAt:
  9462. return m.CreatedAt()
  9463. case messagerecords.FieldUpdatedAt:
  9464. return m.UpdatedAt()
  9465. case messagerecords.FieldStatus:
  9466. return m.Status()
  9467. case messagerecords.FieldDeletedAt:
  9468. return m.DeletedAt()
  9469. case messagerecords.FieldBotWxid:
  9470. return m.BotWxid()
  9471. case messagerecords.FieldContactID:
  9472. return m.ContactID()
  9473. case messagerecords.FieldContactType:
  9474. return m.ContactType()
  9475. case messagerecords.FieldContactWxid:
  9476. return m.ContactWxid()
  9477. case messagerecords.FieldContentType:
  9478. return m.ContentType()
  9479. case messagerecords.FieldContent:
  9480. return m.Content()
  9481. case messagerecords.FieldMeta:
  9482. return m.Meta()
  9483. case messagerecords.FieldErrorDetail:
  9484. return m.ErrorDetail()
  9485. case messagerecords.FieldSendTime:
  9486. return m.SendTime()
  9487. case messagerecords.FieldSourceType:
  9488. return m.SourceType()
  9489. case messagerecords.FieldSourceID:
  9490. return m.SourceID()
  9491. case messagerecords.FieldSubSourceID:
  9492. return m.SubSourceID()
  9493. case messagerecords.FieldOrganizationID:
  9494. return m.OrganizationID()
  9495. }
  9496. return nil, false
  9497. }
  9498. // OldField returns the old value of the field from the database. An error is
  9499. // returned if the mutation operation is not UpdateOne, or the query to the
  9500. // database failed.
  9501. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9502. switch name {
  9503. case messagerecords.FieldCreatedAt:
  9504. return m.OldCreatedAt(ctx)
  9505. case messagerecords.FieldUpdatedAt:
  9506. return m.OldUpdatedAt(ctx)
  9507. case messagerecords.FieldStatus:
  9508. return m.OldStatus(ctx)
  9509. case messagerecords.FieldDeletedAt:
  9510. return m.OldDeletedAt(ctx)
  9511. case messagerecords.FieldBotWxid:
  9512. return m.OldBotWxid(ctx)
  9513. case messagerecords.FieldContactID:
  9514. return m.OldContactID(ctx)
  9515. case messagerecords.FieldContactType:
  9516. return m.OldContactType(ctx)
  9517. case messagerecords.FieldContactWxid:
  9518. return m.OldContactWxid(ctx)
  9519. case messagerecords.FieldContentType:
  9520. return m.OldContentType(ctx)
  9521. case messagerecords.FieldContent:
  9522. return m.OldContent(ctx)
  9523. case messagerecords.FieldMeta:
  9524. return m.OldMeta(ctx)
  9525. case messagerecords.FieldErrorDetail:
  9526. return m.OldErrorDetail(ctx)
  9527. case messagerecords.FieldSendTime:
  9528. return m.OldSendTime(ctx)
  9529. case messagerecords.FieldSourceType:
  9530. return m.OldSourceType(ctx)
  9531. case messagerecords.FieldSourceID:
  9532. return m.OldSourceID(ctx)
  9533. case messagerecords.FieldSubSourceID:
  9534. return m.OldSubSourceID(ctx)
  9535. case messagerecords.FieldOrganizationID:
  9536. return m.OldOrganizationID(ctx)
  9537. }
  9538. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  9539. }
  9540. // SetField sets the value of a field with the given name. It returns an error if
  9541. // the field is not defined in the schema, or if the type mismatched the field
  9542. // type.
  9543. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  9544. switch name {
  9545. case messagerecords.FieldCreatedAt:
  9546. v, ok := value.(time.Time)
  9547. if !ok {
  9548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9549. }
  9550. m.SetCreatedAt(v)
  9551. return nil
  9552. case messagerecords.FieldUpdatedAt:
  9553. v, ok := value.(time.Time)
  9554. if !ok {
  9555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9556. }
  9557. m.SetUpdatedAt(v)
  9558. return nil
  9559. case messagerecords.FieldStatus:
  9560. v, ok := value.(uint8)
  9561. if !ok {
  9562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9563. }
  9564. m.SetStatus(v)
  9565. return nil
  9566. case messagerecords.FieldDeletedAt:
  9567. v, ok := value.(time.Time)
  9568. if !ok {
  9569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9570. }
  9571. m.SetDeletedAt(v)
  9572. return nil
  9573. case messagerecords.FieldBotWxid:
  9574. v, ok := value.(string)
  9575. if !ok {
  9576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9577. }
  9578. m.SetBotWxid(v)
  9579. return nil
  9580. case messagerecords.FieldContactID:
  9581. v, ok := value.(uint64)
  9582. if !ok {
  9583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9584. }
  9585. m.SetContactID(v)
  9586. return nil
  9587. case messagerecords.FieldContactType:
  9588. v, ok := value.(int)
  9589. if !ok {
  9590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9591. }
  9592. m.SetContactType(v)
  9593. return nil
  9594. case messagerecords.FieldContactWxid:
  9595. v, ok := value.(string)
  9596. if !ok {
  9597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9598. }
  9599. m.SetContactWxid(v)
  9600. return nil
  9601. case messagerecords.FieldContentType:
  9602. v, ok := value.(int)
  9603. if !ok {
  9604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9605. }
  9606. m.SetContentType(v)
  9607. return nil
  9608. case messagerecords.FieldContent:
  9609. v, ok := value.(string)
  9610. if !ok {
  9611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9612. }
  9613. m.SetContent(v)
  9614. return nil
  9615. case messagerecords.FieldMeta:
  9616. v, ok := value.(custom_types.Meta)
  9617. if !ok {
  9618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9619. }
  9620. m.SetMeta(v)
  9621. return nil
  9622. case messagerecords.FieldErrorDetail:
  9623. v, ok := value.(string)
  9624. if !ok {
  9625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9626. }
  9627. m.SetErrorDetail(v)
  9628. return nil
  9629. case messagerecords.FieldSendTime:
  9630. v, ok := value.(time.Time)
  9631. if !ok {
  9632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9633. }
  9634. m.SetSendTime(v)
  9635. return nil
  9636. case messagerecords.FieldSourceType:
  9637. v, ok := value.(int)
  9638. if !ok {
  9639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9640. }
  9641. m.SetSourceType(v)
  9642. return nil
  9643. case messagerecords.FieldSourceID:
  9644. v, ok := value.(uint64)
  9645. if !ok {
  9646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9647. }
  9648. m.SetSourceID(v)
  9649. return nil
  9650. case messagerecords.FieldSubSourceID:
  9651. v, ok := value.(uint64)
  9652. if !ok {
  9653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9654. }
  9655. m.SetSubSourceID(v)
  9656. return nil
  9657. case messagerecords.FieldOrganizationID:
  9658. v, ok := value.(uint64)
  9659. if !ok {
  9660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9661. }
  9662. m.SetOrganizationID(v)
  9663. return nil
  9664. }
  9665. return fmt.Errorf("unknown MessageRecords field %s", name)
  9666. }
  9667. // AddedFields returns all numeric fields that were incremented/decremented during
  9668. // this mutation.
  9669. func (m *MessageRecordsMutation) AddedFields() []string {
  9670. var fields []string
  9671. if m.addstatus != nil {
  9672. fields = append(fields, messagerecords.FieldStatus)
  9673. }
  9674. if m.addcontact_type != nil {
  9675. fields = append(fields, messagerecords.FieldContactType)
  9676. }
  9677. if m.addcontent_type != nil {
  9678. fields = append(fields, messagerecords.FieldContentType)
  9679. }
  9680. if m.addsource_type != nil {
  9681. fields = append(fields, messagerecords.FieldSourceType)
  9682. }
  9683. if m.addorganization_id != nil {
  9684. fields = append(fields, messagerecords.FieldOrganizationID)
  9685. }
  9686. return fields
  9687. }
  9688. // AddedField returns the numeric value that was incremented/decremented on a field
  9689. // with the given name. The second boolean return value indicates that this field
  9690. // was not set, or was not defined in the schema.
  9691. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9692. switch name {
  9693. case messagerecords.FieldStatus:
  9694. return m.AddedStatus()
  9695. case messagerecords.FieldContactType:
  9696. return m.AddedContactType()
  9697. case messagerecords.FieldContentType:
  9698. return m.AddedContentType()
  9699. case messagerecords.FieldSourceType:
  9700. return m.AddedSourceType()
  9701. case messagerecords.FieldOrganizationID:
  9702. return m.AddedOrganizationID()
  9703. }
  9704. return nil, false
  9705. }
  9706. // AddField adds the value to the field with the given name. It returns an error if
  9707. // the field is not defined in the schema, or if the type mismatched the field
  9708. // type.
  9709. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  9710. switch name {
  9711. case messagerecords.FieldStatus:
  9712. v, ok := value.(int8)
  9713. if !ok {
  9714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9715. }
  9716. m.AddStatus(v)
  9717. return nil
  9718. case messagerecords.FieldContactType:
  9719. v, ok := value.(int)
  9720. if !ok {
  9721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9722. }
  9723. m.AddContactType(v)
  9724. return nil
  9725. case messagerecords.FieldContentType:
  9726. v, ok := value.(int)
  9727. if !ok {
  9728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9729. }
  9730. m.AddContentType(v)
  9731. return nil
  9732. case messagerecords.FieldSourceType:
  9733. v, ok := value.(int)
  9734. if !ok {
  9735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9736. }
  9737. m.AddSourceType(v)
  9738. return nil
  9739. case messagerecords.FieldOrganizationID:
  9740. v, ok := value.(int64)
  9741. if !ok {
  9742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9743. }
  9744. m.AddOrganizationID(v)
  9745. return nil
  9746. }
  9747. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  9748. }
  9749. // ClearedFields returns all nullable fields that were cleared during this
  9750. // mutation.
  9751. func (m *MessageRecordsMutation) ClearedFields() []string {
  9752. var fields []string
  9753. if m.FieldCleared(messagerecords.FieldStatus) {
  9754. fields = append(fields, messagerecords.FieldStatus)
  9755. }
  9756. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  9757. fields = append(fields, messagerecords.FieldDeletedAt)
  9758. }
  9759. if m.FieldCleared(messagerecords.FieldContactID) {
  9760. fields = append(fields, messagerecords.FieldContactID)
  9761. }
  9762. if m.FieldCleared(messagerecords.FieldMeta) {
  9763. fields = append(fields, messagerecords.FieldMeta)
  9764. }
  9765. if m.FieldCleared(messagerecords.FieldSendTime) {
  9766. fields = append(fields, messagerecords.FieldSendTime)
  9767. }
  9768. if m.FieldCleared(messagerecords.FieldSourceID) {
  9769. fields = append(fields, messagerecords.FieldSourceID)
  9770. }
  9771. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  9772. fields = append(fields, messagerecords.FieldSubSourceID)
  9773. }
  9774. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  9775. fields = append(fields, messagerecords.FieldOrganizationID)
  9776. }
  9777. return fields
  9778. }
  9779. // FieldCleared returns a boolean indicating if a field with the given name was
  9780. // cleared in this mutation.
  9781. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  9782. _, ok := m.clearedFields[name]
  9783. return ok
  9784. }
  9785. // ClearField clears the value of the field with the given name. It returns an
  9786. // error if the field is not defined in the schema.
  9787. func (m *MessageRecordsMutation) ClearField(name string) error {
  9788. switch name {
  9789. case messagerecords.FieldStatus:
  9790. m.ClearStatus()
  9791. return nil
  9792. case messagerecords.FieldDeletedAt:
  9793. m.ClearDeletedAt()
  9794. return nil
  9795. case messagerecords.FieldContactID:
  9796. m.ClearContactID()
  9797. return nil
  9798. case messagerecords.FieldMeta:
  9799. m.ClearMeta()
  9800. return nil
  9801. case messagerecords.FieldSendTime:
  9802. m.ClearSendTime()
  9803. return nil
  9804. case messagerecords.FieldSourceID:
  9805. m.ClearSourceID()
  9806. return nil
  9807. case messagerecords.FieldSubSourceID:
  9808. m.ClearSubSourceID()
  9809. return nil
  9810. case messagerecords.FieldOrganizationID:
  9811. m.ClearOrganizationID()
  9812. return nil
  9813. }
  9814. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  9815. }
  9816. // ResetField resets all changes in the mutation for the field with the given name.
  9817. // It returns an error if the field is not defined in the schema.
  9818. func (m *MessageRecordsMutation) ResetField(name string) error {
  9819. switch name {
  9820. case messagerecords.FieldCreatedAt:
  9821. m.ResetCreatedAt()
  9822. return nil
  9823. case messagerecords.FieldUpdatedAt:
  9824. m.ResetUpdatedAt()
  9825. return nil
  9826. case messagerecords.FieldStatus:
  9827. m.ResetStatus()
  9828. return nil
  9829. case messagerecords.FieldDeletedAt:
  9830. m.ResetDeletedAt()
  9831. return nil
  9832. case messagerecords.FieldBotWxid:
  9833. m.ResetBotWxid()
  9834. return nil
  9835. case messagerecords.FieldContactID:
  9836. m.ResetContactID()
  9837. return nil
  9838. case messagerecords.FieldContactType:
  9839. m.ResetContactType()
  9840. return nil
  9841. case messagerecords.FieldContactWxid:
  9842. m.ResetContactWxid()
  9843. return nil
  9844. case messagerecords.FieldContentType:
  9845. m.ResetContentType()
  9846. return nil
  9847. case messagerecords.FieldContent:
  9848. m.ResetContent()
  9849. return nil
  9850. case messagerecords.FieldMeta:
  9851. m.ResetMeta()
  9852. return nil
  9853. case messagerecords.FieldErrorDetail:
  9854. m.ResetErrorDetail()
  9855. return nil
  9856. case messagerecords.FieldSendTime:
  9857. m.ResetSendTime()
  9858. return nil
  9859. case messagerecords.FieldSourceType:
  9860. m.ResetSourceType()
  9861. return nil
  9862. case messagerecords.FieldSourceID:
  9863. m.ResetSourceID()
  9864. return nil
  9865. case messagerecords.FieldSubSourceID:
  9866. m.ResetSubSourceID()
  9867. return nil
  9868. case messagerecords.FieldOrganizationID:
  9869. m.ResetOrganizationID()
  9870. return nil
  9871. }
  9872. return fmt.Errorf("unknown MessageRecords field %s", name)
  9873. }
  9874. // AddedEdges returns all edge names that were set/added in this mutation.
  9875. func (m *MessageRecordsMutation) AddedEdges() []string {
  9876. edges := make([]string, 0, 3)
  9877. if m.sop_stage != nil {
  9878. edges = append(edges, messagerecords.EdgeSopStage)
  9879. }
  9880. if m.sop_node != nil {
  9881. edges = append(edges, messagerecords.EdgeSopNode)
  9882. }
  9883. if m.message_contact != nil {
  9884. edges = append(edges, messagerecords.EdgeMessageContact)
  9885. }
  9886. return edges
  9887. }
  9888. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9889. // name in this mutation.
  9890. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  9891. switch name {
  9892. case messagerecords.EdgeSopStage:
  9893. if id := m.sop_stage; id != nil {
  9894. return []ent.Value{*id}
  9895. }
  9896. case messagerecords.EdgeSopNode:
  9897. if id := m.sop_node; id != nil {
  9898. return []ent.Value{*id}
  9899. }
  9900. case messagerecords.EdgeMessageContact:
  9901. if id := m.message_contact; id != nil {
  9902. return []ent.Value{*id}
  9903. }
  9904. }
  9905. return nil
  9906. }
  9907. // RemovedEdges returns all edge names that were removed in this mutation.
  9908. func (m *MessageRecordsMutation) RemovedEdges() []string {
  9909. edges := make([]string, 0, 3)
  9910. return edges
  9911. }
  9912. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9913. // the given name in this mutation.
  9914. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  9915. return nil
  9916. }
  9917. // ClearedEdges returns all edge names that were cleared in this mutation.
  9918. func (m *MessageRecordsMutation) ClearedEdges() []string {
  9919. edges := make([]string, 0, 3)
  9920. if m.clearedsop_stage {
  9921. edges = append(edges, messagerecords.EdgeSopStage)
  9922. }
  9923. if m.clearedsop_node {
  9924. edges = append(edges, messagerecords.EdgeSopNode)
  9925. }
  9926. if m.clearedmessage_contact {
  9927. edges = append(edges, messagerecords.EdgeMessageContact)
  9928. }
  9929. return edges
  9930. }
  9931. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9932. // was cleared in this mutation.
  9933. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  9934. switch name {
  9935. case messagerecords.EdgeSopStage:
  9936. return m.clearedsop_stage
  9937. case messagerecords.EdgeSopNode:
  9938. return m.clearedsop_node
  9939. case messagerecords.EdgeMessageContact:
  9940. return m.clearedmessage_contact
  9941. }
  9942. return false
  9943. }
  9944. // ClearEdge clears the value of the edge with the given name. It returns an error
  9945. // if that edge is not defined in the schema.
  9946. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  9947. switch name {
  9948. case messagerecords.EdgeSopStage:
  9949. m.ClearSopStage()
  9950. return nil
  9951. case messagerecords.EdgeSopNode:
  9952. m.ClearSopNode()
  9953. return nil
  9954. case messagerecords.EdgeMessageContact:
  9955. m.ClearMessageContact()
  9956. return nil
  9957. }
  9958. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  9959. }
  9960. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9961. // It returns an error if the edge is not defined in the schema.
  9962. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  9963. switch name {
  9964. case messagerecords.EdgeSopStage:
  9965. m.ResetSopStage()
  9966. return nil
  9967. case messagerecords.EdgeSopNode:
  9968. m.ResetSopNode()
  9969. return nil
  9970. case messagerecords.EdgeMessageContact:
  9971. m.ResetMessageContact()
  9972. return nil
  9973. }
  9974. return fmt.Errorf("unknown MessageRecords edge %s", name)
  9975. }
  9976. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  9977. type MsgMutation struct {
  9978. config
  9979. op Op
  9980. typ string
  9981. id *uint64
  9982. created_at *time.Time
  9983. updated_at *time.Time
  9984. deleted_at *time.Time
  9985. status *uint8
  9986. addstatus *int8
  9987. fromwxid *string
  9988. toid *string
  9989. msgtype *int32
  9990. addmsgtype *int32
  9991. msg *string
  9992. batch_no *string
  9993. clearedFields map[string]struct{}
  9994. done bool
  9995. oldValue func(context.Context) (*Msg, error)
  9996. predicates []predicate.Msg
  9997. }
  9998. var _ ent.Mutation = (*MsgMutation)(nil)
  9999. // msgOption allows management of the mutation configuration using functional options.
  10000. type msgOption func(*MsgMutation)
  10001. // newMsgMutation creates new mutation for the Msg entity.
  10002. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  10003. m := &MsgMutation{
  10004. config: c,
  10005. op: op,
  10006. typ: TypeMsg,
  10007. clearedFields: make(map[string]struct{}),
  10008. }
  10009. for _, opt := range opts {
  10010. opt(m)
  10011. }
  10012. return m
  10013. }
  10014. // withMsgID sets the ID field of the mutation.
  10015. func withMsgID(id uint64) msgOption {
  10016. return func(m *MsgMutation) {
  10017. var (
  10018. err error
  10019. once sync.Once
  10020. value *Msg
  10021. )
  10022. m.oldValue = func(ctx context.Context) (*Msg, error) {
  10023. once.Do(func() {
  10024. if m.done {
  10025. err = errors.New("querying old values post mutation is not allowed")
  10026. } else {
  10027. value, err = m.Client().Msg.Get(ctx, id)
  10028. }
  10029. })
  10030. return value, err
  10031. }
  10032. m.id = &id
  10033. }
  10034. }
  10035. // withMsg sets the old Msg of the mutation.
  10036. func withMsg(node *Msg) msgOption {
  10037. return func(m *MsgMutation) {
  10038. m.oldValue = func(context.Context) (*Msg, error) {
  10039. return node, nil
  10040. }
  10041. m.id = &node.ID
  10042. }
  10043. }
  10044. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10045. // executed in a transaction (ent.Tx), a transactional client is returned.
  10046. func (m MsgMutation) Client() *Client {
  10047. client := &Client{config: m.config}
  10048. client.init()
  10049. return client
  10050. }
  10051. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10052. // it returns an error otherwise.
  10053. func (m MsgMutation) Tx() (*Tx, error) {
  10054. if _, ok := m.driver.(*txDriver); !ok {
  10055. return nil, errors.New("ent: mutation is not running in a transaction")
  10056. }
  10057. tx := &Tx{config: m.config}
  10058. tx.init()
  10059. return tx, nil
  10060. }
  10061. // SetID sets the value of the id field. Note that this
  10062. // operation is only accepted on creation of Msg entities.
  10063. func (m *MsgMutation) SetID(id uint64) {
  10064. m.id = &id
  10065. }
  10066. // ID returns the ID value in the mutation. Note that the ID is only available
  10067. // if it was provided to the builder or after it was returned from the database.
  10068. func (m *MsgMutation) ID() (id uint64, exists bool) {
  10069. if m.id == nil {
  10070. return
  10071. }
  10072. return *m.id, true
  10073. }
  10074. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10075. // That means, if the mutation is applied within a transaction with an isolation level such
  10076. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10077. // or updated by the mutation.
  10078. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  10079. switch {
  10080. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10081. id, exists := m.ID()
  10082. if exists {
  10083. return []uint64{id}, nil
  10084. }
  10085. fallthrough
  10086. case m.op.Is(OpUpdate | OpDelete):
  10087. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  10088. default:
  10089. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10090. }
  10091. }
  10092. // SetCreatedAt sets the "created_at" field.
  10093. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  10094. m.created_at = &t
  10095. }
  10096. // CreatedAt returns the value of the "created_at" field in the mutation.
  10097. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  10098. v := m.created_at
  10099. if v == nil {
  10100. return
  10101. }
  10102. return *v, true
  10103. }
  10104. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  10105. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10107. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10108. if !m.op.Is(OpUpdateOne) {
  10109. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10110. }
  10111. if m.id == nil || m.oldValue == nil {
  10112. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10113. }
  10114. oldValue, err := m.oldValue(ctx)
  10115. if err != nil {
  10116. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10117. }
  10118. return oldValue.CreatedAt, nil
  10119. }
  10120. // ResetCreatedAt resets all changes to the "created_at" field.
  10121. func (m *MsgMutation) ResetCreatedAt() {
  10122. m.created_at = nil
  10123. }
  10124. // SetUpdatedAt sets the "updated_at" field.
  10125. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  10126. m.updated_at = &t
  10127. }
  10128. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10129. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  10130. v := m.updated_at
  10131. if v == nil {
  10132. return
  10133. }
  10134. return *v, true
  10135. }
  10136. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  10137. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10139. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10140. if !m.op.Is(OpUpdateOne) {
  10141. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10142. }
  10143. if m.id == nil || m.oldValue == nil {
  10144. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10145. }
  10146. oldValue, err := m.oldValue(ctx)
  10147. if err != nil {
  10148. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10149. }
  10150. return oldValue.UpdatedAt, nil
  10151. }
  10152. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10153. func (m *MsgMutation) ResetUpdatedAt() {
  10154. m.updated_at = nil
  10155. }
  10156. // SetDeletedAt sets the "deleted_at" field.
  10157. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  10158. m.deleted_at = &t
  10159. }
  10160. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10161. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  10162. v := m.deleted_at
  10163. if v == nil {
  10164. return
  10165. }
  10166. return *v, true
  10167. }
  10168. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  10169. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10171. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10172. if !m.op.Is(OpUpdateOne) {
  10173. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10174. }
  10175. if m.id == nil || m.oldValue == nil {
  10176. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10177. }
  10178. oldValue, err := m.oldValue(ctx)
  10179. if err != nil {
  10180. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10181. }
  10182. return oldValue.DeletedAt, nil
  10183. }
  10184. // ClearDeletedAt clears the value of the "deleted_at" field.
  10185. func (m *MsgMutation) ClearDeletedAt() {
  10186. m.deleted_at = nil
  10187. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  10188. }
  10189. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10190. func (m *MsgMutation) DeletedAtCleared() bool {
  10191. _, ok := m.clearedFields[msg.FieldDeletedAt]
  10192. return ok
  10193. }
  10194. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10195. func (m *MsgMutation) ResetDeletedAt() {
  10196. m.deleted_at = nil
  10197. delete(m.clearedFields, msg.FieldDeletedAt)
  10198. }
  10199. // SetStatus sets the "status" field.
  10200. func (m *MsgMutation) SetStatus(u uint8) {
  10201. m.status = &u
  10202. m.addstatus = nil
  10203. }
  10204. // Status returns the value of the "status" field in the mutation.
  10205. func (m *MsgMutation) Status() (r uint8, exists bool) {
  10206. v := m.status
  10207. if v == nil {
  10208. return
  10209. }
  10210. return *v, true
  10211. }
  10212. // OldStatus returns the old "status" field's value of the Msg entity.
  10213. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10215. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10216. if !m.op.Is(OpUpdateOne) {
  10217. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10218. }
  10219. if m.id == nil || m.oldValue == nil {
  10220. return v, errors.New("OldStatus requires an ID field in the mutation")
  10221. }
  10222. oldValue, err := m.oldValue(ctx)
  10223. if err != nil {
  10224. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10225. }
  10226. return oldValue.Status, nil
  10227. }
  10228. // AddStatus adds u to the "status" field.
  10229. func (m *MsgMutation) AddStatus(u int8) {
  10230. if m.addstatus != nil {
  10231. *m.addstatus += u
  10232. } else {
  10233. m.addstatus = &u
  10234. }
  10235. }
  10236. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10237. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  10238. v := m.addstatus
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // ClearStatus clears the value of the "status" field.
  10245. func (m *MsgMutation) ClearStatus() {
  10246. m.status = nil
  10247. m.addstatus = nil
  10248. m.clearedFields[msg.FieldStatus] = struct{}{}
  10249. }
  10250. // StatusCleared returns if the "status" field was cleared in this mutation.
  10251. func (m *MsgMutation) StatusCleared() bool {
  10252. _, ok := m.clearedFields[msg.FieldStatus]
  10253. return ok
  10254. }
  10255. // ResetStatus resets all changes to the "status" field.
  10256. func (m *MsgMutation) ResetStatus() {
  10257. m.status = nil
  10258. m.addstatus = nil
  10259. delete(m.clearedFields, msg.FieldStatus)
  10260. }
  10261. // SetFromwxid sets the "fromwxid" field.
  10262. func (m *MsgMutation) SetFromwxid(s string) {
  10263. m.fromwxid = &s
  10264. }
  10265. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  10266. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  10267. v := m.fromwxid
  10268. if v == nil {
  10269. return
  10270. }
  10271. return *v, true
  10272. }
  10273. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  10274. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10276. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  10277. if !m.op.Is(OpUpdateOne) {
  10278. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  10279. }
  10280. if m.id == nil || m.oldValue == nil {
  10281. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  10282. }
  10283. oldValue, err := m.oldValue(ctx)
  10284. if err != nil {
  10285. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  10286. }
  10287. return oldValue.Fromwxid, nil
  10288. }
  10289. // ClearFromwxid clears the value of the "fromwxid" field.
  10290. func (m *MsgMutation) ClearFromwxid() {
  10291. m.fromwxid = nil
  10292. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  10293. }
  10294. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  10295. func (m *MsgMutation) FromwxidCleared() bool {
  10296. _, ok := m.clearedFields[msg.FieldFromwxid]
  10297. return ok
  10298. }
  10299. // ResetFromwxid resets all changes to the "fromwxid" field.
  10300. func (m *MsgMutation) ResetFromwxid() {
  10301. m.fromwxid = nil
  10302. delete(m.clearedFields, msg.FieldFromwxid)
  10303. }
  10304. // SetToid sets the "toid" field.
  10305. func (m *MsgMutation) SetToid(s string) {
  10306. m.toid = &s
  10307. }
  10308. // Toid returns the value of the "toid" field in the mutation.
  10309. func (m *MsgMutation) Toid() (r string, exists bool) {
  10310. v := m.toid
  10311. if v == nil {
  10312. return
  10313. }
  10314. return *v, true
  10315. }
  10316. // OldToid returns the old "toid" field's value of the Msg entity.
  10317. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10319. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  10320. if !m.op.Is(OpUpdateOne) {
  10321. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  10322. }
  10323. if m.id == nil || m.oldValue == nil {
  10324. return v, errors.New("OldToid requires an ID field in the mutation")
  10325. }
  10326. oldValue, err := m.oldValue(ctx)
  10327. if err != nil {
  10328. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  10329. }
  10330. return oldValue.Toid, nil
  10331. }
  10332. // ClearToid clears the value of the "toid" field.
  10333. func (m *MsgMutation) ClearToid() {
  10334. m.toid = nil
  10335. m.clearedFields[msg.FieldToid] = struct{}{}
  10336. }
  10337. // ToidCleared returns if the "toid" field was cleared in this mutation.
  10338. func (m *MsgMutation) ToidCleared() bool {
  10339. _, ok := m.clearedFields[msg.FieldToid]
  10340. return ok
  10341. }
  10342. // ResetToid resets all changes to the "toid" field.
  10343. func (m *MsgMutation) ResetToid() {
  10344. m.toid = nil
  10345. delete(m.clearedFields, msg.FieldToid)
  10346. }
  10347. // SetMsgtype sets the "msgtype" field.
  10348. func (m *MsgMutation) SetMsgtype(i int32) {
  10349. m.msgtype = &i
  10350. m.addmsgtype = nil
  10351. }
  10352. // Msgtype returns the value of the "msgtype" field in the mutation.
  10353. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  10354. v := m.msgtype
  10355. if v == nil {
  10356. return
  10357. }
  10358. return *v, true
  10359. }
  10360. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  10361. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10363. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  10364. if !m.op.Is(OpUpdateOne) {
  10365. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  10366. }
  10367. if m.id == nil || m.oldValue == nil {
  10368. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  10369. }
  10370. oldValue, err := m.oldValue(ctx)
  10371. if err != nil {
  10372. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  10373. }
  10374. return oldValue.Msgtype, nil
  10375. }
  10376. // AddMsgtype adds i to the "msgtype" field.
  10377. func (m *MsgMutation) AddMsgtype(i int32) {
  10378. if m.addmsgtype != nil {
  10379. *m.addmsgtype += i
  10380. } else {
  10381. m.addmsgtype = &i
  10382. }
  10383. }
  10384. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  10385. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  10386. v := m.addmsgtype
  10387. if v == nil {
  10388. return
  10389. }
  10390. return *v, true
  10391. }
  10392. // ClearMsgtype clears the value of the "msgtype" field.
  10393. func (m *MsgMutation) ClearMsgtype() {
  10394. m.msgtype = nil
  10395. m.addmsgtype = nil
  10396. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  10397. }
  10398. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  10399. func (m *MsgMutation) MsgtypeCleared() bool {
  10400. _, ok := m.clearedFields[msg.FieldMsgtype]
  10401. return ok
  10402. }
  10403. // ResetMsgtype resets all changes to the "msgtype" field.
  10404. func (m *MsgMutation) ResetMsgtype() {
  10405. m.msgtype = nil
  10406. m.addmsgtype = nil
  10407. delete(m.clearedFields, msg.FieldMsgtype)
  10408. }
  10409. // SetMsg sets the "msg" field.
  10410. func (m *MsgMutation) SetMsg(s string) {
  10411. m.msg = &s
  10412. }
  10413. // Msg returns the value of the "msg" field in the mutation.
  10414. func (m *MsgMutation) Msg() (r string, exists bool) {
  10415. v := m.msg
  10416. if v == nil {
  10417. return
  10418. }
  10419. return *v, true
  10420. }
  10421. // OldMsg returns the old "msg" field's value of the Msg entity.
  10422. // If the Msg 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 *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  10425. if !m.op.Is(OpUpdateOne) {
  10426. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  10427. }
  10428. if m.id == nil || m.oldValue == nil {
  10429. return v, errors.New("OldMsg 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 OldMsg: %w", err)
  10434. }
  10435. return oldValue.Msg, nil
  10436. }
  10437. // ClearMsg clears the value of the "msg" field.
  10438. func (m *MsgMutation) ClearMsg() {
  10439. m.msg = nil
  10440. m.clearedFields[msg.FieldMsg] = struct{}{}
  10441. }
  10442. // MsgCleared returns if the "msg" field was cleared in this mutation.
  10443. func (m *MsgMutation) MsgCleared() bool {
  10444. _, ok := m.clearedFields[msg.FieldMsg]
  10445. return ok
  10446. }
  10447. // ResetMsg resets all changes to the "msg" field.
  10448. func (m *MsgMutation) ResetMsg() {
  10449. m.msg = nil
  10450. delete(m.clearedFields, msg.FieldMsg)
  10451. }
  10452. // SetBatchNo sets the "batch_no" field.
  10453. func (m *MsgMutation) SetBatchNo(s string) {
  10454. m.batch_no = &s
  10455. }
  10456. // BatchNo returns the value of the "batch_no" field in the mutation.
  10457. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  10458. v := m.batch_no
  10459. if v == nil {
  10460. return
  10461. }
  10462. return *v, true
  10463. }
  10464. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  10465. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  10466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10467. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  10468. if !m.op.Is(OpUpdateOne) {
  10469. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  10470. }
  10471. if m.id == nil || m.oldValue == nil {
  10472. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  10473. }
  10474. oldValue, err := m.oldValue(ctx)
  10475. if err != nil {
  10476. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  10477. }
  10478. return oldValue.BatchNo, nil
  10479. }
  10480. // ClearBatchNo clears the value of the "batch_no" field.
  10481. func (m *MsgMutation) ClearBatchNo() {
  10482. m.batch_no = nil
  10483. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  10484. }
  10485. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  10486. func (m *MsgMutation) BatchNoCleared() bool {
  10487. _, ok := m.clearedFields[msg.FieldBatchNo]
  10488. return ok
  10489. }
  10490. // ResetBatchNo resets all changes to the "batch_no" field.
  10491. func (m *MsgMutation) ResetBatchNo() {
  10492. m.batch_no = nil
  10493. delete(m.clearedFields, msg.FieldBatchNo)
  10494. }
  10495. // Where appends a list predicates to the MsgMutation builder.
  10496. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  10497. m.predicates = append(m.predicates, ps...)
  10498. }
  10499. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  10500. // users can use type-assertion to append predicates that do not depend on any generated package.
  10501. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  10502. p := make([]predicate.Msg, len(ps))
  10503. for i := range ps {
  10504. p[i] = ps[i]
  10505. }
  10506. m.Where(p...)
  10507. }
  10508. // Op returns the operation name.
  10509. func (m *MsgMutation) Op() Op {
  10510. return m.op
  10511. }
  10512. // SetOp allows setting the mutation operation.
  10513. func (m *MsgMutation) SetOp(op Op) {
  10514. m.op = op
  10515. }
  10516. // Type returns the node type of this mutation (Msg).
  10517. func (m *MsgMutation) Type() string {
  10518. return m.typ
  10519. }
  10520. // Fields returns all fields that were changed during this mutation. Note that in
  10521. // order to get all numeric fields that were incremented/decremented, call
  10522. // AddedFields().
  10523. func (m *MsgMutation) Fields() []string {
  10524. fields := make([]string, 0, 9)
  10525. if m.created_at != nil {
  10526. fields = append(fields, msg.FieldCreatedAt)
  10527. }
  10528. if m.updated_at != nil {
  10529. fields = append(fields, msg.FieldUpdatedAt)
  10530. }
  10531. if m.deleted_at != nil {
  10532. fields = append(fields, msg.FieldDeletedAt)
  10533. }
  10534. if m.status != nil {
  10535. fields = append(fields, msg.FieldStatus)
  10536. }
  10537. if m.fromwxid != nil {
  10538. fields = append(fields, msg.FieldFromwxid)
  10539. }
  10540. if m.toid != nil {
  10541. fields = append(fields, msg.FieldToid)
  10542. }
  10543. if m.msgtype != nil {
  10544. fields = append(fields, msg.FieldMsgtype)
  10545. }
  10546. if m.msg != nil {
  10547. fields = append(fields, msg.FieldMsg)
  10548. }
  10549. if m.batch_no != nil {
  10550. fields = append(fields, msg.FieldBatchNo)
  10551. }
  10552. return fields
  10553. }
  10554. // Field returns the value of a field with the given name. The second boolean
  10555. // return value indicates that this field was not set, or was not defined in the
  10556. // schema.
  10557. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  10558. switch name {
  10559. case msg.FieldCreatedAt:
  10560. return m.CreatedAt()
  10561. case msg.FieldUpdatedAt:
  10562. return m.UpdatedAt()
  10563. case msg.FieldDeletedAt:
  10564. return m.DeletedAt()
  10565. case msg.FieldStatus:
  10566. return m.Status()
  10567. case msg.FieldFromwxid:
  10568. return m.Fromwxid()
  10569. case msg.FieldToid:
  10570. return m.Toid()
  10571. case msg.FieldMsgtype:
  10572. return m.Msgtype()
  10573. case msg.FieldMsg:
  10574. return m.Msg()
  10575. case msg.FieldBatchNo:
  10576. return m.BatchNo()
  10577. }
  10578. return nil, false
  10579. }
  10580. // OldField returns the old value of the field from the database. An error is
  10581. // returned if the mutation operation is not UpdateOne, or the query to the
  10582. // database failed.
  10583. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10584. switch name {
  10585. case msg.FieldCreatedAt:
  10586. return m.OldCreatedAt(ctx)
  10587. case msg.FieldUpdatedAt:
  10588. return m.OldUpdatedAt(ctx)
  10589. case msg.FieldDeletedAt:
  10590. return m.OldDeletedAt(ctx)
  10591. case msg.FieldStatus:
  10592. return m.OldStatus(ctx)
  10593. case msg.FieldFromwxid:
  10594. return m.OldFromwxid(ctx)
  10595. case msg.FieldToid:
  10596. return m.OldToid(ctx)
  10597. case msg.FieldMsgtype:
  10598. return m.OldMsgtype(ctx)
  10599. case msg.FieldMsg:
  10600. return m.OldMsg(ctx)
  10601. case msg.FieldBatchNo:
  10602. return m.OldBatchNo(ctx)
  10603. }
  10604. return nil, fmt.Errorf("unknown Msg field %s", name)
  10605. }
  10606. // SetField sets the value of a field with the given name. It returns an error if
  10607. // the field is not defined in the schema, or if the type mismatched the field
  10608. // type.
  10609. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  10610. switch name {
  10611. case msg.FieldCreatedAt:
  10612. v, ok := value.(time.Time)
  10613. if !ok {
  10614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10615. }
  10616. m.SetCreatedAt(v)
  10617. return nil
  10618. case msg.FieldUpdatedAt:
  10619. v, ok := value.(time.Time)
  10620. if !ok {
  10621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10622. }
  10623. m.SetUpdatedAt(v)
  10624. return nil
  10625. case msg.FieldDeletedAt:
  10626. v, ok := value.(time.Time)
  10627. if !ok {
  10628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10629. }
  10630. m.SetDeletedAt(v)
  10631. return nil
  10632. case msg.FieldStatus:
  10633. v, ok := value.(uint8)
  10634. if !ok {
  10635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10636. }
  10637. m.SetStatus(v)
  10638. return nil
  10639. case msg.FieldFromwxid:
  10640. v, ok := value.(string)
  10641. if !ok {
  10642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10643. }
  10644. m.SetFromwxid(v)
  10645. return nil
  10646. case msg.FieldToid:
  10647. v, ok := value.(string)
  10648. if !ok {
  10649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10650. }
  10651. m.SetToid(v)
  10652. return nil
  10653. case msg.FieldMsgtype:
  10654. v, ok := value.(int32)
  10655. if !ok {
  10656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10657. }
  10658. m.SetMsgtype(v)
  10659. return nil
  10660. case msg.FieldMsg:
  10661. v, ok := value.(string)
  10662. if !ok {
  10663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10664. }
  10665. m.SetMsg(v)
  10666. return nil
  10667. case msg.FieldBatchNo:
  10668. v, ok := value.(string)
  10669. if !ok {
  10670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10671. }
  10672. m.SetBatchNo(v)
  10673. return nil
  10674. }
  10675. return fmt.Errorf("unknown Msg field %s", name)
  10676. }
  10677. // AddedFields returns all numeric fields that were incremented/decremented during
  10678. // this mutation.
  10679. func (m *MsgMutation) AddedFields() []string {
  10680. var fields []string
  10681. if m.addstatus != nil {
  10682. fields = append(fields, msg.FieldStatus)
  10683. }
  10684. if m.addmsgtype != nil {
  10685. fields = append(fields, msg.FieldMsgtype)
  10686. }
  10687. return fields
  10688. }
  10689. // AddedField returns the numeric value that was incremented/decremented on a field
  10690. // with the given name. The second boolean return value indicates that this field
  10691. // was not set, or was not defined in the schema.
  10692. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  10693. switch name {
  10694. case msg.FieldStatus:
  10695. return m.AddedStatus()
  10696. case msg.FieldMsgtype:
  10697. return m.AddedMsgtype()
  10698. }
  10699. return nil, false
  10700. }
  10701. // AddField adds the value to the field with the given name. It returns an error if
  10702. // the field is not defined in the schema, or if the type mismatched the field
  10703. // type.
  10704. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  10705. switch name {
  10706. case msg.FieldStatus:
  10707. v, ok := value.(int8)
  10708. if !ok {
  10709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10710. }
  10711. m.AddStatus(v)
  10712. return nil
  10713. case msg.FieldMsgtype:
  10714. v, ok := value.(int32)
  10715. if !ok {
  10716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10717. }
  10718. m.AddMsgtype(v)
  10719. return nil
  10720. }
  10721. return fmt.Errorf("unknown Msg numeric field %s", name)
  10722. }
  10723. // ClearedFields returns all nullable fields that were cleared during this
  10724. // mutation.
  10725. func (m *MsgMutation) ClearedFields() []string {
  10726. var fields []string
  10727. if m.FieldCleared(msg.FieldDeletedAt) {
  10728. fields = append(fields, msg.FieldDeletedAt)
  10729. }
  10730. if m.FieldCleared(msg.FieldStatus) {
  10731. fields = append(fields, msg.FieldStatus)
  10732. }
  10733. if m.FieldCleared(msg.FieldFromwxid) {
  10734. fields = append(fields, msg.FieldFromwxid)
  10735. }
  10736. if m.FieldCleared(msg.FieldToid) {
  10737. fields = append(fields, msg.FieldToid)
  10738. }
  10739. if m.FieldCleared(msg.FieldMsgtype) {
  10740. fields = append(fields, msg.FieldMsgtype)
  10741. }
  10742. if m.FieldCleared(msg.FieldMsg) {
  10743. fields = append(fields, msg.FieldMsg)
  10744. }
  10745. if m.FieldCleared(msg.FieldBatchNo) {
  10746. fields = append(fields, msg.FieldBatchNo)
  10747. }
  10748. return fields
  10749. }
  10750. // FieldCleared returns a boolean indicating if a field with the given name was
  10751. // cleared in this mutation.
  10752. func (m *MsgMutation) FieldCleared(name string) bool {
  10753. _, ok := m.clearedFields[name]
  10754. return ok
  10755. }
  10756. // ClearField clears the value of the field with the given name. It returns an
  10757. // error if the field is not defined in the schema.
  10758. func (m *MsgMutation) ClearField(name string) error {
  10759. switch name {
  10760. case msg.FieldDeletedAt:
  10761. m.ClearDeletedAt()
  10762. return nil
  10763. case msg.FieldStatus:
  10764. m.ClearStatus()
  10765. return nil
  10766. case msg.FieldFromwxid:
  10767. m.ClearFromwxid()
  10768. return nil
  10769. case msg.FieldToid:
  10770. m.ClearToid()
  10771. return nil
  10772. case msg.FieldMsgtype:
  10773. m.ClearMsgtype()
  10774. return nil
  10775. case msg.FieldMsg:
  10776. m.ClearMsg()
  10777. return nil
  10778. case msg.FieldBatchNo:
  10779. m.ClearBatchNo()
  10780. return nil
  10781. }
  10782. return fmt.Errorf("unknown Msg nullable field %s", name)
  10783. }
  10784. // ResetField resets all changes in the mutation for the field with the given name.
  10785. // It returns an error if the field is not defined in the schema.
  10786. func (m *MsgMutation) ResetField(name string) error {
  10787. switch name {
  10788. case msg.FieldCreatedAt:
  10789. m.ResetCreatedAt()
  10790. return nil
  10791. case msg.FieldUpdatedAt:
  10792. m.ResetUpdatedAt()
  10793. return nil
  10794. case msg.FieldDeletedAt:
  10795. m.ResetDeletedAt()
  10796. return nil
  10797. case msg.FieldStatus:
  10798. m.ResetStatus()
  10799. return nil
  10800. case msg.FieldFromwxid:
  10801. m.ResetFromwxid()
  10802. return nil
  10803. case msg.FieldToid:
  10804. m.ResetToid()
  10805. return nil
  10806. case msg.FieldMsgtype:
  10807. m.ResetMsgtype()
  10808. return nil
  10809. case msg.FieldMsg:
  10810. m.ResetMsg()
  10811. return nil
  10812. case msg.FieldBatchNo:
  10813. m.ResetBatchNo()
  10814. return nil
  10815. }
  10816. return fmt.Errorf("unknown Msg field %s", name)
  10817. }
  10818. // AddedEdges returns all edge names that were set/added in this mutation.
  10819. func (m *MsgMutation) AddedEdges() []string {
  10820. edges := make([]string, 0, 0)
  10821. return edges
  10822. }
  10823. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10824. // name in this mutation.
  10825. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  10826. return nil
  10827. }
  10828. // RemovedEdges returns all edge names that were removed in this mutation.
  10829. func (m *MsgMutation) RemovedEdges() []string {
  10830. edges := make([]string, 0, 0)
  10831. return edges
  10832. }
  10833. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10834. // the given name in this mutation.
  10835. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  10836. return nil
  10837. }
  10838. // ClearedEdges returns all edge names that were cleared in this mutation.
  10839. func (m *MsgMutation) ClearedEdges() []string {
  10840. edges := make([]string, 0, 0)
  10841. return edges
  10842. }
  10843. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10844. // was cleared in this mutation.
  10845. func (m *MsgMutation) EdgeCleared(name string) bool {
  10846. return false
  10847. }
  10848. // ClearEdge clears the value of the edge with the given name. It returns an error
  10849. // if that edge is not defined in the schema.
  10850. func (m *MsgMutation) ClearEdge(name string) error {
  10851. return fmt.Errorf("unknown Msg unique edge %s", name)
  10852. }
  10853. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10854. // It returns an error if the edge is not defined in the schema.
  10855. func (m *MsgMutation) ResetEdge(name string) error {
  10856. return fmt.Errorf("unknown Msg edge %s", name)
  10857. }
  10858. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  10859. type ServerMutation struct {
  10860. config
  10861. op Op
  10862. typ string
  10863. id *uint64
  10864. created_at *time.Time
  10865. updated_at *time.Time
  10866. status *uint8
  10867. addstatus *int8
  10868. deleted_at *time.Time
  10869. name *string
  10870. public_ip *string
  10871. private_ip *string
  10872. admin_port *string
  10873. clearedFields map[string]struct{}
  10874. wxs map[uint64]struct{}
  10875. removedwxs map[uint64]struct{}
  10876. clearedwxs bool
  10877. done bool
  10878. oldValue func(context.Context) (*Server, error)
  10879. predicates []predicate.Server
  10880. }
  10881. var _ ent.Mutation = (*ServerMutation)(nil)
  10882. // serverOption allows management of the mutation configuration using functional options.
  10883. type serverOption func(*ServerMutation)
  10884. // newServerMutation creates new mutation for the Server entity.
  10885. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  10886. m := &ServerMutation{
  10887. config: c,
  10888. op: op,
  10889. typ: TypeServer,
  10890. clearedFields: make(map[string]struct{}),
  10891. }
  10892. for _, opt := range opts {
  10893. opt(m)
  10894. }
  10895. return m
  10896. }
  10897. // withServerID sets the ID field of the mutation.
  10898. func withServerID(id uint64) serverOption {
  10899. return func(m *ServerMutation) {
  10900. var (
  10901. err error
  10902. once sync.Once
  10903. value *Server
  10904. )
  10905. m.oldValue = func(ctx context.Context) (*Server, error) {
  10906. once.Do(func() {
  10907. if m.done {
  10908. err = errors.New("querying old values post mutation is not allowed")
  10909. } else {
  10910. value, err = m.Client().Server.Get(ctx, id)
  10911. }
  10912. })
  10913. return value, err
  10914. }
  10915. m.id = &id
  10916. }
  10917. }
  10918. // withServer sets the old Server of the mutation.
  10919. func withServer(node *Server) serverOption {
  10920. return func(m *ServerMutation) {
  10921. m.oldValue = func(context.Context) (*Server, error) {
  10922. return node, nil
  10923. }
  10924. m.id = &node.ID
  10925. }
  10926. }
  10927. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10928. // executed in a transaction (ent.Tx), a transactional client is returned.
  10929. func (m ServerMutation) Client() *Client {
  10930. client := &Client{config: m.config}
  10931. client.init()
  10932. return client
  10933. }
  10934. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10935. // it returns an error otherwise.
  10936. func (m ServerMutation) Tx() (*Tx, error) {
  10937. if _, ok := m.driver.(*txDriver); !ok {
  10938. return nil, errors.New("ent: mutation is not running in a transaction")
  10939. }
  10940. tx := &Tx{config: m.config}
  10941. tx.init()
  10942. return tx, nil
  10943. }
  10944. // SetID sets the value of the id field. Note that this
  10945. // operation is only accepted on creation of Server entities.
  10946. func (m *ServerMutation) SetID(id uint64) {
  10947. m.id = &id
  10948. }
  10949. // ID returns the ID value in the mutation. Note that the ID is only available
  10950. // if it was provided to the builder or after it was returned from the database.
  10951. func (m *ServerMutation) ID() (id uint64, exists bool) {
  10952. if m.id == nil {
  10953. return
  10954. }
  10955. return *m.id, true
  10956. }
  10957. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10958. // That means, if the mutation is applied within a transaction with an isolation level such
  10959. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10960. // or updated by the mutation.
  10961. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  10962. switch {
  10963. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10964. id, exists := m.ID()
  10965. if exists {
  10966. return []uint64{id}, nil
  10967. }
  10968. fallthrough
  10969. case m.op.Is(OpUpdate | OpDelete):
  10970. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  10971. default:
  10972. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10973. }
  10974. }
  10975. // SetCreatedAt sets the "created_at" field.
  10976. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  10977. m.created_at = &t
  10978. }
  10979. // CreatedAt returns the value of the "created_at" field in the mutation.
  10980. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  10981. v := m.created_at
  10982. if v == nil {
  10983. return
  10984. }
  10985. return *v, true
  10986. }
  10987. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  10988. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  10989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10990. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10991. if !m.op.Is(OpUpdateOne) {
  10992. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10993. }
  10994. if m.id == nil || m.oldValue == nil {
  10995. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10996. }
  10997. oldValue, err := m.oldValue(ctx)
  10998. if err != nil {
  10999. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11000. }
  11001. return oldValue.CreatedAt, nil
  11002. }
  11003. // ResetCreatedAt resets all changes to the "created_at" field.
  11004. func (m *ServerMutation) ResetCreatedAt() {
  11005. m.created_at = nil
  11006. }
  11007. // SetUpdatedAt sets the "updated_at" field.
  11008. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  11009. m.updated_at = &t
  11010. }
  11011. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11012. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  11013. v := m.updated_at
  11014. if v == nil {
  11015. return
  11016. }
  11017. return *v, true
  11018. }
  11019. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  11020. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11022. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11023. if !m.op.Is(OpUpdateOne) {
  11024. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11025. }
  11026. if m.id == nil || m.oldValue == nil {
  11027. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11028. }
  11029. oldValue, err := m.oldValue(ctx)
  11030. if err != nil {
  11031. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11032. }
  11033. return oldValue.UpdatedAt, nil
  11034. }
  11035. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11036. func (m *ServerMutation) ResetUpdatedAt() {
  11037. m.updated_at = nil
  11038. }
  11039. // SetStatus sets the "status" field.
  11040. func (m *ServerMutation) SetStatus(u uint8) {
  11041. m.status = &u
  11042. m.addstatus = nil
  11043. }
  11044. // Status returns the value of the "status" field in the mutation.
  11045. func (m *ServerMutation) Status() (r uint8, exists bool) {
  11046. v := m.status
  11047. if v == nil {
  11048. return
  11049. }
  11050. return *v, true
  11051. }
  11052. // OldStatus returns the old "status" field's value of the Server entity.
  11053. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11055. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11056. if !m.op.Is(OpUpdateOne) {
  11057. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11058. }
  11059. if m.id == nil || m.oldValue == nil {
  11060. return v, errors.New("OldStatus requires an ID field in the mutation")
  11061. }
  11062. oldValue, err := m.oldValue(ctx)
  11063. if err != nil {
  11064. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11065. }
  11066. return oldValue.Status, nil
  11067. }
  11068. // AddStatus adds u to the "status" field.
  11069. func (m *ServerMutation) AddStatus(u int8) {
  11070. if m.addstatus != nil {
  11071. *m.addstatus += u
  11072. } else {
  11073. m.addstatus = &u
  11074. }
  11075. }
  11076. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11077. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  11078. v := m.addstatus
  11079. if v == nil {
  11080. return
  11081. }
  11082. return *v, true
  11083. }
  11084. // ClearStatus clears the value of the "status" field.
  11085. func (m *ServerMutation) ClearStatus() {
  11086. m.status = nil
  11087. m.addstatus = nil
  11088. m.clearedFields[server.FieldStatus] = struct{}{}
  11089. }
  11090. // StatusCleared returns if the "status" field was cleared in this mutation.
  11091. func (m *ServerMutation) StatusCleared() bool {
  11092. _, ok := m.clearedFields[server.FieldStatus]
  11093. return ok
  11094. }
  11095. // ResetStatus resets all changes to the "status" field.
  11096. func (m *ServerMutation) ResetStatus() {
  11097. m.status = nil
  11098. m.addstatus = nil
  11099. delete(m.clearedFields, server.FieldStatus)
  11100. }
  11101. // SetDeletedAt sets the "deleted_at" field.
  11102. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  11103. m.deleted_at = &t
  11104. }
  11105. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11106. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  11107. v := m.deleted_at
  11108. if v == nil {
  11109. return
  11110. }
  11111. return *v, true
  11112. }
  11113. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  11114. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11116. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11117. if !m.op.Is(OpUpdateOne) {
  11118. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11119. }
  11120. if m.id == nil || m.oldValue == nil {
  11121. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11122. }
  11123. oldValue, err := m.oldValue(ctx)
  11124. if err != nil {
  11125. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11126. }
  11127. return oldValue.DeletedAt, nil
  11128. }
  11129. // ClearDeletedAt clears the value of the "deleted_at" field.
  11130. func (m *ServerMutation) ClearDeletedAt() {
  11131. m.deleted_at = nil
  11132. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  11133. }
  11134. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11135. func (m *ServerMutation) DeletedAtCleared() bool {
  11136. _, ok := m.clearedFields[server.FieldDeletedAt]
  11137. return ok
  11138. }
  11139. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11140. func (m *ServerMutation) ResetDeletedAt() {
  11141. m.deleted_at = nil
  11142. delete(m.clearedFields, server.FieldDeletedAt)
  11143. }
  11144. // SetName sets the "name" field.
  11145. func (m *ServerMutation) SetName(s string) {
  11146. m.name = &s
  11147. }
  11148. // Name returns the value of the "name" field in the mutation.
  11149. func (m *ServerMutation) Name() (r string, exists bool) {
  11150. v := m.name
  11151. if v == nil {
  11152. return
  11153. }
  11154. return *v, true
  11155. }
  11156. // OldName returns the old "name" field's value of the Server entity.
  11157. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11159. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  11160. if !m.op.Is(OpUpdateOne) {
  11161. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11162. }
  11163. if m.id == nil || m.oldValue == nil {
  11164. return v, errors.New("OldName requires an ID field in the mutation")
  11165. }
  11166. oldValue, err := m.oldValue(ctx)
  11167. if err != nil {
  11168. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11169. }
  11170. return oldValue.Name, nil
  11171. }
  11172. // ResetName resets all changes to the "name" field.
  11173. func (m *ServerMutation) ResetName() {
  11174. m.name = nil
  11175. }
  11176. // SetPublicIP sets the "public_ip" field.
  11177. func (m *ServerMutation) SetPublicIP(s string) {
  11178. m.public_ip = &s
  11179. }
  11180. // PublicIP returns the value of the "public_ip" field in the mutation.
  11181. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  11182. v := m.public_ip
  11183. if v == nil {
  11184. return
  11185. }
  11186. return *v, true
  11187. }
  11188. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  11189. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11191. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  11192. if !m.op.Is(OpUpdateOne) {
  11193. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  11194. }
  11195. if m.id == nil || m.oldValue == nil {
  11196. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  11197. }
  11198. oldValue, err := m.oldValue(ctx)
  11199. if err != nil {
  11200. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  11201. }
  11202. return oldValue.PublicIP, nil
  11203. }
  11204. // ResetPublicIP resets all changes to the "public_ip" field.
  11205. func (m *ServerMutation) ResetPublicIP() {
  11206. m.public_ip = nil
  11207. }
  11208. // SetPrivateIP sets the "private_ip" field.
  11209. func (m *ServerMutation) SetPrivateIP(s string) {
  11210. m.private_ip = &s
  11211. }
  11212. // PrivateIP returns the value of the "private_ip" field in the mutation.
  11213. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  11214. v := m.private_ip
  11215. if v == nil {
  11216. return
  11217. }
  11218. return *v, true
  11219. }
  11220. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  11221. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11223. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  11224. if !m.op.Is(OpUpdateOne) {
  11225. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  11226. }
  11227. if m.id == nil || m.oldValue == nil {
  11228. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  11229. }
  11230. oldValue, err := m.oldValue(ctx)
  11231. if err != nil {
  11232. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  11233. }
  11234. return oldValue.PrivateIP, nil
  11235. }
  11236. // ResetPrivateIP resets all changes to the "private_ip" field.
  11237. func (m *ServerMutation) ResetPrivateIP() {
  11238. m.private_ip = nil
  11239. }
  11240. // SetAdminPort sets the "admin_port" field.
  11241. func (m *ServerMutation) SetAdminPort(s string) {
  11242. m.admin_port = &s
  11243. }
  11244. // AdminPort returns the value of the "admin_port" field in the mutation.
  11245. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  11246. v := m.admin_port
  11247. if v == nil {
  11248. return
  11249. }
  11250. return *v, true
  11251. }
  11252. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  11253. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  11254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11255. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  11256. if !m.op.Is(OpUpdateOne) {
  11257. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  11258. }
  11259. if m.id == nil || m.oldValue == nil {
  11260. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  11261. }
  11262. oldValue, err := m.oldValue(ctx)
  11263. if err != nil {
  11264. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  11265. }
  11266. return oldValue.AdminPort, nil
  11267. }
  11268. // ResetAdminPort resets all changes to the "admin_port" field.
  11269. func (m *ServerMutation) ResetAdminPort() {
  11270. m.admin_port = nil
  11271. }
  11272. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  11273. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  11274. if m.wxs == nil {
  11275. m.wxs = make(map[uint64]struct{})
  11276. }
  11277. for i := range ids {
  11278. m.wxs[ids[i]] = struct{}{}
  11279. }
  11280. }
  11281. // ClearWxs clears the "wxs" edge to the Wx entity.
  11282. func (m *ServerMutation) ClearWxs() {
  11283. m.clearedwxs = true
  11284. }
  11285. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  11286. func (m *ServerMutation) WxsCleared() bool {
  11287. return m.clearedwxs
  11288. }
  11289. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  11290. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  11291. if m.removedwxs == nil {
  11292. m.removedwxs = make(map[uint64]struct{})
  11293. }
  11294. for i := range ids {
  11295. delete(m.wxs, ids[i])
  11296. m.removedwxs[ids[i]] = struct{}{}
  11297. }
  11298. }
  11299. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  11300. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  11301. for id := range m.removedwxs {
  11302. ids = append(ids, id)
  11303. }
  11304. return
  11305. }
  11306. // WxsIDs returns the "wxs" edge IDs in the mutation.
  11307. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  11308. for id := range m.wxs {
  11309. ids = append(ids, id)
  11310. }
  11311. return
  11312. }
  11313. // ResetWxs resets all changes to the "wxs" edge.
  11314. func (m *ServerMutation) ResetWxs() {
  11315. m.wxs = nil
  11316. m.clearedwxs = false
  11317. m.removedwxs = nil
  11318. }
  11319. // Where appends a list predicates to the ServerMutation builder.
  11320. func (m *ServerMutation) Where(ps ...predicate.Server) {
  11321. m.predicates = append(m.predicates, ps...)
  11322. }
  11323. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  11324. // users can use type-assertion to append predicates that do not depend on any generated package.
  11325. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  11326. p := make([]predicate.Server, len(ps))
  11327. for i := range ps {
  11328. p[i] = ps[i]
  11329. }
  11330. m.Where(p...)
  11331. }
  11332. // Op returns the operation name.
  11333. func (m *ServerMutation) Op() Op {
  11334. return m.op
  11335. }
  11336. // SetOp allows setting the mutation operation.
  11337. func (m *ServerMutation) SetOp(op Op) {
  11338. m.op = op
  11339. }
  11340. // Type returns the node type of this mutation (Server).
  11341. func (m *ServerMutation) Type() string {
  11342. return m.typ
  11343. }
  11344. // Fields returns all fields that were changed during this mutation. Note that in
  11345. // order to get all numeric fields that were incremented/decremented, call
  11346. // AddedFields().
  11347. func (m *ServerMutation) Fields() []string {
  11348. fields := make([]string, 0, 8)
  11349. if m.created_at != nil {
  11350. fields = append(fields, server.FieldCreatedAt)
  11351. }
  11352. if m.updated_at != nil {
  11353. fields = append(fields, server.FieldUpdatedAt)
  11354. }
  11355. if m.status != nil {
  11356. fields = append(fields, server.FieldStatus)
  11357. }
  11358. if m.deleted_at != nil {
  11359. fields = append(fields, server.FieldDeletedAt)
  11360. }
  11361. if m.name != nil {
  11362. fields = append(fields, server.FieldName)
  11363. }
  11364. if m.public_ip != nil {
  11365. fields = append(fields, server.FieldPublicIP)
  11366. }
  11367. if m.private_ip != nil {
  11368. fields = append(fields, server.FieldPrivateIP)
  11369. }
  11370. if m.admin_port != nil {
  11371. fields = append(fields, server.FieldAdminPort)
  11372. }
  11373. return fields
  11374. }
  11375. // Field returns the value of a field with the given name. The second boolean
  11376. // return value indicates that this field was not set, or was not defined in the
  11377. // schema.
  11378. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  11379. switch name {
  11380. case server.FieldCreatedAt:
  11381. return m.CreatedAt()
  11382. case server.FieldUpdatedAt:
  11383. return m.UpdatedAt()
  11384. case server.FieldStatus:
  11385. return m.Status()
  11386. case server.FieldDeletedAt:
  11387. return m.DeletedAt()
  11388. case server.FieldName:
  11389. return m.Name()
  11390. case server.FieldPublicIP:
  11391. return m.PublicIP()
  11392. case server.FieldPrivateIP:
  11393. return m.PrivateIP()
  11394. case server.FieldAdminPort:
  11395. return m.AdminPort()
  11396. }
  11397. return nil, false
  11398. }
  11399. // OldField returns the old value of the field from the database. An error is
  11400. // returned if the mutation operation is not UpdateOne, or the query to the
  11401. // database failed.
  11402. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11403. switch name {
  11404. case server.FieldCreatedAt:
  11405. return m.OldCreatedAt(ctx)
  11406. case server.FieldUpdatedAt:
  11407. return m.OldUpdatedAt(ctx)
  11408. case server.FieldStatus:
  11409. return m.OldStatus(ctx)
  11410. case server.FieldDeletedAt:
  11411. return m.OldDeletedAt(ctx)
  11412. case server.FieldName:
  11413. return m.OldName(ctx)
  11414. case server.FieldPublicIP:
  11415. return m.OldPublicIP(ctx)
  11416. case server.FieldPrivateIP:
  11417. return m.OldPrivateIP(ctx)
  11418. case server.FieldAdminPort:
  11419. return m.OldAdminPort(ctx)
  11420. }
  11421. return nil, fmt.Errorf("unknown Server field %s", name)
  11422. }
  11423. // SetField sets the value of a field with the given name. It returns an error if
  11424. // the field is not defined in the schema, or if the type mismatched the field
  11425. // type.
  11426. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  11427. switch name {
  11428. case server.FieldCreatedAt:
  11429. v, ok := value.(time.Time)
  11430. if !ok {
  11431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11432. }
  11433. m.SetCreatedAt(v)
  11434. return nil
  11435. case server.FieldUpdatedAt:
  11436. v, ok := value.(time.Time)
  11437. if !ok {
  11438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11439. }
  11440. m.SetUpdatedAt(v)
  11441. return nil
  11442. case server.FieldStatus:
  11443. v, ok := value.(uint8)
  11444. if !ok {
  11445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11446. }
  11447. m.SetStatus(v)
  11448. return nil
  11449. case server.FieldDeletedAt:
  11450. v, ok := value.(time.Time)
  11451. if !ok {
  11452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11453. }
  11454. m.SetDeletedAt(v)
  11455. return nil
  11456. case server.FieldName:
  11457. v, ok := value.(string)
  11458. if !ok {
  11459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11460. }
  11461. m.SetName(v)
  11462. return nil
  11463. case server.FieldPublicIP:
  11464. v, ok := value.(string)
  11465. if !ok {
  11466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11467. }
  11468. m.SetPublicIP(v)
  11469. return nil
  11470. case server.FieldPrivateIP:
  11471. v, ok := value.(string)
  11472. if !ok {
  11473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11474. }
  11475. m.SetPrivateIP(v)
  11476. return nil
  11477. case server.FieldAdminPort:
  11478. v, ok := value.(string)
  11479. if !ok {
  11480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11481. }
  11482. m.SetAdminPort(v)
  11483. return nil
  11484. }
  11485. return fmt.Errorf("unknown Server field %s", name)
  11486. }
  11487. // AddedFields returns all numeric fields that were incremented/decremented during
  11488. // this mutation.
  11489. func (m *ServerMutation) AddedFields() []string {
  11490. var fields []string
  11491. if m.addstatus != nil {
  11492. fields = append(fields, server.FieldStatus)
  11493. }
  11494. return fields
  11495. }
  11496. // AddedField returns the numeric value that was incremented/decremented on a field
  11497. // with the given name. The second boolean return value indicates that this field
  11498. // was not set, or was not defined in the schema.
  11499. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  11500. switch name {
  11501. case server.FieldStatus:
  11502. return m.AddedStatus()
  11503. }
  11504. return nil, false
  11505. }
  11506. // AddField adds the value to the field with the given name. It returns an error if
  11507. // the field is not defined in the schema, or if the type mismatched the field
  11508. // type.
  11509. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  11510. switch name {
  11511. case server.FieldStatus:
  11512. v, ok := value.(int8)
  11513. if !ok {
  11514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11515. }
  11516. m.AddStatus(v)
  11517. return nil
  11518. }
  11519. return fmt.Errorf("unknown Server numeric field %s", name)
  11520. }
  11521. // ClearedFields returns all nullable fields that were cleared during this
  11522. // mutation.
  11523. func (m *ServerMutation) ClearedFields() []string {
  11524. var fields []string
  11525. if m.FieldCleared(server.FieldStatus) {
  11526. fields = append(fields, server.FieldStatus)
  11527. }
  11528. if m.FieldCleared(server.FieldDeletedAt) {
  11529. fields = append(fields, server.FieldDeletedAt)
  11530. }
  11531. return fields
  11532. }
  11533. // FieldCleared returns a boolean indicating if a field with the given name was
  11534. // cleared in this mutation.
  11535. func (m *ServerMutation) FieldCleared(name string) bool {
  11536. _, ok := m.clearedFields[name]
  11537. return ok
  11538. }
  11539. // ClearField clears the value of the field with the given name. It returns an
  11540. // error if the field is not defined in the schema.
  11541. func (m *ServerMutation) ClearField(name string) error {
  11542. switch name {
  11543. case server.FieldStatus:
  11544. m.ClearStatus()
  11545. return nil
  11546. case server.FieldDeletedAt:
  11547. m.ClearDeletedAt()
  11548. return nil
  11549. }
  11550. return fmt.Errorf("unknown Server nullable field %s", name)
  11551. }
  11552. // ResetField resets all changes in the mutation for the field with the given name.
  11553. // It returns an error if the field is not defined in the schema.
  11554. func (m *ServerMutation) ResetField(name string) error {
  11555. switch name {
  11556. case server.FieldCreatedAt:
  11557. m.ResetCreatedAt()
  11558. return nil
  11559. case server.FieldUpdatedAt:
  11560. m.ResetUpdatedAt()
  11561. return nil
  11562. case server.FieldStatus:
  11563. m.ResetStatus()
  11564. return nil
  11565. case server.FieldDeletedAt:
  11566. m.ResetDeletedAt()
  11567. return nil
  11568. case server.FieldName:
  11569. m.ResetName()
  11570. return nil
  11571. case server.FieldPublicIP:
  11572. m.ResetPublicIP()
  11573. return nil
  11574. case server.FieldPrivateIP:
  11575. m.ResetPrivateIP()
  11576. return nil
  11577. case server.FieldAdminPort:
  11578. m.ResetAdminPort()
  11579. return nil
  11580. }
  11581. return fmt.Errorf("unknown Server field %s", name)
  11582. }
  11583. // AddedEdges returns all edge names that were set/added in this mutation.
  11584. func (m *ServerMutation) AddedEdges() []string {
  11585. edges := make([]string, 0, 1)
  11586. if m.wxs != nil {
  11587. edges = append(edges, server.EdgeWxs)
  11588. }
  11589. return edges
  11590. }
  11591. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11592. // name in this mutation.
  11593. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  11594. switch name {
  11595. case server.EdgeWxs:
  11596. ids := make([]ent.Value, 0, len(m.wxs))
  11597. for id := range m.wxs {
  11598. ids = append(ids, id)
  11599. }
  11600. return ids
  11601. }
  11602. return nil
  11603. }
  11604. // RemovedEdges returns all edge names that were removed in this mutation.
  11605. func (m *ServerMutation) RemovedEdges() []string {
  11606. edges := make([]string, 0, 1)
  11607. if m.removedwxs != nil {
  11608. edges = append(edges, server.EdgeWxs)
  11609. }
  11610. return edges
  11611. }
  11612. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11613. // the given name in this mutation.
  11614. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  11615. switch name {
  11616. case server.EdgeWxs:
  11617. ids := make([]ent.Value, 0, len(m.removedwxs))
  11618. for id := range m.removedwxs {
  11619. ids = append(ids, id)
  11620. }
  11621. return ids
  11622. }
  11623. return nil
  11624. }
  11625. // ClearedEdges returns all edge names that were cleared in this mutation.
  11626. func (m *ServerMutation) ClearedEdges() []string {
  11627. edges := make([]string, 0, 1)
  11628. if m.clearedwxs {
  11629. edges = append(edges, server.EdgeWxs)
  11630. }
  11631. return edges
  11632. }
  11633. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11634. // was cleared in this mutation.
  11635. func (m *ServerMutation) EdgeCleared(name string) bool {
  11636. switch name {
  11637. case server.EdgeWxs:
  11638. return m.clearedwxs
  11639. }
  11640. return false
  11641. }
  11642. // ClearEdge clears the value of the edge with the given name. It returns an error
  11643. // if that edge is not defined in the schema.
  11644. func (m *ServerMutation) ClearEdge(name string) error {
  11645. switch name {
  11646. }
  11647. return fmt.Errorf("unknown Server unique edge %s", name)
  11648. }
  11649. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11650. // It returns an error if the edge is not defined in the schema.
  11651. func (m *ServerMutation) ResetEdge(name string) error {
  11652. switch name {
  11653. case server.EdgeWxs:
  11654. m.ResetWxs()
  11655. return nil
  11656. }
  11657. return fmt.Errorf("unknown Server edge %s", name)
  11658. }
  11659. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  11660. type SopNodeMutation struct {
  11661. config
  11662. op Op
  11663. typ string
  11664. id *uint64
  11665. created_at *time.Time
  11666. updated_at *time.Time
  11667. status *uint8
  11668. addstatus *int8
  11669. deleted_at *time.Time
  11670. parent_id *uint64
  11671. addparent_id *int64
  11672. name *string
  11673. condition_type *int
  11674. addcondition_type *int
  11675. condition_list *[]string
  11676. appendcondition_list []string
  11677. no_reply_condition *uint64
  11678. addno_reply_condition *int64
  11679. action_message *[]custom_types.Action
  11680. appendaction_message []custom_types.Action
  11681. action_label *[]uint64
  11682. appendaction_label []uint64
  11683. clearedFields map[string]struct{}
  11684. sop_stage *uint64
  11685. clearedsop_stage bool
  11686. node_messages map[uint64]struct{}
  11687. removednode_messages map[uint64]struct{}
  11688. clearednode_messages bool
  11689. done bool
  11690. oldValue func(context.Context) (*SopNode, error)
  11691. predicates []predicate.SopNode
  11692. }
  11693. var _ ent.Mutation = (*SopNodeMutation)(nil)
  11694. // sopnodeOption allows management of the mutation configuration using functional options.
  11695. type sopnodeOption func(*SopNodeMutation)
  11696. // newSopNodeMutation creates new mutation for the SopNode entity.
  11697. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  11698. m := &SopNodeMutation{
  11699. config: c,
  11700. op: op,
  11701. typ: TypeSopNode,
  11702. clearedFields: make(map[string]struct{}),
  11703. }
  11704. for _, opt := range opts {
  11705. opt(m)
  11706. }
  11707. return m
  11708. }
  11709. // withSopNodeID sets the ID field of the mutation.
  11710. func withSopNodeID(id uint64) sopnodeOption {
  11711. return func(m *SopNodeMutation) {
  11712. var (
  11713. err error
  11714. once sync.Once
  11715. value *SopNode
  11716. )
  11717. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  11718. once.Do(func() {
  11719. if m.done {
  11720. err = errors.New("querying old values post mutation is not allowed")
  11721. } else {
  11722. value, err = m.Client().SopNode.Get(ctx, id)
  11723. }
  11724. })
  11725. return value, err
  11726. }
  11727. m.id = &id
  11728. }
  11729. }
  11730. // withSopNode sets the old SopNode of the mutation.
  11731. func withSopNode(node *SopNode) sopnodeOption {
  11732. return func(m *SopNodeMutation) {
  11733. m.oldValue = func(context.Context) (*SopNode, error) {
  11734. return node, nil
  11735. }
  11736. m.id = &node.ID
  11737. }
  11738. }
  11739. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11740. // executed in a transaction (ent.Tx), a transactional client is returned.
  11741. func (m SopNodeMutation) Client() *Client {
  11742. client := &Client{config: m.config}
  11743. client.init()
  11744. return client
  11745. }
  11746. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11747. // it returns an error otherwise.
  11748. func (m SopNodeMutation) Tx() (*Tx, error) {
  11749. if _, ok := m.driver.(*txDriver); !ok {
  11750. return nil, errors.New("ent: mutation is not running in a transaction")
  11751. }
  11752. tx := &Tx{config: m.config}
  11753. tx.init()
  11754. return tx, nil
  11755. }
  11756. // SetID sets the value of the id field. Note that this
  11757. // operation is only accepted on creation of SopNode entities.
  11758. func (m *SopNodeMutation) SetID(id uint64) {
  11759. m.id = &id
  11760. }
  11761. // ID returns the ID value in the mutation. Note that the ID is only available
  11762. // if it was provided to the builder or after it was returned from the database.
  11763. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  11764. if m.id == nil {
  11765. return
  11766. }
  11767. return *m.id, true
  11768. }
  11769. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11770. // That means, if the mutation is applied within a transaction with an isolation level such
  11771. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11772. // or updated by the mutation.
  11773. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11774. switch {
  11775. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11776. id, exists := m.ID()
  11777. if exists {
  11778. return []uint64{id}, nil
  11779. }
  11780. fallthrough
  11781. case m.op.Is(OpUpdate | OpDelete):
  11782. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  11783. default:
  11784. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11785. }
  11786. }
  11787. // SetCreatedAt sets the "created_at" field.
  11788. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  11789. m.created_at = &t
  11790. }
  11791. // CreatedAt returns the value of the "created_at" field in the mutation.
  11792. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  11793. v := m.created_at
  11794. if v == nil {
  11795. return
  11796. }
  11797. return *v, true
  11798. }
  11799. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  11800. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11802. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11803. if !m.op.Is(OpUpdateOne) {
  11804. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11805. }
  11806. if m.id == nil || m.oldValue == nil {
  11807. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11808. }
  11809. oldValue, err := m.oldValue(ctx)
  11810. if err != nil {
  11811. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11812. }
  11813. return oldValue.CreatedAt, nil
  11814. }
  11815. // ResetCreatedAt resets all changes to the "created_at" field.
  11816. func (m *SopNodeMutation) ResetCreatedAt() {
  11817. m.created_at = nil
  11818. }
  11819. // SetUpdatedAt sets the "updated_at" field.
  11820. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  11821. m.updated_at = &t
  11822. }
  11823. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11824. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  11825. v := m.updated_at
  11826. if v == nil {
  11827. return
  11828. }
  11829. return *v, true
  11830. }
  11831. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  11832. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11834. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11835. if !m.op.Is(OpUpdateOne) {
  11836. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11837. }
  11838. if m.id == nil || m.oldValue == nil {
  11839. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11840. }
  11841. oldValue, err := m.oldValue(ctx)
  11842. if err != nil {
  11843. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11844. }
  11845. return oldValue.UpdatedAt, nil
  11846. }
  11847. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11848. func (m *SopNodeMutation) ResetUpdatedAt() {
  11849. m.updated_at = nil
  11850. }
  11851. // SetStatus sets the "status" field.
  11852. func (m *SopNodeMutation) SetStatus(u uint8) {
  11853. m.status = &u
  11854. m.addstatus = nil
  11855. }
  11856. // Status returns the value of the "status" field in the mutation.
  11857. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  11858. v := m.status
  11859. if v == nil {
  11860. return
  11861. }
  11862. return *v, true
  11863. }
  11864. // OldStatus returns the old "status" field's value of the SopNode entity.
  11865. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11867. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11868. if !m.op.Is(OpUpdateOne) {
  11869. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11870. }
  11871. if m.id == nil || m.oldValue == nil {
  11872. return v, errors.New("OldStatus requires an ID field in the mutation")
  11873. }
  11874. oldValue, err := m.oldValue(ctx)
  11875. if err != nil {
  11876. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11877. }
  11878. return oldValue.Status, nil
  11879. }
  11880. // AddStatus adds u to the "status" field.
  11881. func (m *SopNodeMutation) AddStatus(u int8) {
  11882. if m.addstatus != nil {
  11883. *m.addstatus += u
  11884. } else {
  11885. m.addstatus = &u
  11886. }
  11887. }
  11888. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11889. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  11890. v := m.addstatus
  11891. if v == nil {
  11892. return
  11893. }
  11894. return *v, true
  11895. }
  11896. // ClearStatus clears the value of the "status" field.
  11897. func (m *SopNodeMutation) ClearStatus() {
  11898. m.status = nil
  11899. m.addstatus = nil
  11900. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  11901. }
  11902. // StatusCleared returns if the "status" field was cleared in this mutation.
  11903. func (m *SopNodeMutation) StatusCleared() bool {
  11904. _, ok := m.clearedFields[sopnode.FieldStatus]
  11905. return ok
  11906. }
  11907. // ResetStatus resets all changes to the "status" field.
  11908. func (m *SopNodeMutation) ResetStatus() {
  11909. m.status = nil
  11910. m.addstatus = nil
  11911. delete(m.clearedFields, sopnode.FieldStatus)
  11912. }
  11913. // SetDeletedAt sets the "deleted_at" field.
  11914. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  11915. m.deleted_at = &t
  11916. }
  11917. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11918. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  11919. v := m.deleted_at
  11920. if v == nil {
  11921. return
  11922. }
  11923. return *v, true
  11924. }
  11925. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  11926. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11928. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11929. if !m.op.Is(OpUpdateOne) {
  11930. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11931. }
  11932. if m.id == nil || m.oldValue == nil {
  11933. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11934. }
  11935. oldValue, err := m.oldValue(ctx)
  11936. if err != nil {
  11937. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11938. }
  11939. return oldValue.DeletedAt, nil
  11940. }
  11941. // ClearDeletedAt clears the value of the "deleted_at" field.
  11942. func (m *SopNodeMutation) ClearDeletedAt() {
  11943. m.deleted_at = nil
  11944. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  11945. }
  11946. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11947. func (m *SopNodeMutation) DeletedAtCleared() bool {
  11948. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  11949. return ok
  11950. }
  11951. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11952. func (m *SopNodeMutation) ResetDeletedAt() {
  11953. m.deleted_at = nil
  11954. delete(m.clearedFields, sopnode.FieldDeletedAt)
  11955. }
  11956. // SetStageID sets the "stage_id" field.
  11957. func (m *SopNodeMutation) SetStageID(u uint64) {
  11958. m.sop_stage = &u
  11959. }
  11960. // StageID returns the value of the "stage_id" field in the mutation.
  11961. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  11962. v := m.sop_stage
  11963. if v == nil {
  11964. return
  11965. }
  11966. return *v, true
  11967. }
  11968. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  11969. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  11970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11971. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  11972. if !m.op.Is(OpUpdateOne) {
  11973. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  11974. }
  11975. if m.id == nil || m.oldValue == nil {
  11976. return v, errors.New("OldStageID requires an ID field in the mutation")
  11977. }
  11978. oldValue, err := m.oldValue(ctx)
  11979. if err != nil {
  11980. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  11981. }
  11982. return oldValue.StageID, nil
  11983. }
  11984. // ResetStageID resets all changes to the "stage_id" field.
  11985. func (m *SopNodeMutation) ResetStageID() {
  11986. m.sop_stage = nil
  11987. }
  11988. // SetParentID sets the "parent_id" field.
  11989. func (m *SopNodeMutation) SetParentID(u uint64) {
  11990. m.parent_id = &u
  11991. m.addparent_id = nil
  11992. }
  11993. // ParentID returns the value of the "parent_id" field in the mutation.
  11994. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  11995. v := m.parent_id
  11996. if v == nil {
  11997. return
  11998. }
  11999. return *v, true
  12000. }
  12001. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  12002. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12004. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  12005. if !m.op.Is(OpUpdateOne) {
  12006. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  12007. }
  12008. if m.id == nil || m.oldValue == nil {
  12009. return v, errors.New("OldParentID requires an ID field in the mutation")
  12010. }
  12011. oldValue, err := m.oldValue(ctx)
  12012. if err != nil {
  12013. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  12014. }
  12015. return oldValue.ParentID, nil
  12016. }
  12017. // AddParentID adds u to the "parent_id" field.
  12018. func (m *SopNodeMutation) AddParentID(u int64) {
  12019. if m.addparent_id != nil {
  12020. *m.addparent_id += u
  12021. } else {
  12022. m.addparent_id = &u
  12023. }
  12024. }
  12025. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  12026. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  12027. v := m.addparent_id
  12028. if v == nil {
  12029. return
  12030. }
  12031. return *v, true
  12032. }
  12033. // ResetParentID resets all changes to the "parent_id" field.
  12034. func (m *SopNodeMutation) ResetParentID() {
  12035. m.parent_id = nil
  12036. m.addparent_id = nil
  12037. }
  12038. // SetName sets the "name" field.
  12039. func (m *SopNodeMutation) SetName(s string) {
  12040. m.name = &s
  12041. }
  12042. // Name returns the value of the "name" field in the mutation.
  12043. func (m *SopNodeMutation) Name() (r string, exists bool) {
  12044. v := m.name
  12045. if v == nil {
  12046. return
  12047. }
  12048. return *v, true
  12049. }
  12050. // OldName returns the old "name" field's value of the SopNode entity.
  12051. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12053. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  12054. if !m.op.Is(OpUpdateOne) {
  12055. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12056. }
  12057. if m.id == nil || m.oldValue == nil {
  12058. return v, errors.New("OldName requires an ID field in the mutation")
  12059. }
  12060. oldValue, err := m.oldValue(ctx)
  12061. if err != nil {
  12062. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12063. }
  12064. return oldValue.Name, nil
  12065. }
  12066. // ResetName resets all changes to the "name" field.
  12067. func (m *SopNodeMutation) ResetName() {
  12068. m.name = nil
  12069. }
  12070. // SetConditionType sets the "condition_type" field.
  12071. func (m *SopNodeMutation) SetConditionType(i int) {
  12072. m.condition_type = &i
  12073. m.addcondition_type = nil
  12074. }
  12075. // ConditionType returns the value of the "condition_type" field in the mutation.
  12076. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  12077. v := m.condition_type
  12078. if v == nil {
  12079. return
  12080. }
  12081. return *v, true
  12082. }
  12083. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  12084. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12086. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  12087. if !m.op.Is(OpUpdateOne) {
  12088. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  12089. }
  12090. if m.id == nil || m.oldValue == nil {
  12091. return v, errors.New("OldConditionType requires an ID field in the mutation")
  12092. }
  12093. oldValue, err := m.oldValue(ctx)
  12094. if err != nil {
  12095. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  12096. }
  12097. return oldValue.ConditionType, nil
  12098. }
  12099. // AddConditionType adds i to the "condition_type" field.
  12100. func (m *SopNodeMutation) AddConditionType(i int) {
  12101. if m.addcondition_type != nil {
  12102. *m.addcondition_type += i
  12103. } else {
  12104. m.addcondition_type = &i
  12105. }
  12106. }
  12107. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  12108. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  12109. v := m.addcondition_type
  12110. if v == nil {
  12111. return
  12112. }
  12113. return *v, true
  12114. }
  12115. // ResetConditionType resets all changes to the "condition_type" field.
  12116. func (m *SopNodeMutation) ResetConditionType() {
  12117. m.condition_type = nil
  12118. m.addcondition_type = nil
  12119. }
  12120. // SetConditionList sets the "condition_list" field.
  12121. func (m *SopNodeMutation) SetConditionList(s []string) {
  12122. m.condition_list = &s
  12123. m.appendcondition_list = nil
  12124. }
  12125. // ConditionList returns the value of the "condition_list" field in the mutation.
  12126. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  12127. v := m.condition_list
  12128. if v == nil {
  12129. return
  12130. }
  12131. return *v, true
  12132. }
  12133. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  12134. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12136. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  12137. if !m.op.Is(OpUpdateOne) {
  12138. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  12139. }
  12140. if m.id == nil || m.oldValue == nil {
  12141. return v, errors.New("OldConditionList requires an ID field in the mutation")
  12142. }
  12143. oldValue, err := m.oldValue(ctx)
  12144. if err != nil {
  12145. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  12146. }
  12147. return oldValue.ConditionList, nil
  12148. }
  12149. // AppendConditionList adds s to the "condition_list" field.
  12150. func (m *SopNodeMutation) AppendConditionList(s []string) {
  12151. m.appendcondition_list = append(m.appendcondition_list, s...)
  12152. }
  12153. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  12154. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  12155. if len(m.appendcondition_list) == 0 {
  12156. return nil, false
  12157. }
  12158. return m.appendcondition_list, true
  12159. }
  12160. // ClearConditionList clears the value of the "condition_list" field.
  12161. func (m *SopNodeMutation) ClearConditionList() {
  12162. m.condition_list = nil
  12163. m.appendcondition_list = nil
  12164. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  12165. }
  12166. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  12167. func (m *SopNodeMutation) ConditionListCleared() bool {
  12168. _, ok := m.clearedFields[sopnode.FieldConditionList]
  12169. return ok
  12170. }
  12171. // ResetConditionList resets all changes to the "condition_list" field.
  12172. func (m *SopNodeMutation) ResetConditionList() {
  12173. m.condition_list = nil
  12174. m.appendcondition_list = nil
  12175. delete(m.clearedFields, sopnode.FieldConditionList)
  12176. }
  12177. // SetNoReplyCondition sets the "no_reply_condition" field.
  12178. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  12179. m.no_reply_condition = &u
  12180. m.addno_reply_condition = nil
  12181. }
  12182. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  12183. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  12184. v := m.no_reply_condition
  12185. if v == nil {
  12186. return
  12187. }
  12188. return *v, true
  12189. }
  12190. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  12191. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12193. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  12194. if !m.op.Is(OpUpdateOne) {
  12195. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  12196. }
  12197. if m.id == nil || m.oldValue == nil {
  12198. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  12199. }
  12200. oldValue, err := m.oldValue(ctx)
  12201. if err != nil {
  12202. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  12203. }
  12204. return oldValue.NoReplyCondition, nil
  12205. }
  12206. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  12207. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  12208. if m.addno_reply_condition != nil {
  12209. *m.addno_reply_condition += u
  12210. } else {
  12211. m.addno_reply_condition = &u
  12212. }
  12213. }
  12214. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  12215. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  12216. v := m.addno_reply_condition
  12217. if v == nil {
  12218. return
  12219. }
  12220. return *v, true
  12221. }
  12222. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  12223. func (m *SopNodeMutation) ResetNoReplyCondition() {
  12224. m.no_reply_condition = nil
  12225. m.addno_reply_condition = nil
  12226. }
  12227. // SetActionMessage sets the "action_message" field.
  12228. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  12229. m.action_message = &ct
  12230. m.appendaction_message = nil
  12231. }
  12232. // ActionMessage returns the value of the "action_message" field in the mutation.
  12233. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  12234. v := m.action_message
  12235. if v == nil {
  12236. return
  12237. }
  12238. return *v, true
  12239. }
  12240. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  12241. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12243. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  12244. if !m.op.Is(OpUpdateOne) {
  12245. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  12246. }
  12247. if m.id == nil || m.oldValue == nil {
  12248. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  12249. }
  12250. oldValue, err := m.oldValue(ctx)
  12251. if err != nil {
  12252. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  12253. }
  12254. return oldValue.ActionMessage, nil
  12255. }
  12256. // AppendActionMessage adds ct to the "action_message" field.
  12257. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  12258. m.appendaction_message = append(m.appendaction_message, ct...)
  12259. }
  12260. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  12261. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  12262. if len(m.appendaction_message) == 0 {
  12263. return nil, false
  12264. }
  12265. return m.appendaction_message, true
  12266. }
  12267. // ClearActionMessage clears the value of the "action_message" field.
  12268. func (m *SopNodeMutation) ClearActionMessage() {
  12269. m.action_message = nil
  12270. m.appendaction_message = nil
  12271. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  12272. }
  12273. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  12274. func (m *SopNodeMutation) ActionMessageCleared() bool {
  12275. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  12276. return ok
  12277. }
  12278. // ResetActionMessage resets all changes to the "action_message" field.
  12279. func (m *SopNodeMutation) ResetActionMessage() {
  12280. m.action_message = nil
  12281. m.appendaction_message = nil
  12282. delete(m.clearedFields, sopnode.FieldActionMessage)
  12283. }
  12284. // SetActionLabel sets the "action_label" field.
  12285. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  12286. m.action_label = &u
  12287. m.appendaction_label = nil
  12288. }
  12289. // ActionLabel returns the value of the "action_label" field in the mutation.
  12290. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  12291. v := m.action_label
  12292. if v == nil {
  12293. return
  12294. }
  12295. return *v, true
  12296. }
  12297. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  12298. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  12299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12300. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  12301. if !m.op.Is(OpUpdateOne) {
  12302. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  12303. }
  12304. if m.id == nil || m.oldValue == nil {
  12305. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  12306. }
  12307. oldValue, err := m.oldValue(ctx)
  12308. if err != nil {
  12309. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  12310. }
  12311. return oldValue.ActionLabel, nil
  12312. }
  12313. // AppendActionLabel adds u to the "action_label" field.
  12314. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  12315. m.appendaction_label = append(m.appendaction_label, u...)
  12316. }
  12317. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  12318. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  12319. if len(m.appendaction_label) == 0 {
  12320. return nil, false
  12321. }
  12322. return m.appendaction_label, true
  12323. }
  12324. // ClearActionLabel clears the value of the "action_label" field.
  12325. func (m *SopNodeMutation) ClearActionLabel() {
  12326. m.action_label = nil
  12327. m.appendaction_label = nil
  12328. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  12329. }
  12330. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  12331. func (m *SopNodeMutation) ActionLabelCleared() bool {
  12332. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  12333. return ok
  12334. }
  12335. // ResetActionLabel resets all changes to the "action_label" field.
  12336. func (m *SopNodeMutation) ResetActionLabel() {
  12337. m.action_label = nil
  12338. m.appendaction_label = nil
  12339. delete(m.clearedFields, sopnode.FieldActionLabel)
  12340. }
  12341. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  12342. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  12343. m.sop_stage = &id
  12344. }
  12345. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  12346. func (m *SopNodeMutation) ClearSopStage() {
  12347. m.clearedsop_stage = true
  12348. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  12349. }
  12350. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  12351. func (m *SopNodeMutation) SopStageCleared() bool {
  12352. return m.clearedsop_stage
  12353. }
  12354. // SopStageID returns the "sop_stage" edge ID in the mutation.
  12355. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  12356. if m.sop_stage != nil {
  12357. return *m.sop_stage, true
  12358. }
  12359. return
  12360. }
  12361. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  12362. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12363. // SopStageID instead. It exists only for internal usage by the builders.
  12364. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  12365. if id := m.sop_stage; id != nil {
  12366. ids = append(ids, *id)
  12367. }
  12368. return
  12369. }
  12370. // ResetSopStage resets all changes to the "sop_stage" edge.
  12371. func (m *SopNodeMutation) ResetSopStage() {
  12372. m.sop_stage = nil
  12373. m.clearedsop_stage = false
  12374. }
  12375. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  12376. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  12377. if m.node_messages == nil {
  12378. m.node_messages = make(map[uint64]struct{})
  12379. }
  12380. for i := range ids {
  12381. m.node_messages[ids[i]] = struct{}{}
  12382. }
  12383. }
  12384. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  12385. func (m *SopNodeMutation) ClearNodeMessages() {
  12386. m.clearednode_messages = true
  12387. }
  12388. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  12389. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  12390. return m.clearednode_messages
  12391. }
  12392. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  12393. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  12394. if m.removednode_messages == nil {
  12395. m.removednode_messages = make(map[uint64]struct{})
  12396. }
  12397. for i := range ids {
  12398. delete(m.node_messages, ids[i])
  12399. m.removednode_messages[ids[i]] = struct{}{}
  12400. }
  12401. }
  12402. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  12403. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  12404. for id := range m.removednode_messages {
  12405. ids = append(ids, id)
  12406. }
  12407. return
  12408. }
  12409. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  12410. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  12411. for id := range m.node_messages {
  12412. ids = append(ids, id)
  12413. }
  12414. return
  12415. }
  12416. // ResetNodeMessages resets all changes to the "node_messages" edge.
  12417. func (m *SopNodeMutation) ResetNodeMessages() {
  12418. m.node_messages = nil
  12419. m.clearednode_messages = false
  12420. m.removednode_messages = nil
  12421. }
  12422. // Where appends a list predicates to the SopNodeMutation builder.
  12423. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  12424. m.predicates = append(m.predicates, ps...)
  12425. }
  12426. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  12427. // users can use type-assertion to append predicates that do not depend on any generated package.
  12428. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  12429. p := make([]predicate.SopNode, len(ps))
  12430. for i := range ps {
  12431. p[i] = ps[i]
  12432. }
  12433. m.Where(p...)
  12434. }
  12435. // Op returns the operation name.
  12436. func (m *SopNodeMutation) Op() Op {
  12437. return m.op
  12438. }
  12439. // SetOp allows setting the mutation operation.
  12440. func (m *SopNodeMutation) SetOp(op Op) {
  12441. m.op = op
  12442. }
  12443. // Type returns the node type of this mutation (SopNode).
  12444. func (m *SopNodeMutation) Type() string {
  12445. return m.typ
  12446. }
  12447. // Fields returns all fields that were changed during this mutation. Note that in
  12448. // order to get all numeric fields that were incremented/decremented, call
  12449. // AddedFields().
  12450. func (m *SopNodeMutation) Fields() []string {
  12451. fields := make([]string, 0, 12)
  12452. if m.created_at != nil {
  12453. fields = append(fields, sopnode.FieldCreatedAt)
  12454. }
  12455. if m.updated_at != nil {
  12456. fields = append(fields, sopnode.FieldUpdatedAt)
  12457. }
  12458. if m.status != nil {
  12459. fields = append(fields, sopnode.FieldStatus)
  12460. }
  12461. if m.deleted_at != nil {
  12462. fields = append(fields, sopnode.FieldDeletedAt)
  12463. }
  12464. if m.sop_stage != nil {
  12465. fields = append(fields, sopnode.FieldStageID)
  12466. }
  12467. if m.parent_id != nil {
  12468. fields = append(fields, sopnode.FieldParentID)
  12469. }
  12470. if m.name != nil {
  12471. fields = append(fields, sopnode.FieldName)
  12472. }
  12473. if m.condition_type != nil {
  12474. fields = append(fields, sopnode.FieldConditionType)
  12475. }
  12476. if m.condition_list != nil {
  12477. fields = append(fields, sopnode.FieldConditionList)
  12478. }
  12479. if m.no_reply_condition != nil {
  12480. fields = append(fields, sopnode.FieldNoReplyCondition)
  12481. }
  12482. if m.action_message != nil {
  12483. fields = append(fields, sopnode.FieldActionMessage)
  12484. }
  12485. if m.action_label != nil {
  12486. fields = append(fields, sopnode.FieldActionLabel)
  12487. }
  12488. return fields
  12489. }
  12490. // Field returns the value of a field with the given name. The second boolean
  12491. // return value indicates that this field was not set, or was not defined in the
  12492. // schema.
  12493. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  12494. switch name {
  12495. case sopnode.FieldCreatedAt:
  12496. return m.CreatedAt()
  12497. case sopnode.FieldUpdatedAt:
  12498. return m.UpdatedAt()
  12499. case sopnode.FieldStatus:
  12500. return m.Status()
  12501. case sopnode.FieldDeletedAt:
  12502. return m.DeletedAt()
  12503. case sopnode.FieldStageID:
  12504. return m.StageID()
  12505. case sopnode.FieldParentID:
  12506. return m.ParentID()
  12507. case sopnode.FieldName:
  12508. return m.Name()
  12509. case sopnode.FieldConditionType:
  12510. return m.ConditionType()
  12511. case sopnode.FieldConditionList:
  12512. return m.ConditionList()
  12513. case sopnode.FieldNoReplyCondition:
  12514. return m.NoReplyCondition()
  12515. case sopnode.FieldActionMessage:
  12516. return m.ActionMessage()
  12517. case sopnode.FieldActionLabel:
  12518. return m.ActionLabel()
  12519. }
  12520. return nil, false
  12521. }
  12522. // OldField returns the old value of the field from the database. An error is
  12523. // returned if the mutation operation is not UpdateOne, or the query to the
  12524. // database failed.
  12525. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12526. switch name {
  12527. case sopnode.FieldCreatedAt:
  12528. return m.OldCreatedAt(ctx)
  12529. case sopnode.FieldUpdatedAt:
  12530. return m.OldUpdatedAt(ctx)
  12531. case sopnode.FieldStatus:
  12532. return m.OldStatus(ctx)
  12533. case sopnode.FieldDeletedAt:
  12534. return m.OldDeletedAt(ctx)
  12535. case sopnode.FieldStageID:
  12536. return m.OldStageID(ctx)
  12537. case sopnode.FieldParentID:
  12538. return m.OldParentID(ctx)
  12539. case sopnode.FieldName:
  12540. return m.OldName(ctx)
  12541. case sopnode.FieldConditionType:
  12542. return m.OldConditionType(ctx)
  12543. case sopnode.FieldConditionList:
  12544. return m.OldConditionList(ctx)
  12545. case sopnode.FieldNoReplyCondition:
  12546. return m.OldNoReplyCondition(ctx)
  12547. case sopnode.FieldActionMessage:
  12548. return m.OldActionMessage(ctx)
  12549. case sopnode.FieldActionLabel:
  12550. return m.OldActionLabel(ctx)
  12551. }
  12552. return nil, fmt.Errorf("unknown SopNode field %s", name)
  12553. }
  12554. // SetField sets the value of a field with the given name. It returns an error if
  12555. // the field is not defined in the schema, or if the type mismatched the field
  12556. // type.
  12557. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  12558. switch name {
  12559. case sopnode.FieldCreatedAt:
  12560. v, ok := value.(time.Time)
  12561. if !ok {
  12562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12563. }
  12564. m.SetCreatedAt(v)
  12565. return nil
  12566. case sopnode.FieldUpdatedAt:
  12567. v, ok := value.(time.Time)
  12568. if !ok {
  12569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12570. }
  12571. m.SetUpdatedAt(v)
  12572. return nil
  12573. case sopnode.FieldStatus:
  12574. v, ok := value.(uint8)
  12575. if !ok {
  12576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12577. }
  12578. m.SetStatus(v)
  12579. return nil
  12580. case sopnode.FieldDeletedAt:
  12581. v, ok := value.(time.Time)
  12582. if !ok {
  12583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12584. }
  12585. m.SetDeletedAt(v)
  12586. return nil
  12587. case sopnode.FieldStageID:
  12588. v, ok := value.(uint64)
  12589. if !ok {
  12590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12591. }
  12592. m.SetStageID(v)
  12593. return nil
  12594. case sopnode.FieldParentID:
  12595. v, ok := value.(uint64)
  12596. if !ok {
  12597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12598. }
  12599. m.SetParentID(v)
  12600. return nil
  12601. case sopnode.FieldName:
  12602. v, ok := value.(string)
  12603. if !ok {
  12604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12605. }
  12606. m.SetName(v)
  12607. return nil
  12608. case sopnode.FieldConditionType:
  12609. v, ok := value.(int)
  12610. if !ok {
  12611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12612. }
  12613. m.SetConditionType(v)
  12614. return nil
  12615. case sopnode.FieldConditionList:
  12616. v, ok := value.([]string)
  12617. if !ok {
  12618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12619. }
  12620. m.SetConditionList(v)
  12621. return nil
  12622. case sopnode.FieldNoReplyCondition:
  12623. v, ok := value.(uint64)
  12624. if !ok {
  12625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12626. }
  12627. m.SetNoReplyCondition(v)
  12628. return nil
  12629. case sopnode.FieldActionMessage:
  12630. v, ok := value.([]custom_types.Action)
  12631. if !ok {
  12632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12633. }
  12634. m.SetActionMessage(v)
  12635. return nil
  12636. case sopnode.FieldActionLabel:
  12637. v, ok := value.([]uint64)
  12638. if !ok {
  12639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12640. }
  12641. m.SetActionLabel(v)
  12642. return nil
  12643. }
  12644. return fmt.Errorf("unknown SopNode field %s", name)
  12645. }
  12646. // AddedFields returns all numeric fields that were incremented/decremented during
  12647. // this mutation.
  12648. func (m *SopNodeMutation) AddedFields() []string {
  12649. var fields []string
  12650. if m.addstatus != nil {
  12651. fields = append(fields, sopnode.FieldStatus)
  12652. }
  12653. if m.addparent_id != nil {
  12654. fields = append(fields, sopnode.FieldParentID)
  12655. }
  12656. if m.addcondition_type != nil {
  12657. fields = append(fields, sopnode.FieldConditionType)
  12658. }
  12659. if m.addno_reply_condition != nil {
  12660. fields = append(fields, sopnode.FieldNoReplyCondition)
  12661. }
  12662. return fields
  12663. }
  12664. // AddedField returns the numeric value that was incremented/decremented on a field
  12665. // with the given name. The second boolean return value indicates that this field
  12666. // was not set, or was not defined in the schema.
  12667. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  12668. switch name {
  12669. case sopnode.FieldStatus:
  12670. return m.AddedStatus()
  12671. case sopnode.FieldParentID:
  12672. return m.AddedParentID()
  12673. case sopnode.FieldConditionType:
  12674. return m.AddedConditionType()
  12675. case sopnode.FieldNoReplyCondition:
  12676. return m.AddedNoReplyCondition()
  12677. }
  12678. return nil, false
  12679. }
  12680. // AddField adds the value to the field with the given name. It returns an error if
  12681. // the field is not defined in the schema, or if the type mismatched the field
  12682. // type.
  12683. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  12684. switch name {
  12685. case sopnode.FieldStatus:
  12686. v, ok := value.(int8)
  12687. if !ok {
  12688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12689. }
  12690. m.AddStatus(v)
  12691. return nil
  12692. case sopnode.FieldParentID:
  12693. v, ok := value.(int64)
  12694. if !ok {
  12695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12696. }
  12697. m.AddParentID(v)
  12698. return nil
  12699. case sopnode.FieldConditionType:
  12700. v, ok := value.(int)
  12701. if !ok {
  12702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12703. }
  12704. m.AddConditionType(v)
  12705. return nil
  12706. case sopnode.FieldNoReplyCondition:
  12707. v, ok := value.(int64)
  12708. if !ok {
  12709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12710. }
  12711. m.AddNoReplyCondition(v)
  12712. return nil
  12713. }
  12714. return fmt.Errorf("unknown SopNode numeric field %s", name)
  12715. }
  12716. // ClearedFields returns all nullable fields that were cleared during this
  12717. // mutation.
  12718. func (m *SopNodeMutation) ClearedFields() []string {
  12719. var fields []string
  12720. if m.FieldCleared(sopnode.FieldStatus) {
  12721. fields = append(fields, sopnode.FieldStatus)
  12722. }
  12723. if m.FieldCleared(sopnode.FieldDeletedAt) {
  12724. fields = append(fields, sopnode.FieldDeletedAt)
  12725. }
  12726. if m.FieldCleared(sopnode.FieldConditionList) {
  12727. fields = append(fields, sopnode.FieldConditionList)
  12728. }
  12729. if m.FieldCleared(sopnode.FieldActionMessage) {
  12730. fields = append(fields, sopnode.FieldActionMessage)
  12731. }
  12732. if m.FieldCleared(sopnode.FieldActionLabel) {
  12733. fields = append(fields, sopnode.FieldActionLabel)
  12734. }
  12735. return fields
  12736. }
  12737. // FieldCleared returns a boolean indicating if a field with the given name was
  12738. // cleared in this mutation.
  12739. func (m *SopNodeMutation) FieldCleared(name string) bool {
  12740. _, ok := m.clearedFields[name]
  12741. return ok
  12742. }
  12743. // ClearField clears the value of the field with the given name. It returns an
  12744. // error if the field is not defined in the schema.
  12745. func (m *SopNodeMutation) ClearField(name string) error {
  12746. switch name {
  12747. case sopnode.FieldStatus:
  12748. m.ClearStatus()
  12749. return nil
  12750. case sopnode.FieldDeletedAt:
  12751. m.ClearDeletedAt()
  12752. return nil
  12753. case sopnode.FieldConditionList:
  12754. m.ClearConditionList()
  12755. return nil
  12756. case sopnode.FieldActionMessage:
  12757. m.ClearActionMessage()
  12758. return nil
  12759. case sopnode.FieldActionLabel:
  12760. m.ClearActionLabel()
  12761. return nil
  12762. }
  12763. return fmt.Errorf("unknown SopNode nullable field %s", name)
  12764. }
  12765. // ResetField resets all changes in the mutation for the field with the given name.
  12766. // It returns an error if the field is not defined in the schema.
  12767. func (m *SopNodeMutation) ResetField(name string) error {
  12768. switch name {
  12769. case sopnode.FieldCreatedAt:
  12770. m.ResetCreatedAt()
  12771. return nil
  12772. case sopnode.FieldUpdatedAt:
  12773. m.ResetUpdatedAt()
  12774. return nil
  12775. case sopnode.FieldStatus:
  12776. m.ResetStatus()
  12777. return nil
  12778. case sopnode.FieldDeletedAt:
  12779. m.ResetDeletedAt()
  12780. return nil
  12781. case sopnode.FieldStageID:
  12782. m.ResetStageID()
  12783. return nil
  12784. case sopnode.FieldParentID:
  12785. m.ResetParentID()
  12786. return nil
  12787. case sopnode.FieldName:
  12788. m.ResetName()
  12789. return nil
  12790. case sopnode.FieldConditionType:
  12791. m.ResetConditionType()
  12792. return nil
  12793. case sopnode.FieldConditionList:
  12794. m.ResetConditionList()
  12795. return nil
  12796. case sopnode.FieldNoReplyCondition:
  12797. m.ResetNoReplyCondition()
  12798. return nil
  12799. case sopnode.FieldActionMessage:
  12800. m.ResetActionMessage()
  12801. return nil
  12802. case sopnode.FieldActionLabel:
  12803. m.ResetActionLabel()
  12804. return nil
  12805. }
  12806. return fmt.Errorf("unknown SopNode field %s", name)
  12807. }
  12808. // AddedEdges returns all edge names that were set/added in this mutation.
  12809. func (m *SopNodeMutation) AddedEdges() []string {
  12810. edges := make([]string, 0, 2)
  12811. if m.sop_stage != nil {
  12812. edges = append(edges, sopnode.EdgeSopStage)
  12813. }
  12814. if m.node_messages != nil {
  12815. edges = append(edges, sopnode.EdgeNodeMessages)
  12816. }
  12817. return edges
  12818. }
  12819. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12820. // name in this mutation.
  12821. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  12822. switch name {
  12823. case sopnode.EdgeSopStage:
  12824. if id := m.sop_stage; id != nil {
  12825. return []ent.Value{*id}
  12826. }
  12827. case sopnode.EdgeNodeMessages:
  12828. ids := make([]ent.Value, 0, len(m.node_messages))
  12829. for id := range m.node_messages {
  12830. ids = append(ids, id)
  12831. }
  12832. return ids
  12833. }
  12834. return nil
  12835. }
  12836. // RemovedEdges returns all edge names that were removed in this mutation.
  12837. func (m *SopNodeMutation) RemovedEdges() []string {
  12838. edges := make([]string, 0, 2)
  12839. if m.removednode_messages != nil {
  12840. edges = append(edges, sopnode.EdgeNodeMessages)
  12841. }
  12842. return edges
  12843. }
  12844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12845. // the given name in this mutation.
  12846. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  12847. switch name {
  12848. case sopnode.EdgeNodeMessages:
  12849. ids := make([]ent.Value, 0, len(m.removednode_messages))
  12850. for id := range m.removednode_messages {
  12851. ids = append(ids, id)
  12852. }
  12853. return ids
  12854. }
  12855. return nil
  12856. }
  12857. // ClearedEdges returns all edge names that were cleared in this mutation.
  12858. func (m *SopNodeMutation) ClearedEdges() []string {
  12859. edges := make([]string, 0, 2)
  12860. if m.clearedsop_stage {
  12861. edges = append(edges, sopnode.EdgeSopStage)
  12862. }
  12863. if m.clearednode_messages {
  12864. edges = append(edges, sopnode.EdgeNodeMessages)
  12865. }
  12866. return edges
  12867. }
  12868. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12869. // was cleared in this mutation.
  12870. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  12871. switch name {
  12872. case sopnode.EdgeSopStage:
  12873. return m.clearedsop_stage
  12874. case sopnode.EdgeNodeMessages:
  12875. return m.clearednode_messages
  12876. }
  12877. return false
  12878. }
  12879. // ClearEdge clears the value of the edge with the given name. It returns an error
  12880. // if that edge is not defined in the schema.
  12881. func (m *SopNodeMutation) ClearEdge(name string) error {
  12882. switch name {
  12883. case sopnode.EdgeSopStage:
  12884. m.ClearSopStage()
  12885. return nil
  12886. }
  12887. return fmt.Errorf("unknown SopNode unique edge %s", name)
  12888. }
  12889. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12890. // It returns an error if the edge is not defined in the schema.
  12891. func (m *SopNodeMutation) ResetEdge(name string) error {
  12892. switch name {
  12893. case sopnode.EdgeSopStage:
  12894. m.ResetSopStage()
  12895. return nil
  12896. case sopnode.EdgeNodeMessages:
  12897. m.ResetNodeMessages()
  12898. return nil
  12899. }
  12900. return fmt.Errorf("unknown SopNode edge %s", name)
  12901. }
  12902. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  12903. type SopStageMutation struct {
  12904. config
  12905. op Op
  12906. typ string
  12907. id *uint64
  12908. created_at *time.Time
  12909. updated_at *time.Time
  12910. status *uint8
  12911. addstatus *int8
  12912. deleted_at *time.Time
  12913. name *string
  12914. condition_type *int
  12915. addcondition_type *int
  12916. condition_operator *int
  12917. addcondition_operator *int
  12918. condition_list *[]custom_types.Condition
  12919. appendcondition_list []custom_types.Condition
  12920. action_message *[]custom_types.Action
  12921. appendaction_message []custom_types.Action
  12922. action_label *[]uint64
  12923. appendaction_label []uint64
  12924. index_sort *int
  12925. addindex_sort *int
  12926. clearedFields map[string]struct{}
  12927. sop_task *uint64
  12928. clearedsop_task bool
  12929. stage_nodes map[uint64]struct{}
  12930. removedstage_nodes map[uint64]struct{}
  12931. clearedstage_nodes bool
  12932. stage_messages map[uint64]struct{}
  12933. removedstage_messages map[uint64]struct{}
  12934. clearedstage_messages bool
  12935. done bool
  12936. oldValue func(context.Context) (*SopStage, error)
  12937. predicates []predicate.SopStage
  12938. }
  12939. var _ ent.Mutation = (*SopStageMutation)(nil)
  12940. // sopstageOption allows management of the mutation configuration using functional options.
  12941. type sopstageOption func(*SopStageMutation)
  12942. // newSopStageMutation creates new mutation for the SopStage entity.
  12943. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  12944. m := &SopStageMutation{
  12945. config: c,
  12946. op: op,
  12947. typ: TypeSopStage,
  12948. clearedFields: make(map[string]struct{}),
  12949. }
  12950. for _, opt := range opts {
  12951. opt(m)
  12952. }
  12953. return m
  12954. }
  12955. // withSopStageID sets the ID field of the mutation.
  12956. func withSopStageID(id uint64) sopstageOption {
  12957. return func(m *SopStageMutation) {
  12958. var (
  12959. err error
  12960. once sync.Once
  12961. value *SopStage
  12962. )
  12963. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  12964. once.Do(func() {
  12965. if m.done {
  12966. err = errors.New("querying old values post mutation is not allowed")
  12967. } else {
  12968. value, err = m.Client().SopStage.Get(ctx, id)
  12969. }
  12970. })
  12971. return value, err
  12972. }
  12973. m.id = &id
  12974. }
  12975. }
  12976. // withSopStage sets the old SopStage of the mutation.
  12977. func withSopStage(node *SopStage) sopstageOption {
  12978. return func(m *SopStageMutation) {
  12979. m.oldValue = func(context.Context) (*SopStage, error) {
  12980. return node, nil
  12981. }
  12982. m.id = &node.ID
  12983. }
  12984. }
  12985. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12986. // executed in a transaction (ent.Tx), a transactional client is returned.
  12987. func (m SopStageMutation) Client() *Client {
  12988. client := &Client{config: m.config}
  12989. client.init()
  12990. return client
  12991. }
  12992. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12993. // it returns an error otherwise.
  12994. func (m SopStageMutation) Tx() (*Tx, error) {
  12995. if _, ok := m.driver.(*txDriver); !ok {
  12996. return nil, errors.New("ent: mutation is not running in a transaction")
  12997. }
  12998. tx := &Tx{config: m.config}
  12999. tx.init()
  13000. return tx, nil
  13001. }
  13002. // SetID sets the value of the id field. Note that this
  13003. // operation is only accepted on creation of SopStage entities.
  13004. func (m *SopStageMutation) SetID(id uint64) {
  13005. m.id = &id
  13006. }
  13007. // ID returns the ID value in the mutation. Note that the ID is only available
  13008. // if it was provided to the builder or after it was returned from the database.
  13009. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  13010. if m.id == nil {
  13011. return
  13012. }
  13013. return *m.id, true
  13014. }
  13015. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13016. // That means, if the mutation is applied within a transaction with an isolation level such
  13017. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13018. // or updated by the mutation.
  13019. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13020. switch {
  13021. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13022. id, exists := m.ID()
  13023. if exists {
  13024. return []uint64{id}, nil
  13025. }
  13026. fallthrough
  13027. case m.op.Is(OpUpdate | OpDelete):
  13028. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  13029. default:
  13030. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13031. }
  13032. }
  13033. // SetCreatedAt sets the "created_at" field.
  13034. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  13035. m.created_at = &t
  13036. }
  13037. // CreatedAt returns the value of the "created_at" field in the mutation.
  13038. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  13039. v := m.created_at
  13040. if v == nil {
  13041. return
  13042. }
  13043. return *v, true
  13044. }
  13045. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  13046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13048. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13049. if !m.op.Is(OpUpdateOne) {
  13050. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13051. }
  13052. if m.id == nil || m.oldValue == nil {
  13053. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13054. }
  13055. oldValue, err := m.oldValue(ctx)
  13056. if err != nil {
  13057. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13058. }
  13059. return oldValue.CreatedAt, nil
  13060. }
  13061. // ResetCreatedAt resets all changes to the "created_at" field.
  13062. func (m *SopStageMutation) ResetCreatedAt() {
  13063. m.created_at = nil
  13064. }
  13065. // SetUpdatedAt sets the "updated_at" field.
  13066. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  13067. m.updated_at = &t
  13068. }
  13069. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13070. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  13071. v := m.updated_at
  13072. if v == nil {
  13073. return
  13074. }
  13075. return *v, true
  13076. }
  13077. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  13078. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13080. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13081. if !m.op.Is(OpUpdateOne) {
  13082. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13083. }
  13084. if m.id == nil || m.oldValue == nil {
  13085. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13086. }
  13087. oldValue, err := m.oldValue(ctx)
  13088. if err != nil {
  13089. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13090. }
  13091. return oldValue.UpdatedAt, nil
  13092. }
  13093. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13094. func (m *SopStageMutation) ResetUpdatedAt() {
  13095. m.updated_at = nil
  13096. }
  13097. // SetStatus sets the "status" field.
  13098. func (m *SopStageMutation) SetStatus(u uint8) {
  13099. m.status = &u
  13100. m.addstatus = nil
  13101. }
  13102. // Status returns the value of the "status" field in the mutation.
  13103. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  13104. v := m.status
  13105. if v == nil {
  13106. return
  13107. }
  13108. return *v, true
  13109. }
  13110. // OldStatus returns the old "status" field's value of the SopStage entity.
  13111. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13113. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13114. if !m.op.Is(OpUpdateOne) {
  13115. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13116. }
  13117. if m.id == nil || m.oldValue == nil {
  13118. return v, errors.New("OldStatus requires an ID field in the mutation")
  13119. }
  13120. oldValue, err := m.oldValue(ctx)
  13121. if err != nil {
  13122. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13123. }
  13124. return oldValue.Status, nil
  13125. }
  13126. // AddStatus adds u to the "status" field.
  13127. func (m *SopStageMutation) AddStatus(u int8) {
  13128. if m.addstatus != nil {
  13129. *m.addstatus += u
  13130. } else {
  13131. m.addstatus = &u
  13132. }
  13133. }
  13134. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13135. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  13136. v := m.addstatus
  13137. if v == nil {
  13138. return
  13139. }
  13140. return *v, true
  13141. }
  13142. // ClearStatus clears the value of the "status" field.
  13143. func (m *SopStageMutation) ClearStatus() {
  13144. m.status = nil
  13145. m.addstatus = nil
  13146. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  13147. }
  13148. // StatusCleared returns if the "status" field was cleared in this mutation.
  13149. func (m *SopStageMutation) StatusCleared() bool {
  13150. _, ok := m.clearedFields[sopstage.FieldStatus]
  13151. return ok
  13152. }
  13153. // ResetStatus resets all changes to the "status" field.
  13154. func (m *SopStageMutation) ResetStatus() {
  13155. m.status = nil
  13156. m.addstatus = nil
  13157. delete(m.clearedFields, sopstage.FieldStatus)
  13158. }
  13159. // SetDeletedAt sets the "deleted_at" field.
  13160. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  13161. m.deleted_at = &t
  13162. }
  13163. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13164. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  13165. v := m.deleted_at
  13166. if v == nil {
  13167. return
  13168. }
  13169. return *v, true
  13170. }
  13171. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  13172. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13174. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13175. if !m.op.Is(OpUpdateOne) {
  13176. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13177. }
  13178. if m.id == nil || m.oldValue == nil {
  13179. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13180. }
  13181. oldValue, err := m.oldValue(ctx)
  13182. if err != nil {
  13183. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13184. }
  13185. return oldValue.DeletedAt, nil
  13186. }
  13187. // ClearDeletedAt clears the value of the "deleted_at" field.
  13188. func (m *SopStageMutation) ClearDeletedAt() {
  13189. m.deleted_at = nil
  13190. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  13191. }
  13192. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13193. func (m *SopStageMutation) DeletedAtCleared() bool {
  13194. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  13195. return ok
  13196. }
  13197. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13198. func (m *SopStageMutation) ResetDeletedAt() {
  13199. m.deleted_at = nil
  13200. delete(m.clearedFields, sopstage.FieldDeletedAt)
  13201. }
  13202. // SetTaskID sets the "task_id" field.
  13203. func (m *SopStageMutation) SetTaskID(u uint64) {
  13204. m.sop_task = &u
  13205. }
  13206. // TaskID returns the value of the "task_id" field in the mutation.
  13207. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  13208. v := m.sop_task
  13209. if v == nil {
  13210. return
  13211. }
  13212. return *v, true
  13213. }
  13214. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  13215. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13217. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  13218. if !m.op.Is(OpUpdateOne) {
  13219. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  13220. }
  13221. if m.id == nil || m.oldValue == nil {
  13222. return v, errors.New("OldTaskID requires an ID field in the mutation")
  13223. }
  13224. oldValue, err := m.oldValue(ctx)
  13225. if err != nil {
  13226. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  13227. }
  13228. return oldValue.TaskID, nil
  13229. }
  13230. // ResetTaskID resets all changes to the "task_id" field.
  13231. func (m *SopStageMutation) ResetTaskID() {
  13232. m.sop_task = nil
  13233. }
  13234. // SetName sets the "name" field.
  13235. func (m *SopStageMutation) SetName(s string) {
  13236. m.name = &s
  13237. }
  13238. // Name returns the value of the "name" field in the mutation.
  13239. func (m *SopStageMutation) Name() (r string, exists bool) {
  13240. v := m.name
  13241. if v == nil {
  13242. return
  13243. }
  13244. return *v, true
  13245. }
  13246. // OldName returns the old "name" field's value of the SopStage entity.
  13247. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13249. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  13250. if !m.op.Is(OpUpdateOne) {
  13251. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13252. }
  13253. if m.id == nil || m.oldValue == nil {
  13254. return v, errors.New("OldName requires an ID field in the mutation")
  13255. }
  13256. oldValue, err := m.oldValue(ctx)
  13257. if err != nil {
  13258. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13259. }
  13260. return oldValue.Name, nil
  13261. }
  13262. // ResetName resets all changes to the "name" field.
  13263. func (m *SopStageMutation) ResetName() {
  13264. m.name = nil
  13265. }
  13266. // SetConditionType sets the "condition_type" field.
  13267. func (m *SopStageMutation) SetConditionType(i int) {
  13268. m.condition_type = &i
  13269. m.addcondition_type = nil
  13270. }
  13271. // ConditionType returns the value of the "condition_type" field in the mutation.
  13272. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  13273. v := m.condition_type
  13274. if v == nil {
  13275. return
  13276. }
  13277. return *v, true
  13278. }
  13279. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  13280. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13282. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  13283. if !m.op.Is(OpUpdateOne) {
  13284. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  13285. }
  13286. if m.id == nil || m.oldValue == nil {
  13287. return v, errors.New("OldConditionType requires an ID field in the mutation")
  13288. }
  13289. oldValue, err := m.oldValue(ctx)
  13290. if err != nil {
  13291. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  13292. }
  13293. return oldValue.ConditionType, nil
  13294. }
  13295. // AddConditionType adds i to the "condition_type" field.
  13296. func (m *SopStageMutation) AddConditionType(i int) {
  13297. if m.addcondition_type != nil {
  13298. *m.addcondition_type += i
  13299. } else {
  13300. m.addcondition_type = &i
  13301. }
  13302. }
  13303. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  13304. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  13305. v := m.addcondition_type
  13306. if v == nil {
  13307. return
  13308. }
  13309. return *v, true
  13310. }
  13311. // ResetConditionType resets all changes to the "condition_type" field.
  13312. func (m *SopStageMutation) ResetConditionType() {
  13313. m.condition_type = nil
  13314. m.addcondition_type = nil
  13315. }
  13316. // SetConditionOperator sets the "condition_operator" field.
  13317. func (m *SopStageMutation) SetConditionOperator(i int) {
  13318. m.condition_operator = &i
  13319. m.addcondition_operator = nil
  13320. }
  13321. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  13322. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  13323. v := m.condition_operator
  13324. if v == nil {
  13325. return
  13326. }
  13327. return *v, true
  13328. }
  13329. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  13330. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13332. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  13333. if !m.op.Is(OpUpdateOne) {
  13334. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  13335. }
  13336. if m.id == nil || m.oldValue == nil {
  13337. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  13338. }
  13339. oldValue, err := m.oldValue(ctx)
  13340. if err != nil {
  13341. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  13342. }
  13343. return oldValue.ConditionOperator, nil
  13344. }
  13345. // AddConditionOperator adds i to the "condition_operator" field.
  13346. func (m *SopStageMutation) AddConditionOperator(i int) {
  13347. if m.addcondition_operator != nil {
  13348. *m.addcondition_operator += i
  13349. } else {
  13350. m.addcondition_operator = &i
  13351. }
  13352. }
  13353. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  13354. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  13355. v := m.addcondition_operator
  13356. if v == nil {
  13357. return
  13358. }
  13359. return *v, true
  13360. }
  13361. // ResetConditionOperator resets all changes to the "condition_operator" field.
  13362. func (m *SopStageMutation) ResetConditionOperator() {
  13363. m.condition_operator = nil
  13364. m.addcondition_operator = nil
  13365. }
  13366. // SetConditionList sets the "condition_list" field.
  13367. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  13368. m.condition_list = &ct
  13369. m.appendcondition_list = nil
  13370. }
  13371. // ConditionList returns the value of the "condition_list" field in the mutation.
  13372. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  13373. v := m.condition_list
  13374. if v == nil {
  13375. return
  13376. }
  13377. return *v, true
  13378. }
  13379. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  13380. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13382. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  13383. if !m.op.Is(OpUpdateOne) {
  13384. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  13385. }
  13386. if m.id == nil || m.oldValue == nil {
  13387. return v, errors.New("OldConditionList requires an ID field in the mutation")
  13388. }
  13389. oldValue, err := m.oldValue(ctx)
  13390. if err != nil {
  13391. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  13392. }
  13393. return oldValue.ConditionList, nil
  13394. }
  13395. // AppendConditionList adds ct to the "condition_list" field.
  13396. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  13397. m.appendcondition_list = append(m.appendcondition_list, ct...)
  13398. }
  13399. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  13400. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  13401. if len(m.appendcondition_list) == 0 {
  13402. return nil, false
  13403. }
  13404. return m.appendcondition_list, true
  13405. }
  13406. // ResetConditionList resets all changes to the "condition_list" field.
  13407. func (m *SopStageMutation) ResetConditionList() {
  13408. m.condition_list = nil
  13409. m.appendcondition_list = nil
  13410. }
  13411. // SetActionMessage sets the "action_message" field.
  13412. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  13413. m.action_message = &ct
  13414. m.appendaction_message = nil
  13415. }
  13416. // ActionMessage returns the value of the "action_message" field in the mutation.
  13417. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  13418. v := m.action_message
  13419. if v == nil {
  13420. return
  13421. }
  13422. return *v, true
  13423. }
  13424. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  13425. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13427. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  13428. if !m.op.Is(OpUpdateOne) {
  13429. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  13430. }
  13431. if m.id == nil || m.oldValue == nil {
  13432. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  13433. }
  13434. oldValue, err := m.oldValue(ctx)
  13435. if err != nil {
  13436. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  13437. }
  13438. return oldValue.ActionMessage, nil
  13439. }
  13440. // AppendActionMessage adds ct to the "action_message" field.
  13441. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  13442. m.appendaction_message = append(m.appendaction_message, ct...)
  13443. }
  13444. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  13445. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  13446. if len(m.appendaction_message) == 0 {
  13447. return nil, false
  13448. }
  13449. return m.appendaction_message, true
  13450. }
  13451. // ClearActionMessage clears the value of the "action_message" field.
  13452. func (m *SopStageMutation) ClearActionMessage() {
  13453. m.action_message = nil
  13454. m.appendaction_message = nil
  13455. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  13456. }
  13457. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  13458. func (m *SopStageMutation) ActionMessageCleared() bool {
  13459. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  13460. return ok
  13461. }
  13462. // ResetActionMessage resets all changes to the "action_message" field.
  13463. func (m *SopStageMutation) ResetActionMessage() {
  13464. m.action_message = nil
  13465. m.appendaction_message = nil
  13466. delete(m.clearedFields, sopstage.FieldActionMessage)
  13467. }
  13468. // SetActionLabel sets the "action_label" field.
  13469. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  13470. m.action_label = &u
  13471. m.appendaction_label = nil
  13472. }
  13473. // ActionLabel returns the value of the "action_label" field in the mutation.
  13474. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  13475. v := m.action_label
  13476. if v == nil {
  13477. return
  13478. }
  13479. return *v, true
  13480. }
  13481. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  13482. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13484. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  13485. if !m.op.Is(OpUpdateOne) {
  13486. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  13487. }
  13488. if m.id == nil || m.oldValue == nil {
  13489. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  13490. }
  13491. oldValue, err := m.oldValue(ctx)
  13492. if err != nil {
  13493. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  13494. }
  13495. return oldValue.ActionLabel, nil
  13496. }
  13497. // AppendActionLabel adds u to the "action_label" field.
  13498. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  13499. m.appendaction_label = append(m.appendaction_label, u...)
  13500. }
  13501. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  13502. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  13503. if len(m.appendaction_label) == 0 {
  13504. return nil, false
  13505. }
  13506. return m.appendaction_label, true
  13507. }
  13508. // ClearActionLabel clears the value of the "action_label" field.
  13509. func (m *SopStageMutation) ClearActionLabel() {
  13510. m.action_label = nil
  13511. m.appendaction_label = nil
  13512. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  13513. }
  13514. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  13515. func (m *SopStageMutation) ActionLabelCleared() bool {
  13516. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  13517. return ok
  13518. }
  13519. // ResetActionLabel resets all changes to the "action_label" field.
  13520. func (m *SopStageMutation) ResetActionLabel() {
  13521. m.action_label = nil
  13522. m.appendaction_label = nil
  13523. delete(m.clearedFields, sopstage.FieldActionLabel)
  13524. }
  13525. // SetIndexSort sets the "index_sort" field.
  13526. func (m *SopStageMutation) SetIndexSort(i int) {
  13527. m.index_sort = &i
  13528. m.addindex_sort = nil
  13529. }
  13530. // IndexSort returns the value of the "index_sort" field in the mutation.
  13531. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  13532. v := m.index_sort
  13533. if v == nil {
  13534. return
  13535. }
  13536. return *v, true
  13537. }
  13538. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  13539. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  13540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13541. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  13542. if !m.op.Is(OpUpdateOne) {
  13543. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  13544. }
  13545. if m.id == nil || m.oldValue == nil {
  13546. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  13547. }
  13548. oldValue, err := m.oldValue(ctx)
  13549. if err != nil {
  13550. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  13551. }
  13552. return oldValue.IndexSort, nil
  13553. }
  13554. // AddIndexSort adds i to the "index_sort" field.
  13555. func (m *SopStageMutation) AddIndexSort(i int) {
  13556. if m.addindex_sort != nil {
  13557. *m.addindex_sort += i
  13558. } else {
  13559. m.addindex_sort = &i
  13560. }
  13561. }
  13562. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  13563. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  13564. v := m.addindex_sort
  13565. if v == nil {
  13566. return
  13567. }
  13568. return *v, true
  13569. }
  13570. // ClearIndexSort clears the value of the "index_sort" field.
  13571. func (m *SopStageMutation) ClearIndexSort() {
  13572. m.index_sort = nil
  13573. m.addindex_sort = nil
  13574. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  13575. }
  13576. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  13577. func (m *SopStageMutation) IndexSortCleared() bool {
  13578. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  13579. return ok
  13580. }
  13581. // ResetIndexSort resets all changes to the "index_sort" field.
  13582. func (m *SopStageMutation) ResetIndexSort() {
  13583. m.index_sort = nil
  13584. m.addindex_sort = nil
  13585. delete(m.clearedFields, sopstage.FieldIndexSort)
  13586. }
  13587. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  13588. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  13589. m.sop_task = &id
  13590. }
  13591. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  13592. func (m *SopStageMutation) ClearSopTask() {
  13593. m.clearedsop_task = true
  13594. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  13595. }
  13596. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  13597. func (m *SopStageMutation) SopTaskCleared() bool {
  13598. return m.clearedsop_task
  13599. }
  13600. // SopTaskID returns the "sop_task" edge ID in the mutation.
  13601. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  13602. if m.sop_task != nil {
  13603. return *m.sop_task, true
  13604. }
  13605. return
  13606. }
  13607. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  13608. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13609. // SopTaskID instead. It exists only for internal usage by the builders.
  13610. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  13611. if id := m.sop_task; id != nil {
  13612. ids = append(ids, *id)
  13613. }
  13614. return
  13615. }
  13616. // ResetSopTask resets all changes to the "sop_task" edge.
  13617. func (m *SopStageMutation) ResetSopTask() {
  13618. m.sop_task = nil
  13619. m.clearedsop_task = false
  13620. }
  13621. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  13622. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  13623. if m.stage_nodes == nil {
  13624. m.stage_nodes = make(map[uint64]struct{})
  13625. }
  13626. for i := range ids {
  13627. m.stage_nodes[ids[i]] = struct{}{}
  13628. }
  13629. }
  13630. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  13631. func (m *SopStageMutation) ClearStageNodes() {
  13632. m.clearedstage_nodes = true
  13633. }
  13634. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  13635. func (m *SopStageMutation) StageNodesCleared() bool {
  13636. return m.clearedstage_nodes
  13637. }
  13638. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  13639. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  13640. if m.removedstage_nodes == nil {
  13641. m.removedstage_nodes = make(map[uint64]struct{})
  13642. }
  13643. for i := range ids {
  13644. delete(m.stage_nodes, ids[i])
  13645. m.removedstage_nodes[ids[i]] = struct{}{}
  13646. }
  13647. }
  13648. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  13649. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  13650. for id := range m.removedstage_nodes {
  13651. ids = append(ids, id)
  13652. }
  13653. return
  13654. }
  13655. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  13656. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  13657. for id := range m.stage_nodes {
  13658. ids = append(ids, id)
  13659. }
  13660. return
  13661. }
  13662. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  13663. func (m *SopStageMutation) ResetStageNodes() {
  13664. m.stage_nodes = nil
  13665. m.clearedstage_nodes = false
  13666. m.removedstage_nodes = nil
  13667. }
  13668. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  13669. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  13670. if m.stage_messages == nil {
  13671. m.stage_messages = make(map[uint64]struct{})
  13672. }
  13673. for i := range ids {
  13674. m.stage_messages[ids[i]] = struct{}{}
  13675. }
  13676. }
  13677. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  13678. func (m *SopStageMutation) ClearStageMessages() {
  13679. m.clearedstage_messages = true
  13680. }
  13681. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  13682. func (m *SopStageMutation) StageMessagesCleared() bool {
  13683. return m.clearedstage_messages
  13684. }
  13685. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  13686. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  13687. if m.removedstage_messages == nil {
  13688. m.removedstage_messages = make(map[uint64]struct{})
  13689. }
  13690. for i := range ids {
  13691. delete(m.stage_messages, ids[i])
  13692. m.removedstage_messages[ids[i]] = struct{}{}
  13693. }
  13694. }
  13695. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  13696. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  13697. for id := range m.removedstage_messages {
  13698. ids = append(ids, id)
  13699. }
  13700. return
  13701. }
  13702. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  13703. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  13704. for id := range m.stage_messages {
  13705. ids = append(ids, id)
  13706. }
  13707. return
  13708. }
  13709. // ResetStageMessages resets all changes to the "stage_messages" edge.
  13710. func (m *SopStageMutation) ResetStageMessages() {
  13711. m.stage_messages = nil
  13712. m.clearedstage_messages = false
  13713. m.removedstage_messages = nil
  13714. }
  13715. // Where appends a list predicates to the SopStageMutation builder.
  13716. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  13717. m.predicates = append(m.predicates, ps...)
  13718. }
  13719. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  13720. // users can use type-assertion to append predicates that do not depend on any generated package.
  13721. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  13722. p := make([]predicate.SopStage, len(ps))
  13723. for i := range ps {
  13724. p[i] = ps[i]
  13725. }
  13726. m.Where(p...)
  13727. }
  13728. // Op returns the operation name.
  13729. func (m *SopStageMutation) Op() Op {
  13730. return m.op
  13731. }
  13732. // SetOp allows setting the mutation operation.
  13733. func (m *SopStageMutation) SetOp(op Op) {
  13734. m.op = op
  13735. }
  13736. // Type returns the node type of this mutation (SopStage).
  13737. func (m *SopStageMutation) Type() string {
  13738. return m.typ
  13739. }
  13740. // Fields returns all fields that were changed during this mutation. Note that in
  13741. // order to get all numeric fields that were incremented/decremented, call
  13742. // AddedFields().
  13743. func (m *SopStageMutation) Fields() []string {
  13744. fields := make([]string, 0, 12)
  13745. if m.created_at != nil {
  13746. fields = append(fields, sopstage.FieldCreatedAt)
  13747. }
  13748. if m.updated_at != nil {
  13749. fields = append(fields, sopstage.FieldUpdatedAt)
  13750. }
  13751. if m.status != nil {
  13752. fields = append(fields, sopstage.FieldStatus)
  13753. }
  13754. if m.deleted_at != nil {
  13755. fields = append(fields, sopstage.FieldDeletedAt)
  13756. }
  13757. if m.sop_task != nil {
  13758. fields = append(fields, sopstage.FieldTaskID)
  13759. }
  13760. if m.name != nil {
  13761. fields = append(fields, sopstage.FieldName)
  13762. }
  13763. if m.condition_type != nil {
  13764. fields = append(fields, sopstage.FieldConditionType)
  13765. }
  13766. if m.condition_operator != nil {
  13767. fields = append(fields, sopstage.FieldConditionOperator)
  13768. }
  13769. if m.condition_list != nil {
  13770. fields = append(fields, sopstage.FieldConditionList)
  13771. }
  13772. if m.action_message != nil {
  13773. fields = append(fields, sopstage.FieldActionMessage)
  13774. }
  13775. if m.action_label != nil {
  13776. fields = append(fields, sopstage.FieldActionLabel)
  13777. }
  13778. if m.index_sort != nil {
  13779. fields = append(fields, sopstage.FieldIndexSort)
  13780. }
  13781. return fields
  13782. }
  13783. // Field returns the value of a field with the given name. The second boolean
  13784. // return value indicates that this field was not set, or was not defined in the
  13785. // schema.
  13786. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  13787. switch name {
  13788. case sopstage.FieldCreatedAt:
  13789. return m.CreatedAt()
  13790. case sopstage.FieldUpdatedAt:
  13791. return m.UpdatedAt()
  13792. case sopstage.FieldStatus:
  13793. return m.Status()
  13794. case sopstage.FieldDeletedAt:
  13795. return m.DeletedAt()
  13796. case sopstage.FieldTaskID:
  13797. return m.TaskID()
  13798. case sopstage.FieldName:
  13799. return m.Name()
  13800. case sopstage.FieldConditionType:
  13801. return m.ConditionType()
  13802. case sopstage.FieldConditionOperator:
  13803. return m.ConditionOperator()
  13804. case sopstage.FieldConditionList:
  13805. return m.ConditionList()
  13806. case sopstage.FieldActionMessage:
  13807. return m.ActionMessage()
  13808. case sopstage.FieldActionLabel:
  13809. return m.ActionLabel()
  13810. case sopstage.FieldIndexSort:
  13811. return m.IndexSort()
  13812. }
  13813. return nil, false
  13814. }
  13815. // OldField returns the old value of the field from the database. An error is
  13816. // returned if the mutation operation is not UpdateOne, or the query to the
  13817. // database failed.
  13818. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13819. switch name {
  13820. case sopstage.FieldCreatedAt:
  13821. return m.OldCreatedAt(ctx)
  13822. case sopstage.FieldUpdatedAt:
  13823. return m.OldUpdatedAt(ctx)
  13824. case sopstage.FieldStatus:
  13825. return m.OldStatus(ctx)
  13826. case sopstage.FieldDeletedAt:
  13827. return m.OldDeletedAt(ctx)
  13828. case sopstage.FieldTaskID:
  13829. return m.OldTaskID(ctx)
  13830. case sopstage.FieldName:
  13831. return m.OldName(ctx)
  13832. case sopstage.FieldConditionType:
  13833. return m.OldConditionType(ctx)
  13834. case sopstage.FieldConditionOperator:
  13835. return m.OldConditionOperator(ctx)
  13836. case sopstage.FieldConditionList:
  13837. return m.OldConditionList(ctx)
  13838. case sopstage.FieldActionMessage:
  13839. return m.OldActionMessage(ctx)
  13840. case sopstage.FieldActionLabel:
  13841. return m.OldActionLabel(ctx)
  13842. case sopstage.FieldIndexSort:
  13843. return m.OldIndexSort(ctx)
  13844. }
  13845. return nil, fmt.Errorf("unknown SopStage field %s", name)
  13846. }
  13847. // SetField sets the value of a field with the given name. It returns an error if
  13848. // the field is not defined in the schema, or if the type mismatched the field
  13849. // type.
  13850. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  13851. switch name {
  13852. case sopstage.FieldCreatedAt:
  13853. v, ok := value.(time.Time)
  13854. if !ok {
  13855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13856. }
  13857. m.SetCreatedAt(v)
  13858. return nil
  13859. case sopstage.FieldUpdatedAt:
  13860. v, ok := value.(time.Time)
  13861. if !ok {
  13862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13863. }
  13864. m.SetUpdatedAt(v)
  13865. return nil
  13866. case sopstage.FieldStatus:
  13867. v, ok := value.(uint8)
  13868. if !ok {
  13869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13870. }
  13871. m.SetStatus(v)
  13872. return nil
  13873. case sopstage.FieldDeletedAt:
  13874. v, ok := value.(time.Time)
  13875. if !ok {
  13876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13877. }
  13878. m.SetDeletedAt(v)
  13879. return nil
  13880. case sopstage.FieldTaskID:
  13881. v, ok := value.(uint64)
  13882. if !ok {
  13883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13884. }
  13885. m.SetTaskID(v)
  13886. return nil
  13887. case sopstage.FieldName:
  13888. v, ok := value.(string)
  13889. if !ok {
  13890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13891. }
  13892. m.SetName(v)
  13893. return nil
  13894. case sopstage.FieldConditionType:
  13895. v, ok := value.(int)
  13896. if !ok {
  13897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13898. }
  13899. m.SetConditionType(v)
  13900. return nil
  13901. case sopstage.FieldConditionOperator:
  13902. v, ok := value.(int)
  13903. if !ok {
  13904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13905. }
  13906. m.SetConditionOperator(v)
  13907. return nil
  13908. case sopstage.FieldConditionList:
  13909. v, ok := value.([]custom_types.Condition)
  13910. if !ok {
  13911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13912. }
  13913. m.SetConditionList(v)
  13914. return nil
  13915. case sopstage.FieldActionMessage:
  13916. v, ok := value.([]custom_types.Action)
  13917. if !ok {
  13918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13919. }
  13920. m.SetActionMessage(v)
  13921. return nil
  13922. case sopstage.FieldActionLabel:
  13923. v, ok := value.([]uint64)
  13924. if !ok {
  13925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13926. }
  13927. m.SetActionLabel(v)
  13928. return nil
  13929. case sopstage.FieldIndexSort:
  13930. v, ok := value.(int)
  13931. if !ok {
  13932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13933. }
  13934. m.SetIndexSort(v)
  13935. return nil
  13936. }
  13937. return fmt.Errorf("unknown SopStage field %s", name)
  13938. }
  13939. // AddedFields returns all numeric fields that were incremented/decremented during
  13940. // this mutation.
  13941. func (m *SopStageMutation) AddedFields() []string {
  13942. var fields []string
  13943. if m.addstatus != nil {
  13944. fields = append(fields, sopstage.FieldStatus)
  13945. }
  13946. if m.addcondition_type != nil {
  13947. fields = append(fields, sopstage.FieldConditionType)
  13948. }
  13949. if m.addcondition_operator != nil {
  13950. fields = append(fields, sopstage.FieldConditionOperator)
  13951. }
  13952. if m.addindex_sort != nil {
  13953. fields = append(fields, sopstage.FieldIndexSort)
  13954. }
  13955. return fields
  13956. }
  13957. // AddedField returns the numeric value that was incremented/decremented on a field
  13958. // with the given name. The second boolean return value indicates that this field
  13959. // was not set, or was not defined in the schema.
  13960. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  13961. switch name {
  13962. case sopstage.FieldStatus:
  13963. return m.AddedStatus()
  13964. case sopstage.FieldConditionType:
  13965. return m.AddedConditionType()
  13966. case sopstage.FieldConditionOperator:
  13967. return m.AddedConditionOperator()
  13968. case sopstage.FieldIndexSort:
  13969. return m.AddedIndexSort()
  13970. }
  13971. return nil, false
  13972. }
  13973. // AddField adds the value to the field with the given name. It returns an error if
  13974. // the field is not defined in the schema, or if the type mismatched the field
  13975. // type.
  13976. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  13977. switch name {
  13978. case sopstage.FieldStatus:
  13979. v, ok := value.(int8)
  13980. if !ok {
  13981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13982. }
  13983. m.AddStatus(v)
  13984. return nil
  13985. case sopstage.FieldConditionType:
  13986. v, ok := value.(int)
  13987. if !ok {
  13988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13989. }
  13990. m.AddConditionType(v)
  13991. return nil
  13992. case sopstage.FieldConditionOperator:
  13993. v, ok := value.(int)
  13994. if !ok {
  13995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13996. }
  13997. m.AddConditionOperator(v)
  13998. return nil
  13999. case sopstage.FieldIndexSort:
  14000. v, ok := value.(int)
  14001. if !ok {
  14002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14003. }
  14004. m.AddIndexSort(v)
  14005. return nil
  14006. }
  14007. return fmt.Errorf("unknown SopStage numeric field %s", name)
  14008. }
  14009. // ClearedFields returns all nullable fields that were cleared during this
  14010. // mutation.
  14011. func (m *SopStageMutation) ClearedFields() []string {
  14012. var fields []string
  14013. if m.FieldCleared(sopstage.FieldStatus) {
  14014. fields = append(fields, sopstage.FieldStatus)
  14015. }
  14016. if m.FieldCleared(sopstage.FieldDeletedAt) {
  14017. fields = append(fields, sopstage.FieldDeletedAt)
  14018. }
  14019. if m.FieldCleared(sopstage.FieldActionMessage) {
  14020. fields = append(fields, sopstage.FieldActionMessage)
  14021. }
  14022. if m.FieldCleared(sopstage.FieldActionLabel) {
  14023. fields = append(fields, sopstage.FieldActionLabel)
  14024. }
  14025. if m.FieldCleared(sopstage.FieldIndexSort) {
  14026. fields = append(fields, sopstage.FieldIndexSort)
  14027. }
  14028. return fields
  14029. }
  14030. // FieldCleared returns a boolean indicating if a field with the given name was
  14031. // cleared in this mutation.
  14032. func (m *SopStageMutation) FieldCleared(name string) bool {
  14033. _, ok := m.clearedFields[name]
  14034. return ok
  14035. }
  14036. // ClearField clears the value of the field with the given name. It returns an
  14037. // error if the field is not defined in the schema.
  14038. func (m *SopStageMutation) ClearField(name string) error {
  14039. switch name {
  14040. case sopstage.FieldStatus:
  14041. m.ClearStatus()
  14042. return nil
  14043. case sopstage.FieldDeletedAt:
  14044. m.ClearDeletedAt()
  14045. return nil
  14046. case sopstage.FieldActionMessage:
  14047. m.ClearActionMessage()
  14048. return nil
  14049. case sopstage.FieldActionLabel:
  14050. m.ClearActionLabel()
  14051. return nil
  14052. case sopstage.FieldIndexSort:
  14053. m.ClearIndexSort()
  14054. return nil
  14055. }
  14056. return fmt.Errorf("unknown SopStage nullable field %s", name)
  14057. }
  14058. // ResetField resets all changes in the mutation for the field with the given name.
  14059. // It returns an error if the field is not defined in the schema.
  14060. func (m *SopStageMutation) ResetField(name string) error {
  14061. switch name {
  14062. case sopstage.FieldCreatedAt:
  14063. m.ResetCreatedAt()
  14064. return nil
  14065. case sopstage.FieldUpdatedAt:
  14066. m.ResetUpdatedAt()
  14067. return nil
  14068. case sopstage.FieldStatus:
  14069. m.ResetStatus()
  14070. return nil
  14071. case sopstage.FieldDeletedAt:
  14072. m.ResetDeletedAt()
  14073. return nil
  14074. case sopstage.FieldTaskID:
  14075. m.ResetTaskID()
  14076. return nil
  14077. case sopstage.FieldName:
  14078. m.ResetName()
  14079. return nil
  14080. case sopstage.FieldConditionType:
  14081. m.ResetConditionType()
  14082. return nil
  14083. case sopstage.FieldConditionOperator:
  14084. m.ResetConditionOperator()
  14085. return nil
  14086. case sopstage.FieldConditionList:
  14087. m.ResetConditionList()
  14088. return nil
  14089. case sopstage.FieldActionMessage:
  14090. m.ResetActionMessage()
  14091. return nil
  14092. case sopstage.FieldActionLabel:
  14093. m.ResetActionLabel()
  14094. return nil
  14095. case sopstage.FieldIndexSort:
  14096. m.ResetIndexSort()
  14097. return nil
  14098. }
  14099. return fmt.Errorf("unknown SopStage field %s", name)
  14100. }
  14101. // AddedEdges returns all edge names that were set/added in this mutation.
  14102. func (m *SopStageMutation) AddedEdges() []string {
  14103. edges := make([]string, 0, 3)
  14104. if m.sop_task != nil {
  14105. edges = append(edges, sopstage.EdgeSopTask)
  14106. }
  14107. if m.stage_nodes != nil {
  14108. edges = append(edges, sopstage.EdgeStageNodes)
  14109. }
  14110. if m.stage_messages != nil {
  14111. edges = append(edges, sopstage.EdgeStageMessages)
  14112. }
  14113. return edges
  14114. }
  14115. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14116. // name in this mutation.
  14117. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  14118. switch name {
  14119. case sopstage.EdgeSopTask:
  14120. if id := m.sop_task; id != nil {
  14121. return []ent.Value{*id}
  14122. }
  14123. case sopstage.EdgeStageNodes:
  14124. ids := make([]ent.Value, 0, len(m.stage_nodes))
  14125. for id := range m.stage_nodes {
  14126. ids = append(ids, id)
  14127. }
  14128. return ids
  14129. case sopstage.EdgeStageMessages:
  14130. ids := make([]ent.Value, 0, len(m.stage_messages))
  14131. for id := range m.stage_messages {
  14132. ids = append(ids, id)
  14133. }
  14134. return ids
  14135. }
  14136. return nil
  14137. }
  14138. // RemovedEdges returns all edge names that were removed in this mutation.
  14139. func (m *SopStageMutation) RemovedEdges() []string {
  14140. edges := make([]string, 0, 3)
  14141. if m.removedstage_nodes != nil {
  14142. edges = append(edges, sopstage.EdgeStageNodes)
  14143. }
  14144. if m.removedstage_messages != nil {
  14145. edges = append(edges, sopstage.EdgeStageMessages)
  14146. }
  14147. return edges
  14148. }
  14149. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14150. // the given name in this mutation.
  14151. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  14152. switch name {
  14153. case sopstage.EdgeStageNodes:
  14154. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  14155. for id := range m.removedstage_nodes {
  14156. ids = append(ids, id)
  14157. }
  14158. return ids
  14159. case sopstage.EdgeStageMessages:
  14160. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  14161. for id := range m.removedstage_messages {
  14162. ids = append(ids, id)
  14163. }
  14164. return ids
  14165. }
  14166. return nil
  14167. }
  14168. // ClearedEdges returns all edge names that were cleared in this mutation.
  14169. func (m *SopStageMutation) ClearedEdges() []string {
  14170. edges := make([]string, 0, 3)
  14171. if m.clearedsop_task {
  14172. edges = append(edges, sopstage.EdgeSopTask)
  14173. }
  14174. if m.clearedstage_nodes {
  14175. edges = append(edges, sopstage.EdgeStageNodes)
  14176. }
  14177. if m.clearedstage_messages {
  14178. edges = append(edges, sopstage.EdgeStageMessages)
  14179. }
  14180. return edges
  14181. }
  14182. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14183. // was cleared in this mutation.
  14184. func (m *SopStageMutation) EdgeCleared(name string) bool {
  14185. switch name {
  14186. case sopstage.EdgeSopTask:
  14187. return m.clearedsop_task
  14188. case sopstage.EdgeStageNodes:
  14189. return m.clearedstage_nodes
  14190. case sopstage.EdgeStageMessages:
  14191. return m.clearedstage_messages
  14192. }
  14193. return false
  14194. }
  14195. // ClearEdge clears the value of the edge with the given name. It returns an error
  14196. // if that edge is not defined in the schema.
  14197. func (m *SopStageMutation) ClearEdge(name string) error {
  14198. switch name {
  14199. case sopstage.EdgeSopTask:
  14200. m.ClearSopTask()
  14201. return nil
  14202. }
  14203. return fmt.Errorf("unknown SopStage unique edge %s", name)
  14204. }
  14205. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14206. // It returns an error if the edge is not defined in the schema.
  14207. func (m *SopStageMutation) ResetEdge(name string) error {
  14208. switch name {
  14209. case sopstage.EdgeSopTask:
  14210. m.ResetSopTask()
  14211. return nil
  14212. case sopstage.EdgeStageNodes:
  14213. m.ResetStageNodes()
  14214. return nil
  14215. case sopstage.EdgeStageMessages:
  14216. m.ResetStageMessages()
  14217. return nil
  14218. }
  14219. return fmt.Errorf("unknown SopStage edge %s", name)
  14220. }
  14221. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  14222. type SopTaskMutation struct {
  14223. config
  14224. op Op
  14225. typ string
  14226. id *uint64
  14227. created_at *time.Time
  14228. updated_at *time.Time
  14229. status *uint8
  14230. addstatus *int8
  14231. deleted_at *time.Time
  14232. name *string
  14233. bot_wxid_list *[]string
  14234. appendbot_wxid_list []string
  14235. _type *int
  14236. add_type *int
  14237. plan_start_time *time.Time
  14238. plan_end_time *time.Time
  14239. creator_id *string
  14240. organization_id *uint64
  14241. addorganization_id *int64
  14242. clearedFields map[string]struct{}
  14243. task_stages map[uint64]struct{}
  14244. removedtask_stages map[uint64]struct{}
  14245. clearedtask_stages bool
  14246. done bool
  14247. oldValue func(context.Context) (*SopTask, error)
  14248. predicates []predicate.SopTask
  14249. }
  14250. var _ ent.Mutation = (*SopTaskMutation)(nil)
  14251. // soptaskOption allows management of the mutation configuration using functional options.
  14252. type soptaskOption func(*SopTaskMutation)
  14253. // newSopTaskMutation creates new mutation for the SopTask entity.
  14254. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  14255. m := &SopTaskMutation{
  14256. config: c,
  14257. op: op,
  14258. typ: TypeSopTask,
  14259. clearedFields: make(map[string]struct{}),
  14260. }
  14261. for _, opt := range opts {
  14262. opt(m)
  14263. }
  14264. return m
  14265. }
  14266. // withSopTaskID sets the ID field of the mutation.
  14267. func withSopTaskID(id uint64) soptaskOption {
  14268. return func(m *SopTaskMutation) {
  14269. var (
  14270. err error
  14271. once sync.Once
  14272. value *SopTask
  14273. )
  14274. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  14275. once.Do(func() {
  14276. if m.done {
  14277. err = errors.New("querying old values post mutation is not allowed")
  14278. } else {
  14279. value, err = m.Client().SopTask.Get(ctx, id)
  14280. }
  14281. })
  14282. return value, err
  14283. }
  14284. m.id = &id
  14285. }
  14286. }
  14287. // withSopTask sets the old SopTask of the mutation.
  14288. func withSopTask(node *SopTask) soptaskOption {
  14289. return func(m *SopTaskMutation) {
  14290. m.oldValue = func(context.Context) (*SopTask, error) {
  14291. return node, nil
  14292. }
  14293. m.id = &node.ID
  14294. }
  14295. }
  14296. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14297. // executed in a transaction (ent.Tx), a transactional client is returned.
  14298. func (m SopTaskMutation) Client() *Client {
  14299. client := &Client{config: m.config}
  14300. client.init()
  14301. return client
  14302. }
  14303. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14304. // it returns an error otherwise.
  14305. func (m SopTaskMutation) Tx() (*Tx, error) {
  14306. if _, ok := m.driver.(*txDriver); !ok {
  14307. return nil, errors.New("ent: mutation is not running in a transaction")
  14308. }
  14309. tx := &Tx{config: m.config}
  14310. tx.init()
  14311. return tx, nil
  14312. }
  14313. // SetID sets the value of the id field. Note that this
  14314. // operation is only accepted on creation of SopTask entities.
  14315. func (m *SopTaskMutation) SetID(id uint64) {
  14316. m.id = &id
  14317. }
  14318. // ID returns the ID value in the mutation. Note that the ID is only available
  14319. // if it was provided to the builder or after it was returned from the database.
  14320. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  14321. if m.id == nil {
  14322. return
  14323. }
  14324. return *m.id, true
  14325. }
  14326. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14327. // That means, if the mutation is applied within a transaction with an isolation level such
  14328. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14329. // or updated by the mutation.
  14330. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  14331. switch {
  14332. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14333. id, exists := m.ID()
  14334. if exists {
  14335. return []uint64{id}, nil
  14336. }
  14337. fallthrough
  14338. case m.op.Is(OpUpdate | OpDelete):
  14339. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  14340. default:
  14341. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14342. }
  14343. }
  14344. // SetCreatedAt sets the "created_at" field.
  14345. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  14346. m.created_at = &t
  14347. }
  14348. // CreatedAt returns the value of the "created_at" field in the mutation.
  14349. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  14350. v := m.created_at
  14351. if v == nil {
  14352. return
  14353. }
  14354. return *v, true
  14355. }
  14356. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  14357. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14359. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14360. if !m.op.Is(OpUpdateOne) {
  14361. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14362. }
  14363. if m.id == nil || m.oldValue == nil {
  14364. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14365. }
  14366. oldValue, err := m.oldValue(ctx)
  14367. if err != nil {
  14368. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14369. }
  14370. return oldValue.CreatedAt, nil
  14371. }
  14372. // ResetCreatedAt resets all changes to the "created_at" field.
  14373. func (m *SopTaskMutation) ResetCreatedAt() {
  14374. m.created_at = nil
  14375. }
  14376. // SetUpdatedAt sets the "updated_at" field.
  14377. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  14378. m.updated_at = &t
  14379. }
  14380. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14381. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  14382. v := m.updated_at
  14383. if v == nil {
  14384. return
  14385. }
  14386. return *v, true
  14387. }
  14388. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  14389. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14391. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14392. if !m.op.Is(OpUpdateOne) {
  14393. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14394. }
  14395. if m.id == nil || m.oldValue == nil {
  14396. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14397. }
  14398. oldValue, err := m.oldValue(ctx)
  14399. if err != nil {
  14400. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14401. }
  14402. return oldValue.UpdatedAt, nil
  14403. }
  14404. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14405. func (m *SopTaskMutation) ResetUpdatedAt() {
  14406. m.updated_at = nil
  14407. }
  14408. // SetStatus sets the "status" field.
  14409. func (m *SopTaskMutation) SetStatus(u uint8) {
  14410. m.status = &u
  14411. m.addstatus = nil
  14412. }
  14413. // Status returns the value of the "status" field in the mutation.
  14414. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  14415. v := m.status
  14416. if v == nil {
  14417. return
  14418. }
  14419. return *v, true
  14420. }
  14421. // OldStatus returns the old "status" field's value of the SopTask entity.
  14422. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14424. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14425. if !m.op.Is(OpUpdateOne) {
  14426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14427. }
  14428. if m.id == nil || m.oldValue == nil {
  14429. return v, errors.New("OldStatus requires an ID field in the mutation")
  14430. }
  14431. oldValue, err := m.oldValue(ctx)
  14432. if err != nil {
  14433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14434. }
  14435. return oldValue.Status, nil
  14436. }
  14437. // AddStatus adds u to the "status" field.
  14438. func (m *SopTaskMutation) AddStatus(u int8) {
  14439. if m.addstatus != nil {
  14440. *m.addstatus += u
  14441. } else {
  14442. m.addstatus = &u
  14443. }
  14444. }
  14445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14446. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  14447. v := m.addstatus
  14448. if v == nil {
  14449. return
  14450. }
  14451. return *v, true
  14452. }
  14453. // ClearStatus clears the value of the "status" field.
  14454. func (m *SopTaskMutation) ClearStatus() {
  14455. m.status = nil
  14456. m.addstatus = nil
  14457. m.clearedFields[soptask.FieldStatus] = struct{}{}
  14458. }
  14459. // StatusCleared returns if the "status" field was cleared in this mutation.
  14460. func (m *SopTaskMutation) StatusCleared() bool {
  14461. _, ok := m.clearedFields[soptask.FieldStatus]
  14462. return ok
  14463. }
  14464. // ResetStatus resets all changes to the "status" field.
  14465. func (m *SopTaskMutation) ResetStatus() {
  14466. m.status = nil
  14467. m.addstatus = nil
  14468. delete(m.clearedFields, soptask.FieldStatus)
  14469. }
  14470. // SetDeletedAt sets the "deleted_at" field.
  14471. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  14472. m.deleted_at = &t
  14473. }
  14474. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14475. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  14476. v := m.deleted_at
  14477. if v == nil {
  14478. return
  14479. }
  14480. return *v, true
  14481. }
  14482. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  14483. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14485. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14486. if !m.op.Is(OpUpdateOne) {
  14487. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14488. }
  14489. if m.id == nil || m.oldValue == nil {
  14490. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14491. }
  14492. oldValue, err := m.oldValue(ctx)
  14493. if err != nil {
  14494. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14495. }
  14496. return oldValue.DeletedAt, nil
  14497. }
  14498. // ClearDeletedAt clears the value of the "deleted_at" field.
  14499. func (m *SopTaskMutation) ClearDeletedAt() {
  14500. m.deleted_at = nil
  14501. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  14502. }
  14503. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14504. func (m *SopTaskMutation) DeletedAtCleared() bool {
  14505. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  14506. return ok
  14507. }
  14508. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14509. func (m *SopTaskMutation) ResetDeletedAt() {
  14510. m.deleted_at = nil
  14511. delete(m.clearedFields, soptask.FieldDeletedAt)
  14512. }
  14513. // SetName sets the "name" field.
  14514. func (m *SopTaskMutation) SetName(s string) {
  14515. m.name = &s
  14516. }
  14517. // Name returns the value of the "name" field in the mutation.
  14518. func (m *SopTaskMutation) Name() (r string, exists bool) {
  14519. v := m.name
  14520. if v == nil {
  14521. return
  14522. }
  14523. return *v, true
  14524. }
  14525. // OldName returns the old "name" field's value of the SopTask entity.
  14526. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14528. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  14529. if !m.op.Is(OpUpdateOne) {
  14530. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14531. }
  14532. if m.id == nil || m.oldValue == nil {
  14533. return v, errors.New("OldName requires an ID field in the mutation")
  14534. }
  14535. oldValue, err := m.oldValue(ctx)
  14536. if err != nil {
  14537. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14538. }
  14539. return oldValue.Name, nil
  14540. }
  14541. // ResetName resets all changes to the "name" field.
  14542. func (m *SopTaskMutation) ResetName() {
  14543. m.name = nil
  14544. }
  14545. // SetBotWxidList sets the "bot_wxid_list" field.
  14546. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  14547. m.bot_wxid_list = &s
  14548. m.appendbot_wxid_list = nil
  14549. }
  14550. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  14551. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  14552. v := m.bot_wxid_list
  14553. if v == nil {
  14554. return
  14555. }
  14556. return *v, true
  14557. }
  14558. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  14559. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14561. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  14562. if !m.op.Is(OpUpdateOne) {
  14563. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  14564. }
  14565. if m.id == nil || m.oldValue == nil {
  14566. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  14567. }
  14568. oldValue, err := m.oldValue(ctx)
  14569. if err != nil {
  14570. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  14571. }
  14572. return oldValue.BotWxidList, nil
  14573. }
  14574. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  14575. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  14576. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  14577. }
  14578. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  14579. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  14580. if len(m.appendbot_wxid_list) == 0 {
  14581. return nil, false
  14582. }
  14583. return m.appendbot_wxid_list, true
  14584. }
  14585. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  14586. func (m *SopTaskMutation) ClearBotWxidList() {
  14587. m.bot_wxid_list = nil
  14588. m.appendbot_wxid_list = nil
  14589. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  14590. }
  14591. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  14592. func (m *SopTaskMutation) BotWxidListCleared() bool {
  14593. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  14594. return ok
  14595. }
  14596. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  14597. func (m *SopTaskMutation) ResetBotWxidList() {
  14598. m.bot_wxid_list = nil
  14599. m.appendbot_wxid_list = nil
  14600. delete(m.clearedFields, soptask.FieldBotWxidList)
  14601. }
  14602. // SetType sets the "type" field.
  14603. func (m *SopTaskMutation) SetType(i int) {
  14604. m._type = &i
  14605. m.add_type = nil
  14606. }
  14607. // GetType returns the value of the "type" field in the mutation.
  14608. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  14609. v := m._type
  14610. if v == nil {
  14611. return
  14612. }
  14613. return *v, true
  14614. }
  14615. // OldType returns the old "type" field's value of the SopTask entity.
  14616. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14618. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  14619. if !m.op.Is(OpUpdateOne) {
  14620. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14621. }
  14622. if m.id == nil || m.oldValue == nil {
  14623. return v, errors.New("OldType requires an ID field in the mutation")
  14624. }
  14625. oldValue, err := m.oldValue(ctx)
  14626. if err != nil {
  14627. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14628. }
  14629. return oldValue.Type, nil
  14630. }
  14631. // AddType adds i to the "type" field.
  14632. func (m *SopTaskMutation) AddType(i int) {
  14633. if m.add_type != nil {
  14634. *m.add_type += i
  14635. } else {
  14636. m.add_type = &i
  14637. }
  14638. }
  14639. // AddedType returns the value that was added to the "type" field in this mutation.
  14640. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  14641. v := m.add_type
  14642. if v == nil {
  14643. return
  14644. }
  14645. return *v, true
  14646. }
  14647. // ResetType resets all changes to the "type" field.
  14648. func (m *SopTaskMutation) ResetType() {
  14649. m._type = nil
  14650. m.add_type = nil
  14651. }
  14652. // SetPlanStartTime sets the "plan_start_time" field.
  14653. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  14654. m.plan_start_time = &t
  14655. }
  14656. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  14657. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  14658. v := m.plan_start_time
  14659. if v == nil {
  14660. return
  14661. }
  14662. return *v, true
  14663. }
  14664. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  14665. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14667. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  14668. if !m.op.Is(OpUpdateOne) {
  14669. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  14670. }
  14671. if m.id == nil || m.oldValue == nil {
  14672. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  14673. }
  14674. oldValue, err := m.oldValue(ctx)
  14675. if err != nil {
  14676. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  14677. }
  14678. return oldValue.PlanStartTime, nil
  14679. }
  14680. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  14681. func (m *SopTaskMutation) ClearPlanStartTime() {
  14682. m.plan_start_time = nil
  14683. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  14684. }
  14685. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  14686. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  14687. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  14688. return ok
  14689. }
  14690. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  14691. func (m *SopTaskMutation) ResetPlanStartTime() {
  14692. m.plan_start_time = nil
  14693. delete(m.clearedFields, soptask.FieldPlanStartTime)
  14694. }
  14695. // SetPlanEndTime sets the "plan_end_time" field.
  14696. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  14697. m.plan_end_time = &t
  14698. }
  14699. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  14700. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  14701. v := m.plan_end_time
  14702. if v == nil {
  14703. return
  14704. }
  14705. return *v, true
  14706. }
  14707. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  14708. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14710. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  14711. if !m.op.Is(OpUpdateOne) {
  14712. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  14713. }
  14714. if m.id == nil || m.oldValue == nil {
  14715. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  14716. }
  14717. oldValue, err := m.oldValue(ctx)
  14718. if err != nil {
  14719. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  14720. }
  14721. return oldValue.PlanEndTime, nil
  14722. }
  14723. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  14724. func (m *SopTaskMutation) ClearPlanEndTime() {
  14725. m.plan_end_time = nil
  14726. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  14727. }
  14728. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  14729. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  14730. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  14731. return ok
  14732. }
  14733. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  14734. func (m *SopTaskMutation) ResetPlanEndTime() {
  14735. m.plan_end_time = nil
  14736. delete(m.clearedFields, soptask.FieldPlanEndTime)
  14737. }
  14738. // SetCreatorID sets the "creator_id" field.
  14739. func (m *SopTaskMutation) SetCreatorID(s string) {
  14740. m.creator_id = &s
  14741. }
  14742. // CreatorID returns the value of the "creator_id" field in the mutation.
  14743. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  14744. v := m.creator_id
  14745. if v == nil {
  14746. return
  14747. }
  14748. return *v, true
  14749. }
  14750. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  14751. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14753. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  14754. if !m.op.Is(OpUpdateOne) {
  14755. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  14756. }
  14757. if m.id == nil || m.oldValue == nil {
  14758. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  14759. }
  14760. oldValue, err := m.oldValue(ctx)
  14761. if err != nil {
  14762. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  14763. }
  14764. return oldValue.CreatorID, nil
  14765. }
  14766. // ClearCreatorID clears the value of the "creator_id" field.
  14767. func (m *SopTaskMutation) ClearCreatorID() {
  14768. m.creator_id = nil
  14769. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  14770. }
  14771. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  14772. func (m *SopTaskMutation) CreatorIDCleared() bool {
  14773. _, ok := m.clearedFields[soptask.FieldCreatorID]
  14774. return ok
  14775. }
  14776. // ResetCreatorID resets all changes to the "creator_id" field.
  14777. func (m *SopTaskMutation) ResetCreatorID() {
  14778. m.creator_id = nil
  14779. delete(m.clearedFields, soptask.FieldCreatorID)
  14780. }
  14781. // SetOrganizationID sets the "organization_id" field.
  14782. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  14783. m.organization_id = &u
  14784. m.addorganization_id = nil
  14785. }
  14786. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14787. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  14788. v := m.organization_id
  14789. if v == nil {
  14790. return
  14791. }
  14792. return *v, true
  14793. }
  14794. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  14795. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  14796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14797. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14798. if !m.op.Is(OpUpdateOne) {
  14799. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14800. }
  14801. if m.id == nil || m.oldValue == nil {
  14802. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14803. }
  14804. oldValue, err := m.oldValue(ctx)
  14805. if err != nil {
  14806. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14807. }
  14808. return oldValue.OrganizationID, nil
  14809. }
  14810. // AddOrganizationID adds u to the "organization_id" field.
  14811. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  14812. if m.addorganization_id != nil {
  14813. *m.addorganization_id += u
  14814. } else {
  14815. m.addorganization_id = &u
  14816. }
  14817. }
  14818. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14819. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  14820. v := m.addorganization_id
  14821. if v == nil {
  14822. return
  14823. }
  14824. return *v, true
  14825. }
  14826. // ClearOrganizationID clears the value of the "organization_id" field.
  14827. func (m *SopTaskMutation) ClearOrganizationID() {
  14828. m.organization_id = nil
  14829. m.addorganization_id = nil
  14830. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  14831. }
  14832. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14833. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  14834. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  14835. return ok
  14836. }
  14837. // ResetOrganizationID resets all changes to the "organization_id" field.
  14838. func (m *SopTaskMutation) ResetOrganizationID() {
  14839. m.organization_id = nil
  14840. m.addorganization_id = nil
  14841. delete(m.clearedFields, soptask.FieldOrganizationID)
  14842. }
  14843. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  14844. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  14845. if m.task_stages == nil {
  14846. m.task_stages = make(map[uint64]struct{})
  14847. }
  14848. for i := range ids {
  14849. m.task_stages[ids[i]] = struct{}{}
  14850. }
  14851. }
  14852. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  14853. func (m *SopTaskMutation) ClearTaskStages() {
  14854. m.clearedtask_stages = true
  14855. }
  14856. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  14857. func (m *SopTaskMutation) TaskStagesCleared() bool {
  14858. return m.clearedtask_stages
  14859. }
  14860. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  14861. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  14862. if m.removedtask_stages == nil {
  14863. m.removedtask_stages = make(map[uint64]struct{})
  14864. }
  14865. for i := range ids {
  14866. delete(m.task_stages, ids[i])
  14867. m.removedtask_stages[ids[i]] = struct{}{}
  14868. }
  14869. }
  14870. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  14871. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  14872. for id := range m.removedtask_stages {
  14873. ids = append(ids, id)
  14874. }
  14875. return
  14876. }
  14877. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  14878. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  14879. for id := range m.task_stages {
  14880. ids = append(ids, id)
  14881. }
  14882. return
  14883. }
  14884. // ResetTaskStages resets all changes to the "task_stages" edge.
  14885. func (m *SopTaskMutation) ResetTaskStages() {
  14886. m.task_stages = nil
  14887. m.clearedtask_stages = false
  14888. m.removedtask_stages = nil
  14889. }
  14890. // Where appends a list predicates to the SopTaskMutation builder.
  14891. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  14892. m.predicates = append(m.predicates, ps...)
  14893. }
  14894. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  14895. // users can use type-assertion to append predicates that do not depend on any generated package.
  14896. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  14897. p := make([]predicate.SopTask, len(ps))
  14898. for i := range ps {
  14899. p[i] = ps[i]
  14900. }
  14901. m.Where(p...)
  14902. }
  14903. // Op returns the operation name.
  14904. func (m *SopTaskMutation) Op() Op {
  14905. return m.op
  14906. }
  14907. // SetOp allows setting the mutation operation.
  14908. func (m *SopTaskMutation) SetOp(op Op) {
  14909. m.op = op
  14910. }
  14911. // Type returns the node type of this mutation (SopTask).
  14912. func (m *SopTaskMutation) Type() string {
  14913. return m.typ
  14914. }
  14915. // Fields returns all fields that were changed during this mutation. Note that in
  14916. // order to get all numeric fields that were incremented/decremented, call
  14917. // AddedFields().
  14918. func (m *SopTaskMutation) Fields() []string {
  14919. fields := make([]string, 0, 11)
  14920. if m.created_at != nil {
  14921. fields = append(fields, soptask.FieldCreatedAt)
  14922. }
  14923. if m.updated_at != nil {
  14924. fields = append(fields, soptask.FieldUpdatedAt)
  14925. }
  14926. if m.status != nil {
  14927. fields = append(fields, soptask.FieldStatus)
  14928. }
  14929. if m.deleted_at != nil {
  14930. fields = append(fields, soptask.FieldDeletedAt)
  14931. }
  14932. if m.name != nil {
  14933. fields = append(fields, soptask.FieldName)
  14934. }
  14935. if m.bot_wxid_list != nil {
  14936. fields = append(fields, soptask.FieldBotWxidList)
  14937. }
  14938. if m._type != nil {
  14939. fields = append(fields, soptask.FieldType)
  14940. }
  14941. if m.plan_start_time != nil {
  14942. fields = append(fields, soptask.FieldPlanStartTime)
  14943. }
  14944. if m.plan_end_time != nil {
  14945. fields = append(fields, soptask.FieldPlanEndTime)
  14946. }
  14947. if m.creator_id != nil {
  14948. fields = append(fields, soptask.FieldCreatorID)
  14949. }
  14950. if m.organization_id != nil {
  14951. fields = append(fields, soptask.FieldOrganizationID)
  14952. }
  14953. return fields
  14954. }
  14955. // Field returns the value of a field with the given name. The second boolean
  14956. // return value indicates that this field was not set, or was not defined in the
  14957. // schema.
  14958. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  14959. switch name {
  14960. case soptask.FieldCreatedAt:
  14961. return m.CreatedAt()
  14962. case soptask.FieldUpdatedAt:
  14963. return m.UpdatedAt()
  14964. case soptask.FieldStatus:
  14965. return m.Status()
  14966. case soptask.FieldDeletedAt:
  14967. return m.DeletedAt()
  14968. case soptask.FieldName:
  14969. return m.Name()
  14970. case soptask.FieldBotWxidList:
  14971. return m.BotWxidList()
  14972. case soptask.FieldType:
  14973. return m.GetType()
  14974. case soptask.FieldPlanStartTime:
  14975. return m.PlanStartTime()
  14976. case soptask.FieldPlanEndTime:
  14977. return m.PlanEndTime()
  14978. case soptask.FieldCreatorID:
  14979. return m.CreatorID()
  14980. case soptask.FieldOrganizationID:
  14981. return m.OrganizationID()
  14982. }
  14983. return nil, false
  14984. }
  14985. // OldField returns the old value of the field from the database. An error is
  14986. // returned if the mutation operation is not UpdateOne, or the query to the
  14987. // database failed.
  14988. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14989. switch name {
  14990. case soptask.FieldCreatedAt:
  14991. return m.OldCreatedAt(ctx)
  14992. case soptask.FieldUpdatedAt:
  14993. return m.OldUpdatedAt(ctx)
  14994. case soptask.FieldStatus:
  14995. return m.OldStatus(ctx)
  14996. case soptask.FieldDeletedAt:
  14997. return m.OldDeletedAt(ctx)
  14998. case soptask.FieldName:
  14999. return m.OldName(ctx)
  15000. case soptask.FieldBotWxidList:
  15001. return m.OldBotWxidList(ctx)
  15002. case soptask.FieldType:
  15003. return m.OldType(ctx)
  15004. case soptask.FieldPlanStartTime:
  15005. return m.OldPlanStartTime(ctx)
  15006. case soptask.FieldPlanEndTime:
  15007. return m.OldPlanEndTime(ctx)
  15008. case soptask.FieldCreatorID:
  15009. return m.OldCreatorID(ctx)
  15010. case soptask.FieldOrganizationID:
  15011. return m.OldOrganizationID(ctx)
  15012. }
  15013. return nil, fmt.Errorf("unknown SopTask field %s", name)
  15014. }
  15015. // SetField sets the value of a field with the given name. It returns an error if
  15016. // the field is not defined in the schema, or if the type mismatched the field
  15017. // type.
  15018. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  15019. switch name {
  15020. case soptask.FieldCreatedAt:
  15021. v, ok := value.(time.Time)
  15022. if !ok {
  15023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15024. }
  15025. m.SetCreatedAt(v)
  15026. return nil
  15027. case soptask.FieldUpdatedAt:
  15028. v, ok := value.(time.Time)
  15029. if !ok {
  15030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15031. }
  15032. m.SetUpdatedAt(v)
  15033. return nil
  15034. case soptask.FieldStatus:
  15035. v, ok := value.(uint8)
  15036. if !ok {
  15037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15038. }
  15039. m.SetStatus(v)
  15040. return nil
  15041. case soptask.FieldDeletedAt:
  15042. v, ok := value.(time.Time)
  15043. if !ok {
  15044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15045. }
  15046. m.SetDeletedAt(v)
  15047. return nil
  15048. case soptask.FieldName:
  15049. v, ok := value.(string)
  15050. if !ok {
  15051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15052. }
  15053. m.SetName(v)
  15054. return nil
  15055. case soptask.FieldBotWxidList:
  15056. v, ok := value.([]string)
  15057. if !ok {
  15058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15059. }
  15060. m.SetBotWxidList(v)
  15061. return nil
  15062. case soptask.FieldType:
  15063. v, ok := value.(int)
  15064. if !ok {
  15065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15066. }
  15067. m.SetType(v)
  15068. return nil
  15069. case soptask.FieldPlanStartTime:
  15070. v, ok := value.(time.Time)
  15071. if !ok {
  15072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15073. }
  15074. m.SetPlanStartTime(v)
  15075. return nil
  15076. case soptask.FieldPlanEndTime:
  15077. v, ok := value.(time.Time)
  15078. if !ok {
  15079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15080. }
  15081. m.SetPlanEndTime(v)
  15082. return nil
  15083. case soptask.FieldCreatorID:
  15084. v, ok := value.(string)
  15085. if !ok {
  15086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15087. }
  15088. m.SetCreatorID(v)
  15089. return nil
  15090. case soptask.FieldOrganizationID:
  15091. v, ok := value.(uint64)
  15092. if !ok {
  15093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15094. }
  15095. m.SetOrganizationID(v)
  15096. return nil
  15097. }
  15098. return fmt.Errorf("unknown SopTask field %s", name)
  15099. }
  15100. // AddedFields returns all numeric fields that were incremented/decremented during
  15101. // this mutation.
  15102. func (m *SopTaskMutation) AddedFields() []string {
  15103. var fields []string
  15104. if m.addstatus != nil {
  15105. fields = append(fields, soptask.FieldStatus)
  15106. }
  15107. if m.add_type != nil {
  15108. fields = append(fields, soptask.FieldType)
  15109. }
  15110. if m.addorganization_id != nil {
  15111. fields = append(fields, soptask.FieldOrganizationID)
  15112. }
  15113. return fields
  15114. }
  15115. // AddedField returns the numeric value that was incremented/decremented on a field
  15116. // with the given name. The second boolean return value indicates that this field
  15117. // was not set, or was not defined in the schema.
  15118. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  15119. switch name {
  15120. case soptask.FieldStatus:
  15121. return m.AddedStatus()
  15122. case soptask.FieldType:
  15123. return m.AddedType()
  15124. case soptask.FieldOrganizationID:
  15125. return m.AddedOrganizationID()
  15126. }
  15127. return nil, false
  15128. }
  15129. // AddField adds the value to the field with the given name. It returns an error if
  15130. // the field is not defined in the schema, or if the type mismatched the field
  15131. // type.
  15132. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  15133. switch name {
  15134. case soptask.FieldStatus:
  15135. v, ok := value.(int8)
  15136. if !ok {
  15137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15138. }
  15139. m.AddStatus(v)
  15140. return nil
  15141. case soptask.FieldType:
  15142. v, ok := value.(int)
  15143. if !ok {
  15144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15145. }
  15146. m.AddType(v)
  15147. return nil
  15148. case soptask.FieldOrganizationID:
  15149. v, ok := value.(int64)
  15150. if !ok {
  15151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15152. }
  15153. m.AddOrganizationID(v)
  15154. return nil
  15155. }
  15156. return fmt.Errorf("unknown SopTask numeric field %s", name)
  15157. }
  15158. // ClearedFields returns all nullable fields that were cleared during this
  15159. // mutation.
  15160. func (m *SopTaskMutation) ClearedFields() []string {
  15161. var fields []string
  15162. if m.FieldCleared(soptask.FieldStatus) {
  15163. fields = append(fields, soptask.FieldStatus)
  15164. }
  15165. if m.FieldCleared(soptask.FieldDeletedAt) {
  15166. fields = append(fields, soptask.FieldDeletedAt)
  15167. }
  15168. if m.FieldCleared(soptask.FieldBotWxidList) {
  15169. fields = append(fields, soptask.FieldBotWxidList)
  15170. }
  15171. if m.FieldCleared(soptask.FieldPlanStartTime) {
  15172. fields = append(fields, soptask.FieldPlanStartTime)
  15173. }
  15174. if m.FieldCleared(soptask.FieldPlanEndTime) {
  15175. fields = append(fields, soptask.FieldPlanEndTime)
  15176. }
  15177. if m.FieldCleared(soptask.FieldCreatorID) {
  15178. fields = append(fields, soptask.FieldCreatorID)
  15179. }
  15180. if m.FieldCleared(soptask.FieldOrganizationID) {
  15181. fields = append(fields, soptask.FieldOrganizationID)
  15182. }
  15183. return fields
  15184. }
  15185. // FieldCleared returns a boolean indicating if a field with the given name was
  15186. // cleared in this mutation.
  15187. func (m *SopTaskMutation) FieldCleared(name string) bool {
  15188. _, ok := m.clearedFields[name]
  15189. return ok
  15190. }
  15191. // ClearField clears the value of the field with the given name. It returns an
  15192. // error if the field is not defined in the schema.
  15193. func (m *SopTaskMutation) ClearField(name string) error {
  15194. switch name {
  15195. case soptask.FieldStatus:
  15196. m.ClearStatus()
  15197. return nil
  15198. case soptask.FieldDeletedAt:
  15199. m.ClearDeletedAt()
  15200. return nil
  15201. case soptask.FieldBotWxidList:
  15202. m.ClearBotWxidList()
  15203. return nil
  15204. case soptask.FieldPlanStartTime:
  15205. m.ClearPlanStartTime()
  15206. return nil
  15207. case soptask.FieldPlanEndTime:
  15208. m.ClearPlanEndTime()
  15209. return nil
  15210. case soptask.FieldCreatorID:
  15211. m.ClearCreatorID()
  15212. return nil
  15213. case soptask.FieldOrganizationID:
  15214. m.ClearOrganizationID()
  15215. return nil
  15216. }
  15217. return fmt.Errorf("unknown SopTask nullable field %s", name)
  15218. }
  15219. // ResetField resets all changes in the mutation for the field with the given name.
  15220. // It returns an error if the field is not defined in the schema.
  15221. func (m *SopTaskMutation) ResetField(name string) error {
  15222. switch name {
  15223. case soptask.FieldCreatedAt:
  15224. m.ResetCreatedAt()
  15225. return nil
  15226. case soptask.FieldUpdatedAt:
  15227. m.ResetUpdatedAt()
  15228. return nil
  15229. case soptask.FieldStatus:
  15230. m.ResetStatus()
  15231. return nil
  15232. case soptask.FieldDeletedAt:
  15233. m.ResetDeletedAt()
  15234. return nil
  15235. case soptask.FieldName:
  15236. m.ResetName()
  15237. return nil
  15238. case soptask.FieldBotWxidList:
  15239. m.ResetBotWxidList()
  15240. return nil
  15241. case soptask.FieldType:
  15242. m.ResetType()
  15243. return nil
  15244. case soptask.FieldPlanStartTime:
  15245. m.ResetPlanStartTime()
  15246. return nil
  15247. case soptask.FieldPlanEndTime:
  15248. m.ResetPlanEndTime()
  15249. return nil
  15250. case soptask.FieldCreatorID:
  15251. m.ResetCreatorID()
  15252. return nil
  15253. case soptask.FieldOrganizationID:
  15254. m.ResetOrganizationID()
  15255. return nil
  15256. }
  15257. return fmt.Errorf("unknown SopTask field %s", name)
  15258. }
  15259. // AddedEdges returns all edge names that were set/added in this mutation.
  15260. func (m *SopTaskMutation) AddedEdges() []string {
  15261. edges := make([]string, 0, 1)
  15262. if m.task_stages != nil {
  15263. edges = append(edges, soptask.EdgeTaskStages)
  15264. }
  15265. return edges
  15266. }
  15267. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15268. // name in this mutation.
  15269. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  15270. switch name {
  15271. case soptask.EdgeTaskStages:
  15272. ids := make([]ent.Value, 0, len(m.task_stages))
  15273. for id := range m.task_stages {
  15274. ids = append(ids, id)
  15275. }
  15276. return ids
  15277. }
  15278. return nil
  15279. }
  15280. // RemovedEdges returns all edge names that were removed in this mutation.
  15281. func (m *SopTaskMutation) RemovedEdges() []string {
  15282. edges := make([]string, 0, 1)
  15283. if m.removedtask_stages != nil {
  15284. edges = append(edges, soptask.EdgeTaskStages)
  15285. }
  15286. return edges
  15287. }
  15288. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15289. // the given name in this mutation.
  15290. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  15291. switch name {
  15292. case soptask.EdgeTaskStages:
  15293. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  15294. for id := range m.removedtask_stages {
  15295. ids = append(ids, id)
  15296. }
  15297. return ids
  15298. }
  15299. return nil
  15300. }
  15301. // ClearedEdges returns all edge names that were cleared in this mutation.
  15302. func (m *SopTaskMutation) ClearedEdges() []string {
  15303. edges := make([]string, 0, 1)
  15304. if m.clearedtask_stages {
  15305. edges = append(edges, soptask.EdgeTaskStages)
  15306. }
  15307. return edges
  15308. }
  15309. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15310. // was cleared in this mutation.
  15311. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  15312. switch name {
  15313. case soptask.EdgeTaskStages:
  15314. return m.clearedtask_stages
  15315. }
  15316. return false
  15317. }
  15318. // ClearEdge clears the value of the edge with the given name. It returns an error
  15319. // if that edge is not defined in the schema.
  15320. func (m *SopTaskMutation) ClearEdge(name string) error {
  15321. switch name {
  15322. }
  15323. return fmt.Errorf("unknown SopTask unique edge %s", name)
  15324. }
  15325. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15326. // It returns an error if the edge is not defined in the schema.
  15327. func (m *SopTaskMutation) ResetEdge(name string) error {
  15328. switch name {
  15329. case soptask.EdgeTaskStages:
  15330. m.ResetTaskStages()
  15331. return nil
  15332. }
  15333. return fmt.Errorf("unknown SopTask edge %s", name)
  15334. }
  15335. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  15336. type TokenMutation struct {
  15337. config
  15338. op Op
  15339. typ string
  15340. id *uint64
  15341. created_at *time.Time
  15342. updated_at *time.Time
  15343. deleted_at *time.Time
  15344. expire_at *time.Time
  15345. token *string
  15346. mac *string
  15347. clearedFields map[string]struct{}
  15348. done bool
  15349. oldValue func(context.Context) (*Token, error)
  15350. predicates []predicate.Token
  15351. }
  15352. var _ ent.Mutation = (*TokenMutation)(nil)
  15353. // tokenOption allows management of the mutation configuration using functional options.
  15354. type tokenOption func(*TokenMutation)
  15355. // newTokenMutation creates new mutation for the Token entity.
  15356. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  15357. m := &TokenMutation{
  15358. config: c,
  15359. op: op,
  15360. typ: TypeToken,
  15361. clearedFields: make(map[string]struct{}),
  15362. }
  15363. for _, opt := range opts {
  15364. opt(m)
  15365. }
  15366. return m
  15367. }
  15368. // withTokenID sets the ID field of the mutation.
  15369. func withTokenID(id uint64) tokenOption {
  15370. return func(m *TokenMutation) {
  15371. var (
  15372. err error
  15373. once sync.Once
  15374. value *Token
  15375. )
  15376. m.oldValue = func(ctx context.Context) (*Token, error) {
  15377. once.Do(func() {
  15378. if m.done {
  15379. err = errors.New("querying old values post mutation is not allowed")
  15380. } else {
  15381. value, err = m.Client().Token.Get(ctx, id)
  15382. }
  15383. })
  15384. return value, err
  15385. }
  15386. m.id = &id
  15387. }
  15388. }
  15389. // withToken sets the old Token of the mutation.
  15390. func withToken(node *Token) tokenOption {
  15391. return func(m *TokenMutation) {
  15392. m.oldValue = func(context.Context) (*Token, error) {
  15393. return node, nil
  15394. }
  15395. m.id = &node.ID
  15396. }
  15397. }
  15398. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15399. // executed in a transaction (ent.Tx), a transactional client is returned.
  15400. func (m TokenMutation) Client() *Client {
  15401. client := &Client{config: m.config}
  15402. client.init()
  15403. return client
  15404. }
  15405. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15406. // it returns an error otherwise.
  15407. func (m TokenMutation) Tx() (*Tx, error) {
  15408. if _, ok := m.driver.(*txDriver); !ok {
  15409. return nil, errors.New("ent: mutation is not running in a transaction")
  15410. }
  15411. tx := &Tx{config: m.config}
  15412. tx.init()
  15413. return tx, nil
  15414. }
  15415. // SetID sets the value of the id field. Note that this
  15416. // operation is only accepted on creation of Token entities.
  15417. func (m *TokenMutation) SetID(id uint64) {
  15418. m.id = &id
  15419. }
  15420. // ID returns the ID value in the mutation. Note that the ID is only available
  15421. // if it was provided to the builder or after it was returned from the database.
  15422. func (m *TokenMutation) ID() (id uint64, exists bool) {
  15423. if m.id == nil {
  15424. return
  15425. }
  15426. return *m.id, true
  15427. }
  15428. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15429. // That means, if the mutation is applied within a transaction with an isolation level such
  15430. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15431. // or updated by the mutation.
  15432. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  15433. switch {
  15434. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15435. id, exists := m.ID()
  15436. if exists {
  15437. return []uint64{id}, nil
  15438. }
  15439. fallthrough
  15440. case m.op.Is(OpUpdate | OpDelete):
  15441. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  15442. default:
  15443. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15444. }
  15445. }
  15446. // SetCreatedAt sets the "created_at" field.
  15447. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  15448. m.created_at = &t
  15449. }
  15450. // CreatedAt returns the value of the "created_at" field in the mutation.
  15451. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  15452. v := m.created_at
  15453. if v == nil {
  15454. return
  15455. }
  15456. return *v, true
  15457. }
  15458. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  15459. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15461. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15462. if !m.op.Is(OpUpdateOne) {
  15463. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15464. }
  15465. if m.id == nil || m.oldValue == nil {
  15466. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15467. }
  15468. oldValue, err := m.oldValue(ctx)
  15469. if err != nil {
  15470. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15471. }
  15472. return oldValue.CreatedAt, nil
  15473. }
  15474. // ResetCreatedAt resets all changes to the "created_at" field.
  15475. func (m *TokenMutation) ResetCreatedAt() {
  15476. m.created_at = nil
  15477. }
  15478. // SetUpdatedAt sets the "updated_at" field.
  15479. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  15480. m.updated_at = &t
  15481. }
  15482. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15483. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  15484. v := m.updated_at
  15485. if v == nil {
  15486. return
  15487. }
  15488. return *v, true
  15489. }
  15490. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  15491. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15493. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15494. if !m.op.Is(OpUpdateOne) {
  15495. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15496. }
  15497. if m.id == nil || m.oldValue == nil {
  15498. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15499. }
  15500. oldValue, err := m.oldValue(ctx)
  15501. if err != nil {
  15502. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15503. }
  15504. return oldValue.UpdatedAt, nil
  15505. }
  15506. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15507. func (m *TokenMutation) ResetUpdatedAt() {
  15508. m.updated_at = nil
  15509. }
  15510. // SetDeletedAt sets the "deleted_at" field.
  15511. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  15512. m.deleted_at = &t
  15513. }
  15514. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15515. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  15516. v := m.deleted_at
  15517. if v == nil {
  15518. return
  15519. }
  15520. return *v, true
  15521. }
  15522. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  15523. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15525. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15526. if !m.op.Is(OpUpdateOne) {
  15527. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15528. }
  15529. if m.id == nil || m.oldValue == nil {
  15530. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15531. }
  15532. oldValue, err := m.oldValue(ctx)
  15533. if err != nil {
  15534. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15535. }
  15536. return oldValue.DeletedAt, nil
  15537. }
  15538. // ClearDeletedAt clears the value of the "deleted_at" field.
  15539. func (m *TokenMutation) ClearDeletedAt() {
  15540. m.deleted_at = nil
  15541. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  15542. }
  15543. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15544. func (m *TokenMutation) DeletedAtCleared() bool {
  15545. _, ok := m.clearedFields[token.FieldDeletedAt]
  15546. return ok
  15547. }
  15548. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15549. func (m *TokenMutation) ResetDeletedAt() {
  15550. m.deleted_at = nil
  15551. delete(m.clearedFields, token.FieldDeletedAt)
  15552. }
  15553. // SetExpireAt sets the "expire_at" field.
  15554. func (m *TokenMutation) SetExpireAt(t time.Time) {
  15555. m.expire_at = &t
  15556. }
  15557. // ExpireAt returns the value of the "expire_at" field in the mutation.
  15558. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  15559. v := m.expire_at
  15560. if v == nil {
  15561. return
  15562. }
  15563. return *v, true
  15564. }
  15565. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  15566. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15568. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  15569. if !m.op.Is(OpUpdateOne) {
  15570. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  15571. }
  15572. if m.id == nil || m.oldValue == nil {
  15573. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  15574. }
  15575. oldValue, err := m.oldValue(ctx)
  15576. if err != nil {
  15577. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  15578. }
  15579. return oldValue.ExpireAt, nil
  15580. }
  15581. // ClearExpireAt clears the value of the "expire_at" field.
  15582. func (m *TokenMutation) ClearExpireAt() {
  15583. m.expire_at = nil
  15584. m.clearedFields[token.FieldExpireAt] = struct{}{}
  15585. }
  15586. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  15587. func (m *TokenMutation) ExpireAtCleared() bool {
  15588. _, ok := m.clearedFields[token.FieldExpireAt]
  15589. return ok
  15590. }
  15591. // ResetExpireAt resets all changes to the "expire_at" field.
  15592. func (m *TokenMutation) ResetExpireAt() {
  15593. m.expire_at = nil
  15594. delete(m.clearedFields, token.FieldExpireAt)
  15595. }
  15596. // SetToken sets the "token" field.
  15597. func (m *TokenMutation) SetToken(s string) {
  15598. m.token = &s
  15599. }
  15600. // Token returns the value of the "token" field in the mutation.
  15601. func (m *TokenMutation) Token() (r string, exists bool) {
  15602. v := m.token
  15603. if v == nil {
  15604. return
  15605. }
  15606. return *v, true
  15607. }
  15608. // OldToken returns the old "token" field's value of the Token entity.
  15609. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15611. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  15612. if !m.op.Is(OpUpdateOne) {
  15613. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  15614. }
  15615. if m.id == nil || m.oldValue == nil {
  15616. return v, errors.New("OldToken requires an ID field in the mutation")
  15617. }
  15618. oldValue, err := m.oldValue(ctx)
  15619. if err != nil {
  15620. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  15621. }
  15622. return oldValue.Token, nil
  15623. }
  15624. // ClearToken clears the value of the "token" field.
  15625. func (m *TokenMutation) ClearToken() {
  15626. m.token = nil
  15627. m.clearedFields[token.FieldToken] = struct{}{}
  15628. }
  15629. // TokenCleared returns if the "token" field was cleared in this mutation.
  15630. func (m *TokenMutation) TokenCleared() bool {
  15631. _, ok := m.clearedFields[token.FieldToken]
  15632. return ok
  15633. }
  15634. // ResetToken resets all changes to the "token" field.
  15635. func (m *TokenMutation) ResetToken() {
  15636. m.token = nil
  15637. delete(m.clearedFields, token.FieldToken)
  15638. }
  15639. // SetMAC sets the "mac" field.
  15640. func (m *TokenMutation) SetMAC(s string) {
  15641. m.mac = &s
  15642. }
  15643. // MAC returns the value of the "mac" field in the mutation.
  15644. func (m *TokenMutation) MAC() (r string, exists bool) {
  15645. v := m.mac
  15646. if v == nil {
  15647. return
  15648. }
  15649. return *v, true
  15650. }
  15651. // OldMAC returns the old "mac" field's value of the Token entity.
  15652. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  15653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15654. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  15655. if !m.op.Is(OpUpdateOne) {
  15656. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  15657. }
  15658. if m.id == nil || m.oldValue == nil {
  15659. return v, errors.New("OldMAC requires an ID field in the mutation")
  15660. }
  15661. oldValue, err := m.oldValue(ctx)
  15662. if err != nil {
  15663. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  15664. }
  15665. return oldValue.MAC, nil
  15666. }
  15667. // ResetMAC resets all changes to the "mac" field.
  15668. func (m *TokenMutation) ResetMAC() {
  15669. m.mac = nil
  15670. }
  15671. // Where appends a list predicates to the TokenMutation builder.
  15672. func (m *TokenMutation) Where(ps ...predicate.Token) {
  15673. m.predicates = append(m.predicates, ps...)
  15674. }
  15675. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  15676. // users can use type-assertion to append predicates that do not depend on any generated package.
  15677. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  15678. p := make([]predicate.Token, len(ps))
  15679. for i := range ps {
  15680. p[i] = ps[i]
  15681. }
  15682. m.Where(p...)
  15683. }
  15684. // Op returns the operation name.
  15685. func (m *TokenMutation) Op() Op {
  15686. return m.op
  15687. }
  15688. // SetOp allows setting the mutation operation.
  15689. func (m *TokenMutation) SetOp(op Op) {
  15690. m.op = op
  15691. }
  15692. // Type returns the node type of this mutation (Token).
  15693. func (m *TokenMutation) Type() string {
  15694. return m.typ
  15695. }
  15696. // Fields returns all fields that were changed during this mutation. Note that in
  15697. // order to get all numeric fields that were incremented/decremented, call
  15698. // AddedFields().
  15699. func (m *TokenMutation) Fields() []string {
  15700. fields := make([]string, 0, 6)
  15701. if m.created_at != nil {
  15702. fields = append(fields, token.FieldCreatedAt)
  15703. }
  15704. if m.updated_at != nil {
  15705. fields = append(fields, token.FieldUpdatedAt)
  15706. }
  15707. if m.deleted_at != nil {
  15708. fields = append(fields, token.FieldDeletedAt)
  15709. }
  15710. if m.expire_at != nil {
  15711. fields = append(fields, token.FieldExpireAt)
  15712. }
  15713. if m.token != nil {
  15714. fields = append(fields, token.FieldToken)
  15715. }
  15716. if m.mac != nil {
  15717. fields = append(fields, token.FieldMAC)
  15718. }
  15719. return fields
  15720. }
  15721. // Field returns the value of a field with the given name. The second boolean
  15722. // return value indicates that this field was not set, or was not defined in the
  15723. // schema.
  15724. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  15725. switch name {
  15726. case token.FieldCreatedAt:
  15727. return m.CreatedAt()
  15728. case token.FieldUpdatedAt:
  15729. return m.UpdatedAt()
  15730. case token.FieldDeletedAt:
  15731. return m.DeletedAt()
  15732. case token.FieldExpireAt:
  15733. return m.ExpireAt()
  15734. case token.FieldToken:
  15735. return m.Token()
  15736. case token.FieldMAC:
  15737. return m.MAC()
  15738. }
  15739. return nil, false
  15740. }
  15741. // OldField returns the old value of the field from the database. An error is
  15742. // returned if the mutation operation is not UpdateOne, or the query to the
  15743. // database failed.
  15744. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15745. switch name {
  15746. case token.FieldCreatedAt:
  15747. return m.OldCreatedAt(ctx)
  15748. case token.FieldUpdatedAt:
  15749. return m.OldUpdatedAt(ctx)
  15750. case token.FieldDeletedAt:
  15751. return m.OldDeletedAt(ctx)
  15752. case token.FieldExpireAt:
  15753. return m.OldExpireAt(ctx)
  15754. case token.FieldToken:
  15755. return m.OldToken(ctx)
  15756. case token.FieldMAC:
  15757. return m.OldMAC(ctx)
  15758. }
  15759. return nil, fmt.Errorf("unknown Token field %s", name)
  15760. }
  15761. // SetField sets the value of a field with the given name. It returns an error if
  15762. // the field is not defined in the schema, or if the type mismatched the field
  15763. // type.
  15764. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  15765. switch name {
  15766. case token.FieldCreatedAt:
  15767. v, ok := value.(time.Time)
  15768. if !ok {
  15769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15770. }
  15771. m.SetCreatedAt(v)
  15772. return nil
  15773. case token.FieldUpdatedAt:
  15774. v, ok := value.(time.Time)
  15775. if !ok {
  15776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15777. }
  15778. m.SetUpdatedAt(v)
  15779. return nil
  15780. case token.FieldDeletedAt:
  15781. v, ok := value.(time.Time)
  15782. if !ok {
  15783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15784. }
  15785. m.SetDeletedAt(v)
  15786. return nil
  15787. case token.FieldExpireAt:
  15788. v, ok := value.(time.Time)
  15789. if !ok {
  15790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15791. }
  15792. m.SetExpireAt(v)
  15793. return nil
  15794. case token.FieldToken:
  15795. v, ok := value.(string)
  15796. if !ok {
  15797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15798. }
  15799. m.SetToken(v)
  15800. return nil
  15801. case token.FieldMAC:
  15802. v, ok := value.(string)
  15803. if !ok {
  15804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15805. }
  15806. m.SetMAC(v)
  15807. return nil
  15808. }
  15809. return fmt.Errorf("unknown Token field %s", name)
  15810. }
  15811. // AddedFields returns all numeric fields that were incremented/decremented during
  15812. // this mutation.
  15813. func (m *TokenMutation) AddedFields() []string {
  15814. return nil
  15815. }
  15816. // AddedField returns the numeric value that was incremented/decremented on a field
  15817. // with the given name. The second boolean return value indicates that this field
  15818. // was not set, or was not defined in the schema.
  15819. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  15820. return nil, false
  15821. }
  15822. // AddField adds the value to the field with the given name. It returns an error if
  15823. // the field is not defined in the schema, or if the type mismatched the field
  15824. // type.
  15825. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  15826. switch name {
  15827. }
  15828. return fmt.Errorf("unknown Token numeric field %s", name)
  15829. }
  15830. // ClearedFields returns all nullable fields that were cleared during this
  15831. // mutation.
  15832. func (m *TokenMutation) ClearedFields() []string {
  15833. var fields []string
  15834. if m.FieldCleared(token.FieldDeletedAt) {
  15835. fields = append(fields, token.FieldDeletedAt)
  15836. }
  15837. if m.FieldCleared(token.FieldExpireAt) {
  15838. fields = append(fields, token.FieldExpireAt)
  15839. }
  15840. if m.FieldCleared(token.FieldToken) {
  15841. fields = append(fields, token.FieldToken)
  15842. }
  15843. return fields
  15844. }
  15845. // FieldCleared returns a boolean indicating if a field with the given name was
  15846. // cleared in this mutation.
  15847. func (m *TokenMutation) FieldCleared(name string) bool {
  15848. _, ok := m.clearedFields[name]
  15849. return ok
  15850. }
  15851. // ClearField clears the value of the field with the given name. It returns an
  15852. // error if the field is not defined in the schema.
  15853. func (m *TokenMutation) ClearField(name string) error {
  15854. switch name {
  15855. case token.FieldDeletedAt:
  15856. m.ClearDeletedAt()
  15857. return nil
  15858. case token.FieldExpireAt:
  15859. m.ClearExpireAt()
  15860. return nil
  15861. case token.FieldToken:
  15862. m.ClearToken()
  15863. return nil
  15864. }
  15865. return fmt.Errorf("unknown Token nullable field %s", name)
  15866. }
  15867. // ResetField resets all changes in the mutation for the field with the given name.
  15868. // It returns an error if the field is not defined in the schema.
  15869. func (m *TokenMutation) ResetField(name string) error {
  15870. switch name {
  15871. case token.FieldCreatedAt:
  15872. m.ResetCreatedAt()
  15873. return nil
  15874. case token.FieldUpdatedAt:
  15875. m.ResetUpdatedAt()
  15876. return nil
  15877. case token.FieldDeletedAt:
  15878. m.ResetDeletedAt()
  15879. return nil
  15880. case token.FieldExpireAt:
  15881. m.ResetExpireAt()
  15882. return nil
  15883. case token.FieldToken:
  15884. m.ResetToken()
  15885. return nil
  15886. case token.FieldMAC:
  15887. m.ResetMAC()
  15888. return nil
  15889. }
  15890. return fmt.Errorf("unknown Token field %s", name)
  15891. }
  15892. // AddedEdges returns all edge names that were set/added in this mutation.
  15893. func (m *TokenMutation) AddedEdges() []string {
  15894. edges := make([]string, 0, 0)
  15895. return edges
  15896. }
  15897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15898. // name in this mutation.
  15899. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  15900. return nil
  15901. }
  15902. // RemovedEdges returns all edge names that were removed in this mutation.
  15903. func (m *TokenMutation) RemovedEdges() []string {
  15904. edges := make([]string, 0, 0)
  15905. return edges
  15906. }
  15907. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15908. // the given name in this mutation.
  15909. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  15910. return nil
  15911. }
  15912. // ClearedEdges returns all edge names that were cleared in this mutation.
  15913. func (m *TokenMutation) ClearedEdges() []string {
  15914. edges := make([]string, 0, 0)
  15915. return edges
  15916. }
  15917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15918. // was cleared in this mutation.
  15919. func (m *TokenMutation) EdgeCleared(name string) bool {
  15920. return false
  15921. }
  15922. // ClearEdge clears the value of the edge with the given name. It returns an error
  15923. // if that edge is not defined in the schema.
  15924. func (m *TokenMutation) ClearEdge(name string) error {
  15925. return fmt.Errorf("unknown Token unique edge %s", name)
  15926. }
  15927. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15928. // It returns an error if the edge is not defined in the schema.
  15929. func (m *TokenMutation) ResetEdge(name string) error {
  15930. return fmt.Errorf("unknown Token edge %s", name)
  15931. }
  15932. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  15933. type TutorialMutation struct {
  15934. config
  15935. op Op
  15936. typ string
  15937. id *uint64
  15938. created_at *time.Time
  15939. updated_at *time.Time
  15940. deleted_at *time.Time
  15941. index *int
  15942. addindex *int
  15943. title *string
  15944. content *string
  15945. organization_id *uint64
  15946. addorganization_id *int64
  15947. clearedFields map[string]struct{}
  15948. employee *uint64
  15949. clearedemployee bool
  15950. done bool
  15951. oldValue func(context.Context) (*Tutorial, error)
  15952. predicates []predicate.Tutorial
  15953. }
  15954. var _ ent.Mutation = (*TutorialMutation)(nil)
  15955. // tutorialOption allows management of the mutation configuration using functional options.
  15956. type tutorialOption func(*TutorialMutation)
  15957. // newTutorialMutation creates new mutation for the Tutorial entity.
  15958. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  15959. m := &TutorialMutation{
  15960. config: c,
  15961. op: op,
  15962. typ: TypeTutorial,
  15963. clearedFields: make(map[string]struct{}),
  15964. }
  15965. for _, opt := range opts {
  15966. opt(m)
  15967. }
  15968. return m
  15969. }
  15970. // withTutorialID sets the ID field of the mutation.
  15971. func withTutorialID(id uint64) tutorialOption {
  15972. return func(m *TutorialMutation) {
  15973. var (
  15974. err error
  15975. once sync.Once
  15976. value *Tutorial
  15977. )
  15978. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  15979. once.Do(func() {
  15980. if m.done {
  15981. err = errors.New("querying old values post mutation is not allowed")
  15982. } else {
  15983. value, err = m.Client().Tutorial.Get(ctx, id)
  15984. }
  15985. })
  15986. return value, err
  15987. }
  15988. m.id = &id
  15989. }
  15990. }
  15991. // withTutorial sets the old Tutorial of the mutation.
  15992. func withTutorial(node *Tutorial) tutorialOption {
  15993. return func(m *TutorialMutation) {
  15994. m.oldValue = func(context.Context) (*Tutorial, error) {
  15995. return node, nil
  15996. }
  15997. m.id = &node.ID
  15998. }
  15999. }
  16000. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16001. // executed in a transaction (ent.Tx), a transactional client is returned.
  16002. func (m TutorialMutation) Client() *Client {
  16003. client := &Client{config: m.config}
  16004. client.init()
  16005. return client
  16006. }
  16007. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16008. // it returns an error otherwise.
  16009. func (m TutorialMutation) Tx() (*Tx, error) {
  16010. if _, ok := m.driver.(*txDriver); !ok {
  16011. return nil, errors.New("ent: mutation is not running in a transaction")
  16012. }
  16013. tx := &Tx{config: m.config}
  16014. tx.init()
  16015. return tx, nil
  16016. }
  16017. // SetID sets the value of the id field. Note that this
  16018. // operation is only accepted on creation of Tutorial entities.
  16019. func (m *TutorialMutation) SetID(id uint64) {
  16020. m.id = &id
  16021. }
  16022. // ID returns the ID value in the mutation. Note that the ID is only available
  16023. // if it was provided to the builder or after it was returned from the database.
  16024. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  16025. if m.id == nil {
  16026. return
  16027. }
  16028. return *m.id, true
  16029. }
  16030. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16031. // That means, if the mutation is applied within a transaction with an isolation level such
  16032. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16033. // or updated by the mutation.
  16034. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  16035. switch {
  16036. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16037. id, exists := m.ID()
  16038. if exists {
  16039. return []uint64{id}, nil
  16040. }
  16041. fallthrough
  16042. case m.op.Is(OpUpdate | OpDelete):
  16043. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  16044. default:
  16045. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16046. }
  16047. }
  16048. // SetCreatedAt sets the "created_at" field.
  16049. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  16050. m.created_at = &t
  16051. }
  16052. // CreatedAt returns the value of the "created_at" field in the mutation.
  16053. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  16054. v := m.created_at
  16055. if v == nil {
  16056. return
  16057. }
  16058. return *v, true
  16059. }
  16060. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  16061. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16063. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16064. if !m.op.Is(OpUpdateOne) {
  16065. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16066. }
  16067. if m.id == nil || m.oldValue == nil {
  16068. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16069. }
  16070. oldValue, err := m.oldValue(ctx)
  16071. if err != nil {
  16072. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16073. }
  16074. return oldValue.CreatedAt, nil
  16075. }
  16076. // ResetCreatedAt resets all changes to the "created_at" field.
  16077. func (m *TutorialMutation) ResetCreatedAt() {
  16078. m.created_at = nil
  16079. }
  16080. // SetUpdatedAt sets the "updated_at" field.
  16081. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  16082. m.updated_at = &t
  16083. }
  16084. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16085. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  16086. v := m.updated_at
  16087. if v == nil {
  16088. return
  16089. }
  16090. return *v, true
  16091. }
  16092. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  16093. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16095. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16096. if !m.op.Is(OpUpdateOne) {
  16097. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16098. }
  16099. if m.id == nil || m.oldValue == nil {
  16100. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16101. }
  16102. oldValue, err := m.oldValue(ctx)
  16103. if err != nil {
  16104. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16105. }
  16106. return oldValue.UpdatedAt, nil
  16107. }
  16108. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16109. func (m *TutorialMutation) ResetUpdatedAt() {
  16110. m.updated_at = nil
  16111. }
  16112. // SetDeletedAt sets the "deleted_at" field.
  16113. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  16114. m.deleted_at = &t
  16115. }
  16116. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16117. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  16118. v := m.deleted_at
  16119. if v == nil {
  16120. return
  16121. }
  16122. return *v, true
  16123. }
  16124. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  16125. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16127. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16128. if !m.op.Is(OpUpdateOne) {
  16129. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16130. }
  16131. if m.id == nil || m.oldValue == nil {
  16132. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16133. }
  16134. oldValue, err := m.oldValue(ctx)
  16135. if err != nil {
  16136. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16137. }
  16138. return oldValue.DeletedAt, nil
  16139. }
  16140. // ClearDeletedAt clears the value of the "deleted_at" field.
  16141. func (m *TutorialMutation) ClearDeletedAt() {
  16142. m.deleted_at = nil
  16143. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  16144. }
  16145. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16146. func (m *TutorialMutation) DeletedAtCleared() bool {
  16147. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  16148. return ok
  16149. }
  16150. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16151. func (m *TutorialMutation) ResetDeletedAt() {
  16152. m.deleted_at = nil
  16153. delete(m.clearedFields, tutorial.FieldDeletedAt)
  16154. }
  16155. // SetEmployeeID sets the "employee_id" field.
  16156. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  16157. m.employee = &u
  16158. }
  16159. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16160. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  16161. v := m.employee
  16162. if v == nil {
  16163. return
  16164. }
  16165. return *v, true
  16166. }
  16167. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  16168. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16170. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16171. if !m.op.Is(OpUpdateOne) {
  16172. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16173. }
  16174. if m.id == nil || m.oldValue == nil {
  16175. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16176. }
  16177. oldValue, err := m.oldValue(ctx)
  16178. if err != nil {
  16179. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16180. }
  16181. return oldValue.EmployeeID, nil
  16182. }
  16183. // ResetEmployeeID resets all changes to the "employee_id" field.
  16184. func (m *TutorialMutation) ResetEmployeeID() {
  16185. m.employee = nil
  16186. }
  16187. // SetIndex sets the "index" field.
  16188. func (m *TutorialMutation) SetIndex(i int) {
  16189. m.index = &i
  16190. m.addindex = nil
  16191. }
  16192. // Index returns the value of the "index" field in the mutation.
  16193. func (m *TutorialMutation) Index() (r int, exists bool) {
  16194. v := m.index
  16195. if v == nil {
  16196. return
  16197. }
  16198. return *v, true
  16199. }
  16200. // OldIndex returns the old "index" field's value of the Tutorial entity.
  16201. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16203. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  16204. if !m.op.Is(OpUpdateOne) {
  16205. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  16206. }
  16207. if m.id == nil || m.oldValue == nil {
  16208. return v, errors.New("OldIndex requires an ID field in the mutation")
  16209. }
  16210. oldValue, err := m.oldValue(ctx)
  16211. if err != nil {
  16212. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  16213. }
  16214. return oldValue.Index, nil
  16215. }
  16216. // AddIndex adds i to the "index" field.
  16217. func (m *TutorialMutation) AddIndex(i int) {
  16218. if m.addindex != nil {
  16219. *m.addindex += i
  16220. } else {
  16221. m.addindex = &i
  16222. }
  16223. }
  16224. // AddedIndex returns the value that was added to the "index" field in this mutation.
  16225. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  16226. v := m.addindex
  16227. if v == nil {
  16228. return
  16229. }
  16230. return *v, true
  16231. }
  16232. // ResetIndex resets all changes to the "index" field.
  16233. func (m *TutorialMutation) ResetIndex() {
  16234. m.index = nil
  16235. m.addindex = nil
  16236. }
  16237. // SetTitle sets the "title" field.
  16238. func (m *TutorialMutation) SetTitle(s string) {
  16239. m.title = &s
  16240. }
  16241. // Title returns the value of the "title" field in the mutation.
  16242. func (m *TutorialMutation) Title() (r string, exists bool) {
  16243. v := m.title
  16244. if v == nil {
  16245. return
  16246. }
  16247. return *v, true
  16248. }
  16249. // OldTitle returns the old "title" field's value of the Tutorial entity.
  16250. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16252. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  16253. if !m.op.Is(OpUpdateOne) {
  16254. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16255. }
  16256. if m.id == nil || m.oldValue == nil {
  16257. return v, errors.New("OldTitle requires an ID field in the mutation")
  16258. }
  16259. oldValue, err := m.oldValue(ctx)
  16260. if err != nil {
  16261. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16262. }
  16263. return oldValue.Title, nil
  16264. }
  16265. // ResetTitle resets all changes to the "title" field.
  16266. func (m *TutorialMutation) ResetTitle() {
  16267. m.title = nil
  16268. }
  16269. // SetContent sets the "content" field.
  16270. func (m *TutorialMutation) SetContent(s string) {
  16271. m.content = &s
  16272. }
  16273. // Content returns the value of the "content" field in the mutation.
  16274. func (m *TutorialMutation) Content() (r string, exists bool) {
  16275. v := m.content
  16276. if v == nil {
  16277. return
  16278. }
  16279. return *v, true
  16280. }
  16281. // OldContent returns the old "content" field's value of the Tutorial entity.
  16282. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16284. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  16285. if !m.op.Is(OpUpdateOne) {
  16286. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16287. }
  16288. if m.id == nil || m.oldValue == nil {
  16289. return v, errors.New("OldContent requires an ID field in the mutation")
  16290. }
  16291. oldValue, err := m.oldValue(ctx)
  16292. if err != nil {
  16293. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16294. }
  16295. return oldValue.Content, nil
  16296. }
  16297. // ResetContent resets all changes to the "content" field.
  16298. func (m *TutorialMutation) ResetContent() {
  16299. m.content = nil
  16300. }
  16301. // SetOrganizationID sets the "organization_id" field.
  16302. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  16303. m.organization_id = &u
  16304. m.addorganization_id = nil
  16305. }
  16306. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16307. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  16308. v := m.organization_id
  16309. if v == nil {
  16310. return
  16311. }
  16312. return *v, true
  16313. }
  16314. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  16315. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  16316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16317. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16318. if !m.op.Is(OpUpdateOne) {
  16319. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16320. }
  16321. if m.id == nil || m.oldValue == nil {
  16322. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16323. }
  16324. oldValue, err := m.oldValue(ctx)
  16325. if err != nil {
  16326. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16327. }
  16328. return oldValue.OrganizationID, nil
  16329. }
  16330. // AddOrganizationID adds u to the "organization_id" field.
  16331. func (m *TutorialMutation) AddOrganizationID(u int64) {
  16332. if m.addorganization_id != nil {
  16333. *m.addorganization_id += u
  16334. } else {
  16335. m.addorganization_id = &u
  16336. }
  16337. }
  16338. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16339. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  16340. v := m.addorganization_id
  16341. if v == nil {
  16342. return
  16343. }
  16344. return *v, true
  16345. }
  16346. // ResetOrganizationID resets all changes to the "organization_id" field.
  16347. func (m *TutorialMutation) ResetOrganizationID() {
  16348. m.organization_id = nil
  16349. m.addorganization_id = nil
  16350. }
  16351. // ClearEmployee clears the "employee" edge to the Employee entity.
  16352. func (m *TutorialMutation) ClearEmployee() {
  16353. m.clearedemployee = true
  16354. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  16355. }
  16356. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  16357. func (m *TutorialMutation) EmployeeCleared() bool {
  16358. return m.clearedemployee
  16359. }
  16360. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  16361. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16362. // EmployeeID instead. It exists only for internal usage by the builders.
  16363. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  16364. if id := m.employee; id != nil {
  16365. ids = append(ids, *id)
  16366. }
  16367. return
  16368. }
  16369. // ResetEmployee resets all changes to the "employee" edge.
  16370. func (m *TutorialMutation) ResetEmployee() {
  16371. m.employee = nil
  16372. m.clearedemployee = false
  16373. }
  16374. // Where appends a list predicates to the TutorialMutation builder.
  16375. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  16376. m.predicates = append(m.predicates, ps...)
  16377. }
  16378. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  16379. // users can use type-assertion to append predicates that do not depend on any generated package.
  16380. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  16381. p := make([]predicate.Tutorial, len(ps))
  16382. for i := range ps {
  16383. p[i] = ps[i]
  16384. }
  16385. m.Where(p...)
  16386. }
  16387. // Op returns the operation name.
  16388. func (m *TutorialMutation) Op() Op {
  16389. return m.op
  16390. }
  16391. // SetOp allows setting the mutation operation.
  16392. func (m *TutorialMutation) SetOp(op Op) {
  16393. m.op = op
  16394. }
  16395. // Type returns the node type of this mutation (Tutorial).
  16396. func (m *TutorialMutation) Type() string {
  16397. return m.typ
  16398. }
  16399. // Fields returns all fields that were changed during this mutation. Note that in
  16400. // order to get all numeric fields that were incremented/decremented, call
  16401. // AddedFields().
  16402. func (m *TutorialMutation) Fields() []string {
  16403. fields := make([]string, 0, 8)
  16404. if m.created_at != nil {
  16405. fields = append(fields, tutorial.FieldCreatedAt)
  16406. }
  16407. if m.updated_at != nil {
  16408. fields = append(fields, tutorial.FieldUpdatedAt)
  16409. }
  16410. if m.deleted_at != nil {
  16411. fields = append(fields, tutorial.FieldDeletedAt)
  16412. }
  16413. if m.employee != nil {
  16414. fields = append(fields, tutorial.FieldEmployeeID)
  16415. }
  16416. if m.index != nil {
  16417. fields = append(fields, tutorial.FieldIndex)
  16418. }
  16419. if m.title != nil {
  16420. fields = append(fields, tutorial.FieldTitle)
  16421. }
  16422. if m.content != nil {
  16423. fields = append(fields, tutorial.FieldContent)
  16424. }
  16425. if m.organization_id != nil {
  16426. fields = append(fields, tutorial.FieldOrganizationID)
  16427. }
  16428. return fields
  16429. }
  16430. // Field returns the value of a field with the given name. The second boolean
  16431. // return value indicates that this field was not set, or was not defined in the
  16432. // schema.
  16433. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  16434. switch name {
  16435. case tutorial.FieldCreatedAt:
  16436. return m.CreatedAt()
  16437. case tutorial.FieldUpdatedAt:
  16438. return m.UpdatedAt()
  16439. case tutorial.FieldDeletedAt:
  16440. return m.DeletedAt()
  16441. case tutorial.FieldEmployeeID:
  16442. return m.EmployeeID()
  16443. case tutorial.FieldIndex:
  16444. return m.Index()
  16445. case tutorial.FieldTitle:
  16446. return m.Title()
  16447. case tutorial.FieldContent:
  16448. return m.Content()
  16449. case tutorial.FieldOrganizationID:
  16450. return m.OrganizationID()
  16451. }
  16452. return nil, false
  16453. }
  16454. // OldField returns the old value of the field from the database. An error is
  16455. // returned if the mutation operation is not UpdateOne, or the query to the
  16456. // database failed.
  16457. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16458. switch name {
  16459. case tutorial.FieldCreatedAt:
  16460. return m.OldCreatedAt(ctx)
  16461. case tutorial.FieldUpdatedAt:
  16462. return m.OldUpdatedAt(ctx)
  16463. case tutorial.FieldDeletedAt:
  16464. return m.OldDeletedAt(ctx)
  16465. case tutorial.FieldEmployeeID:
  16466. return m.OldEmployeeID(ctx)
  16467. case tutorial.FieldIndex:
  16468. return m.OldIndex(ctx)
  16469. case tutorial.FieldTitle:
  16470. return m.OldTitle(ctx)
  16471. case tutorial.FieldContent:
  16472. return m.OldContent(ctx)
  16473. case tutorial.FieldOrganizationID:
  16474. return m.OldOrganizationID(ctx)
  16475. }
  16476. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  16477. }
  16478. // SetField sets the value of a field with the given name. It returns an error if
  16479. // the field is not defined in the schema, or if the type mismatched the field
  16480. // type.
  16481. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  16482. switch name {
  16483. case tutorial.FieldCreatedAt:
  16484. v, ok := value.(time.Time)
  16485. if !ok {
  16486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16487. }
  16488. m.SetCreatedAt(v)
  16489. return nil
  16490. case tutorial.FieldUpdatedAt:
  16491. v, ok := value.(time.Time)
  16492. if !ok {
  16493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16494. }
  16495. m.SetUpdatedAt(v)
  16496. return nil
  16497. case tutorial.FieldDeletedAt:
  16498. v, ok := value.(time.Time)
  16499. if !ok {
  16500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16501. }
  16502. m.SetDeletedAt(v)
  16503. return nil
  16504. case tutorial.FieldEmployeeID:
  16505. v, ok := value.(uint64)
  16506. if !ok {
  16507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16508. }
  16509. m.SetEmployeeID(v)
  16510. return nil
  16511. case tutorial.FieldIndex:
  16512. v, ok := value.(int)
  16513. if !ok {
  16514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16515. }
  16516. m.SetIndex(v)
  16517. return nil
  16518. case tutorial.FieldTitle:
  16519. v, ok := value.(string)
  16520. if !ok {
  16521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16522. }
  16523. m.SetTitle(v)
  16524. return nil
  16525. case tutorial.FieldContent:
  16526. v, ok := value.(string)
  16527. if !ok {
  16528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16529. }
  16530. m.SetContent(v)
  16531. return nil
  16532. case tutorial.FieldOrganizationID:
  16533. v, ok := value.(uint64)
  16534. if !ok {
  16535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16536. }
  16537. m.SetOrganizationID(v)
  16538. return nil
  16539. }
  16540. return fmt.Errorf("unknown Tutorial field %s", name)
  16541. }
  16542. // AddedFields returns all numeric fields that were incremented/decremented during
  16543. // this mutation.
  16544. func (m *TutorialMutation) AddedFields() []string {
  16545. var fields []string
  16546. if m.addindex != nil {
  16547. fields = append(fields, tutorial.FieldIndex)
  16548. }
  16549. if m.addorganization_id != nil {
  16550. fields = append(fields, tutorial.FieldOrganizationID)
  16551. }
  16552. return fields
  16553. }
  16554. // AddedField returns the numeric value that was incremented/decremented on a field
  16555. // with the given name. The second boolean return value indicates that this field
  16556. // was not set, or was not defined in the schema.
  16557. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  16558. switch name {
  16559. case tutorial.FieldIndex:
  16560. return m.AddedIndex()
  16561. case tutorial.FieldOrganizationID:
  16562. return m.AddedOrganizationID()
  16563. }
  16564. return nil, false
  16565. }
  16566. // AddField adds the value to the field with the given name. It returns an error if
  16567. // the field is not defined in the schema, or if the type mismatched the field
  16568. // type.
  16569. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  16570. switch name {
  16571. case tutorial.FieldIndex:
  16572. v, ok := value.(int)
  16573. if !ok {
  16574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16575. }
  16576. m.AddIndex(v)
  16577. return nil
  16578. case tutorial.FieldOrganizationID:
  16579. v, ok := value.(int64)
  16580. if !ok {
  16581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16582. }
  16583. m.AddOrganizationID(v)
  16584. return nil
  16585. }
  16586. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  16587. }
  16588. // ClearedFields returns all nullable fields that were cleared during this
  16589. // mutation.
  16590. func (m *TutorialMutation) ClearedFields() []string {
  16591. var fields []string
  16592. if m.FieldCleared(tutorial.FieldDeletedAt) {
  16593. fields = append(fields, tutorial.FieldDeletedAt)
  16594. }
  16595. return fields
  16596. }
  16597. // FieldCleared returns a boolean indicating if a field with the given name was
  16598. // cleared in this mutation.
  16599. func (m *TutorialMutation) FieldCleared(name string) bool {
  16600. _, ok := m.clearedFields[name]
  16601. return ok
  16602. }
  16603. // ClearField clears the value of the field with the given name. It returns an
  16604. // error if the field is not defined in the schema.
  16605. func (m *TutorialMutation) ClearField(name string) error {
  16606. switch name {
  16607. case tutorial.FieldDeletedAt:
  16608. m.ClearDeletedAt()
  16609. return nil
  16610. }
  16611. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  16612. }
  16613. // ResetField resets all changes in the mutation for the field with the given name.
  16614. // It returns an error if the field is not defined in the schema.
  16615. func (m *TutorialMutation) ResetField(name string) error {
  16616. switch name {
  16617. case tutorial.FieldCreatedAt:
  16618. m.ResetCreatedAt()
  16619. return nil
  16620. case tutorial.FieldUpdatedAt:
  16621. m.ResetUpdatedAt()
  16622. return nil
  16623. case tutorial.FieldDeletedAt:
  16624. m.ResetDeletedAt()
  16625. return nil
  16626. case tutorial.FieldEmployeeID:
  16627. m.ResetEmployeeID()
  16628. return nil
  16629. case tutorial.FieldIndex:
  16630. m.ResetIndex()
  16631. return nil
  16632. case tutorial.FieldTitle:
  16633. m.ResetTitle()
  16634. return nil
  16635. case tutorial.FieldContent:
  16636. m.ResetContent()
  16637. return nil
  16638. case tutorial.FieldOrganizationID:
  16639. m.ResetOrganizationID()
  16640. return nil
  16641. }
  16642. return fmt.Errorf("unknown Tutorial field %s", name)
  16643. }
  16644. // AddedEdges returns all edge names that were set/added in this mutation.
  16645. func (m *TutorialMutation) AddedEdges() []string {
  16646. edges := make([]string, 0, 1)
  16647. if m.employee != nil {
  16648. edges = append(edges, tutorial.EdgeEmployee)
  16649. }
  16650. return edges
  16651. }
  16652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16653. // name in this mutation.
  16654. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  16655. switch name {
  16656. case tutorial.EdgeEmployee:
  16657. if id := m.employee; id != nil {
  16658. return []ent.Value{*id}
  16659. }
  16660. }
  16661. return nil
  16662. }
  16663. // RemovedEdges returns all edge names that were removed in this mutation.
  16664. func (m *TutorialMutation) RemovedEdges() []string {
  16665. edges := make([]string, 0, 1)
  16666. return edges
  16667. }
  16668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16669. // the given name in this mutation.
  16670. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  16671. return nil
  16672. }
  16673. // ClearedEdges returns all edge names that were cleared in this mutation.
  16674. func (m *TutorialMutation) ClearedEdges() []string {
  16675. edges := make([]string, 0, 1)
  16676. if m.clearedemployee {
  16677. edges = append(edges, tutorial.EdgeEmployee)
  16678. }
  16679. return edges
  16680. }
  16681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16682. // was cleared in this mutation.
  16683. func (m *TutorialMutation) EdgeCleared(name string) bool {
  16684. switch name {
  16685. case tutorial.EdgeEmployee:
  16686. return m.clearedemployee
  16687. }
  16688. return false
  16689. }
  16690. // ClearEdge clears the value of the edge with the given name. It returns an error
  16691. // if that edge is not defined in the schema.
  16692. func (m *TutorialMutation) ClearEdge(name string) error {
  16693. switch name {
  16694. case tutorial.EdgeEmployee:
  16695. m.ClearEmployee()
  16696. return nil
  16697. }
  16698. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  16699. }
  16700. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16701. // It returns an error if the edge is not defined in the schema.
  16702. func (m *TutorialMutation) ResetEdge(name string) error {
  16703. switch name {
  16704. case tutorial.EdgeEmployee:
  16705. m.ResetEmployee()
  16706. return nil
  16707. }
  16708. return fmt.Errorf("unknown Tutorial edge %s", name)
  16709. }
  16710. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  16711. type WorkExperienceMutation struct {
  16712. config
  16713. op Op
  16714. typ string
  16715. id *uint64
  16716. created_at *time.Time
  16717. updated_at *time.Time
  16718. deleted_at *time.Time
  16719. start_date *time.Time
  16720. end_date *time.Time
  16721. company *string
  16722. experience *string
  16723. organization_id *uint64
  16724. addorganization_id *int64
  16725. clearedFields map[string]struct{}
  16726. employee *uint64
  16727. clearedemployee bool
  16728. done bool
  16729. oldValue func(context.Context) (*WorkExperience, error)
  16730. predicates []predicate.WorkExperience
  16731. }
  16732. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  16733. // workexperienceOption allows management of the mutation configuration using functional options.
  16734. type workexperienceOption func(*WorkExperienceMutation)
  16735. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  16736. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  16737. m := &WorkExperienceMutation{
  16738. config: c,
  16739. op: op,
  16740. typ: TypeWorkExperience,
  16741. clearedFields: make(map[string]struct{}),
  16742. }
  16743. for _, opt := range opts {
  16744. opt(m)
  16745. }
  16746. return m
  16747. }
  16748. // withWorkExperienceID sets the ID field of the mutation.
  16749. func withWorkExperienceID(id uint64) workexperienceOption {
  16750. return func(m *WorkExperienceMutation) {
  16751. var (
  16752. err error
  16753. once sync.Once
  16754. value *WorkExperience
  16755. )
  16756. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  16757. once.Do(func() {
  16758. if m.done {
  16759. err = errors.New("querying old values post mutation is not allowed")
  16760. } else {
  16761. value, err = m.Client().WorkExperience.Get(ctx, id)
  16762. }
  16763. })
  16764. return value, err
  16765. }
  16766. m.id = &id
  16767. }
  16768. }
  16769. // withWorkExperience sets the old WorkExperience of the mutation.
  16770. func withWorkExperience(node *WorkExperience) workexperienceOption {
  16771. return func(m *WorkExperienceMutation) {
  16772. m.oldValue = func(context.Context) (*WorkExperience, error) {
  16773. return node, nil
  16774. }
  16775. m.id = &node.ID
  16776. }
  16777. }
  16778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16779. // executed in a transaction (ent.Tx), a transactional client is returned.
  16780. func (m WorkExperienceMutation) Client() *Client {
  16781. client := &Client{config: m.config}
  16782. client.init()
  16783. return client
  16784. }
  16785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16786. // it returns an error otherwise.
  16787. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  16788. if _, ok := m.driver.(*txDriver); !ok {
  16789. return nil, errors.New("ent: mutation is not running in a transaction")
  16790. }
  16791. tx := &Tx{config: m.config}
  16792. tx.init()
  16793. return tx, nil
  16794. }
  16795. // SetID sets the value of the id field. Note that this
  16796. // operation is only accepted on creation of WorkExperience entities.
  16797. func (m *WorkExperienceMutation) SetID(id uint64) {
  16798. m.id = &id
  16799. }
  16800. // ID returns the ID value in the mutation. Note that the ID is only available
  16801. // if it was provided to the builder or after it was returned from the database.
  16802. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  16803. if m.id == nil {
  16804. return
  16805. }
  16806. return *m.id, true
  16807. }
  16808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16809. // That means, if the mutation is applied within a transaction with an isolation level such
  16810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16811. // or updated by the mutation.
  16812. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  16813. switch {
  16814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16815. id, exists := m.ID()
  16816. if exists {
  16817. return []uint64{id}, nil
  16818. }
  16819. fallthrough
  16820. case m.op.Is(OpUpdate | OpDelete):
  16821. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  16822. default:
  16823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16824. }
  16825. }
  16826. // SetCreatedAt sets the "created_at" field.
  16827. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  16828. m.created_at = &t
  16829. }
  16830. // CreatedAt returns the value of the "created_at" field in the mutation.
  16831. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  16832. v := m.created_at
  16833. if v == nil {
  16834. return
  16835. }
  16836. return *v, true
  16837. }
  16838. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  16839. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16841. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16842. if !m.op.Is(OpUpdateOne) {
  16843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16844. }
  16845. if m.id == nil || m.oldValue == nil {
  16846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16847. }
  16848. oldValue, err := m.oldValue(ctx)
  16849. if err != nil {
  16850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16851. }
  16852. return oldValue.CreatedAt, nil
  16853. }
  16854. // ResetCreatedAt resets all changes to the "created_at" field.
  16855. func (m *WorkExperienceMutation) ResetCreatedAt() {
  16856. m.created_at = nil
  16857. }
  16858. // SetUpdatedAt sets the "updated_at" field.
  16859. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  16860. m.updated_at = &t
  16861. }
  16862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16863. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  16864. v := m.updated_at
  16865. if v == nil {
  16866. return
  16867. }
  16868. return *v, true
  16869. }
  16870. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  16871. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16873. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16874. if !m.op.Is(OpUpdateOne) {
  16875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16876. }
  16877. if m.id == nil || m.oldValue == nil {
  16878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16879. }
  16880. oldValue, err := m.oldValue(ctx)
  16881. if err != nil {
  16882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16883. }
  16884. return oldValue.UpdatedAt, nil
  16885. }
  16886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16887. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  16888. m.updated_at = nil
  16889. }
  16890. // SetDeletedAt sets the "deleted_at" field.
  16891. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  16892. m.deleted_at = &t
  16893. }
  16894. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16895. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  16896. v := m.deleted_at
  16897. if v == nil {
  16898. return
  16899. }
  16900. return *v, true
  16901. }
  16902. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  16903. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16905. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16906. if !m.op.Is(OpUpdateOne) {
  16907. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16908. }
  16909. if m.id == nil || m.oldValue == nil {
  16910. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16911. }
  16912. oldValue, err := m.oldValue(ctx)
  16913. if err != nil {
  16914. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16915. }
  16916. return oldValue.DeletedAt, nil
  16917. }
  16918. // ClearDeletedAt clears the value of the "deleted_at" field.
  16919. func (m *WorkExperienceMutation) ClearDeletedAt() {
  16920. m.deleted_at = nil
  16921. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  16922. }
  16923. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16924. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  16925. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  16926. return ok
  16927. }
  16928. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16929. func (m *WorkExperienceMutation) ResetDeletedAt() {
  16930. m.deleted_at = nil
  16931. delete(m.clearedFields, workexperience.FieldDeletedAt)
  16932. }
  16933. // SetEmployeeID sets the "employee_id" field.
  16934. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  16935. m.employee = &u
  16936. }
  16937. // EmployeeID returns the value of the "employee_id" field in the mutation.
  16938. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  16939. v := m.employee
  16940. if v == nil {
  16941. return
  16942. }
  16943. return *v, true
  16944. }
  16945. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  16946. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16948. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  16949. if !m.op.Is(OpUpdateOne) {
  16950. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  16951. }
  16952. if m.id == nil || m.oldValue == nil {
  16953. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  16954. }
  16955. oldValue, err := m.oldValue(ctx)
  16956. if err != nil {
  16957. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  16958. }
  16959. return oldValue.EmployeeID, nil
  16960. }
  16961. // ResetEmployeeID resets all changes to the "employee_id" field.
  16962. func (m *WorkExperienceMutation) ResetEmployeeID() {
  16963. m.employee = nil
  16964. }
  16965. // SetStartDate sets the "start_date" field.
  16966. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  16967. m.start_date = &t
  16968. }
  16969. // StartDate returns the value of the "start_date" field in the mutation.
  16970. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  16971. v := m.start_date
  16972. if v == nil {
  16973. return
  16974. }
  16975. return *v, true
  16976. }
  16977. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  16978. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  16979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16980. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  16981. if !m.op.Is(OpUpdateOne) {
  16982. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  16983. }
  16984. if m.id == nil || m.oldValue == nil {
  16985. return v, errors.New("OldStartDate requires an ID field in the mutation")
  16986. }
  16987. oldValue, err := m.oldValue(ctx)
  16988. if err != nil {
  16989. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  16990. }
  16991. return oldValue.StartDate, nil
  16992. }
  16993. // ResetStartDate resets all changes to the "start_date" field.
  16994. func (m *WorkExperienceMutation) ResetStartDate() {
  16995. m.start_date = nil
  16996. }
  16997. // SetEndDate sets the "end_date" field.
  16998. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  16999. m.end_date = &t
  17000. }
  17001. // EndDate returns the value of the "end_date" field in the mutation.
  17002. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  17003. v := m.end_date
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  17010. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldEndDate requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  17022. }
  17023. return oldValue.EndDate, nil
  17024. }
  17025. // ResetEndDate resets all changes to the "end_date" field.
  17026. func (m *WorkExperienceMutation) ResetEndDate() {
  17027. m.end_date = nil
  17028. }
  17029. // SetCompany sets the "company" field.
  17030. func (m *WorkExperienceMutation) SetCompany(s string) {
  17031. m.company = &s
  17032. }
  17033. // Company returns the value of the "company" field in the mutation.
  17034. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  17035. v := m.company
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  17042. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldCompany requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  17054. }
  17055. return oldValue.Company, nil
  17056. }
  17057. // ResetCompany resets all changes to the "company" field.
  17058. func (m *WorkExperienceMutation) ResetCompany() {
  17059. m.company = nil
  17060. }
  17061. // SetExperience sets the "experience" field.
  17062. func (m *WorkExperienceMutation) SetExperience(s string) {
  17063. m.experience = &s
  17064. }
  17065. // Experience returns the value of the "experience" field in the mutation.
  17066. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  17067. v := m.experience
  17068. if v == nil {
  17069. return
  17070. }
  17071. return *v, true
  17072. }
  17073. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  17074. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17076. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  17077. if !m.op.Is(OpUpdateOne) {
  17078. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  17079. }
  17080. if m.id == nil || m.oldValue == nil {
  17081. return v, errors.New("OldExperience requires an ID field in the mutation")
  17082. }
  17083. oldValue, err := m.oldValue(ctx)
  17084. if err != nil {
  17085. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  17086. }
  17087. return oldValue.Experience, nil
  17088. }
  17089. // ResetExperience resets all changes to the "experience" field.
  17090. func (m *WorkExperienceMutation) ResetExperience() {
  17091. m.experience = nil
  17092. }
  17093. // SetOrganizationID sets the "organization_id" field.
  17094. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  17095. m.organization_id = &u
  17096. m.addorganization_id = nil
  17097. }
  17098. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17099. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  17100. v := m.organization_id
  17101. if v == nil {
  17102. return
  17103. }
  17104. return *v, true
  17105. }
  17106. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  17107. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  17108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17109. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17110. if !m.op.Is(OpUpdateOne) {
  17111. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17112. }
  17113. if m.id == nil || m.oldValue == nil {
  17114. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17115. }
  17116. oldValue, err := m.oldValue(ctx)
  17117. if err != nil {
  17118. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17119. }
  17120. return oldValue.OrganizationID, nil
  17121. }
  17122. // AddOrganizationID adds u to the "organization_id" field.
  17123. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  17124. if m.addorganization_id != nil {
  17125. *m.addorganization_id += u
  17126. } else {
  17127. m.addorganization_id = &u
  17128. }
  17129. }
  17130. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17131. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  17132. v := m.addorganization_id
  17133. if v == nil {
  17134. return
  17135. }
  17136. return *v, true
  17137. }
  17138. // ResetOrganizationID resets all changes to the "organization_id" field.
  17139. func (m *WorkExperienceMutation) ResetOrganizationID() {
  17140. m.organization_id = nil
  17141. m.addorganization_id = nil
  17142. }
  17143. // ClearEmployee clears the "employee" edge to the Employee entity.
  17144. func (m *WorkExperienceMutation) ClearEmployee() {
  17145. m.clearedemployee = true
  17146. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  17147. }
  17148. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  17149. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  17150. return m.clearedemployee
  17151. }
  17152. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  17153. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17154. // EmployeeID instead. It exists only for internal usage by the builders.
  17155. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  17156. if id := m.employee; id != nil {
  17157. ids = append(ids, *id)
  17158. }
  17159. return
  17160. }
  17161. // ResetEmployee resets all changes to the "employee" edge.
  17162. func (m *WorkExperienceMutation) ResetEmployee() {
  17163. m.employee = nil
  17164. m.clearedemployee = false
  17165. }
  17166. // Where appends a list predicates to the WorkExperienceMutation builder.
  17167. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  17168. m.predicates = append(m.predicates, ps...)
  17169. }
  17170. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  17171. // users can use type-assertion to append predicates that do not depend on any generated package.
  17172. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  17173. p := make([]predicate.WorkExperience, len(ps))
  17174. for i := range ps {
  17175. p[i] = ps[i]
  17176. }
  17177. m.Where(p...)
  17178. }
  17179. // Op returns the operation name.
  17180. func (m *WorkExperienceMutation) Op() Op {
  17181. return m.op
  17182. }
  17183. // SetOp allows setting the mutation operation.
  17184. func (m *WorkExperienceMutation) SetOp(op Op) {
  17185. m.op = op
  17186. }
  17187. // Type returns the node type of this mutation (WorkExperience).
  17188. func (m *WorkExperienceMutation) Type() string {
  17189. return m.typ
  17190. }
  17191. // Fields returns all fields that were changed during this mutation. Note that in
  17192. // order to get all numeric fields that were incremented/decremented, call
  17193. // AddedFields().
  17194. func (m *WorkExperienceMutation) Fields() []string {
  17195. fields := make([]string, 0, 9)
  17196. if m.created_at != nil {
  17197. fields = append(fields, workexperience.FieldCreatedAt)
  17198. }
  17199. if m.updated_at != nil {
  17200. fields = append(fields, workexperience.FieldUpdatedAt)
  17201. }
  17202. if m.deleted_at != nil {
  17203. fields = append(fields, workexperience.FieldDeletedAt)
  17204. }
  17205. if m.employee != nil {
  17206. fields = append(fields, workexperience.FieldEmployeeID)
  17207. }
  17208. if m.start_date != nil {
  17209. fields = append(fields, workexperience.FieldStartDate)
  17210. }
  17211. if m.end_date != nil {
  17212. fields = append(fields, workexperience.FieldEndDate)
  17213. }
  17214. if m.company != nil {
  17215. fields = append(fields, workexperience.FieldCompany)
  17216. }
  17217. if m.experience != nil {
  17218. fields = append(fields, workexperience.FieldExperience)
  17219. }
  17220. if m.organization_id != nil {
  17221. fields = append(fields, workexperience.FieldOrganizationID)
  17222. }
  17223. return fields
  17224. }
  17225. // Field returns the value of a field with the given name. The second boolean
  17226. // return value indicates that this field was not set, or was not defined in the
  17227. // schema.
  17228. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  17229. switch name {
  17230. case workexperience.FieldCreatedAt:
  17231. return m.CreatedAt()
  17232. case workexperience.FieldUpdatedAt:
  17233. return m.UpdatedAt()
  17234. case workexperience.FieldDeletedAt:
  17235. return m.DeletedAt()
  17236. case workexperience.FieldEmployeeID:
  17237. return m.EmployeeID()
  17238. case workexperience.FieldStartDate:
  17239. return m.StartDate()
  17240. case workexperience.FieldEndDate:
  17241. return m.EndDate()
  17242. case workexperience.FieldCompany:
  17243. return m.Company()
  17244. case workexperience.FieldExperience:
  17245. return m.Experience()
  17246. case workexperience.FieldOrganizationID:
  17247. return m.OrganizationID()
  17248. }
  17249. return nil, false
  17250. }
  17251. // OldField returns the old value of the field from the database. An error is
  17252. // returned if the mutation operation is not UpdateOne, or the query to the
  17253. // database failed.
  17254. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17255. switch name {
  17256. case workexperience.FieldCreatedAt:
  17257. return m.OldCreatedAt(ctx)
  17258. case workexperience.FieldUpdatedAt:
  17259. return m.OldUpdatedAt(ctx)
  17260. case workexperience.FieldDeletedAt:
  17261. return m.OldDeletedAt(ctx)
  17262. case workexperience.FieldEmployeeID:
  17263. return m.OldEmployeeID(ctx)
  17264. case workexperience.FieldStartDate:
  17265. return m.OldStartDate(ctx)
  17266. case workexperience.FieldEndDate:
  17267. return m.OldEndDate(ctx)
  17268. case workexperience.FieldCompany:
  17269. return m.OldCompany(ctx)
  17270. case workexperience.FieldExperience:
  17271. return m.OldExperience(ctx)
  17272. case workexperience.FieldOrganizationID:
  17273. return m.OldOrganizationID(ctx)
  17274. }
  17275. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  17276. }
  17277. // SetField sets the value of a field with the given name. It returns an error if
  17278. // the field is not defined in the schema, or if the type mismatched the field
  17279. // type.
  17280. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  17281. switch name {
  17282. case workexperience.FieldCreatedAt:
  17283. v, ok := value.(time.Time)
  17284. if !ok {
  17285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17286. }
  17287. m.SetCreatedAt(v)
  17288. return nil
  17289. case workexperience.FieldUpdatedAt:
  17290. v, ok := value.(time.Time)
  17291. if !ok {
  17292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17293. }
  17294. m.SetUpdatedAt(v)
  17295. return nil
  17296. case workexperience.FieldDeletedAt:
  17297. v, ok := value.(time.Time)
  17298. if !ok {
  17299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17300. }
  17301. m.SetDeletedAt(v)
  17302. return nil
  17303. case workexperience.FieldEmployeeID:
  17304. v, ok := value.(uint64)
  17305. if !ok {
  17306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17307. }
  17308. m.SetEmployeeID(v)
  17309. return nil
  17310. case workexperience.FieldStartDate:
  17311. v, ok := value.(time.Time)
  17312. if !ok {
  17313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17314. }
  17315. m.SetStartDate(v)
  17316. return nil
  17317. case workexperience.FieldEndDate:
  17318. v, ok := value.(time.Time)
  17319. if !ok {
  17320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17321. }
  17322. m.SetEndDate(v)
  17323. return nil
  17324. case workexperience.FieldCompany:
  17325. v, ok := value.(string)
  17326. if !ok {
  17327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17328. }
  17329. m.SetCompany(v)
  17330. return nil
  17331. case workexperience.FieldExperience:
  17332. v, ok := value.(string)
  17333. if !ok {
  17334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17335. }
  17336. m.SetExperience(v)
  17337. return nil
  17338. case workexperience.FieldOrganizationID:
  17339. v, ok := value.(uint64)
  17340. if !ok {
  17341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17342. }
  17343. m.SetOrganizationID(v)
  17344. return nil
  17345. }
  17346. return fmt.Errorf("unknown WorkExperience field %s", name)
  17347. }
  17348. // AddedFields returns all numeric fields that were incremented/decremented during
  17349. // this mutation.
  17350. func (m *WorkExperienceMutation) AddedFields() []string {
  17351. var fields []string
  17352. if m.addorganization_id != nil {
  17353. fields = append(fields, workexperience.FieldOrganizationID)
  17354. }
  17355. return fields
  17356. }
  17357. // AddedField returns the numeric value that was incremented/decremented on a field
  17358. // with the given name. The second boolean return value indicates that this field
  17359. // was not set, or was not defined in the schema.
  17360. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  17361. switch name {
  17362. case workexperience.FieldOrganizationID:
  17363. return m.AddedOrganizationID()
  17364. }
  17365. return nil, false
  17366. }
  17367. // AddField adds the value to the field with the given name. It returns an error if
  17368. // the field is not defined in the schema, or if the type mismatched the field
  17369. // type.
  17370. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  17371. switch name {
  17372. case workexperience.FieldOrganizationID:
  17373. v, ok := value.(int64)
  17374. if !ok {
  17375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17376. }
  17377. m.AddOrganizationID(v)
  17378. return nil
  17379. }
  17380. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  17381. }
  17382. // ClearedFields returns all nullable fields that were cleared during this
  17383. // mutation.
  17384. func (m *WorkExperienceMutation) ClearedFields() []string {
  17385. var fields []string
  17386. if m.FieldCleared(workexperience.FieldDeletedAt) {
  17387. fields = append(fields, workexperience.FieldDeletedAt)
  17388. }
  17389. return fields
  17390. }
  17391. // FieldCleared returns a boolean indicating if a field with the given name was
  17392. // cleared in this mutation.
  17393. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  17394. _, ok := m.clearedFields[name]
  17395. return ok
  17396. }
  17397. // ClearField clears the value of the field with the given name. It returns an
  17398. // error if the field is not defined in the schema.
  17399. func (m *WorkExperienceMutation) ClearField(name string) error {
  17400. switch name {
  17401. case workexperience.FieldDeletedAt:
  17402. m.ClearDeletedAt()
  17403. return nil
  17404. }
  17405. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  17406. }
  17407. // ResetField resets all changes in the mutation for the field with the given name.
  17408. // It returns an error if the field is not defined in the schema.
  17409. func (m *WorkExperienceMutation) ResetField(name string) error {
  17410. switch name {
  17411. case workexperience.FieldCreatedAt:
  17412. m.ResetCreatedAt()
  17413. return nil
  17414. case workexperience.FieldUpdatedAt:
  17415. m.ResetUpdatedAt()
  17416. return nil
  17417. case workexperience.FieldDeletedAt:
  17418. m.ResetDeletedAt()
  17419. return nil
  17420. case workexperience.FieldEmployeeID:
  17421. m.ResetEmployeeID()
  17422. return nil
  17423. case workexperience.FieldStartDate:
  17424. m.ResetStartDate()
  17425. return nil
  17426. case workexperience.FieldEndDate:
  17427. m.ResetEndDate()
  17428. return nil
  17429. case workexperience.FieldCompany:
  17430. m.ResetCompany()
  17431. return nil
  17432. case workexperience.FieldExperience:
  17433. m.ResetExperience()
  17434. return nil
  17435. case workexperience.FieldOrganizationID:
  17436. m.ResetOrganizationID()
  17437. return nil
  17438. }
  17439. return fmt.Errorf("unknown WorkExperience field %s", name)
  17440. }
  17441. // AddedEdges returns all edge names that were set/added in this mutation.
  17442. func (m *WorkExperienceMutation) AddedEdges() []string {
  17443. edges := make([]string, 0, 1)
  17444. if m.employee != nil {
  17445. edges = append(edges, workexperience.EdgeEmployee)
  17446. }
  17447. return edges
  17448. }
  17449. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17450. // name in this mutation.
  17451. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  17452. switch name {
  17453. case workexperience.EdgeEmployee:
  17454. if id := m.employee; id != nil {
  17455. return []ent.Value{*id}
  17456. }
  17457. }
  17458. return nil
  17459. }
  17460. // RemovedEdges returns all edge names that were removed in this mutation.
  17461. func (m *WorkExperienceMutation) RemovedEdges() []string {
  17462. edges := make([]string, 0, 1)
  17463. return edges
  17464. }
  17465. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17466. // the given name in this mutation.
  17467. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  17468. return nil
  17469. }
  17470. // ClearedEdges returns all edge names that were cleared in this mutation.
  17471. func (m *WorkExperienceMutation) ClearedEdges() []string {
  17472. edges := make([]string, 0, 1)
  17473. if m.clearedemployee {
  17474. edges = append(edges, workexperience.EdgeEmployee)
  17475. }
  17476. return edges
  17477. }
  17478. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17479. // was cleared in this mutation.
  17480. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  17481. switch name {
  17482. case workexperience.EdgeEmployee:
  17483. return m.clearedemployee
  17484. }
  17485. return false
  17486. }
  17487. // ClearEdge clears the value of the edge with the given name. It returns an error
  17488. // if that edge is not defined in the schema.
  17489. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  17490. switch name {
  17491. case workexperience.EdgeEmployee:
  17492. m.ClearEmployee()
  17493. return nil
  17494. }
  17495. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  17496. }
  17497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17498. // It returns an error if the edge is not defined in the schema.
  17499. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  17500. switch name {
  17501. case workexperience.EdgeEmployee:
  17502. m.ResetEmployee()
  17503. return nil
  17504. }
  17505. return fmt.Errorf("unknown WorkExperience edge %s", name)
  17506. }
  17507. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  17508. type WxMutation struct {
  17509. config
  17510. op Op
  17511. typ string
  17512. id *uint64
  17513. created_at *time.Time
  17514. updated_at *time.Time
  17515. status *uint8
  17516. addstatus *int8
  17517. deleted_at *time.Time
  17518. port *string
  17519. process_id *string
  17520. callback *string
  17521. wxid *string
  17522. account *string
  17523. nickname *string
  17524. tel *string
  17525. head_big *string
  17526. organization_id *uint64
  17527. addorganization_id *int64
  17528. clearedFields map[string]struct{}
  17529. server *uint64
  17530. clearedserver bool
  17531. agent *uint64
  17532. clearedagent bool
  17533. done bool
  17534. oldValue func(context.Context) (*Wx, error)
  17535. predicates []predicate.Wx
  17536. }
  17537. var _ ent.Mutation = (*WxMutation)(nil)
  17538. // wxOption allows management of the mutation configuration using functional options.
  17539. type wxOption func(*WxMutation)
  17540. // newWxMutation creates new mutation for the Wx entity.
  17541. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  17542. m := &WxMutation{
  17543. config: c,
  17544. op: op,
  17545. typ: TypeWx,
  17546. clearedFields: make(map[string]struct{}),
  17547. }
  17548. for _, opt := range opts {
  17549. opt(m)
  17550. }
  17551. return m
  17552. }
  17553. // withWxID sets the ID field of the mutation.
  17554. func withWxID(id uint64) wxOption {
  17555. return func(m *WxMutation) {
  17556. var (
  17557. err error
  17558. once sync.Once
  17559. value *Wx
  17560. )
  17561. m.oldValue = func(ctx context.Context) (*Wx, error) {
  17562. once.Do(func() {
  17563. if m.done {
  17564. err = errors.New("querying old values post mutation is not allowed")
  17565. } else {
  17566. value, err = m.Client().Wx.Get(ctx, id)
  17567. }
  17568. })
  17569. return value, err
  17570. }
  17571. m.id = &id
  17572. }
  17573. }
  17574. // withWx sets the old Wx of the mutation.
  17575. func withWx(node *Wx) wxOption {
  17576. return func(m *WxMutation) {
  17577. m.oldValue = func(context.Context) (*Wx, error) {
  17578. return node, nil
  17579. }
  17580. m.id = &node.ID
  17581. }
  17582. }
  17583. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17584. // executed in a transaction (ent.Tx), a transactional client is returned.
  17585. func (m WxMutation) Client() *Client {
  17586. client := &Client{config: m.config}
  17587. client.init()
  17588. return client
  17589. }
  17590. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17591. // it returns an error otherwise.
  17592. func (m WxMutation) Tx() (*Tx, error) {
  17593. if _, ok := m.driver.(*txDriver); !ok {
  17594. return nil, errors.New("ent: mutation is not running in a transaction")
  17595. }
  17596. tx := &Tx{config: m.config}
  17597. tx.init()
  17598. return tx, nil
  17599. }
  17600. // SetID sets the value of the id field. Note that this
  17601. // operation is only accepted on creation of Wx entities.
  17602. func (m *WxMutation) SetID(id uint64) {
  17603. m.id = &id
  17604. }
  17605. // ID returns the ID value in the mutation. Note that the ID is only available
  17606. // if it was provided to the builder or after it was returned from the database.
  17607. func (m *WxMutation) ID() (id uint64, exists bool) {
  17608. if m.id == nil {
  17609. return
  17610. }
  17611. return *m.id, true
  17612. }
  17613. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17614. // That means, if the mutation is applied within a transaction with an isolation level such
  17615. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17616. // or updated by the mutation.
  17617. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  17618. switch {
  17619. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17620. id, exists := m.ID()
  17621. if exists {
  17622. return []uint64{id}, nil
  17623. }
  17624. fallthrough
  17625. case m.op.Is(OpUpdate | OpDelete):
  17626. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  17627. default:
  17628. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17629. }
  17630. }
  17631. // SetCreatedAt sets the "created_at" field.
  17632. func (m *WxMutation) SetCreatedAt(t time.Time) {
  17633. m.created_at = &t
  17634. }
  17635. // CreatedAt returns the value of the "created_at" field in the mutation.
  17636. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  17637. v := m.created_at
  17638. if v == nil {
  17639. return
  17640. }
  17641. return *v, true
  17642. }
  17643. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  17644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17646. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17647. if !m.op.Is(OpUpdateOne) {
  17648. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17649. }
  17650. if m.id == nil || m.oldValue == nil {
  17651. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17652. }
  17653. oldValue, err := m.oldValue(ctx)
  17654. if err != nil {
  17655. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17656. }
  17657. return oldValue.CreatedAt, nil
  17658. }
  17659. // ResetCreatedAt resets all changes to the "created_at" field.
  17660. func (m *WxMutation) ResetCreatedAt() {
  17661. m.created_at = nil
  17662. }
  17663. // SetUpdatedAt sets the "updated_at" field.
  17664. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  17665. m.updated_at = &t
  17666. }
  17667. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17668. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  17669. v := m.updated_at
  17670. if v == nil {
  17671. return
  17672. }
  17673. return *v, true
  17674. }
  17675. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  17676. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17678. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17679. if !m.op.Is(OpUpdateOne) {
  17680. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17681. }
  17682. if m.id == nil || m.oldValue == nil {
  17683. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17684. }
  17685. oldValue, err := m.oldValue(ctx)
  17686. if err != nil {
  17687. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17688. }
  17689. return oldValue.UpdatedAt, nil
  17690. }
  17691. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17692. func (m *WxMutation) ResetUpdatedAt() {
  17693. m.updated_at = nil
  17694. }
  17695. // SetStatus sets the "status" field.
  17696. func (m *WxMutation) SetStatus(u uint8) {
  17697. m.status = &u
  17698. m.addstatus = nil
  17699. }
  17700. // Status returns the value of the "status" field in the mutation.
  17701. func (m *WxMutation) Status() (r uint8, exists bool) {
  17702. v := m.status
  17703. if v == nil {
  17704. return
  17705. }
  17706. return *v, true
  17707. }
  17708. // OldStatus returns the old "status" field's value of the Wx entity.
  17709. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17711. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17712. if !m.op.Is(OpUpdateOne) {
  17713. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17714. }
  17715. if m.id == nil || m.oldValue == nil {
  17716. return v, errors.New("OldStatus requires an ID field in the mutation")
  17717. }
  17718. oldValue, err := m.oldValue(ctx)
  17719. if err != nil {
  17720. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17721. }
  17722. return oldValue.Status, nil
  17723. }
  17724. // AddStatus adds u to the "status" field.
  17725. func (m *WxMutation) AddStatus(u int8) {
  17726. if m.addstatus != nil {
  17727. *m.addstatus += u
  17728. } else {
  17729. m.addstatus = &u
  17730. }
  17731. }
  17732. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17733. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  17734. v := m.addstatus
  17735. if v == nil {
  17736. return
  17737. }
  17738. return *v, true
  17739. }
  17740. // ClearStatus clears the value of the "status" field.
  17741. func (m *WxMutation) ClearStatus() {
  17742. m.status = nil
  17743. m.addstatus = nil
  17744. m.clearedFields[wx.FieldStatus] = struct{}{}
  17745. }
  17746. // StatusCleared returns if the "status" field was cleared in this mutation.
  17747. func (m *WxMutation) StatusCleared() bool {
  17748. _, ok := m.clearedFields[wx.FieldStatus]
  17749. return ok
  17750. }
  17751. // ResetStatus resets all changes to the "status" field.
  17752. func (m *WxMutation) ResetStatus() {
  17753. m.status = nil
  17754. m.addstatus = nil
  17755. delete(m.clearedFields, wx.FieldStatus)
  17756. }
  17757. // SetDeletedAt sets the "deleted_at" field.
  17758. func (m *WxMutation) SetDeletedAt(t time.Time) {
  17759. m.deleted_at = &t
  17760. }
  17761. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17762. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  17763. v := m.deleted_at
  17764. if v == nil {
  17765. return
  17766. }
  17767. return *v, true
  17768. }
  17769. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  17770. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17772. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17773. if !m.op.Is(OpUpdateOne) {
  17774. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17775. }
  17776. if m.id == nil || m.oldValue == nil {
  17777. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17778. }
  17779. oldValue, err := m.oldValue(ctx)
  17780. if err != nil {
  17781. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17782. }
  17783. return oldValue.DeletedAt, nil
  17784. }
  17785. // ClearDeletedAt clears the value of the "deleted_at" field.
  17786. func (m *WxMutation) ClearDeletedAt() {
  17787. m.deleted_at = nil
  17788. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  17789. }
  17790. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17791. func (m *WxMutation) DeletedAtCleared() bool {
  17792. _, ok := m.clearedFields[wx.FieldDeletedAt]
  17793. return ok
  17794. }
  17795. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17796. func (m *WxMutation) ResetDeletedAt() {
  17797. m.deleted_at = nil
  17798. delete(m.clearedFields, wx.FieldDeletedAt)
  17799. }
  17800. // SetServerID sets the "server_id" field.
  17801. func (m *WxMutation) SetServerID(u uint64) {
  17802. m.server = &u
  17803. }
  17804. // ServerID returns the value of the "server_id" field in the mutation.
  17805. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  17806. v := m.server
  17807. if v == nil {
  17808. return
  17809. }
  17810. return *v, true
  17811. }
  17812. // OldServerID returns the old "server_id" field's value of the Wx entity.
  17813. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17815. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  17816. if !m.op.Is(OpUpdateOne) {
  17817. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  17818. }
  17819. if m.id == nil || m.oldValue == nil {
  17820. return v, errors.New("OldServerID requires an ID field in the mutation")
  17821. }
  17822. oldValue, err := m.oldValue(ctx)
  17823. if err != nil {
  17824. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  17825. }
  17826. return oldValue.ServerID, nil
  17827. }
  17828. // ClearServerID clears the value of the "server_id" field.
  17829. func (m *WxMutation) ClearServerID() {
  17830. m.server = nil
  17831. m.clearedFields[wx.FieldServerID] = struct{}{}
  17832. }
  17833. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  17834. func (m *WxMutation) ServerIDCleared() bool {
  17835. _, ok := m.clearedFields[wx.FieldServerID]
  17836. return ok
  17837. }
  17838. // ResetServerID resets all changes to the "server_id" field.
  17839. func (m *WxMutation) ResetServerID() {
  17840. m.server = nil
  17841. delete(m.clearedFields, wx.FieldServerID)
  17842. }
  17843. // SetPort sets the "port" field.
  17844. func (m *WxMutation) SetPort(s string) {
  17845. m.port = &s
  17846. }
  17847. // Port returns the value of the "port" field in the mutation.
  17848. func (m *WxMutation) Port() (r string, exists bool) {
  17849. v := m.port
  17850. if v == nil {
  17851. return
  17852. }
  17853. return *v, true
  17854. }
  17855. // OldPort returns the old "port" field's value of the Wx entity.
  17856. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17858. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  17859. if !m.op.Is(OpUpdateOne) {
  17860. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  17861. }
  17862. if m.id == nil || m.oldValue == nil {
  17863. return v, errors.New("OldPort requires an ID field in the mutation")
  17864. }
  17865. oldValue, err := m.oldValue(ctx)
  17866. if err != nil {
  17867. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  17868. }
  17869. return oldValue.Port, nil
  17870. }
  17871. // ResetPort resets all changes to the "port" field.
  17872. func (m *WxMutation) ResetPort() {
  17873. m.port = nil
  17874. }
  17875. // SetProcessID sets the "process_id" field.
  17876. func (m *WxMutation) SetProcessID(s string) {
  17877. m.process_id = &s
  17878. }
  17879. // ProcessID returns the value of the "process_id" field in the mutation.
  17880. func (m *WxMutation) ProcessID() (r string, exists bool) {
  17881. v := m.process_id
  17882. if v == nil {
  17883. return
  17884. }
  17885. return *v, true
  17886. }
  17887. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  17888. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17890. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  17891. if !m.op.Is(OpUpdateOne) {
  17892. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  17893. }
  17894. if m.id == nil || m.oldValue == nil {
  17895. return v, errors.New("OldProcessID requires an ID field in the mutation")
  17896. }
  17897. oldValue, err := m.oldValue(ctx)
  17898. if err != nil {
  17899. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  17900. }
  17901. return oldValue.ProcessID, nil
  17902. }
  17903. // ResetProcessID resets all changes to the "process_id" field.
  17904. func (m *WxMutation) ResetProcessID() {
  17905. m.process_id = nil
  17906. }
  17907. // SetCallback sets the "callback" field.
  17908. func (m *WxMutation) SetCallback(s string) {
  17909. m.callback = &s
  17910. }
  17911. // Callback returns the value of the "callback" field in the mutation.
  17912. func (m *WxMutation) Callback() (r string, exists bool) {
  17913. v := m.callback
  17914. if v == nil {
  17915. return
  17916. }
  17917. return *v, true
  17918. }
  17919. // OldCallback returns the old "callback" field's value of the Wx entity.
  17920. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17922. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  17923. if !m.op.Is(OpUpdateOne) {
  17924. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  17925. }
  17926. if m.id == nil || m.oldValue == nil {
  17927. return v, errors.New("OldCallback requires an ID field in the mutation")
  17928. }
  17929. oldValue, err := m.oldValue(ctx)
  17930. if err != nil {
  17931. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  17932. }
  17933. return oldValue.Callback, nil
  17934. }
  17935. // ResetCallback resets all changes to the "callback" field.
  17936. func (m *WxMutation) ResetCallback() {
  17937. m.callback = nil
  17938. }
  17939. // SetWxid sets the "wxid" field.
  17940. func (m *WxMutation) SetWxid(s string) {
  17941. m.wxid = &s
  17942. }
  17943. // Wxid returns the value of the "wxid" field in the mutation.
  17944. func (m *WxMutation) Wxid() (r string, exists bool) {
  17945. v := m.wxid
  17946. if v == nil {
  17947. return
  17948. }
  17949. return *v, true
  17950. }
  17951. // OldWxid returns the old "wxid" field's value of the Wx entity.
  17952. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17954. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  17955. if !m.op.Is(OpUpdateOne) {
  17956. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17957. }
  17958. if m.id == nil || m.oldValue == nil {
  17959. return v, errors.New("OldWxid requires an ID field in the mutation")
  17960. }
  17961. oldValue, err := m.oldValue(ctx)
  17962. if err != nil {
  17963. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17964. }
  17965. return oldValue.Wxid, nil
  17966. }
  17967. // ResetWxid resets all changes to the "wxid" field.
  17968. func (m *WxMutation) ResetWxid() {
  17969. m.wxid = nil
  17970. }
  17971. // SetAccount sets the "account" field.
  17972. func (m *WxMutation) SetAccount(s string) {
  17973. m.account = &s
  17974. }
  17975. // Account returns the value of the "account" field in the mutation.
  17976. func (m *WxMutation) Account() (r string, exists bool) {
  17977. v := m.account
  17978. if v == nil {
  17979. return
  17980. }
  17981. return *v, true
  17982. }
  17983. // OldAccount returns the old "account" field's value of the Wx entity.
  17984. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  17985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17986. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  17987. if !m.op.Is(OpUpdateOne) {
  17988. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  17989. }
  17990. if m.id == nil || m.oldValue == nil {
  17991. return v, errors.New("OldAccount requires an ID field in the mutation")
  17992. }
  17993. oldValue, err := m.oldValue(ctx)
  17994. if err != nil {
  17995. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  17996. }
  17997. return oldValue.Account, nil
  17998. }
  17999. // ResetAccount resets all changes to the "account" field.
  18000. func (m *WxMutation) ResetAccount() {
  18001. m.account = nil
  18002. }
  18003. // SetNickname sets the "nickname" field.
  18004. func (m *WxMutation) SetNickname(s string) {
  18005. m.nickname = &s
  18006. }
  18007. // Nickname returns the value of the "nickname" field in the mutation.
  18008. func (m *WxMutation) Nickname() (r string, exists bool) {
  18009. v := m.nickname
  18010. if v == nil {
  18011. return
  18012. }
  18013. return *v, true
  18014. }
  18015. // OldNickname returns the old "nickname" field's value of the Wx entity.
  18016. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18018. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  18019. if !m.op.Is(OpUpdateOne) {
  18020. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  18021. }
  18022. if m.id == nil || m.oldValue == nil {
  18023. return v, errors.New("OldNickname requires an ID field in the mutation")
  18024. }
  18025. oldValue, err := m.oldValue(ctx)
  18026. if err != nil {
  18027. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  18028. }
  18029. return oldValue.Nickname, nil
  18030. }
  18031. // ResetNickname resets all changes to the "nickname" field.
  18032. func (m *WxMutation) ResetNickname() {
  18033. m.nickname = nil
  18034. }
  18035. // SetTel sets the "tel" field.
  18036. func (m *WxMutation) SetTel(s string) {
  18037. m.tel = &s
  18038. }
  18039. // Tel returns the value of the "tel" field in the mutation.
  18040. func (m *WxMutation) Tel() (r string, exists bool) {
  18041. v := m.tel
  18042. if v == nil {
  18043. return
  18044. }
  18045. return *v, true
  18046. }
  18047. // OldTel returns the old "tel" field's value of the Wx entity.
  18048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18050. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  18051. if !m.op.Is(OpUpdateOne) {
  18052. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  18053. }
  18054. if m.id == nil || m.oldValue == nil {
  18055. return v, errors.New("OldTel requires an ID field in the mutation")
  18056. }
  18057. oldValue, err := m.oldValue(ctx)
  18058. if err != nil {
  18059. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  18060. }
  18061. return oldValue.Tel, nil
  18062. }
  18063. // ResetTel resets all changes to the "tel" field.
  18064. func (m *WxMutation) ResetTel() {
  18065. m.tel = nil
  18066. }
  18067. // SetHeadBig sets the "head_big" field.
  18068. func (m *WxMutation) SetHeadBig(s string) {
  18069. m.head_big = &s
  18070. }
  18071. // HeadBig returns the value of the "head_big" field in the mutation.
  18072. func (m *WxMutation) HeadBig() (r string, exists bool) {
  18073. v := m.head_big
  18074. if v == nil {
  18075. return
  18076. }
  18077. return *v, true
  18078. }
  18079. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  18080. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18082. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  18083. if !m.op.Is(OpUpdateOne) {
  18084. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  18085. }
  18086. if m.id == nil || m.oldValue == nil {
  18087. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  18088. }
  18089. oldValue, err := m.oldValue(ctx)
  18090. if err != nil {
  18091. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  18092. }
  18093. return oldValue.HeadBig, nil
  18094. }
  18095. // ResetHeadBig resets all changes to the "head_big" field.
  18096. func (m *WxMutation) ResetHeadBig() {
  18097. m.head_big = nil
  18098. }
  18099. // SetOrganizationID sets the "organization_id" field.
  18100. func (m *WxMutation) SetOrganizationID(u uint64) {
  18101. m.organization_id = &u
  18102. m.addorganization_id = nil
  18103. }
  18104. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18105. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  18106. v := m.organization_id
  18107. if v == nil {
  18108. return
  18109. }
  18110. return *v, true
  18111. }
  18112. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  18113. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18115. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18116. if !m.op.Is(OpUpdateOne) {
  18117. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18118. }
  18119. if m.id == nil || m.oldValue == nil {
  18120. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18121. }
  18122. oldValue, err := m.oldValue(ctx)
  18123. if err != nil {
  18124. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18125. }
  18126. return oldValue.OrganizationID, nil
  18127. }
  18128. // AddOrganizationID adds u to the "organization_id" field.
  18129. func (m *WxMutation) AddOrganizationID(u int64) {
  18130. if m.addorganization_id != nil {
  18131. *m.addorganization_id += u
  18132. } else {
  18133. m.addorganization_id = &u
  18134. }
  18135. }
  18136. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18137. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  18138. v := m.addorganization_id
  18139. if v == nil {
  18140. return
  18141. }
  18142. return *v, true
  18143. }
  18144. // ClearOrganizationID clears the value of the "organization_id" field.
  18145. func (m *WxMutation) ClearOrganizationID() {
  18146. m.organization_id = nil
  18147. m.addorganization_id = nil
  18148. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  18149. }
  18150. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18151. func (m *WxMutation) OrganizationIDCleared() bool {
  18152. _, ok := m.clearedFields[wx.FieldOrganizationID]
  18153. return ok
  18154. }
  18155. // ResetOrganizationID resets all changes to the "organization_id" field.
  18156. func (m *WxMutation) ResetOrganizationID() {
  18157. m.organization_id = nil
  18158. m.addorganization_id = nil
  18159. delete(m.clearedFields, wx.FieldOrganizationID)
  18160. }
  18161. // SetAgentID sets the "agent_id" field.
  18162. func (m *WxMutation) SetAgentID(u uint64) {
  18163. m.agent = &u
  18164. }
  18165. // AgentID returns the value of the "agent_id" field in the mutation.
  18166. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  18167. v := m.agent
  18168. if v == nil {
  18169. return
  18170. }
  18171. return *v, true
  18172. }
  18173. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  18174. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  18175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18176. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  18177. if !m.op.Is(OpUpdateOne) {
  18178. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  18179. }
  18180. if m.id == nil || m.oldValue == nil {
  18181. return v, errors.New("OldAgentID requires an ID field in the mutation")
  18182. }
  18183. oldValue, err := m.oldValue(ctx)
  18184. if err != nil {
  18185. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  18186. }
  18187. return oldValue.AgentID, nil
  18188. }
  18189. // ResetAgentID resets all changes to the "agent_id" field.
  18190. func (m *WxMutation) ResetAgentID() {
  18191. m.agent = nil
  18192. }
  18193. // ClearServer clears the "server" edge to the Server entity.
  18194. func (m *WxMutation) ClearServer() {
  18195. m.clearedserver = true
  18196. m.clearedFields[wx.FieldServerID] = struct{}{}
  18197. }
  18198. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  18199. func (m *WxMutation) ServerCleared() bool {
  18200. return m.ServerIDCleared() || m.clearedserver
  18201. }
  18202. // ServerIDs returns the "server" edge IDs in the mutation.
  18203. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18204. // ServerID instead. It exists only for internal usage by the builders.
  18205. func (m *WxMutation) ServerIDs() (ids []uint64) {
  18206. if id := m.server; id != nil {
  18207. ids = append(ids, *id)
  18208. }
  18209. return
  18210. }
  18211. // ResetServer resets all changes to the "server" edge.
  18212. func (m *WxMutation) ResetServer() {
  18213. m.server = nil
  18214. m.clearedserver = false
  18215. }
  18216. // ClearAgent clears the "agent" edge to the Agent entity.
  18217. func (m *WxMutation) ClearAgent() {
  18218. m.clearedagent = true
  18219. m.clearedFields[wx.FieldAgentID] = struct{}{}
  18220. }
  18221. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  18222. func (m *WxMutation) AgentCleared() bool {
  18223. return m.clearedagent
  18224. }
  18225. // AgentIDs returns the "agent" edge IDs in the mutation.
  18226. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18227. // AgentID instead. It exists only for internal usage by the builders.
  18228. func (m *WxMutation) AgentIDs() (ids []uint64) {
  18229. if id := m.agent; id != nil {
  18230. ids = append(ids, *id)
  18231. }
  18232. return
  18233. }
  18234. // ResetAgent resets all changes to the "agent" edge.
  18235. func (m *WxMutation) ResetAgent() {
  18236. m.agent = nil
  18237. m.clearedagent = false
  18238. }
  18239. // Where appends a list predicates to the WxMutation builder.
  18240. func (m *WxMutation) Where(ps ...predicate.Wx) {
  18241. m.predicates = append(m.predicates, ps...)
  18242. }
  18243. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  18244. // users can use type-assertion to append predicates that do not depend on any generated package.
  18245. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  18246. p := make([]predicate.Wx, len(ps))
  18247. for i := range ps {
  18248. p[i] = ps[i]
  18249. }
  18250. m.Where(p...)
  18251. }
  18252. // Op returns the operation name.
  18253. func (m *WxMutation) Op() Op {
  18254. return m.op
  18255. }
  18256. // SetOp allows setting the mutation operation.
  18257. func (m *WxMutation) SetOp(op Op) {
  18258. m.op = op
  18259. }
  18260. // Type returns the node type of this mutation (Wx).
  18261. func (m *WxMutation) Type() string {
  18262. return m.typ
  18263. }
  18264. // Fields returns all fields that were changed during this mutation. Note that in
  18265. // order to get all numeric fields that were incremented/decremented, call
  18266. // AddedFields().
  18267. func (m *WxMutation) Fields() []string {
  18268. fields := make([]string, 0, 15)
  18269. if m.created_at != nil {
  18270. fields = append(fields, wx.FieldCreatedAt)
  18271. }
  18272. if m.updated_at != nil {
  18273. fields = append(fields, wx.FieldUpdatedAt)
  18274. }
  18275. if m.status != nil {
  18276. fields = append(fields, wx.FieldStatus)
  18277. }
  18278. if m.deleted_at != nil {
  18279. fields = append(fields, wx.FieldDeletedAt)
  18280. }
  18281. if m.server != nil {
  18282. fields = append(fields, wx.FieldServerID)
  18283. }
  18284. if m.port != nil {
  18285. fields = append(fields, wx.FieldPort)
  18286. }
  18287. if m.process_id != nil {
  18288. fields = append(fields, wx.FieldProcessID)
  18289. }
  18290. if m.callback != nil {
  18291. fields = append(fields, wx.FieldCallback)
  18292. }
  18293. if m.wxid != nil {
  18294. fields = append(fields, wx.FieldWxid)
  18295. }
  18296. if m.account != nil {
  18297. fields = append(fields, wx.FieldAccount)
  18298. }
  18299. if m.nickname != nil {
  18300. fields = append(fields, wx.FieldNickname)
  18301. }
  18302. if m.tel != nil {
  18303. fields = append(fields, wx.FieldTel)
  18304. }
  18305. if m.head_big != nil {
  18306. fields = append(fields, wx.FieldHeadBig)
  18307. }
  18308. if m.organization_id != nil {
  18309. fields = append(fields, wx.FieldOrganizationID)
  18310. }
  18311. if m.agent != nil {
  18312. fields = append(fields, wx.FieldAgentID)
  18313. }
  18314. return fields
  18315. }
  18316. // Field returns the value of a field with the given name. The second boolean
  18317. // return value indicates that this field was not set, or was not defined in the
  18318. // schema.
  18319. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  18320. switch name {
  18321. case wx.FieldCreatedAt:
  18322. return m.CreatedAt()
  18323. case wx.FieldUpdatedAt:
  18324. return m.UpdatedAt()
  18325. case wx.FieldStatus:
  18326. return m.Status()
  18327. case wx.FieldDeletedAt:
  18328. return m.DeletedAt()
  18329. case wx.FieldServerID:
  18330. return m.ServerID()
  18331. case wx.FieldPort:
  18332. return m.Port()
  18333. case wx.FieldProcessID:
  18334. return m.ProcessID()
  18335. case wx.FieldCallback:
  18336. return m.Callback()
  18337. case wx.FieldWxid:
  18338. return m.Wxid()
  18339. case wx.FieldAccount:
  18340. return m.Account()
  18341. case wx.FieldNickname:
  18342. return m.Nickname()
  18343. case wx.FieldTel:
  18344. return m.Tel()
  18345. case wx.FieldHeadBig:
  18346. return m.HeadBig()
  18347. case wx.FieldOrganizationID:
  18348. return m.OrganizationID()
  18349. case wx.FieldAgentID:
  18350. return m.AgentID()
  18351. }
  18352. return nil, false
  18353. }
  18354. // OldField returns the old value of the field from the database. An error is
  18355. // returned if the mutation operation is not UpdateOne, or the query to the
  18356. // database failed.
  18357. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18358. switch name {
  18359. case wx.FieldCreatedAt:
  18360. return m.OldCreatedAt(ctx)
  18361. case wx.FieldUpdatedAt:
  18362. return m.OldUpdatedAt(ctx)
  18363. case wx.FieldStatus:
  18364. return m.OldStatus(ctx)
  18365. case wx.FieldDeletedAt:
  18366. return m.OldDeletedAt(ctx)
  18367. case wx.FieldServerID:
  18368. return m.OldServerID(ctx)
  18369. case wx.FieldPort:
  18370. return m.OldPort(ctx)
  18371. case wx.FieldProcessID:
  18372. return m.OldProcessID(ctx)
  18373. case wx.FieldCallback:
  18374. return m.OldCallback(ctx)
  18375. case wx.FieldWxid:
  18376. return m.OldWxid(ctx)
  18377. case wx.FieldAccount:
  18378. return m.OldAccount(ctx)
  18379. case wx.FieldNickname:
  18380. return m.OldNickname(ctx)
  18381. case wx.FieldTel:
  18382. return m.OldTel(ctx)
  18383. case wx.FieldHeadBig:
  18384. return m.OldHeadBig(ctx)
  18385. case wx.FieldOrganizationID:
  18386. return m.OldOrganizationID(ctx)
  18387. case wx.FieldAgentID:
  18388. return m.OldAgentID(ctx)
  18389. }
  18390. return nil, fmt.Errorf("unknown Wx field %s", name)
  18391. }
  18392. // SetField sets the value of a field with the given name. It returns an error if
  18393. // the field is not defined in the schema, or if the type mismatched the field
  18394. // type.
  18395. func (m *WxMutation) SetField(name string, value ent.Value) error {
  18396. switch name {
  18397. case wx.FieldCreatedAt:
  18398. v, ok := value.(time.Time)
  18399. if !ok {
  18400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18401. }
  18402. m.SetCreatedAt(v)
  18403. return nil
  18404. case wx.FieldUpdatedAt:
  18405. v, ok := value.(time.Time)
  18406. if !ok {
  18407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18408. }
  18409. m.SetUpdatedAt(v)
  18410. return nil
  18411. case wx.FieldStatus:
  18412. v, ok := value.(uint8)
  18413. if !ok {
  18414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18415. }
  18416. m.SetStatus(v)
  18417. return nil
  18418. case wx.FieldDeletedAt:
  18419. v, ok := value.(time.Time)
  18420. if !ok {
  18421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18422. }
  18423. m.SetDeletedAt(v)
  18424. return nil
  18425. case wx.FieldServerID:
  18426. v, ok := value.(uint64)
  18427. if !ok {
  18428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18429. }
  18430. m.SetServerID(v)
  18431. return nil
  18432. case wx.FieldPort:
  18433. v, ok := value.(string)
  18434. if !ok {
  18435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18436. }
  18437. m.SetPort(v)
  18438. return nil
  18439. case wx.FieldProcessID:
  18440. v, ok := value.(string)
  18441. if !ok {
  18442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18443. }
  18444. m.SetProcessID(v)
  18445. return nil
  18446. case wx.FieldCallback:
  18447. v, ok := value.(string)
  18448. if !ok {
  18449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18450. }
  18451. m.SetCallback(v)
  18452. return nil
  18453. case wx.FieldWxid:
  18454. v, ok := value.(string)
  18455. if !ok {
  18456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18457. }
  18458. m.SetWxid(v)
  18459. return nil
  18460. case wx.FieldAccount:
  18461. v, ok := value.(string)
  18462. if !ok {
  18463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18464. }
  18465. m.SetAccount(v)
  18466. return nil
  18467. case wx.FieldNickname:
  18468. v, ok := value.(string)
  18469. if !ok {
  18470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18471. }
  18472. m.SetNickname(v)
  18473. return nil
  18474. case wx.FieldTel:
  18475. v, ok := value.(string)
  18476. if !ok {
  18477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18478. }
  18479. m.SetTel(v)
  18480. return nil
  18481. case wx.FieldHeadBig:
  18482. v, ok := value.(string)
  18483. if !ok {
  18484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18485. }
  18486. m.SetHeadBig(v)
  18487. return nil
  18488. case wx.FieldOrganizationID:
  18489. v, ok := value.(uint64)
  18490. if !ok {
  18491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18492. }
  18493. m.SetOrganizationID(v)
  18494. return nil
  18495. case wx.FieldAgentID:
  18496. v, ok := value.(uint64)
  18497. if !ok {
  18498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18499. }
  18500. m.SetAgentID(v)
  18501. return nil
  18502. }
  18503. return fmt.Errorf("unknown Wx field %s", name)
  18504. }
  18505. // AddedFields returns all numeric fields that were incremented/decremented during
  18506. // this mutation.
  18507. func (m *WxMutation) AddedFields() []string {
  18508. var fields []string
  18509. if m.addstatus != nil {
  18510. fields = append(fields, wx.FieldStatus)
  18511. }
  18512. if m.addorganization_id != nil {
  18513. fields = append(fields, wx.FieldOrganizationID)
  18514. }
  18515. return fields
  18516. }
  18517. // AddedField returns the numeric value that was incremented/decremented on a field
  18518. // with the given name. The second boolean return value indicates that this field
  18519. // was not set, or was not defined in the schema.
  18520. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  18521. switch name {
  18522. case wx.FieldStatus:
  18523. return m.AddedStatus()
  18524. case wx.FieldOrganizationID:
  18525. return m.AddedOrganizationID()
  18526. }
  18527. return nil, false
  18528. }
  18529. // AddField adds the value to the field with the given name. It returns an error if
  18530. // the field is not defined in the schema, or if the type mismatched the field
  18531. // type.
  18532. func (m *WxMutation) AddField(name string, value ent.Value) error {
  18533. switch name {
  18534. case wx.FieldStatus:
  18535. v, ok := value.(int8)
  18536. if !ok {
  18537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18538. }
  18539. m.AddStatus(v)
  18540. return nil
  18541. case wx.FieldOrganizationID:
  18542. v, ok := value.(int64)
  18543. if !ok {
  18544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18545. }
  18546. m.AddOrganizationID(v)
  18547. return nil
  18548. }
  18549. return fmt.Errorf("unknown Wx numeric field %s", name)
  18550. }
  18551. // ClearedFields returns all nullable fields that were cleared during this
  18552. // mutation.
  18553. func (m *WxMutation) ClearedFields() []string {
  18554. var fields []string
  18555. if m.FieldCleared(wx.FieldStatus) {
  18556. fields = append(fields, wx.FieldStatus)
  18557. }
  18558. if m.FieldCleared(wx.FieldDeletedAt) {
  18559. fields = append(fields, wx.FieldDeletedAt)
  18560. }
  18561. if m.FieldCleared(wx.FieldServerID) {
  18562. fields = append(fields, wx.FieldServerID)
  18563. }
  18564. if m.FieldCleared(wx.FieldOrganizationID) {
  18565. fields = append(fields, wx.FieldOrganizationID)
  18566. }
  18567. return fields
  18568. }
  18569. // FieldCleared returns a boolean indicating if a field with the given name was
  18570. // cleared in this mutation.
  18571. func (m *WxMutation) FieldCleared(name string) bool {
  18572. _, ok := m.clearedFields[name]
  18573. return ok
  18574. }
  18575. // ClearField clears the value of the field with the given name. It returns an
  18576. // error if the field is not defined in the schema.
  18577. func (m *WxMutation) ClearField(name string) error {
  18578. switch name {
  18579. case wx.FieldStatus:
  18580. m.ClearStatus()
  18581. return nil
  18582. case wx.FieldDeletedAt:
  18583. m.ClearDeletedAt()
  18584. return nil
  18585. case wx.FieldServerID:
  18586. m.ClearServerID()
  18587. return nil
  18588. case wx.FieldOrganizationID:
  18589. m.ClearOrganizationID()
  18590. return nil
  18591. }
  18592. return fmt.Errorf("unknown Wx nullable field %s", name)
  18593. }
  18594. // ResetField resets all changes in the mutation for the field with the given name.
  18595. // It returns an error if the field is not defined in the schema.
  18596. func (m *WxMutation) ResetField(name string) error {
  18597. switch name {
  18598. case wx.FieldCreatedAt:
  18599. m.ResetCreatedAt()
  18600. return nil
  18601. case wx.FieldUpdatedAt:
  18602. m.ResetUpdatedAt()
  18603. return nil
  18604. case wx.FieldStatus:
  18605. m.ResetStatus()
  18606. return nil
  18607. case wx.FieldDeletedAt:
  18608. m.ResetDeletedAt()
  18609. return nil
  18610. case wx.FieldServerID:
  18611. m.ResetServerID()
  18612. return nil
  18613. case wx.FieldPort:
  18614. m.ResetPort()
  18615. return nil
  18616. case wx.FieldProcessID:
  18617. m.ResetProcessID()
  18618. return nil
  18619. case wx.FieldCallback:
  18620. m.ResetCallback()
  18621. return nil
  18622. case wx.FieldWxid:
  18623. m.ResetWxid()
  18624. return nil
  18625. case wx.FieldAccount:
  18626. m.ResetAccount()
  18627. return nil
  18628. case wx.FieldNickname:
  18629. m.ResetNickname()
  18630. return nil
  18631. case wx.FieldTel:
  18632. m.ResetTel()
  18633. return nil
  18634. case wx.FieldHeadBig:
  18635. m.ResetHeadBig()
  18636. return nil
  18637. case wx.FieldOrganizationID:
  18638. m.ResetOrganizationID()
  18639. return nil
  18640. case wx.FieldAgentID:
  18641. m.ResetAgentID()
  18642. return nil
  18643. }
  18644. return fmt.Errorf("unknown Wx field %s", name)
  18645. }
  18646. // AddedEdges returns all edge names that were set/added in this mutation.
  18647. func (m *WxMutation) AddedEdges() []string {
  18648. edges := make([]string, 0, 2)
  18649. if m.server != nil {
  18650. edges = append(edges, wx.EdgeServer)
  18651. }
  18652. if m.agent != nil {
  18653. edges = append(edges, wx.EdgeAgent)
  18654. }
  18655. return edges
  18656. }
  18657. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18658. // name in this mutation.
  18659. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  18660. switch name {
  18661. case wx.EdgeServer:
  18662. if id := m.server; id != nil {
  18663. return []ent.Value{*id}
  18664. }
  18665. case wx.EdgeAgent:
  18666. if id := m.agent; id != nil {
  18667. return []ent.Value{*id}
  18668. }
  18669. }
  18670. return nil
  18671. }
  18672. // RemovedEdges returns all edge names that were removed in this mutation.
  18673. func (m *WxMutation) RemovedEdges() []string {
  18674. edges := make([]string, 0, 2)
  18675. return edges
  18676. }
  18677. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18678. // the given name in this mutation.
  18679. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  18680. return nil
  18681. }
  18682. // ClearedEdges returns all edge names that were cleared in this mutation.
  18683. func (m *WxMutation) ClearedEdges() []string {
  18684. edges := make([]string, 0, 2)
  18685. if m.clearedserver {
  18686. edges = append(edges, wx.EdgeServer)
  18687. }
  18688. if m.clearedagent {
  18689. edges = append(edges, wx.EdgeAgent)
  18690. }
  18691. return edges
  18692. }
  18693. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18694. // was cleared in this mutation.
  18695. func (m *WxMutation) EdgeCleared(name string) bool {
  18696. switch name {
  18697. case wx.EdgeServer:
  18698. return m.clearedserver
  18699. case wx.EdgeAgent:
  18700. return m.clearedagent
  18701. }
  18702. return false
  18703. }
  18704. // ClearEdge clears the value of the edge with the given name. It returns an error
  18705. // if that edge is not defined in the schema.
  18706. func (m *WxMutation) ClearEdge(name string) error {
  18707. switch name {
  18708. case wx.EdgeServer:
  18709. m.ClearServer()
  18710. return nil
  18711. case wx.EdgeAgent:
  18712. m.ClearAgent()
  18713. return nil
  18714. }
  18715. return fmt.Errorf("unknown Wx unique edge %s", name)
  18716. }
  18717. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18718. // It returns an error if the edge is not defined in the schema.
  18719. func (m *WxMutation) ResetEdge(name string) error {
  18720. switch name {
  18721. case wx.EdgeServer:
  18722. m.ResetServer()
  18723. return nil
  18724. case wx.EdgeAgent:
  18725. m.ResetAgent()
  18726. return nil
  18727. }
  18728. return fmt.Errorf("unknown Wx edge %s", name)
  18729. }