mutation.go 873 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/custom_types"
  18. "wechat-api/ent/employee"
  19. "wechat-api/ent/employeeconfig"
  20. "wechat-api/ent/label"
  21. "wechat-api/ent/labelrelationship"
  22. "wechat-api/ent/message"
  23. "wechat-api/ent/messagerecords"
  24. "wechat-api/ent/msg"
  25. "wechat-api/ent/predicate"
  26. "wechat-api/ent/server"
  27. "wechat-api/ent/sopnode"
  28. "wechat-api/ent/sopstage"
  29. "wechat-api/ent/soptask"
  30. "wechat-api/ent/token"
  31. "wechat-api/ent/tutorial"
  32. "wechat-api/ent/workexperience"
  33. "wechat-api/ent/wx"
  34. "wechat-api/ent/wxcard"
  35. "wechat-api/ent/wxcarduser"
  36. "wechat-api/ent/wxcardvisit"
  37. "entgo.io/ent"
  38. "entgo.io/ent/dialect/sql"
  39. )
  40. const (
  41. // Operation types.
  42. OpCreate = ent.OpCreate
  43. OpDelete = ent.OpDelete
  44. OpDeleteOne = ent.OpDeleteOne
  45. OpUpdate = ent.OpUpdate
  46. OpUpdateOne = ent.OpUpdateOne
  47. // Node types.
  48. TypeAgent = "Agent"
  49. TypeAgentBase = "AgentBase"
  50. TypeAliyunAvatar = "AliyunAvatar"
  51. TypeBatchMsg = "BatchMsg"
  52. TypeCategory = "Category"
  53. TypeChatRecords = "ChatRecords"
  54. TypeChatSession = "ChatSession"
  55. TypeContact = "Contact"
  56. TypeEmployee = "Employee"
  57. TypeEmployeeConfig = "EmployeeConfig"
  58. TypeLabel = "Label"
  59. TypeLabelRelationship = "LabelRelationship"
  60. TypeMessage = "Message"
  61. TypeMessageRecords = "MessageRecords"
  62. TypeMsg = "Msg"
  63. TypeServer = "Server"
  64. TypeSopNode = "SopNode"
  65. TypeSopStage = "SopStage"
  66. TypeSopTask = "SopTask"
  67. TypeToken = "Token"
  68. TypeTutorial = "Tutorial"
  69. TypeWorkExperience = "WorkExperience"
  70. TypeWx = "Wx"
  71. TypeWxCard = "WxCard"
  72. TypeWxCardUser = "WxCardUser"
  73. TypeWxCardVisit = "WxCardVisit"
  74. )
  75. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  76. type AgentMutation struct {
  77. config
  78. op Op
  79. typ string
  80. id *uint64
  81. created_at *time.Time
  82. updated_at *time.Time
  83. deleted_at *time.Time
  84. name *string
  85. role *string
  86. status *int
  87. addstatus *int
  88. background *string
  89. examples *string
  90. organization_id *uint64
  91. addorganization_id *int64
  92. dataset_id *string
  93. collection_id *string
  94. clearedFields map[string]struct{}
  95. wx_agent map[uint64]struct{}
  96. removedwx_agent map[uint64]struct{}
  97. clearedwx_agent bool
  98. done bool
  99. oldValue func(context.Context) (*Agent, error)
  100. predicates []predicate.Agent
  101. }
  102. var _ ent.Mutation = (*AgentMutation)(nil)
  103. // agentOption allows management of the mutation configuration using functional options.
  104. type agentOption func(*AgentMutation)
  105. // newAgentMutation creates new mutation for the Agent entity.
  106. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  107. m := &AgentMutation{
  108. config: c,
  109. op: op,
  110. typ: TypeAgent,
  111. clearedFields: make(map[string]struct{}),
  112. }
  113. for _, opt := range opts {
  114. opt(m)
  115. }
  116. return m
  117. }
  118. // withAgentID sets the ID field of the mutation.
  119. func withAgentID(id uint64) agentOption {
  120. return func(m *AgentMutation) {
  121. var (
  122. err error
  123. once sync.Once
  124. value *Agent
  125. )
  126. m.oldValue = func(ctx context.Context) (*Agent, error) {
  127. once.Do(func() {
  128. if m.done {
  129. err = errors.New("querying old values post mutation is not allowed")
  130. } else {
  131. value, err = m.Client().Agent.Get(ctx, id)
  132. }
  133. })
  134. return value, err
  135. }
  136. m.id = &id
  137. }
  138. }
  139. // withAgent sets the old Agent of the mutation.
  140. func withAgent(node *Agent) agentOption {
  141. return func(m *AgentMutation) {
  142. m.oldValue = func(context.Context) (*Agent, error) {
  143. return node, nil
  144. }
  145. m.id = &node.ID
  146. }
  147. }
  148. // Client returns a new `ent.Client` from the mutation. If the mutation was
  149. // executed in a transaction (ent.Tx), a transactional client is returned.
  150. func (m AgentMutation) Client() *Client {
  151. client := &Client{config: m.config}
  152. client.init()
  153. return client
  154. }
  155. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  156. // it returns an error otherwise.
  157. func (m AgentMutation) Tx() (*Tx, error) {
  158. if _, ok := m.driver.(*txDriver); !ok {
  159. return nil, errors.New("ent: mutation is not running in a transaction")
  160. }
  161. tx := &Tx{config: m.config}
  162. tx.init()
  163. return tx, nil
  164. }
  165. // SetID sets the value of the id field. Note that this
  166. // operation is only accepted on creation of Agent entities.
  167. func (m *AgentMutation) SetID(id uint64) {
  168. m.id = &id
  169. }
  170. // ID returns the ID value in the mutation. Note that the ID is only available
  171. // if it was provided to the builder or after it was returned from the database.
  172. func (m *AgentMutation) ID() (id uint64, exists bool) {
  173. if m.id == nil {
  174. return
  175. }
  176. return *m.id, true
  177. }
  178. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  179. // That means, if the mutation is applied within a transaction with an isolation level such
  180. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  181. // or updated by the mutation.
  182. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  183. switch {
  184. case m.op.Is(OpUpdateOne | OpDeleteOne):
  185. id, exists := m.ID()
  186. if exists {
  187. return []uint64{id}, nil
  188. }
  189. fallthrough
  190. case m.op.Is(OpUpdate | OpDelete):
  191. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  192. default:
  193. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  194. }
  195. }
  196. // SetCreatedAt sets the "created_at" field.
  197. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  198. m.created_at = &t
  199. }
  200. // CreatedAt returns the value of the "created_at" field in the mutation.
  201. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  202. v := m.created_at
  203. if v == nil {
  204. return
  205. }
  206. return *v, true
  207. }
  208. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  209. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  211. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  212. if !m.op.Is(OpUpdateOne) {
  213. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  214. }
  215. if m.id == nil || m.oldValue == nil {
  216. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  217. }
  218. oldValue, err := m.oldValue(ctx)
  219. if err != nil {
  220. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  221. }
  222. return oldValue.CreatedAt, nil
  223. }
  224. // ResetCreatedAt resets all changes to the "created_at" field.
  225. func (m *AgentMutation) ResetCreatedAt() {
  226. m.created_at = nil
  227. }
  228. // SetUpdatedAt sets the "updated_at" field.
  229. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  230. m.updated_at = &t
  231. }
  232. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  233. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  234. v := m.updated_at
  235. if v == nil {
  236. return
  237. }
  238. return *v, true
  239. }
  240. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  241. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  243. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  244. if !m.op.Is(OpUpdateOne) {
  245. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  246. }
  247. if m.id == nil || m.oldValue == nil {
  248. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  249. }
  250. oldValue, err := m.oldValue(ctx)
  251. if err != nil {
  252. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  253. }
  254. return oldValue.UpdatedAt, nil
  255. }
  256. // ResetUpdatedAt resets all changes to the "updated_at" field.
  257. func (m *AgentMutation) ResetUpdatedAt() {
  258. m.updated_at = nil
  259. }
  260. // SetDeletedAt sets the "deleted_at" field.
  261. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  262. m.deleted_at = &t
  263. }
  264. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  265. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  266. v := m.deleted_at
  267. if v == nil {
  268. return
  269. }
  270. return *v, true
  271. }
  272. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  273. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  275. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  276. if !m.op.Is(OpUpdateOne) {
  277. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  278. }
  279. if m.id == nil || m.oldValue == nil {
  280. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  281. }
  282. oldValue, err := m.oldValue(ctx)
  283. if err != nil {
  284. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  285. }
  286. return oldValue.DeletedAt, nil
  287. }
  288. // ClearDeletedAt clears the value of the "deleted_at" field.
  289. func (m *AgentMutation) ClearDeletedAt() {
  290. m.deleted_at = nil
  291. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  292. }
  293. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  294. func (m *AgentMutation) DeletedAtCleared() bool {
  295. _, ok := m.clearedFields[agent.FieldDeletedAt]
  296. return ok
  297. }
  298. // ResetDeletedAt resets all changes to the "deleted_at" field.
  299. func (m *AgentMutation) ResetDeletedAt() {
  300. m.deleted_at = nil
  301. delete(m.clearedFields, agent.FieldDeletedAt)
  302. }
  303. // SetName sets the "name" field.
  304. func (m *AgentMutation) SetName(s string) {
  305. m.name = &s
  306. }
  307. // Name returns the value of the "name" field in the mutation.
  308. func (m *AgentMutation) Name() (r string, exists bool) {
  309. v := m.name
  310. if v == nil {
  311. return
  312. }
  313. return *v, true
  314. }
  315. // OldName returns the old "name" field's value of the Agent entity.
  316. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  318. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  319. if !m.op.Is(OpUpdateOne) {
  320. return v, errors.New("OldName is only allowed on UpdateOne operations")
  321. }
  322. if m.id == nil || m.oldValue == nil {
  323. return v, errors.New("OldName requires an ID field in the mutation")
  324. }
  325. oldValue, err := m.oldValue(ctx)
  326. if err != nil {
  327. return v, fmt.Errorf("querying old value for OldName: %w", err)
  328. }
  329. return oldValue.Name, nil
  330. }
  331. // ResetName resets all changes to the "name" field.
  332. func (m *AgentMutation) ResetName() {
  333. m.name = nil
  334. }
  335. // SetRole sets the "role" field.
  336. func (m *AgentMutation) SetRole(s string) {
  337. m.role = &s
  338. }
  339. // Role returns the value of the "role" field in the mutation.
  340. func (m *AgentMutation) Role() (r string, exists bool) {
  341. v := m.role
  342. if v == nil {
  343. return
  344. }
  345. return *v, true
  346. }
  347. // OldRole returns the old "role" field's value of the Agent entity.
  348. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  350. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  351. if !m.op.Is(OpUpdateOne) {
  352. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  353. }
  354. if m.id == nil || m.oldValue == nil {
  355. return v, errors.New("OldRole requires an ID field in the mutation")
  356. }
  357. oldValue, err := m.oldValue(ctx)
  358. if err != nil {
  359. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  360. }
  361. return oldValue.Role, nil
  362. }
  363. // ResetRole resets all changes to the "role" field.
  364. func (m *AgentMutation) ResetRole() {
  365. m.role = nil
  366. }
  367. // SetStatus sets the "status" field.
  368. func (m *AgentMutation) SetStatus(i int) {
  369. m.status = &i
  370. m.addstatus = nil
  371. }
  372. // Status returns the value of the "status" field in the mutation.
  373. func (m *AgentMutation) Status() (r int, exists bool) {
  374. v := m.status
  375. if v == nil {
  376. return
  377. }
  378. return *v, true
  379. }
  380. // OldStatus returns the old "status" field's value of the Agent entity.
  381. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  383. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  384. if !m.op.Is(OpUpdateOne) {
  385. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  386. }
  387. if m.id == nil || m.oldValue == nil {
  388. return v, errors.New("OldStatus requires an ID field in the mutation")
  389. }
  390. oldValue, err := m.oldValue(ctx)
  391. if err != nil {
  392. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  393. }
  394. return oldValue.Status, nil
  395. }
  396. // AddStatus adds i to the "status" field.
  397. func (m *AgentMutation) AddStatus(i int) {
  398. if m.addstatus != nil {
  399. *m.addstatus += i
  400. } else {
  401. m.addstatus = &i
  402. }
  403. }
  404. // AddedStatus returns the value that was added to the "status" field in this mutation.
  405. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  406. v := m.addstatus
  407. if v == nil {
  408. return
  409. }
  410. return *v, true
  411. }
  412. // ClearStatus clears the value of the "status" field.
  413. func (m *AgentMutation) ClearStatus() {
  414. m.status = nil
  415. m.addstatus = nil
  416. m.clearedFields[agent.FieldStatus] = struct{}{}
  417. }
  418. // StatusCleared returns if the "status" field was cleared in this mutation.
  419. func (m *AgentMutation) StatusCleared() bool {
  420. _, ok := m.clearedFields[agent.FieldStatus]
  421. return ok
  422. }
  423. // ResetStatus resets all changes to the "status" field.
  424. func (m *AgentMutation) ResetStatus() {
  425. m.status = nil
  426. m.addstatus = nil
  427. delete(m.clearedFields, agent.FieldStatus)
  428. }
  429. // SetBackground sets the "background" field.
  430. func (m *AgentMutation) SetBackground(s string) {
  431. m.background = &s
  432. }
  433. // Background returns the value of the "background" field in the mutation.
  434. func (m *AgentMutation) Background() (r string, exists bool) {
  435. v := m.background
  436. if v == nil {
  437. return
  438. }
  439. return *v, true
  440. }
  441. // OldBackground returns the old "background" field's value of the Agent entity.
  442. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  444. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  445. if !m.op.Is(OpUpdateOne) {
  446. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  447. }
  448. if m.id == nil || m.oldValue == nil {
  449. return v, errors.New("OldBackground requires an ID field in the mutation")
  450. }
  451. oldValue, err := m.oldValue(ctx)
  452. if err != nil {
  453. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  454. }
  455. return oldValue.Background, nil
  456. }
  457. // ClearBackground clears the value of the "background" field.
  458. func (m *AgentMutation) ClearBackground() {
  459. m.background = nil
  460. m.clearedFields[agent.FieldBackground] = struct{}{}
  461. }
  462. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  463. func (m *AgentMutation) BackgroundCleared() bool {
  464. _, ok := m.clearedFields[agent.FieldBackground]
  465. return ok
  466. }
  467. // ResetBackground resets all changes to the "background" field.
  468. func (m *AgentMutation) ResetBackground() {
  469. m.background = nil
  470. delete(m.clearedFields, agent.FieldBackground)
  471. }
  472. // SetExamples sets the "examples" field.
  473. func (m *AgentMutation) SetExamples(s string) {
  474. m.examples = &s
  475. }
  476. // Examples returns the value of the "examples" field in the mutation.
  477. func (m *AgentMutation) Examples() (r string, exists bool) {
  478. v := m.examples
  479. if v == nil {
  480. return
  481. }
  482. return *v, true
  483. }
  484. // OldExamples returns the old "examples" field's value of the Agent entity.
  485. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  487. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  488. if !m.op.Is(OpUpdateOne) {
  489. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  490. }
  491. if m.id == nil || m.oldValue == nil {
  492. return v, errors.New("OldExamples requires an ID field in the mutation")
  493. }
  494. oldValue, err := m.oldValue(ctx)
  495. if err != nil {
  496. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  497. }
  498. return oldValue.Examples, nil
  499. }
  500. // ClearExamples clears the value of the "examples" field.
  501. func (m *AgentMutation) ClearExamples() {
  502. m.examples = nil
  503. m.clearedFields[agent.FieldExamples] = struct{}{}
  504. }
  505. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  506. func (m *AgentMutation) ExamplesCleared() bool {
  507. _, ok := m.clearedFields[agent.FieldExamples]
  508. return ok
  509. }
  510. // ResetExamples resets all changes to the "examples" field.
  511. func (m *AgentMutation) ResetExamples() {
  512. m.examples = nil
  513. delete(m.clearedFields, agent.FieldExamples)
  514. }
  515. // SetOrganizationID sets the "organization_id" field.
  516. func (m *AgentMutation) SetOrganizationID(u uint64) {
  517. m.organization_id = &u
  518. m.addorganization_id = nil
  519. }
  520. // OrganizationID returns the value of the "organization_id" field in the mutation.
  521. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  522. v := m.organization_id
  523. if v == nil {
  524. return
  525. }
  526. return *v, true
  527. }
  528. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  529. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  531. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  532. if !m.op.Is(OpUpdateOne) {
  533. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  534. }
  535. if m.id == nil || m.oldValue == nil {
  536. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  537. }
  538. oldValue, err := m.oldValue(ctx)
  539. if err != nil {
  540. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  541. }
  542. return oldValue.OrganizationID, nil
  543. }
  544. // AddOrganizationID adds u to the "organization_id" field.
  545. func (m *AgentMutation) AddOrganizationID(u int64) {
  546. if m.addorganization_id != nil {
  547. *m.addorganization_id += u
  548. } else {
  549. m.addorganization_id = &u
  550. }
  551. }
  552. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  553. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  554. v := m.addorganization_id
  555. if v == nil {
  556. return
  557. }
  558. return *v, true
  559. }
  560. // ResetOrganizationID resets all changes to the "organization_id" field.
  561. func (m *AgentMutation) ResetOrganizationID() {
  562. m.organization_id = nil
  563. m.addorganization_id = nil
  564. }
  565. // SetDatasetID sets the "dataset_id" field.
  566. func (m *AgentMutation) SetDatasetID(s string) {
  567. m.dataset_id = &s
  568. }
  569. // DatasetID returns the value of the "dataset_id" field in the mutation.
  570. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  571. v := m.dataset_id
  572. if v == nil {
  573. return
  574. }
  575. return *v, true
  576. }
  577. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  578. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  580. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  581. if !m.op.Is(OpUpdateOne) {
  582. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  583. }
  584. if m.id == nil || m.oldValue == nil {
  585. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  586. }
  587. oldValue, err := m.oldValue(ctx)
  588. if err != nil {
  589. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  590. }
  591. return oldValue.DatasetID, nil
  592. }
  593. // ResetDatasetID resets all changes to the "dataset_id" field.
  594. func (m *AgentMutation) ResetDatasetID() {
  595. m.dataset_id = nil
  596. }
  597. // SetCollectionID sets the "collection_id" field.
  598. func (m *AgentMutation) SetCollectionID(s string) {
  599. m.collection_id = &s
  600. }
  601. // CollectionID returns the value of the "collection_id" field in the mutation.
  602. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  603. v := m.collection_id
  604. if v == nil {
  605. return
  606. }
  607. return *v, true
  608. }
  609. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  610. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  612. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  613. if !m.op.Is(OpUpdateOne) {
  614. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  615. }
  616. if m.id == nil || m.oldValue == nil {
  617. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  618. }
  619. oldValue, err := m.oldValue(ctx)
  620. if err != nil {
  621. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  622. }
  623. return oldValue.CollectionID, nil
  624. }
  625. // ResetCollectionID resets all changes to the "collection_id" field.
  626. func (m *AgentMutation) ResetCollectionID() {
  627. m.collection_id = nil
  628. }
  629. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  630. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  631. if m.wx_agent == nil {
  632. m.wx_agent = make(map[uint64]struct{})
  633. }
  634. for i := range ids {
  635. m.wx_agent[ids[i]] = struct{}{}
  636. }
  637. }
  638. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  639. func (m *AgentMutation) ClearWxAgent() {
  640. m.clearedwx_agent = true
  641. }
  642. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  643. func (m *AgentMutation) WxAgentCleared() bool {
  644. return m.clearedwx_agent
  645. }
  646. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  647. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  648. if m.removedwx_agent == nil {
  649. m.removedwx_agent = make(map[uint64]struct{})
  650. }
  651. for i := range ids {
  652. delete(m.wx_agent, ids[i])
  653. m.removedwx_agent[ids[i]] = struct{}{}
  654. }
  655. }
  656. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  657. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  658. for id := range m.removedwx_agent {
  659. ids = append(ids, id)
  660. }
  661. return
  662. }
  663. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  664. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  665. for id := range m.wx_agent {
  666. ids = append(ids, id)
  667. }
  668. return
  669. }
  670. // ResetWxAgent resets all changes to the "wx_agent" edge.
  671. func (m *AgentMutation) ResetWxAgent() {
  672. m.wx_agent = nil
  673. m.clearedwx_agent = false
  674. m.removedwx_agent = nil
  675. }
  676. // Where appends a list predicates to the AgentMutation builder.
  677. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  678. m.predicates = append(m.predicates, ps...)
  679. }
  680. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  681. // users can use type-assertion to append predicates that do not depend on any generated package.
  682. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  683. p := make([]predicate.Agent, len(ps))
  684. for i := range ps {
  685. p[i] = ps[i]
  686. }
  687. m.Where(p...)
  688. }
  689. // Op returns the operation name.
  690. func (m *AgentMutation) Op() Op {
  691. return m.op
  692. }
  693. // SetOp allows setting the mutation operation.
  694. func (m *AgentMutation) SetOp(op Op) {
  695. m.op = op
  696. }
  697. // Type returns the node type of this mutation (Agent).
  698. func (m *AgentMutation) Type() string {
  699. return m.typ
  700. }
  701. // Fields returns all fields that were changed during this mutation. Note that in
  702. // order to get all numeric fields that were incremented/decremented, call
  703. // AddedFields().
  704. func (m *AgentMutation) Fields() []string {
  705. fields := make([]string, 0, 11)
  706. if m.created_at != nil {
  707. fields = append(fields, agent.FieldCreatedAt)
  708. }
  709. if m.updated_at != nil {
  710. fields = append(fields, agent.FieldUpdatedAt)
  711. }
  712. if m.deleted_at != nil {
  713. fields = append(fields, agent.FieldDeletedAt)
  714. }
  715. if m.name != nil {
  716. fields = append(fields, agent.FieldName)
  717. }
  718. if m.role != nil {
  719. fields = append(fields, agent.FieldRole)
  720. }
  721. if m.status != nil {
  722. fields = append(fields, agent.FieldStatus)
  723. }
  724. if m.background != nil {
  725. fields = append(fields, agent.FieldBackground)
  726. }
  727. if m.examples != nil {
  728. fields = append(fields, agent.FieldExamples)
  729. }
  730. if m.organization_id != nil {
  731. fields = append(fields, agent.FieldOrganizationID)
  732. }
  733. if m.dataset_id != nil {
  734. fields = append(fields, agent.FieldDatasetID)
  735. }
  736. if m.collection_id != nil {
  737. fields = append(fields, agent.FieldCollectionID)
  738. }
  739. return fields
  740. }
  741. // Field returns the value of a field with the given name. The second boolean
  742. // return value indicates that this field was not set, or was not defined in the
  743. // schema.
  744. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  745. switch name {
  746. case agent.FieldCreatedAt:
  747. return m.CreatedAt()
  748. case agent.FieldUpdatedAt:
  749. return m.UpdatedAt()
  750. case agent.FieldDeletedAt:
  751. return m.DeletedAt()
  752. case agent.FieldName:
  753. return m.Name()
  754. case agent.FieldRole:
  755. return m.Role()
  756. case agent.FieldStatus:
  757. return m.Status()
  758. case agent.FieldBackground:
  759. return m.Background()
  760. case agent.FieldExamples:
  761. return m.Examples()
  762. case agent.FieldOrganizationID:
  763. return m.OrganizationID()
  764. case agent.FieldDatasetID:
  765. return m.DatasetID()
  766. case agent.FieldCollectionID:
  767. return m.CollectionID()
  768. }
  769. return nil, false
  770. }
  771. // OldField returns the old value of the field from the database. An error is
  772. // returned if the mutation operation is not UpdateOne, or the query to the
  773. // database failed.
  774. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  775. switch name {
  776. case agent.FieldCreatedAt:
  777. return m.OldCreatedAt(ctx)
  778. case agent.FieldUpdatedAt:
  779. return m.OldUpdatedAt(ctx)
  780. case agent.FieldDeletedAt:
  781. return m.OldDeletedAt(ctx)
  782. case agent.FieldName:
  783. return m.OldName(ctx)
  784. case agent.FieldRole:
  785. return m.OldRole(ctx)
  786. case agent.FieldStatus:
  787. return m.OldStatus(ctx)
  788. case agent.FieldBackground:
  789. return m.OldBackground(ctx)
  790. case agent.FieldExamples:
  791. return m.OldExamples(ctx)
  792. case agent.FieldOrganizationID:
  793. return m.OldOrganizationID(ctx)
  794. case agent.FieldDatasetID:
  795. return m.OldDatasetID(ctx)
  796. case agent.FieldCollectionID:
  797. return m.OldCollectionID(ctx)
  798. }
  799. return nil, fmt.Errorf("unknown Agent field %s", name)
  800. }
  801. // SetField sets the value of a field with the given name. It returns an error if
  802. // the field is not defined in the schema, or if the type mismatched the field
  803. // type.
  804. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  805. switch name {
  806. case agent.FieldCreatedAt:
  807. v, ok := value.(time.Time)
  808. if !ok {
  809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  810. }
  811. m.SetCreatedAt(v)
  812. return nil
  813. case agent.FieldUpdatedAt:
  814. v, ok := value.(time.Time)
  815. if !ok {
  816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  817. }
  818. m.SetUpdatedAt(v)
  819. return nil
  820. case agent.FieldDeletedAt:
  821. v, ok := value.(time.Time)
  822. if !ok {
  823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  824. }
  825. m.SetDeletedAt(v)
  826. return nil
  827. case agent.FieldName:
  828. v, ok := value.(string)
  829. if !ok {
  830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  831. }
  832. m.SetName(v)
  833. return nil
  834. case agent.FieldRole:
  835. v, ok := value.(string)
  836. if !ok {
  837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  838. }
  839. m.SetRole(v)
  840. return nil
  841. case agent.FieldStatus:
  842. v, ok := value.(int)
  843. if !ok {
  844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  845. }
  846. m.SetStatus(v)
  847. return nil
  848. case agent.FieldBackground:
  849. v, ok := value.(string)
  850. if !ok {
  851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  852. }
  853. m.SetBackground(v)
  854. return nil
  855. case agent.FieldExamples:
  856. v, ok := value.(string)
  857. if !ok {
  858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  859. }
  860. m.SetExamples(v)
  861. return nil
  862. case agent.FieldOrganizationID:
  863. v, ok := value.(uint64)
  864. if !ok {
  865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  866. }
  867. m.SetOrganizationID(v)
  868. return nil
  869. case agent.FieldDatasetID:
  870. v, ok := value.(string)
  871. if !ok {
  872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  873. }
  874. m.SetDatasetID(v)
  875. return nil
  876. case agent.FieldCollectionID:
  877. v, ok := value.(string)
  878. if !ok {
  879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  880. }
  881. m.SetCollectionID(v)
  882. return nil
  883. }
  884. return fmt.Errorf("unknown Agent field %s", name)
  885. }
  886. // AddedFields returns all numeric fields that were incremented/decremented during
  887. // this mutation.
  888. func (m *AgentMutation) AddedFields() []string {
  889. var fields []string
  890. if m.addstatus != nil {
  891. fields = append(fields, agent.FieldStatus)
  892. }
  893. if m.addorganization_id != nil {
  894. fields = append(fields, agent.FieldOrganizationID)
  895. }
  896. return fields
  897. }
  898. // AddedField returns the numeric value that was incremented/decremented on a field
  899. // with the given name. The second boolean return value indicates that this field
  900. // was not set, or was not defined in the schema.
  901. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  902. switch name {
  903. case agent.FieldStatus:
  904. return m.AddedStatus()
  905. case agent.FieldOrganizationID:
  906. return m.AddedOrganizationID()
  907. }
  908. return nil, false
  909. }
  910. // AddField adds the value to the field with the given name. It returns an error if
  911. // the field is not defined in the schema, or if the type mismatched the field
  912. // type.
  913. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  914. switch name {
  915. case agent.FieldStatus:
  916. v, ok := value.(int)
  917. if !ok {
  918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  919. }
  920. m.AddStatus(v)
  921. return nil
  922. case agent.FieldOrganizationID:
  923. v, ok := value.(int64)
  924. if !ok {
  925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  926. }
  927. m.AddOrganizationID(v)
  928. return nil
  929. }
  930. return fmt.Errorf("unknown Agent numeric field %s", name)
  931. }
  932. // ClearedFields returns all nullable fields that were cleared during this
  933. // mutation.
  934. func (m *AgentMutation) ClearedFields() []string {
  935. var fields []string
  936. if m.FieldCleared(agent.FieldDeletedAt) {
  937. fields = append(fields, agent.FieldDeletedAt)
  938. }
  939. if m.FieldCleared(agent.FieldStatus) {
  940. fields = append(fields, agent.FieldStatus)
  941. }
  942. if m.FieldCleared(agent.FieldBackground) {
  943. fields = append(fields, agent.FieldBackground)
  944. }
  945. if m.FieldCleared(agent.FieldExamples) {
  946. fields = append(fields, agent.FieldExamples)
  947. }
  948. return fields
  949. }
  950. // FieldCleared returns a boolean indicating if a field with the given name was
  951. // cleared in this mutation.
  952. func (m *AgentMutation) FieldCleared(name string) bool {
  953. _, ok := m.clearedFields[name]
  954. return ok
  955. }
  956. // ClearField clears the value of the field with the given name. It returns an
  957. // error if the field is not defined in the schema.
  958. func (m *AgentMutation) ClearField(name string) error {
  959. switch name {
  960. case agent.FieldDeletedAt:
  961. m.ClearDeletedAt()
  962. return nil
  963. case agent.FieldStatus:
  964. m.ClearStatus()
  965. return nil
  966. case agent.FieldBackground:
  967. m.ClearBackground()
  968. return nil
  969. case agent.FieldExamples:
  970. m.ClearExamples()
  971. return nil
  972. }
  973. return fmt.Errorf("unknown Agent nullable field %s", name)
  974. }
  975. // ResetField resets all changes in the mutation for the field with the given name.
  976. // It returns an error if the field is not defined in the schema.
  977. func (m *AgentMutation) ResetField(name string) error {
  978. switch name {
  979. case agent.FieldCreatedAt:
  980. m.ResetCreatedAt()
  981. return nil
  982. case agent.FieldUpdatedAt:
  983. m.ResetUpdatedAt()
  984. return nil
  985. case agent.FieldDeletedAt:
  986. m.ResetDeletedAt()
  987. return nil
  988. case agent.FieldName:
  989. m.ResetName()
  990. return nil
  991. case agent.FieldRole:
  992. m.ResetRole()
  993. return nil
  994. case agent.FieldStatus:
  995. m.ResetStatus()
  996. return nil
  997. case agent.FieldBackground:
  998. m.ResetBackground()
  999. return nil
  1000. case agent.FieldExamples:
  1001. m.ResetExamples()
  1002. return nil
  1003. case agent.FieldOrganizationID:
  1004. m.ResetOrganizationID()
  1005. return nil
  1006. case agent.FieldDatasetID:
  1007. m.ResetDatasetID()
  1008. return nil
  1009. case agent.FieldCollectionID:
  1010. m.ResetCollectionID()
  1011. return nil
  1012. }
  1013. return fmt.Errorf("unknown Agent field %s", name)
  1014. }
  1015. // AddedEdges returns all edge names that were set/added in this mutation.
  1016. func (m *AgentMutation) AddedEdges() []string {
  1017. edges := make([]string, 0, 1)
  1018. if m.wx_agent != nil {
  1019. edges = append(edges, agent.EdgeWxAgent)
  1020. }
  1021. return edges
  1022. }
  1023. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1024. // name in this mutation.
  1025. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1026. switch name {
  1027. case agent.EdgeWxAgent:
  1028. ids := make([]ent.Value, 0, len(m.wx_agent))
  1029. for id := range m.wx_agent {
  1030. ids = append(ids, id)
  1031. }
  1032. return ids
  1033. }
  1034. return nil
  1035. }
  1036. // RemovedEdges returns all edge names that were removed in this mutation.
  1037. func (m *AgentMutation) RemovedEdges() []string {
  1038. edges := make([]string, 0, 1)
  1039. if m.removedwx_agent != nil {
  1040. edges = append(edges, agent.EdgeWxAgent)
  1041. }
  1042. return edges
  1043. }
  1044. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1045. // the given name in this mutation.
  1046. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1047. switch name {
  1048. case agent.EdgeWxAgent:
  1049. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1050. for id := range m.removedwx_agent {
  1051. ids = append(ids, id)
  1052. }
  1053. return ids
  1054. }
  1055. return nil
  1056. }
  1057. // ClearedEdges returns all edge names that were cleared in this mutation.
  1058. func (m *AgentMutation) ClearedEdges() []string {
  1059. edges := make([]string, 0, 1)
  1060. if m.clearedwx_agent {
  1061. edges = append(edges, agent.EdgeWxAgent)
  1062. }
  1063. return edges
  1064. }
  1065. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1066. // was cleared in this mutation.
  1067. func (m *AgentMutation) EdgeCleared(name string) bool {
  1068. switch name {
  1069. case agent.EdgeWxAgent:
  1070. return m.clearedwx_agent
  1071. }
  1072. return false
  1073. }
  1074. // ClearEdge clears the value of the edge with the given name. It returns an error
  1075. // if that edge is not defined in the schema.
  1076. func (m *AgentMutation) ClearEdge(name string) error {
  1077. switch name {
  1078. }
  1079. return fmt.Errorf("unknown Agent unique edge %s", name)
  1080. }
  1081. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1082. // It returns an error if the edge is not defined in the schema.
  1083. func (m *AgentMutation) ResetEdge(name string) error {
  1084. switch name {
  1085. case agent.EdgeWxAgent:
  1086. m.ResetWxAgent()
  1087. return nil
  1088. }
  1089. return fmt.Errorf("unknown Agent edge %s", name)
  1090. }
  1091. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1092. type AgentBaseMutation struct {
  1093. config
  1094. op Op
  1095. typ string
  1096. id *string
  1097. q *string
  1098. a *string
  1099. chunk_index *uint64
  1100. addchunk_index *int64
  1101. indexes *[]string
  1102. appendindexes []string
  1103. dataset_id *string
  1104. collection_id *string
  1105. source_name *string
  1106. can_write *[]bool
  1107. appendcan_write []bool
  1108. is_owner *[]bool
  1109. appendis_owner []bool
  1110. clearedFields map[string]struct{}
  1111. wx_agent map[uint64]struct{}
  1112. removedwx_agent map[uint64]struct{}
  1113. clearedwx_agent bool
  1114. done bool
  1115. oldValue func(context.Context) (*AgentBase, error)
  1116. predicates []predicate.AgentBase
  1117. }
  1118. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1119. // agentbaseOption allows management of the mutation configuration using functional options.
  1120. type agentbaseOption func(*AgentBaseMutation)
  1121. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1122. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1123. m := &AgentBaseMutation{
  1124. config: c,
  1125. op: op,
  1126. typ: TypeAgentBase,
  1127. clearedFields: make(map[string]struct{}),
  1128. }
  1129. for _, opt := range opts {
  1130. opt(m)
  1131. }
  1132. return m
  1133. }
  1134. // withAgentBaseID sets the ID field of the mutation.
  1135. func withAgentBaseID(id string) agentbaseOption {
  1136. return func(m *AgentBaseMutation) {
  1137. var (
  1138. err error
  1139. once sync.Once
  1140. value *AgentBase
  1141. )
  1142. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1143. once.Do(func() {
  1144. if m.done {
  1145. err = errors.New("querying old values post mutation is not allowed")
  1146. } else {
  1147. value, err = m.Client().AgentBase.Get(ctx, id)
  1148. }
  1149. })
  1150. return value, err
  1151. }
  1152. m.id = &id
  1153. }
  1154. }
  1155. // withAgentBase sets the old AgentBase of the mutation.
  1156. func withAgentBase(node *AgentBase) agentbaseOption {
  1157. return func(m *AgentBaseMutation) {
  1158. m.oldValue = func(context.Context) (*AgentBase, error) {
  1159. return node, nil
  1160. }
  1161. m.id = &node.ID
  1162. }
  1163. }
  1164. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1165. // executed in a transaction (ent.Tx), a transactional client is returned.
  1166. func (m AgentBaseMutation) Client() *Client {
  1167. client := &Client{config: m.config}
  1168. client.init()
  1169. return client
  1170. }
  1171. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1172. // it returns an error otherwise.
  1173. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1174. if _, ok := m.driver.(*txDriver); !ok {
  1175. return nil, errors.New("ent: mutation is not running in a transaction")
  1176. }
  1177. tx := &Tx{config: m.config}
  1178. tx.init()
  1179. return tx, nil
  1180. }
  1181. // SetID sets the value of the id field. Note that this
  1182. // operation is only accepted on creation of AgentBase entities.
  1183. func (m *AgentBaseMutation) SetID(id string) {
  1184. m.id = &id
  1185. }
  1186. // ID returns the ID value in the mutation. Note that the ID is only available
  1187. // if it was provided to the builder or after it was returned from the database.
  1188. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1189. if m.id == nil {
  1190. return
  1191. }
  1192. return *m.id, true
  1193. }
  1194. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1195. // That means, if the mutation is applied within a transaction with an isolation level such
  1196. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1197. // or updated by the mutation.
  1198. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1199. switch {
  1200. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1201. id, exists := m.ID()
  1202. if exists {
  1203. return []string{id}, nil
  1204. }
  1205. fallthrough
  1206. case m.op.Is(OpUpdate | OpDelete):
  1207. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1208. default:
  1209. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1210. }
  1211. }
  1212. // SetQ sets the "q" field.
  1213. func (m *AgentBaseMutation) SetQ(s string) {
  1214. m.q = &s
  1215. }
  1216. // Q returns the value of the "q" field in the mutation.
  1217. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1218. v := m.q
  1219. if v == nil {
  1220. return
  1221. }
  1222. return *v, true
  1223. }
  1224. // OldQ returns the old "q" field's value of the AgentBase entity.
  1225. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1227. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1228. if !m.op.Is(OpUpdateOne) {
  1229. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1230. }
  1231. if m.id == nil || m.oldValue == nil {
  1232. return v, errors.New("OldQ requires an ID field in the mutation")
  1233. }
  1234. oldValue, err := m.oldValue(ctx)
  1235. if err != nil {
  1236. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1237. }
  1238. return oldValue.Q, nil
  1239. }
  1240. // ClearQ clears the value of the "q" field.
  1241. func (m *AgentBaseMutation) ClearQ() {
  1242. m.q = nil
  1243. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1244. }
  1245. // QCleared returns if the "q" field was cleared in this mutation.
  1246. func (m *AgentBaseMutation) QCleared() bool {
  1247. _, ok := m.clearedFields[agentbase.FieldQ]
  1248. return ok
  1249. }
  1250. // ResetQ resets all changes to the "q" field.
  1251. func (m *AgentBaseMutation) ResetQ() {
  1252. m.q = nil
  1253. delete(m.clearedFields, agentbase.FieldQ)
  1254. }
  1255. // SetA sets the "a" field.
  1256. func (m *AgentBaseMutation) SetA(s string) {
  1257. m.a = &s
  1258. }
  1259. // A returns the value of the "a" field in the mutation.
  1260. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1261. v := m.a
  1262. if v == nil {
  1263. return
  1264. }
  1265. return *v, true
  1266. }
  1267. // OldA returns the old "a" field's value of the AgentBase entity.
  1268. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1270. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1271. if !m.op.Is(OpUpdateOne) {
  1272. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1273. }
  1274. if m.id == nil || m.oldValue == nil {
  1275. return v, errors.New("OldA requires an ID field in the mutation")
  1276. }
  1277. oldValue, err := m.oldValue(ctx)
  1278. if err != nil {
  1279. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1280. }
  1281. return oldValue.A, nil
  1282. }
  1283. // ClearA clears the value of the "a" field.
  1284. func (m *AgentBaseMutation) ClearA() {
  1285. m.a = nil
  1286. m.clearedFields[agentbase.FieldA] = struct{}{}
  1287. }
  1288. // ACleared returns if the "a" field was cleared in this mutation.
  1289. func (m *AgentBaseMutation) ACleared() bool {
  1290. _, ok := m.clearedFields[agentbase.FieldA]
  1291. return ok
  1292. }
  1293. // ResetA resets all changes to the "a" field.
  1294. func (m *AgentBaseMutation) ResetA() {
  1295. m.a = nil
  1296. delete(m.clearedFields, agentbase.FieldA)
  1297. }
  1298. // SetChunkIndex sets the "chunk_index" field.
  1299. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1300. m.chunk_index = &u
  1301. m.addchunk_index = nil
  1302. }
  1303. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1304. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1305. v := m.chunk_index
  1306. if v == nil {
  1307. return
  1308. }
  1309. return *v, true
  1310. }
  1311. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1312. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1314. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1315. if !m.op.Is(OpUpdateOne) {
  1316. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1317. }
  1318. if m.id == nil || m.oldValue == nil {
  1319. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1320. }
  1321. oldValue, err := m.oldValue(ctx)
  1322. if err != nil {
  1323. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1324. }
  1325. return oldValue.ChunkIndex, nil
  1326. }
  1327. // AddChunkIndex adds u to the "chunk_index" field.
  1328. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1329. if m.addchunk_index != nil {
  1330. *m.addchunk_index += u
  1331. } else {
  1332. m.addchunk_index = &u
  1333. }
  1334. }
  1335. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1336. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1337. v := m.addchunk_index
  1338. if v == nil {
  1339. return
  1340. }
  1341. return *v, true
  1342. }
  1343. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1344. func (m *AgentBaseMutation) ResetChunkIndex() {
  1345. m.chunk_index = nil
  1346. m.addchunk_index = nil
  1347. }
  1348. // SetIndexes sets the "indexes" field.
  1349. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1350. m.indexes = &s
  1351. m.appendindexes = nil
  1352. }
  1353. // Indexes returns the value of the "indexes" field in the mutation.
  1354. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1355. v := m.indexes
  1356. if v == nil {
  1357. return
  1358. }
  1359. return *v, true
  1360. }
  1361. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1362. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1364. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1365. if !m.op.Is(OpUpdateOne) {
  1366. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1367. }
  1368. if m.id == nil || m.oldValue == nil {
  1369. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1370. }
  1371. oldValue, err := m.oldValue(ctx)
  1372. if err != nil {
  1373. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1374. }
  1375. return oldValue.Indexes, nil
  1376. }
  1377. // AppendIndexes adds s to the "indexes" field.
  1378. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1379. m.appendindexes = append(m.appendindexes, s...)
  1380. }
  1381. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1382. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1383. if len(m.appendindexes) == 0 {
  1384. return nil, false
  1385. }
  1386. return m.appendindexes, true
  1387. }
  1388. // ClearIndexes clears the value of the "indexes" field.
  1389. func (m *AgentBaseMutation) ClearIndexes() {
  1390. m.indexes = nil
  1391. m.appendindexes = nil
  1392. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1393. }
  1394. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1395. func (m *AgentBaseMutation) IndexesCleared() bool {
  1396. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1397. return ok
  1398. }
  1399. // ResetIndexes resets all changes to the "indexes" field.
  1400. func (m *AgentBaseMutation) ResetIndexes() {
  1401. m.indexes = nil
  1402. m.appendindexes = nil
  1403. delete(m.clearedFields, agentbase.FieldIndexes)
  1404. }
  1405. // SetDatasetID sets the "dataset_id" field.
  1406. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1407. m.dataset_id = &s
  1408. }
  1409. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1410. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1411. v := m.dataset_id
  1412. if v == nil {
  1413. return
  1414. }
  1415. return *v, true
  1416. }
  1417. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1418. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1420. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1421. if !m.op.Is(OpUpdateOne) {
  1422. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1423. }
  1424. if m.id == nil || m.oldValue == nil {
  1425. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1426. }
  1427. oldValue, err := m.oldValue(ctx)
  1428. if err != nil {
  1429. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1430. }
  1431. return oldValue.DatasetID, nil
  1432. }
  1433. // ClearDatasetID clears the value of the "dataset_id" field.
  1434. func (m *AgentBaseMutation) ClearDatasetID() {
  1435. m.dataset_id = nil
  1436. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1437. }
  1438. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1439. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1440. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1441. return ok
  1442. }
  1443. // ResetDatasetID resets all changes to the "dataset_id" field.
  1444. func (m *AgentBaseMutation) ResetDatasetID() {
  1445. m.dataset_id = nil
  1446. delete(m.clearedFields, agentbase.FieldDatasetID)
  1447. }
  1448. // SetCollectionID sets the "collection_id" field.
  1449. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1450. m.collection_id = &s
  1451. }
  1452. // CollectionID returns the value of the "collection_id" field in the mutation.
  1453. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1454. v := m.collection_id
  1455. if v == nil {
  1456. return
  1457. }
  1458. return *v, true
  1459. }
  1460. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1461. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1463. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1464. if !m.op.Is(OpUpdateOne) {
  1465. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1466. }
  1467. if m.id == nil || m.oldValue == nil {
  1468. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1469. }
  1470. oldValue, err := m.oldValue(ctx)
  1471. if err != nil {
  1472. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1473. }
  1474. return oldValue.CollectionID, nil
  1475. }
  1476. // ClearCollectionID clears the value of the "collection_id" field.
  1477. func (m *AgentBaseMutation) ClearCollectionID() {
  1478. m.collection_id = nil
  1479. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1480. }
  1481. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1482. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1483. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1484. return ok
  1485. }
  1486. // ResetCollectionID resets all changes to the "collection_id" field.
  1487. func (m *AgentBaseMutation) ResetCollectionID() {
  1488. m.collection_id = nil
  1489. delete(m.clearedFields, agentbase.FieldCollectionID)
  1490. }
  1491. // SetSourceName sets the "source_name" field.
  1492. func (m *AgentBaseMutation) SetSourceName(s string) {
  1493. m.source_name = &s
  1494. }
  1495. // SourceName returns the value of the "source_name" field in the mutation.
  1496. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1497. v := m.source_name
  1498. if v == nil {
  1499. return
  1500. }
  1501. return *v, true
  1502. }
  1503. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1504. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1506. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1507. if !m.op.Is(OpUpdateOne) {
  1508. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1509. }
  1510. if m.id == nil || m.oldValue == nil {
  1511. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1512. }
  1513. oldValue, err := m.oldValue(ctx)
  1514. if err != nil {
  1515. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1516. }
  1517. return oldValue.SourceName, nil
  1518. }
  1519. // ClearSourceName clears the value of the "source_name" field.
  1520. func (m *AgentBaseMutation) ClearSourceName() {
  1521. m.source_name = nil
  1522. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1523. }
  1524. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1525. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1526. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1527. return ok
  1528. }
  1529. // ResetSourceName resets all changes to the "source_name" field.
  1530. func (m *AgentBaseMutation) ResetSourceName() {
  1531. m.source_name = nil
  1532. delete(m.clearedFields, agentbase.FieldSourceName)
  1533. }
  1534. // SetCanWrite sets the "can_write" field.
  1535. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1536. m.can_write = &b
  1537. m.appendcan_write = nil
  1538. }
  1539. // CanWrite returns the value of the "can_write" field in the mutation.
  1540. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1541. v := m.can_write
  1542. if v == nil {
  1543. return
  1544. }
  1545. return *v, true
  1546. }
  1547. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1548. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1550. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1551. if !m.op.Is(OpUpdateOne) {
  1552. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1553. }
  1554. if m.id == nil || m.oldValue == nil {
  1555. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1556. }
  1557. oldValue, err := m.oldValue(ctx)
  1558. if err != nil {
  1559. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1560. }
  1561. return oldValue.CanWrite, nil
  1562. }
  1563. // AppendCanWrite adds b to the "can_write" field.
  1564. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1565. m.appendcan_write = append(m.appendcan_write, b...)
  1566. }
  1567. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1568. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1569. if len(m.appendcan_write) == 0 {
  1570. return nil, false
  1571. }
  1572. return m.appendcan_write, true
  1573. }
  1574. // ClearCanWrite clears the value of the "can_write" field.
  1575. func (m *AgentBaseMutation) ClearCanWrite() {
  1576. m.can_write = nil
  1577. m.appendcan_write = nil
  1578. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1579. }
  1580. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1581. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1582. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1583. return ok
  1584. }
  1585. // ResetCanWrite resets all changes to the "can_write" field.
  1586. func (m *AgentBaseMutation) ResetCanWrite() {
  1587. m.can_write = nil
  1588. m.appendcan_write = nil
  1589. delete(m.clearedFields, agentbase.FieldCanWrite)
  1590. }
  1591. // SetIsOwner sets the "is_owner" field.
  1592. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1593. m.is_owner = &b
  1594. m.appendis_owner = nil
  1595. }
  1596. // IsOwner returns the value of the "is_owner" field in the mutation.
  1597. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1598. v := m.is_owner
  1599. if v == nil {
  1600. return
  1601. }
  1602. return *v, true
  1603. }
  1604. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1605. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1607. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1608. if !m.op.Is(OpUpdateOne) {
  1609. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1610. }
  1611. if m.id == nil || m.oldValue == nil {
  1612. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1613. }
  1614. oldValue, err := m.oldValue(ctx)
  1615. if err != nil {
  1616. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1617. }
  1618. return oldValue.IsOwner, nil
  1619. }
  1620. // AppendIsOwner adds b to the "is_owner" field.
  1621. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1622. m.appendis_owner = append(m.appendis_owner, b...)
  1623. }
  1624. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1625. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1626. if len(m.appendis_owner) == 0 {
  1627. return nil, false
  1628. }
  1629. return m.appendis_owner, true
  1630. }
  1631. // ClearIsOwner clears the value of the "is_owner" field.
  1632. func (m *AgentBaseMutation) ClearIsOwner() {
  1633. m.is_owner = nil
  1634. m.appendis_owner = nil
  1635. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1636. }
  1637. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1638. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1639. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1640. return ok
  1641. }
  1642. // ResetIsOwner resets all changes to the "is_owner" field.
  1643. func (m *AgentBaseMutation) ResetIsOwner() {
  1644. m.is_owner = nil
  1645. m.appendis_owner = nil
  1646. delete(m.clearedFields, agentbase.FieldIsOwner)
  1647. }
  1648. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1649. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1650. if m.wx_agent == nil {
  1651. m.wx_agent = make(map[uint64]struct{})
  1652. }
  1653. for i := range ids {
  1654. m.wx_agent[ids[i]] = struct{}{}
  1655. }
  1656. }
  1657. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1658. func (m *AgentBaseMutation) ClearWxAgent() {
  1659. m.clearedwx_agent = true
  1660. }
  1661. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1662. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1663. return m.clearedwx_agent
  1664. }
  1665. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1666. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1667. if m.removedwx_agent == nil {
  1668. m.removedwx_agent = make(map[uint64]struct{})
  1669. }
  1670. for i := range ids {
  1671. delete(m.wx_agent, ids[i])
  1672. m.removedwx_agent[ids[i]] = struct{}{}
  1673. }
  1674. }
  1675. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1676. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1677. for id := range m.removedwx_agent {
  1678. ids = append(ids, id)
  1679. }
  1680. return
  1681. }
  1682. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1683. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1684. for id := range m.wx_agent {
  1685. ids = append(ids, id)
  1686. }
  1687. return
  1688. }
  1689. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1690. func (m *AgentBaseMutation) ResetWxAgent() {
  1691. m.wx_agent = nil
  1692. m.clearedwx_agent = false
  1693. m.removedwx_agent = nil
  1694. }
  1695. // Where appends a list predicates to the AgentBaseMutation builder.
  1696. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1697. m.predicates = append(m.predicates, ps...)
  1698. }
  1699. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1700. // users can use type-assertion to append predicates that do not depend on any generated package.
  1701. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1702. p := make([]predicate.AgentBase, len(ps))
  1703. for i := range ps {
  1704. p[i] = ps[i]
  1705. }
  1706. m.Where(p...)
  1707. }
  1708. // Op returns the operation name.
  1709. func (m *AgentBaseMutation) Op() Op {
  1710. return m.op
  1711. }
  1712. // SetOp allows setting the mutation operation.
  1713. func (m *AgentBaseMutation) SetOp(op Op) {
  1714. m.op = op
  1715. }
  1716. // Type returns the node type of this mutation (AgentBase).
  1717. func (m *AgentBaseMutation) Type() string {
  1718. return m.typ
  1719. }
  1720. // Fields returns all fields that were changed during this mutation. Note that in
  1721. // order to get all numeric fields that were incremented/decremented, call
  1722. // AddedFields().
  1723. func (m *AgentBaseMutation) Fields() []string {
  1724. fields := make([]string, 0, 9)
  1725. if m.q != nil {
  1726. fields = append(fields, agentbase.FieldQ)
  1727. }
  1728. if m.a != nil {
  1729. fields = append(fields, agentbase.FieldA)
  1730. }
  1731. if m.chunk_index != nil {
  1732. fields = append(fields, agentbase.FieldChunkIndex)
  1733. }
  1734. if m.indexes != nil {
  1735. fields = append(fields, agentbase.FieldIndexes)
  1736. }
  1737. if m.dataset_id != nil {
  1738. fields = append(fields, agentbase.FieldDatasetID)
  1739. }
  1740. if m.collection_id != nil {
  1741. fields = append(fields, agentbase.FieldCollectionID)
  1742. }
  1743. if m.source_name != nil {
  1744. fields = append(fields, agentbase.FieldSourceName)
  1745. }
  1746. if m.can_write != nil {
  1747. fields = append(fields, agentbase.FieldCanWrite)
  1748. }
  1749. if m.is_owner != nil {
  1750. fields = append(fields, agentbase.FieldIsOwner)
  1751. }
  1752. return fields
  1753. }
  1754. // Field returns the value of a field with the given name. The second boolean
  1755. // return value indicates that this field was not set, or was not defined in the
  1756. // schema.
  1757. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1758. switch name {
  1759. case agentbase.FieldQ:
  1760. return m.Q()
  1761. case agentbase.FieldA:
  1762. return m.A()
  1763. case agentbase.FieldChunkIndex:
  1764. return m.ChunkIndex()
  1765. case agentbase.FieldIndexes:
  1766. return m.Indexes()
  1767. case agentbase.FieldDatasetID:
  1768. return m.DatasetID()
  1769. case agentbase.FieldCollectionID:
  1770. return m.CollectionID()
  1771. case agentbase.FieldSourceName:
  1772. return m.SourceName()
  1773. case agentbase.FieldCanWrite:
  1774. return m.CanWrite()
  1775. case agentbase.FieldIsOwner:
  1776. return m.IsOwner()
  1777. }
  1778. return nil, false
  1779. }
  1780. // OldField returns the old value of the field from the database. An error is
  1781. // returned if the mutation operation is not UpdateOne, or the query to the
  1782. // database failed.
  1783. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1784. switch name {
  1785. case agentbase.FieldQ:
  1786. return m.OldQ(ctx)
  1787. case agentbase.FieldA:
  1788. return m.OldA(ctx)
  1789. case agentbase.FieldChunkIndex:
  1790. return m.OldChunkIndex(ctx)
  1791. case agentbase.FieldIndexes:
  1792. return m.OldIndexes(ctx)
  1793. case agentbase.FieldDatasetID:
  1794. return m.OldDatasetID(ctx)
  1795. case agentbase.FieldCollectionID:
  1796. return m.OldCollectionID(ctx)
  1797. case agentbase.FieldSourceName:
  1798. return m.OldSourceName(ctx)
  1799. case agentbase.FieldCanWrite:
  1800. return m.OldCanWrite(ctx)
  1801. case agentbase.FieldIsOwner:
  1802. return m.OldIsOwner(ctx)
  1803. }
  1804. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1805. }
  1806. // SetField sets the value of a field with the given name. It returns an error if
  1807. // the field is not defined in the schema, or if the type mismatched the field
  1808. // type.
  1809. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1810. switch name {
  1811. case agentbase.FieldQ:
  1812. v, ok := value.(string)
  1813. if !ok {
  1814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1815. }
  1816. m.SetQ(v)
  1817. return nil
  1818. case agentbase.FieldA:
  1819. v, ok := value.(string)
  1820. if !ok {
  1821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1822. }
  1823. m.SetA(v)
  1824. return nil
  1825. case agentbase.FieldChunkIndex:
  1826. v, ok := value.(uint64)
  1827. if !ok {
  1828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1829. }
  1830. m.SetChunkIndex(v)
  1831. return nil
  1832. case agentbase.FieldIndexes:
  1833. v, ok := value.([]string)
  1834. if !ok {
  1835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1836. }
  1837. m.SetIndexes(v)
  1838. return nil
  1839. case agentbase.FieldDatasetID:
  1840. v, ok := value.(string)
  1841. if !ok {
  1842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1843. }
  1844. m.SetDatasetID(v)
  1845. return nil
  1846. case agentbase.FieldCollectionID:
  1847. v, ok := value.(string)
  1848. if !ok {
  1849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1850. }
  1851. m.SetCollectionID(v)
  1852. return nil
  1853. case agentbase.FieldSourceName:
  1854. v, ok := value.(string)
  1855. if !ok {
  1856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1857. }
  1858. m.SetSourceName(v)
  1859. return nil
  1860. case agentbase.FieldCanWrite:
  1861. v, ok := value.([]bool)
  1862. if !ok {
  1863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1864. }
  1865. m.SetCanWrite(v)
  1866. return nil
  1867. case agentbase.FieldIsOwner:
  1868. v, ok := value.([]bool)
  1869. if !ok {
  1870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1871. }
  1872. m.SetIsOwner(v)
  1873. return nil
  1874. }
  1875. return fmt.Errorf("unknown AgentBase field %s", name)
  1876. }
  1877. // AddedFields returns all numeric fields that were incremented/decremented during
  1878. // this mutation.
  1879. func (m *AgentBaseMutation) AddedFields() []string {
  1880. var fields []string
  1881. if m.addchunk_index != nil {
  1882. fields = append(fields, agentbase.FieldChunkIndex)
  1883. }
  1884. return fields
  1885. }
  1886. // AddedField returns the numeric value that was incremented/decremented on a field
  1887. // with the given name. The second boolean return value indicates that this field
  1888. // was not set, or was not defined in the schema.
  1889. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1890. switch name {
  1891. case agentbase.FieldChunkIndex:
  1892. return m.AddedChunkIndex()
  1893. }
  1894. return nil, false
  1895. }
  1896. // AddField adds the value to the field with the given name. It returns an error if
  1897. // the field is not defined in the schema, or if the type mismatched the field
  1898. // type.
  1899. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1900. switch name {
  1901. case agentbase.FieldChunkIndex:
  1902. v, ok := value.(int64)
  1903. if !ok {
  1904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1905. }
  1906. m.AddChunkIndex(v)
  1907. return nil
  1908. }
  1909. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1910. }
  1911. // ClearedFields returns all nullable fields that were cleared during this
  1912. // mutation.
  1913. func (m *AgentBaseMutation) ClearedFields() []string {
  1914. var fields []string
  1915. if m.FieldCleared(agentbase.FieldQ) {
  1916. fields = append(fields, agentbase.FieldQ)
  1917. }
  1918. if m.FieldCleared(agentbase.FieldA) {
  1919. fields = append(fields, agentbase.FieldA)
  1920. }
  1921. if m.FieldCleared(agentbase.FieldIndexes) {
  1922. fields = append(fields, agentbase.FieldIndexes)
  1923. }
  1924. if m.FieldCleared(agentbase.FieldDatasetID) {
  1925. fields = append(fields, agentbase.FieldDatasetID)
  1926. }
  1927. if m.FieldCleared(agentbase.FieldCollectionID) {
  1928. fields = append(fields, agentbase.FieldCollectionID)
  1929. }
  1930. if m.FieldCleared(agentbase.FieldSourceName) {
  1931. fields = append(fields, agentbase.FieldSourceName)
  1932. }
  1933. if m.FieldCleared(agentbase.FieldCanWrite) {
  1934. fields = append(fields, agentbase.FieldCanWrite)
  1935. }
  1936. if m.FieldCleared(agentbase.FieldIsOwner) {
  1937. fields = append(fields, agentbase.FieldIsOwner)
  1938. }
  1939. return fields
  1940. }
  1941. // FieldCleared returns a boolean indicating if a field with the given name was
  1942. // cleared in this mutation.
  1943. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  1944. _, ok := m.clearedFields[name]
  1945. return ok
  1946. }
  1947. // ClearField clears the value of the field with the given name. It returns an
  1948. // error if the field is not defined in the schema.
  1949. func (m *AgentBaseMutation) ClearField(name string) error {
  1950. switch name {
  1951. case agentbase.FieldQ:
  1952. m.ClearQ()
  1953. return nil
  1954. case agentbase.FieldA:
  1955. m.ClearA()
  1956. return nil
  1957. case agentbase.FieldIndexes:
  1958. m.ClearIndexes()
  1959. return nil
  1960. case agentbase.FieldDatasetID:
  1961. m.ClearDatasetID()
  1962. return nil
  1963. case agentbase.FieldCollectionID:
  1964. m.ClearCollectionID()
  1965. return nil
  1966. case agentbase.FieldSourceName:
  1967. m.ClearSourceName()
  1968. return nil
  1969. case agentbase.FieldCanWrite:
  1970. m.ClearCanWrite()
  1971. return nil
  1972. case agentbase.FieldIsOwner:
  1973. m.ClearIsOwner()
  1974. return nil
  1975. }
  1976. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  1977. }
  1978. // ResetField resets all changes in the mutation for the field with the given name.
  1979. // It returns an error if the field is not defined in the schema.
  1980. func (m *AgentBaseMutation) ResetField(name string) error {
  1981. switch name {
  1982. case agentbase.FieldQ:
  1983. m.ResetQ()
  1984. return nil
  1985. case agentbase.FieldA:
  1986. m.ResetA()
  1987. return nil
  1988. case agentbase.FieldChunkIndex:
  1989. m.ResetChunkIndex()
  1990. return nil
  1991. case agentbase.FieldIndexes:
  1992. m.ResetIndexes()
  1993. return nil
  1994. case agentbase.FieldDatasetID:
  1995. m.ResetDatasetID()
  1996. return nil
  1997. case agentbase.FieldCollectionID:
  1998. m.ResetCollectionID()
  1999. return nil
  2000. case agentbase.FieldSourceName:
  2001. m.ResetSourceName()
  2002. return nil
  2003. case agentbase.FieldCanWrite:
  2004. m.ResetCanWrite()
  2005. return nil
  2006. case agentbase.FieldIsOwner:
  2007. m.ResetIsOwner()
  2008. return nil
  2009. }
  2010. return fmt.Errorf("unknown AgentBase field %s", name)
  2011. }
  2012. // AddedEdges returns all edge names that were set/added in this mutation.
  2013. func (m *AgentBaseMutation) AddedEdges() []string {
  2014. edges := make([]string, 0, 1)
  2015. if m.wx_agent != nil {
  2016. edges = append(edges, agentbase.EdgeWxAgent)
  2017. }
  2018. return edges
  2019. }
  2020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2021. // name in this mutation.
  2022. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2023. switch name {
  2024. case agentbase.EdgeWxAgent:
  2025. ids := make([]ent.Value, 0, len(m.wx_agent))
  2026. for id := range m.wx_agent {
  2027. ids = append(ids, id)
  2028. }
  2029. return ids
  2030. }
  2031. return nil
  2032. }
  2033. // RemovedEdges returns all edge names that were removed in this mutation.
  2034. func (m *AgentBaseMutation) RemovedEdges() []string {
  2035. edges := make([]string, 0, 1)
  2036. if m.removedwx_agent != nil {
  2037. edges = append(edges, agentbase.EdgeWxAgent)
  2038. }
  2039. return edges
  2040. }
  2041. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2042. // the given name in this mutation.
  2043. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2044. switch name {
  2045. case agentbase.EdgeWxAgent:
  2046. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2047. for id := range m.removedwx_agent {
  2048. ids = append(ids, id)
  2049. }
  2050. return ids
  2051. }
  2052. return nil
  2053. }
  2054. // ClearedEdges returns all edge names that were cleared in this mutation.
  2055. func (m *AgentBaseMutation) ClearedEdges() []string {
  2056. edges := make([]string, 0, 1)
  2057. if m.clearedwx_agent {
  2058. edges = append(edges, agentbase.EdgeWxAgent)
  2059. }
  2060. return edges
  2061. }
  2062. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2063. // was cleared in this mutation.
  2064. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2065. switch name {
  2066. case agentbase.EdgeWxAgent:
  2067. return m.clearedwx_agent
  2068. }
  2069. return false
  2070. }
  2071. // ClearEdge clears the value of the edge with the given name. It returns an error
  2072. // if that edge is not defined in the schema.
  2073. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2074. switch name {
  2075. }
  2076. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2077. }
  2078. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2079. // It returns an error if the edge is not defined in the schema.
  2080. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2081. switch name {
  2082. case agentbase.EdgeWxAgent:
  2083. m.ResetWxAgent()
  2084. return nil
  2085. }
  2086. return fmt.Errorf("unknown AgentBase edge %s", name)
  2087. }
  2088. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2089. type AliyunAvatarMutation struct {
  2090. config
  2091. op Op
  2092. typ string
  2093. id *uint64
  2094. created_at *time.Time
  2095. updated_at *time.Time
  2096. deleted_at *time.Time
  2097. user_id *uint64
  2098. adduser_id *int64
  2099. biz_id *string
  2100. access_key_id *string
  2101. access_key_secret *string
  2102. app_id *string
  2103. tenant_id *uint64
  2104. addtenant_id *int64
  2105. response *string
  2106. token *string
  2107. session_id *string
  2108. clearedFields map[string]struct{}
  2109. done bool
  2110. oldValue func(context.Context) (*AliyunAvatar, error)
  2111. predicates []predicate.AliyunAvatar
  2112. }
  2113. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2114. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2115. type aliyunavatarOption func(*AliyunAvatarMutation)
  2116. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2117. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2118. m := &AliyunAvatarMutation{
  2119. config: c,
  2120. op: op,
  2121. typ: TypeAliyunAvatar,
  2122. clearedFields: make(map[string]struct{}),
  2123. }
  2124. for _, opt := range opts {
  2125. opt(m)
  2126. }
  2127. return m
  2128. }
  2129. // withAliyunAvatarID sets the ID field of the mutation.
  2130. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2131. return func(m *AliyunAvatarMutation) {
  2132. var (
  2133. err error
  2134. once sync.Once
  2135. value *AliyunAvatar
  2136. )
  2137. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2138. once.Do(func() {
  2139. if m.done {
  2140. err = errors.New("querying old values post mutation is not allowed")
  2141. } else {
  2142. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2143. }
  2144. })
  2145. return value, err
  2146. }
  2147. m.id = &id
  2148. }
  2149. }
  2150. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2151. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2152. return func(m *AliyunAvatarMutation) {
  2153. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2154. return node, nil
  2155. }
  2156. m.id = &node.ID
  2157. }
  2158. }
  2159. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2160. // executed in a transaction (ent.Tx), a transactional client is returned.
  2161. func (m AliyunAvatarMutation) Client() *Client {
  2162. client := &Client{config: m.config}
  2163. client.init()
  2164. return client
  2165. }
  2166. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2167. // it returns an error otherwise.
  2168. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2169. if _, ok := m.driver.(*txDriver); !ok {
  2170. return nil, errors.New("ent: mutation is not running in a transaction")
  2171. }
  2172. tx := &Tx{config: m.config}
  2173. tx.init()
  2174. return tx, nil
  2175. }
  2176. // SetID sets the value of the id field. Note that this
  2177. // operation is only accepted on creation of AliyunAvatar entities.
  2178. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2179. m.id = &id
  2180. }
  2181. // ID returns the ID value in the mutation. Note that the ID is only available
  2182. // if it was provided to the builder or after it was returned from the database.
  2183. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2184. if m.id == nil {
  2185. return
  2186. }
  2187. return *m.id, true
  2188. }
  2189. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2190. // That means, if the mutation is applied within a transaction with an isolation level such
  2191. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2192. // or updated by the mutation.
  2193. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2194. switch {
  2195. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2196. id, exists := m.ID()
  2197. if exists {
  2198. return []uint64{id}, nil
  2199. }
  2200. fallthrough
  2201. case m.op.Is(OpUpdate | OpDelete):
  2202. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2203. default:
  2204. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2205. }
  2206. }
  2207. // SetCreatedAt sets the "created_at" field.
  2208. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2209. m.created_at = &t
  2210. }
  2211. // CreatedAt returns the value of the "created_at" field in the mutation.
  2212. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2213. v := m.created_at
  2214. if v == nil {
  2215. return
  2216. }
  2217. return *v, true
  2218. }
  2219. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2220. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2222. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2223. if !m.op.Is(OpUpdateOne) {
  2224. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2225. }
  2226. if m.id == nil || m.oldValue == nil {
  2227. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2228. }
  2229. oldValue, err := m.oldValue(ctx)
  2230. if err != nil {
  2231. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2232. }
  2233. return oldValue.CreatedAt, nil
  2234. }
  2235. // ResetCreatedAt resets all changes to the "created_at" field.
  2236. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2237. m.created_at = nil
  2238. }
  2239. // SetUpdatedAt sets the "updated_at" field.
  2240. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2241. m.updated_at = &t
  2242. }
  2243. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2244. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2245. v := m.updated_at
  2246. if v == nil {
  2247. return
  2248. }
  2249. return *v, true
  2250. }
  2251. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2252. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2254. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2255. if !m.op.Is(OpUpdateOne) {
  2256. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2257. }
  2258. if m.id == nil || m.oldValue == nil {
  2259. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2260. }
  2261. oldValue, err := m.oldValue(ctx)
  2262. if err != nil {
  2263. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2264. }
  2265. return oldValue.UpdatedAt, nil
  2266. }
  2267. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2268. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2269. m.updated_at = nil
  2270. }
  2271. // SetDeletedAt sets the "deleted_at" field.
  2272. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2273. m.deleted_at = &t
  2274. }
  2275. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2276. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2277. v := m.deleted_at
  2278. if v == nil {
  2279. return
  2280. }
  2281. return *v, true
  2282. }
  2283. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2284. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2286. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2287. if !m.op.Is(OpUpdateOne) {
  2288. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2289. }
  2290. if m.id == nil || m.oldValue == nil {
  2291. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2292. }
  2293. oldValue, err := m.oldValue(ctx)
  2294. if err != nil {
  2295. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2296. }
  2297. return oldValue.DeletedAt, nil
  2298. }
  2299. // ClearDeletedAt clears the value of the "deleted_at" field.
  2300. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2301. m.deleted_at = nil
  2302. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2303. }
  2304. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2305. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2306. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2307. return ok
  2308. }
  2309. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2310. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2311. m.deleted_at = nil
  2312. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2313. }
  2314. // SetUserID sets the "user_id" field.
  2315. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2316. m.user_id = &u
  2317. m.adduser_id = nil
  2318. }
  2319. // UserID returns the value of the "user_id" field in the mutation.
  2320. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2321. v := m.user_id
  2322. if v == nil {
  2323. return
  2324. }
  2325. return *v, true
  2326. }
  2327. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2328. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2330. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2331. if !m.op.Is(OpUpdateOne) {
  2332. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2333. }
  2334. if m.id == nil || m.oldValue == nil {
  2335. return v, errors.New("OldUserID requires an ID field in the mutation")
  2336. }
  2337. oldValue, err := m.oldValue(ctx)
  2338. if err != nil {
  2339. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2340. }
  2341. return oldValue.UserID, nil
  2342. }
  2343. // AddUserID adds u to the "user_id" field.
  2344. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2345. if m.adduser_id != nil {
  2346. *m.adduser_id += u
  2347. } else {
  2348. m.adduser_id = &u
  2349. }
  2350. }
  2351. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2352. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2353. v := m.adduser_id
  2354. if v == nil {
  2355. return
  2356. }
  2357. return *v, true
  2358. }
  2359. // ResetUserID resets all changes to the "user_id" field.
  2360. func (m *AliyunAvatarMutation) ResetUserID() {
  2361. m.user_id = nil
  2362. m.adduser_id = nil
  2363. }
  2364. // SetBizID sets the "biz_id" field.
  2365. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2366. m.biz_id = &s
  2367. }
  2368. // BizID returns the value of the "biz_id" field in the mutation.
  2369. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2370. v := m.biz_id
  2371. if v == nil {
  2372. return
  2373. }
  2374. return *v, true
  2375. }
  2376. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2377. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2379. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2380. if !m.op.Is(OpUpdateOne) {
  2381. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2382. }
  2383. if m.id == nil || m.oldValue == nil {
  2384. return v, errors.New("OldBizID requires an ID field in the mutation")
  2385. }
  2386. oldValue, err := m.oldValue(ctx)
  2387. if err != nil {
  2388. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2389. }
  2390. return oldValue.BizID, nil
  2391. }
  2392. // ResetBizID resets all changes to the "biz_id" field.
  2393. func (m *AliyunAvatarMutation) ResetBizID() {
  2394. m.biz_id = nil
  2395. }
  2396. // SetAccessKeyID sets the "access_key_id" field.
  2397. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2398. m.access_key_id = &s
  2399. }
  2400. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2401. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2402. v := m.access_key_id
  2403. if v == nil {
  2404. return
  2405. }
  2406. return *v, true
  2407. }
  2408. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2409. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2411. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2412. if !m.op.Is(OpUpdateOne) {
  2413. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2414. }
  2415. if m.id == nil || m.oldValue == nil {
  2416. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2417. }
  2418. oldValue, err := m.oldValue(ctx)
  2419. if err != nil {
  2420. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2421. }
  2422. return oldValue.AccessKeyID, nil
  2423. }
  2424. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2425. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2426. m.access_key_id = nil
  2427. }
  2428. // SetAccessKeySecret sets the "access_key_secret" field.
  2429. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2430. m.access_key_secret = &s
  2431. }
  2432. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2433. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2434. v := m.access_key_secret
  2435. if v == nil {
  2436. return
  2437. }
  2438. return *v, true
  2439. }
  2440. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2441. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2443. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2444. if !m.op.Is(OpUpdateOne) {
  2445. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2446. }
  2447. if m.id == nil || m.oldValue == nil {
  2448. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2449. }
  2450. oldValue, err := m.oldValue(ctx)
  2451. if err != nil {
  2452. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2453. }
  2454. return oldValue.AccessKeySecret, nil
  2455. }
  2456. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2457. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2458. m.access_key_secret = nil
  2459. }
  2460. // SetAppID sets the "app_id" field.
  2461. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2462. m.app_id = &s
  2463. }
  2464. // AppID returns the value of the "app_id" field in the mutation.
  2465. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2466. v := m.app_id
  2467. if v == nil {
  2468. return
  2469. }
  2470. return *v, true
  2471. }
  2472. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2473. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2475. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2476. if !m.op.Is(OpUpdateOne) {
  2477. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2478. }
  2479. if m.id == nil || m.oldValue == nil {
  2480. return v, errors.New("OldAppID requires an ID field in the mutation")
  2481. }
  2482. oldValue, err := m.oldValue(ctx)
  2483. if err != nil {
  2484. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2485. }
  2486. return oldValue.AppID, nil
  2487. }
  2488. // ClearAppID clears the value of the "app_id" field.
  2489. func (m *AliyunAvatarMutation) ClearAppID() {
  2490. m.app_id = nil
  2491. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2492. }
  2493. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2494. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2495. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2496. return ok
  2497. }
  2498. // ResetAppID resets all changes to the "app_id" field.
  2499. func (m *AliyunAvatarMutation) ResetAppID() {
  2500. m.app_id = nil
  2501. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2502. }
  2503. // SetTenantID sets the "tenant_id" field.
  2504. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2505. m.tenant_id = &u
  2506. m.addtenant_id = nil
  2507. }
  2508. // TenantID returns the value of the "tenant_id" field in the mutation.
  2509. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2510. v := m.tenant_id
  2511. if v == nil {
  2512. return
  2513. }
  2514. return *v, true
  2515. }
  2516. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2517. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2519. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2520. if !m.op.Is(OpUpdateOne) {
  2521. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2522. }
  2523. if m.id == nil || m.oldValue == nil {
  2524. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2525. }
  2526. oldValue, err := m.oldValue(ctx)
  2527. if err != nil {
  2528. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2529. }
  2530. return oldValue.TenantID, nil
  2531. }
  2532. // AddTenantID adds u to the "tenant_id" field.
  2533. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2534. if m.addtenant_id != nil {
  2535. *m.addtenant_id += u
  2536. } else {
  2537. m.addtenant_id = &u
  2538. }
  2539. }
  2540. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2541. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2542. v := m.addtenant_id
  2543. if v == nil {
  2544. return
  2545. }
  2546. return *v, true
  2547. }
  2548. // ResetTenantID resets all changes to the "tenant_id" field.
  2549. func (m *AliyunAvatarMutation) ResetTenantID() {
  2550. m.tenant_id = nil
  2551. m.addtenant_id = nil
  2552. }
  2553. // SetResponse sets the "response" field.
  2554. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2555. m.response = &s
  2556. }
  2557. // Response returns the value of the "response" field in the mutation.
  2558. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2559. v := m.response
  2560. if v == nil {
  2561. return
  2562. }
  2563. return *v, true
  2564. }
  2565. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2566. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2568. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2569. if !m.op.Is(OpUpdateOne) {
  2570. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2571. }
  2572. if m.id == nil || m.oldValue == nil {
  2573. return v, errors.New("OldResponse requires an ID field in the mutation")
  2574. }
  2575. oldValue, err := m.oldValue(ctx)
  2576. if err != nil {
  2577. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2578. }
  2579. return oldValue.Response, nil
  2580. }
  2581. // ResetResponse resets all changes to the "response" field.
  2582. func (m *AliyunAvatarMutation) ResetResponse() {
  2583. m.response = nil
  2584. }
  2585. // SetToken sets the "token" field.
  2586. func (m *AliyunAvatarMutation) SetToken(s string) {
  2587. m.token = &s
  2588. }
  2589. // Token returns the value of the "token" field in the mutation.
  2590. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2591. v := m.token
  2592. if v == nil {
  2593. return
  2594. }
  2595. return *v, true
  2596. }
  2597. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2598. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2600. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2601. if !m.op.Is(OpUpdateOne) {
  2602. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2603. }
  2604. if m.id == nil || m.oldValue == nil {
  2605. return v, errors.New("OldToken requires an ID field in the mutation")
  2606. }
  2607. oldValue, err := m.oldValue(ctx)
  2608. if err != nil {
  2609. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2610. }
  2611. return oldValue.Token, nil
  2612. }
  2613. // ResetToken resets all changes to the "token" field.
  2614. func (m *AliyunAvatarMutation) ResetToken() {
  2615. m.token = nil
  2616. }
  2617. // SetSessionID sets the "session_id" field.
  2618. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2619. m.session_id = &s
  2620. }
  2621. // SessionID returns the value of the "session_id" field in the mutation.
  2622. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2623. v := m.session_id
  2624. if v == nil {
  2625. return
  2626. }
  2627. return *v, true
  2628. }
  2629. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2630. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2632. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2633. if !m.op.Is(OpUpdateOne) {
  2634. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2635. }
  2636. if m.id == nil || m.oldValue == nil {
  2637. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2638. }
  2639. oldValue, err := m.oldValue(ctx)
  2640. if err != nil {
  2641. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2642. }
  2643. return oldValue.SessionID, nil
  2644. }
  2645. // ResetSessionID resets all changes to the "session_id" field.
  2646. func (m *AliyunAvatarMutation) ResetSessionID() {
  2647. m.session_id = nil
  2648. }
  2649. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2650. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2651. m.predicates = append(m.predicates, ps...)
  2652. }
  2653. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2654. // users can use type-assertion to append predicates that do not depend on any generated package.
  2655. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2656. p := make([]predicate.AliyunAvatar, len(ps))
  2657. for i := range ps {
  2658. p[i] = ps[i]
  2659. }
  2660. m.Where(p...)
  2661. }
  2662. // Op returns the operation name.
  2663. func (m *AliyunAvatarMutation) Op() Op {
  2664. return m.op
  2665. }
  2666. // SetOp allows setting the mutation operation.
  2667. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2668. m.op = op
  2669. }
  2670. // Type returns the node type of this mutation (AliyunAvatar).
  2671. func (m *AliyunAvatarMutation) Type() string {
  2672. return m.typ
  2673. }
  2674. // Fields returns all fields that were changed during this mutation. Note that in
  2675. // order to get all numeric fields that were incremented/decremented, call
  2676. // AddedFields().
  2677. func (m *AliyunAvatarMutation) Fields() []string {
  2678. fields := make([]string, 0, 12)
  2679. if m.created_at != nil {
  2680. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2681. }
  2682. if m.updated_at != nil {
  2683. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2684. }
  2685. if m.deleted_at != nil {
  2686. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2687. }
  2688. if m.user_id != nil {
  2689. fields = append(fields, aliyunavatar.FieldUserID)
  2690. }
  2691. if m.biz_id != nil {
  2692. fields = append(fields, aliyunavatar.FieldBizID)
  2693. }
  2694. if m.access_key_id != nil {
  2695. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2696. }
  2697. if m.access_key_secret != nil {
  2698. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2699. }
  2700. if m.app_id != nil {
  2701. fields = append(fields, aliyunavatar.FieldAppID)
  2702. }
  2703. if m.tenant_id != nil {
  2704. fields = append(fields, aliyunavatar.FieldTenantID)
  2705. }
  2706. if m.response != nil {
  2707. fields = append(fields, aliyunavatar.FieldResponse)
  2708. }
  2709. if m.token != nil {
  2710. fields = append(fields, aliyunavatar.FieldToken)
  2711. }
  2712. if m.session_id != nil {
  2713. fields = append(fields, aliyunavatar.FieldSessionID)
  2714. }
  2715. return fields
  2716. }
  2717. // Field returns the value of a field with the given name. The second boolean
  2718. // return value indicates that this field was not set, or was not defined in the
  2719. // schema.
  2720. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2721. switch name {
  2722. case aliyunavatar.FieldCreatedAt:
  2723. return m.CreatedAt()
  2724. case aliyunavatar.FieldUpdatedAt:
  2725. return m.UpdatedAt()
  2726. case aliyunavatar.FieldDeletedAt:
  2727. return m.DeletedAt()
  2728. case aliyunavatar.FieldUserID:
  2729. return m.UserID()
  2730. case aliyunavatar.FieldBizID:
  2731. return m.BizID()
  2732. case aliyunavatar.FieldAccessKeyID:
  2733. return m.AccessKeyID()
  2734. case aliyunavatar.FieldAccessKeySecret:
  2735. return m.AccessKeySecret()
  2736. case aliyunavatar.FieldAppID:
  2737. return m.AppID()
  2738. case aliyunavatar.FieldTenantID:
  2739. return m.TenantID()
  2740. case aliyunavatar.FieldResponse:
  2741. return m.Response()
  2742. case aliyunavatar.FieldToken:
  2743. return m.Token()
  2744. case aliyunavatar.FieldSessionID:
  2745. return m.SessionID()
  2746. }
  2747. return nil, false
  2748. }
  2749. // OldField returns the old value of the field from the database. An error is
  2750. // returned if the mutation operation is not UpdateOne, or the query to the
  2751. // database failed.
  2752. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2753. switch name {
  2754. case aliyunavatar.FieldCreatedAt:
  2755. return m.OldCreatedAt(ctx)
  2756. case aliyunavatar.FieldUpdatedAt:
  2757. return m.OldUpdatedAt(ctx)
  2758. case aliyunavatar.FieldDeletedAt:
  2759. return m.OldDeletedAt(ctx)
  2760. case aliyunavatar.FieldUserID:
  2761. return m.OldUserID(ctx)
  2762. case aliyunavatar.FieldBizID:
  2763. return m.OldBizID(ctx)
  2764. case aliyunavatar.FieldAccessKeyID:
  2765. return m.OldAccessKeyID(ctx)
  2766. case aliyunavatar.FieldAccessKeySecret:
  2767. return m.OldAccessKeySecret(ctx)
  2768. case aliyunavatar.FieldAppID:
  2769. return m.OldAppID(ctx)
  2770. case aliyunavatar.FieldTenantID:
  2771. return m.OldTenantID(ctx)
  2772. case aliyunavatar.FieldResponse:
  2773. return m.OldResponse(ctx)
  2774. case aliyunavatar.FieldToken:
  2775. return m.OldToken(ctx)
  2776. case aliyunavatar.FieldSessionID:
  2777. return m.OldSessionID(ctx)
  2778. }
  2779. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2780. }
  2781. // SetField sets the value of a field with the given name. It returns an error if
  2782. // the field is not defined in the schema, or if the type mismatched the field
  2783. // type.
  2784. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2785. switch name {
  2786. case aliyunavatar.FieldCreatedAt:
  2787. v, ok := value.(time.Time)
  2788. if !ok {
  2789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2790. }
  2791. m.SetCreatedAt(v)
  2792. return nil
  2793. case aliyunavatar.FieldUpdatedAt:
  2794. v, ok := value.(time.Time)
  2795. if !ok {
  2796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2797. }
  2798. m.SetUpdatedAt(v)
  2799. return nil
  2800. case aliyunavatar.FieldDeletedAt:
  2801. v, ok := value.(time.Time)
  2802. if !ok {
  2803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2804. }
  2805. m.SetDeletedAt(v)
  2806. return nil
  2807. case aliyunavatar.FieldUserID:
  2808. v, ok := value.(uint64)
  2809. if !ok {
  2810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2811. }
  2812. m.SetUserID(v)
  2813. return nil
  2814. case aliyunavatar.FieldBizID:
  2815. v, ok := value.(string)
  2816. if !ok {
  2817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2818. }
  2819. m.SetBizID(v)
  2820. return nil
  2821. case aliyunavatar.FieldAccessKeyID:
  2822. v, ok := value.(string)
  2823. if !ok {
  2824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2825. }
  2826. m.SetAccessKeyID(v)
  2827. return nil
  2828. case aliyunavatar.FieldAccessKeySecret:
  2829. v, ok := value.(string)
  2830. if !ok {
  2831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2832. }
  2833. m.SetAccessKeySecret(v)
  2834. return nil
  2835. case aliyunavatar.FieldAppID:
  2836. v, ok := value.(string)
  2837. if !ok {
  2838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2839. }
  2840. m.SetAppID(v)
  2841. return nil
  2842. case aliyunavatar.FieldTenantID:
  2843. v, ok := value.(uint64)
  2844. if !ok {
  2845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2846. }
  2847. m.SetTenantID(v)
  2848. return nil
  2849. case aliyunavatar.FieldResponse:
  2850. v, ok := value.(string)
  2851. if !ok {
  2852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2853. }
  2854. m.SetResponse(v)
  2855. return nil
  2856. case aliyunavatar.FieldToken:
  2857. v, ok := value.(string)
  2858. if !ok {
  2859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2860. }
  2861. m.SetToken(v)
  2862. return nil
  2863. case aliyunavatar.FieldSessionID:
  2864. v, ok := value.(string)
  2865. if !ok {
  2866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2867. }
  2868. m.SetSessionID(v)
  2869. return nil
  2870. }
  2871. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2872. }
  2873. // AddedFields returns all numeric fields that were incremented/decremented during
  2874. // this mutation.
  2875. func (m *AliyunAvatarMutation) AddedFields() []string {
  2876. var fields []string
  2877. if m.adduser_id != nil {
  2878. fields = append(fields, aliyunavatar.FieldUserID)
  2879. }
  2880. if m.addtenant_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldTenantID)
  2882. }
  2883. return fields
  2884. }
  2885. // AddedField returns the numeric value that was incremented/decremented on a field
  2886. // with the given name. The second boolean return value indicates that this field
  2887. // was not set, or was not defined in the schema.
  2888. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2889. switch name {
  2890. case aliyunavatar.FieldUserID:
  2891. return m.AddedUserID()
  2892. case aliyunavatar.FieldTenantID:
  2893. return m.AddedTenantID()
  2894. }
  2895. return nil, false
  2896. }
  2897. // AddField adds the value to the field with the given name. It returns an error if
  2898. // the field is not defined in the schema, or if the type mismatched the field
  2899. // type.
  2900. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2901. switch name {
  2902. case aliyunavatar.FieldUserID:
  2903. v, ok := value.(int64)
  2904. if !ok {
  2905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2906. }
  2907. m.AddUserID(v)
  2908. return nil
  2909. case aliyunavatar.FieldTenantID:
  2910. v, ok := value.(int64)
  2911. if !ok {
  2912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2913. }
  2914. m.AddTenantID(v)
  2915. return nil
  2916. }
  2917. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  2918. }
  2919. // ClearedFields returns all nullable fields that were cleared during this
  2920. // mutation.
  2921. func (m *AliyunAvatarMutation) ClearedFields() []string {
  2922. var fields []string
  2923. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  2924. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2925. }
  2926. if m.FieldCleared(aliyunavatar.FieldAppID) {
  2927. fields = append(fields, aliyunavatar.FieldAppID)
  2928. }
  2929. return fields
  2930. }
  2931. // FieldCleared returns a boolean indicating if a field with the given name was
  2932. // cleared in this mutation.
  2933. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  2934. _, ok := m.clearedFields[name]
  2935. return ok
  2936. }
  2937. // ClearField clears the value of the field with the given name. It returns an
  2938. // error if the field is not defined in the schema.
  2939. func (m *AliyunAvatarMutation) ClearField(name string) error {
  2940. switch name {
  2941. case aliyunavatar.FieldDeletedAt:
  2942. m.ClearDeletedAt()
  2943. return nil
  2944. case aliyunavatar.FieldAppID:
  2945. m.ClearAppID()
  2946. return nil
  2947. }
  2948. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  2949. }
  2950. // ResetField resets all changes in the mutation for the field with the given name.
  2951. // It returns an error if the field is not defined in the schema.
  2952. func (m *AliyunAvatarMutation) ResetField(name string) error {
  2953. switch name {
  2954. case aliyunavatar.FieldCreatedAt:
  2955. m.ResetCreatedAt()
  2956. return nil
  2957. case aliyunavatar.FieldUpdatedAt:
  2958. m.ResetUpdatedAt()
  2959. return nil
  2960. case aliyunavatar.FieldDeletedAt:
  2961. m.ResetDeletedAt()
  2962. return nil
  2963. case aliyunavatar.FieldUserID:
  2964. m.ResetUserID()
  2965. return nil
  2966. case aliyunavatar.FieldBizID:
  2967. m.ResetBizID()
  2968. return nil
  2969. case aliyunavatar.FieldAccessKeyID:
  2970. m.ResetAccessKeyID()
  2971. return nil
  2972. case aliyunavatar.FieldAccessKeySecret:
  2973. m.ResetAccessKeySecret()
  2974. return nil
  2975. case aliyunavatar.FieldAppID:
  2976. m.ResetAppID()
  2977. return nil
  2978. case aliyunavatar.FieldTenantID:
  2979. m.ResetTenantID()
  2980. return nil
  2981. case aliyunavatar.FieldResponse:
  2982. m.ResetResponse()
  2983. return nil
  2984. case aliyunavatar.FieldToken:
  2985. m.ResetToken()
  2986. return nil
  2987. case aliyunavatar.FieldSessionID:
  2988. m.ResetSessionID()
  2989. return nil
  2990. }
  2991. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2992. }
  2993. // AddedEdges returns all edge names that were set/added in this mutation.
  2994. func (m *AliyunAvatarMutation) AddedEdges() []string {
  2995. edges := make([]string, 0, 0)
  2996. return edges
  2997. }
  2998. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2999. // name in this mutation.
  3000. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3001. return nil
  3002. }
  3003. // RemovedEdges returns all edge names that were removed in this mutation.
  3004. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3005. edges := make([]string, 0, 0)
  3006. return edges
  3007. }
  3008. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3009. // the given name in this mutation.
  3010. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3011. return nil
  3012. }
  3013. // ClearedEdges returns all edge names that were cleared in this mutation.
  3014. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3015. edges := make([]string, 0, 0)
  3016. return edges
  3017. }
  3018. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3019. // was cleared in this mutation.
  3020. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3021. return false
  3022. }
  3023. // ClearEdge clears the value of the edge with the given name. It returns an error
  3024. // if that edge is not defined in the schema.
  3025. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3026. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3027. }
  3028. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3029. // It returns an error if the edge is not defined in the schema.
  3030. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3031. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3032. }
  3033. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3034. type BatchMsgMutation struct {
  3035. config
  3036. op Op
  3037. typ string
  3038. id *uint64
  3039. created_at *time.Time
  3040. updated_at *time.Time
  3041. deleted_at *time.Time
  3042. status *uint8
  3043. addstatus *int8
  3044. batch_no *string
  3045. task_name *string
  3046. fromwxid *string
  3047. msg *string
  3048. tag *string
  3049. tagids *string
  3050. total *int32
  3051. addtotal *int32
  3052. success *int32
  3053. addsuccess *int32
  3054. fail *int32
  3055. addfail *int32
  3056. start_time *time.Time
  3057. stop_time *time.Time
  3058. send_time *time.Time
  3059. _type *int32
  3060. add_type *int32
  3061. organization_id *uint64
  3062. addorganization_id *int64
  3063. clearedFields map[string]struct{}
  3064. done bool
  3065. oldValue func(context.Context) (*BatchMsg, error)
  3066. predicates []predicate.BatchMsg
  3067. }
  3068. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3069. // batchmsgOption allows management of the mutation configuration using functional options.
  3070. type batchmsgOption func(*BatchMsgMutation)
  3071. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3072. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3073. m := &BatchMsgMutation{
  3074. config: c,
  3075. op: op,
  3076. typ: TypeBatchMsg,
  3077. clearedFields: make(map[string]struct{}),
  3078. }
  3079. for _, opt := range opts {
  3080. opt(m)
  3081. }
  3082. return m
  3083. }
  3084. // withBatchMsgID sets the ID field of the mutation.
  3085. func withBatchMsgID(id uint64) batchmsgOption {
  3086. return func(m *BatchMsgMutation) {
  3087. var (
  3088. err error
  3089. once sync.Once
  3090. value *BatchMsg
  3091. )
  3092. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3093. once.Do(func() {
  3094. if m.done {
  3095. err = errors.New("querying old values post mutation is not allowed")
  3096. } else {
  3097. value, err = m.Client().BatchMsg.Get(ctx, id)
  3098. }
  3099. })
  3100. return value, err
  3101. }
  3102. m.id = &id
  3103. }
  3104. }
  3105. // withBatchMsg sets the old BatchMsg of the mutation.
  3106. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3107. return func(m *BatchMsgMutation) {
  3108. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3109. return node, nil
  3110. }
  3111. m.id = &node.ID
  3112. }
  3113. }
  3114. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3115. // executed in a transaction (ent.Tx), a transactional client is returned.
  3116. func (m BatchMsgMutation) Client() *Client {
  3117. client := &Client{config: m.config}
  3118. client.init()
  3119. return client
  3120. }
  3121. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3122. // it returns an error otherwise.
  3123. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3124. if _, ok := m.driver.(*txDriver); !ok {
  3125. return nil, errors.New("ent: mutation is not running in a transaction")
  3126. }
  3127. tx := &Tx{config: m.config}
  3128. tx.init()
  3129. return tx, nil
  3130. }
  3131. // SetID sets the value of the id field. Note that this
  3132. // operation is only accepted on creation of BatchMsg entities.
  3133. func (m *BatchMsgMutation) SetID(id uint64) {
  3134. m.id = &id
  3135. }
  3136. // ID returns the ID value in the mutation. Note that the ID is only available
  3137. // if it was provided to the builder or after it was returned from the database.
  3138. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3139. if m.id == nil {
  3140. return
  3141. }
  3142. return *m.id, true
  3143. }
  3144. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3145. // That means, if the mutation is applied within a transaction with an isolation level such
  3146. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3147. // or updated by the mutation.
  3148. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3149. switch {
  3150. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3151. id, exists := m.ID()
  3152. if exists {
  3153. return []uint64{id}, nil
  3154. }
  3155. fallthrough
  3156. case m.op.Is(OpUpdate | OpDelete):
  3157. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3158. default:
  3159. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3160. }
  3161. }
  3162. // SetCreatedAt sets the "created_at" field.
  3163. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3164. m.created_at = &t
  3165. }
  3166. // CreatedAt returns the value of the "created_at" field in the mutation.
  3167. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3168. v := m.created_at
  3169. if v == nil {
  3170. return
  3171. }
  3172. return *v, true
  3173. }
  3174. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3175. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3177. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3178. if !m.op.Is(OpUpdateOne) {
  3179. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3180. }
  3181. if m.id == nil || m.oldValue == nil {
  3182. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3183. }
  3184. oldValue, err := m.oldValue(ctx)
  3185. if err != nil {
  3186. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3187. }
  3188. return oldValue.CreatedAt, nil
  3189. }
  3190. // ResetCreatedAt resets all changes to the "created_at" field.
  3191. func (m *BatchMsgMutation) ResetCreatedAt() {
  3192. m.created_at = nil
  3193. }
  3194. // SetUpdatedAt sets the "updated_at" field.
  3195. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3196. m.updated_at = &t
  3197. }
  3198. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3199. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3200. v := m.updated_at
  3201. if v == nil {
  3202. return
  3203. }
  3204. return *v, true
  3205. }
  3206. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3207. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3209. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3210. if !m.op.Is(OpUpdateOne) {
  3211. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3212. }
  3213. if m.id == nil || m.oldValue == nil {
  3214. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3215. }
  3216. oldValue, err := m.oldValue(ctx)
  3217. if err != nil {
  3218. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3219. }
  3220. return oldValue.UpdatedAt, nil
  3221. }
  3222. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3223. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3224. m.updated_at = nil
  3225. }
  3226. // SetDeletedAt sets the "deleted_at" field.
  3227. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3228. m.deleted_at = &t
  3229. }
  3230. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3231. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3232. v := m.deleted_at
  3233. if v == nil {
  3234. return
  3235. }
  3236. return *v, true
  3237. }
  3238. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3239. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3241. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3242. if !m.op.Is(OpUpdateOne) {
  3243. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3244. }
  3245. if m.id == nil || m.oldValue == nil {
  3246. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3247. }
  3248. oldValue, err := m.oldValue(ctx)
  3249. if err != nil {
  3250. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3251. }
  3252. return oldValue.DeletedAt, nil
  3253. }
  3254. // ClearDeletedAt clears the value of the "deleted_at" field.
  3255. func (m *BatchMsgMutation) ClearDeletedAt() {
  3256. m.deleted_at = nil
  3257. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3258. }
  3259. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3260. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3261. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3262. return ok
  3263. }
  3264. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3265. func (m *BatchMsgMutation) ResetDeletedAt() {
  3266. m.deleted_at = nil
  3267. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3268. }
  3269. // SetStatus sets the "status" field.
  3270. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3271. m.status = &u
  3272. m.addstatus = nil
  3273. }
  3274. // Status returns the value of the "status" field in the mutation.
  3275. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3276. v := m.status
  3277. if v == nil {
  3278. return
  3279. }
  3280. return *v, true
  3281. }
  3282. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3283. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3285. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3286. if !m.op.Is(OpUpdateOne) {
  3287. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3288. }
  3289. if m.id == nil || m.oldValue == nil {
  3290. return v, errors.New("OldStatus requires an ID field in the mutation")
  3291. }
  3292. oldValue, err := m.oldValue(ctx)
  3293. if err != nil {
  3294. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3295. }
  3296. return oldValue.Status, nil
  3297. }
  3298. // AddStatus adds u to the "status" field.
  3299. func (m *BatchMsgMutation) AddStatus(u int8) {
  3300. if m.addstatus != nil {
  3301. *m.addstatus += u
  3302. } else {
  3303. m.addstatus = &u
  3304. }
  3305. }
  3306. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3307. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3308. v := m.addstatus
  3309. if v == nil {
  3310. return
  3311. }
  3312. return *v, true
  3313. }
  3314. // ClearStatus clears the value of the "status" field.
  3315. func (m *BatchMsgMutation) ClearStatus() {
  3316. m.status = nil
  3317. m.addstatus = nil
  3318. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3319. }
  3320. // StatusCleared returns if the "status" field was cleared in this mutation.
  3321. func (m *BatchMsgMutation) StatusCleared() bool {
  3322. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3323. return ok
  3324. }
  3325. // ResetStatus resets all changes to the "status" field.
  3326. func (m *BatchMsgMutation) ResetStatus() {
  3327. m.status = nil
  3328. m.addstatus = nil
  3329. delete(m.clearedFields, batchmsg.FieldStatus)
  3330. }
  3331. // SetBatchNo sets the "batch_no" field.
  3332. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3333. m.batch_no = &s
  3334. }
  3335. // BatchNo returns the value of the "batch_no" field in the mutation.
  3336. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3337. v := m.batch_no
  3338. if v == nil {
  3339. return
  3340. }
  3341. return *v, true
  3342. }
  3343. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3344. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3346. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3347. if !m.op.Is(OpUpdateOne) {
  3348. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3349. }
  3350. if m.id == nil || m.oldValue == nil {
  3351. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3352. }
  3353. oldValue, err := m.oldValue(ctx)
  3354. if err != nil {
  3355. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3356. }
  3357. return oldValue.BatchNo, nil
  3358. }
  3359. // ClearBatchNo clears the value of the "batch_no" field.
  3360. func (m *BatchMsgMutation) ClearBatchNo() {
  3361. m.batch_no = nil
  3362. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3363. }
  3364. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3365. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3366. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3367. return ok
  3368. }
  3369. // ResetBatchNo resets all changes to the "batch_no" field.
  3370. func (m *BatchMsgMutation) ResetBatchNo() {
  3371. m.batch_no = nil
  3372. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3373. }
  3374. // SetTaskName sets the "task_name" field.
  3375. func (m *BatchMsgMutation) SetTaskName(s string) {
  3376. m.task_name = &s
  3377. }
  3378. // TaskName returns the value of the "task_name" field in the mutation.
  3379. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3380. v := m.task_name
  3381. if v == nil {
  3382. return
  3383. }
  3384. return *v, true
  3385. }
  3386. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3387. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3389. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3390. if !m.op.Is(OpUpdateOne) {
  3391. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3392. }
  3393. if m.id == nil || m.oldValue == nil {
  3394. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3395. }
  3396. oldValue, err := m.oldValue(ctx)
  3397. if err != nil {
  3398. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3399. }
  3400. return oldValue.TaskName, nil
  3401. }
  3402. // ClearTaskName clears the value of the "task_name" field.
  3403. func (m *BatchMsgMutation) ClearTaskName() {
  3404. m.task_name = nil
  3405. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3406. }
  3407. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3408. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3409. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3410. return ok
  3411. }
  3412. // ResetTaskName resets all changes to the "task_name" field.
  3413. func (m *BatchMsgMutation) ResetTaskName() {
  3414. m.task_name = nil
  3415. delete(m.clearedFields, batchmsg.FieldTaskName)
  3416. }
  3417. // SetFromwxid sets the "fromwxid" field.
  3418. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3419. m.fromwxid = &s
  3420. }
  3421. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3422. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3423. v := m.fromwxid
  3424. if v == nil {
  3425. return
  3426. }
  3427. return *v, true
  3428. }
  3429. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3430. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3432. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3433. if !m.op.Is(OpUpdateOne) {
  3434. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3435. }
  3436. if m.id == nil || m.oldValue == nil {
  3437. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3438. }
  3439. oldValue, err := m.oldValue(ctx)
  3440. if err != nil {
  3441. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3442. }
  3443. return oldValue.Fromwxid, nil
  3444. }
  3445. // ClearFromwxid clears the value of the "fromwxid" field.
  3446. func (m *BatchMsgMutation) ClearFromwxid() {
  3447. m.fromwxid = nil
  3448. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3449. }
  3450. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3451. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3452. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3453. return ok
  3454. }
  3455. // ResetFromwxid resets all changes to the "fromwxid" field.
  3456. func (m *BatchMsgMutation) ResetFromwxid() {
  3457. m.fromwxid = nil
  3458. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3459. }
  3460. // SetMsg sets the "msg" field.
  3461. func (m *BatchMsgMutation) SetMsg(s string) {
  3462. m.msg = &s
  3463. }
  3464. // Msg returns the value of the "msg" field in the mutation.
  3465. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3466. v := m.msg
  3467. if v == nil {
  3468. return
  3469. }
  3470. return *v, true
  3471. }
  3472. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3473. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3475. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3476. if !m.op.Is(OpUpdateOne) {
  3477. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3478. }
  3479. if m.id == nil || m.oldValue == nil {
  3480. return v, errors.New("OldMsg requires an ID field in the mutation")
  3481. }
  3482. oldValue, err := m.oldValue(ctx)
  3483. if err != nil {
  3484. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3485. }
  3486. return oldValue.Msg, nil
  3487. }
  3488. // ClearMsg clears the value of the "msg" field.
  3489. func (m *BatchMsgMutation) ClearMsg() {
  3490. m.msg = nil
  3491. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3492. }
  3493. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3494. func (m *BatchMsgMutation) MsgCleared() bool {
  3495. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3496. return ok
  3497. }
  3498. // ResetMsg resets all changes to the "msg" field.
  3499. func (m *BatchMsgMutation) ResetMsg() {
  3500. m.msg = nil
  3501. delete(m.clearedFields, batchmsg.FieldMsg)
  3502. }
  3503. // SetTag sets the "tag" field.
  3504. func (m *BatchMsgMutation) SetTag(s string) {
  3505. m.tag = &s
  3506. }
  3507. // Tag returns the value of the "tag" field in the mutation.
  3508. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3509. v := m.tag
  3510. if v == nil {
  3511. return
  3512. }
  3513. return *v, true
  3514. }
  3515. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3516. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3518. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3519. if !m.op.Is(OpUpdateOne) {
  3520. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3521. }
  3522. if m.id == nil || m.oldValue == nil {
  3523. return v, errors.New("OldTag requires an ID field in the mutation")
  3524. }
  3525. oldValue, err := m.oldValue(ctx)
  3526. if err != nil {
  3527. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3528. }
  3529. return oldValue.Tag, nil
  3530. }
  3531. // ClearTag clears the value of the "tag" field.
  3532. func (m *BatchMsgMutation) ClearTag() {
  3533. m.tag = nil
  3534. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3535. }
  3536. // TagCleared returns if the "tag" field was cleared in this mutation.
  3537. func (m *BatchMsgMutation) TagCleared() bool {
  3538. _, ok := m.clearedFields[batchmsg.FieldTag]
  3539. return ok
  3540. }
  3541. // ResetTag resets all changes to the "tag" field.
  3542. func (m *BatchMsgMutation) ResetTag() {
  3543. m.tag = nil
  3544. delete(m.clearedFields, batchmsg.FieldTag)
  3545. }
  3546. // SetTagids sets the "tagids" field.
  3547. func (m *BatchMsgMutation) SetTagids(s string) {
  3548. m.tagids = &s
  3549. }
  3550. // Tagids returns the value of the "tagids" field in the mutation.
  3551. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3552. v := m.tagids
  3553. if v == nil {
  3554. return
  3555. }
  3556. return *v, true
  3557. }
  3558. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3559. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3561. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3562. if !m.op.Is(OpUpdateOne) {
  3563. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3564. }
  3565. if m.id == nil || m.oldValue == nil {
  3566. return v, errors.New("OldTagids requires an ID field in the mutation")
  3567. }
  3568. oldValue, err := m.oldValue(ctx)
  3569. if err != nil {
  3570. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3571. }
  3572. return oldValue.Tagids, nil
  3573. }
  3574. // ClearTagids clears the value of the "tagids" field.
  3575. func (m *BatchMsgMutation) ClearTagids() {
  3576. m.tagids = nil
  3577. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3578. }
  3579. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3580. func (m *BatchMsgMutation) TagidsCleared() bool {
  3581. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3582. return ok
  3583. }
  3584. // ResetTagids resets all changes to the "tagids" field.
  3585. func (m *BatchMsgMutation) ResetTagids() {
  3586. m.tagids = nil
  3587. delete(m.clearedFields, batchmsg.FieldTagids)
  3588. }
  3589. // SetTotal sets the "total" field.
  3590. func (m *BatchMsgMutation) SetTotal(i int32) {
  3591. m.total = &i
  3592. m.addtotal = nil
  3593. }
  3594. // Total returns the value of the "total" field in the mutation.
  3595. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3596. v := m.total
  3597. if v == nil {
  3598. return
  3599. }
  3600. return *v, true
  3601. }
  3602. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3603. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3605. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3606. if !m.op.Is(OpUpdateOne) {
  3607. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3608. }
  3609. if m.id == nil || m.oldValue == nil {
  3610. return v, errors.New("OldTotal requires an ID field in the mutation")
  3611. }
  3612. oldValue, err := m.oldValue(ctx)
  3613. if err != nil {
  3614. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3615. }
  3616. return oldValue.Total, nil
  3617. }
  3618. // AddTotal adds i to the "total" field.
  3619. func (m *BatchMsgMutation) AddTotal(i int32) {
  3620. if m.addtotal != nil {
  3621. *m.addtotal += i
  3622. } else {
  3623. m.addtotal = &i
  3624. }
  3625. }
  3626. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3627. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3628. v := m.addtotal
  3629. if v == nil {
  3630. return
  3631. }
  3632. return *v, true
  3633. }
  3634. // ClearTotal clears the value of the "total" field.
  3635. func (m *BatchMsgMutation) ClearTotal() {
  3636. m.total = nil
  3637. m.addtotal = nil
  3638. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3639. }
  3640. // TotalCleared returns if the "total" field was cleared in this mutation.
  3641. func (m *BatchMsgMutation) TotalCleared() bool {
  3642. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3643. return ok
  3644. }
  3645. // ResetTotal resets all changes to the "total" field.
  3646. func (m *BatchMsgMutation) ResetTotal() {
  3647. m.total = nil
  3648. m.addtotal = nil
  3649. delete(m.clearedFields, batchmsg.FieldTotal)
  3650. }
  3651. // SetSuccess sets the "success" field.
  3652. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3653. m.success = &i
  3654. m.addsuccess = nil
  3655. }
  3656. // Success returns the value of the "success" field in the mutation.
  3657. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3658. v := m.success
  3659. if v == nil {
  3660. return
  3661. }
  3662. return *v, true
  3663. }
  3664. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3665. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3667. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3668. if !m.op.Is(OpUpdateOne) {
  3669. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3670. }
  3671. if m.id == nil || m.oldValue == nil {
  3672. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3673. }
  3674. oldValue, err := m.oldValue(ctx)
  3675. if err != nil {
  3676. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3677. }
  3678. return oldValue.Success, nil
  3679. }
  3680. // AddSuccess adds i to the "success" field.
  3681. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3682. if m.addsuccess != nil {
  3683. *m.addsuccess += i
  3684. } else {
  3685. m.addsuccess = &i
  3686. }
  3687. }
  3688. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3689. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3690. v := m.addsuccess
  3691. if v == nil {
  3692. return
  3693. }
  3694. return *v, true
  3695. }
  3696. // ClearSuccess clears the value of the "success" field.
  3697. func (m *BatchMsgMutation) ClearSuccess() {
  3698. m.success = nil
  3699. m.addsuccess = nil
  3700. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3701. }
  3702. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3703. func (m *BatchMsgMutation) SuccessCleared() bool {
  3704. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3705. return ok
  3706. }
  3707. // ResetSuccess resets all changes to the "success" field.
  3708. func (m *BatchMsgMutation) ResetSuccess() {
  3709. m.success = nil
  3710. m.addsuccess = nil
  3711. delete(m.clearedFields, batchmsg.FieldSuccess)
  3712. }
  3713. // SetFail sets the "fail" field.
  3714. func (m *BatchMsgMutation) SetFail(i int32) {
  3715. m.fail = &i
  3716. m.addfail = nil
  3717. }
  3718. // Fail returns the value of the "fail" field in the mutation.
  3719. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3720. v := m.fail
  3721. if v == nil {
  3722. return
  3723. }
  3724. return *v, true
  3725. }
  3726. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3727. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3729. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3730. if !m.op.Is(OpUpdateOne) {
  3731. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3732. }
  3733. if m.id == nil || m.oldValue == nil {
  3734. return v, errors.New("OldFail requires an ID field in the mutation")
  3735. }
  3736. oldValue, err := m.oldValue(ctx)
  3737. if err != nil {
  3738. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3739. }
  3740. return oldValue.Fail, nil
  3741. }
  3742. // AddFail adds i to the "fail" field.
  3743. func (m *BatchMsgMutation) AddFail(i int32) {
  3744. if m.addfail != nil {
  3745. *m.addfail += i
  3746. } else {
  3747. m.addfail = &i
  3748. }
  3749. }
  3750. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3751. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3752. v := m.addfail
  3753. if v == nil {
  3754. return
  3755. }
  3756. return *v, true
  3757. }
  3758. // ClearFail clears the value of the "fail" field.
  3759. func (m *BatchMsgMutation) ClearFail() {
  3760. m.fail = nil
  3761. m.addfail = nil
  3762. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3763. }
  3764. // FailCleared returns if the "fail" field was cleared in this mutation.
  3765. func (m *BatchMsgMutation) FailCleared() bool {
  3766. _, ok := m.clearedFields[batchmsg.FieldFail]
  3767. return ok
  3768. }
  3769. // ResetFail resets all changes to the "fail" field.
  3770. func (m *BatchMsgMutation) ResetFail() {
  3771. m.fail = nil
  3772. m.addfail = nil
  3773. delete(m.clearedFields, batchmsg.FieldFail)
  3774. }
  3775. // SetStartTime sets the "start_time" field.
  3776. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3777. m.start_time = &t
  3778. }
  3779. // StartTime returns the value of the "start_time" field in the mutation.
  3780. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3781. v := m.start_time
  3782. if v == nil {
  3783. return
  3784. }
  3785. return *v, true
  3786. }
  3787. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3788. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3790. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3791. if !m.op.Is(OpUpdateOne) {
  3792. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3793. }
  3794. if m.id == nil || m.oldValue == nil {
  3795. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3796. }
  3797. oldValue, err := m.oldValue(ctx)
  3798. if err != nil {
  3799. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3800. }
  3801. return oldValue.StartTime, nil
  3802. }
  3803. // ClearStartTime clears the value of the "start_time" field.
  3804. func (m *BatchMsgMutation) ClearStartTime() {
  3805. m.start_time = nil
  3806. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3807. }
  3808. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3809. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3810. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3811. return ok
  3812. }
  3813. // ResetStartTime resets all changes to the "start_time" field.
  3814. func (m *BatchMsgMutation) ResetStartTime() {
  3815. m.start_time = nil
  3816. delete(m.clearedFields, batchmsg.FieldStartTime)
  3817. }
  3818. // SetStopTime sets the "stop_time" field.
  3819. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3820. m.stop_time = &t
  3821. }
  3822. // StopTime returns the value of the "stop_time" field in the mutation.
  3823. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3824. v := m.stop_time
  3825. if v == nil {
  3826. return
  3827. }
  3828. return *v, true
  3829. }
  3830. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3831. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3833. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3834. if !m.op.Is(OpUpdateOne) {
  3835. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3836. }
  3837. if m.id == nil || m.oldValue == nil {
  3838. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3839. }
  3840. oldValue, err := m.oldValue(ctx)
  3841. if err != nil {
  3842. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3843. }
  3844. return oldValue.StopTime, nil
  3845. }
  3846. // ClearStopTime clears the value of the "stop_time" field.
  3847. func (m *BatchMsgMutation) ClearStopTime() {
  3848. m.stop_time = nil
  3849. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3850. }
  3851. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3852. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3853. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3854. return ok
  3855. }
  3856. // ResetStopTime resets all changes to the "stop_time" field.
  3857. func (m *BatchMsgMutation) ResetStopTime() {
  3858. m.stop_time = nil
  3859. delete(m.clearedFields, batchmsg.FieldStopTime)
  3860. }
  3861. // SetSendTime sets the "send_time" field.
  3862. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3863. m.send_time = &t
  3864. }
  3865. // SendTime returns the value of the "send_time" field in the mutation.
  3866. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3867. v := m.send_time
  3868. if v == nil {
  3869. return
  3870. }
  3871. return *v, true
  3872. }
  3873. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3874. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3876. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3877. if !m.op.Is(OpUpdateOne) {
  3878. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3879. }
  3880. if m.id == nil || m.oldValue == nil {
  3881. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3882. }
  3883. oldValue, err := m.oldValue(ctx)
  3884. if err != nil {
  3885. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3886. }
  3887. return oldValue.SendTime, nil
  3888. }
  3889. // ClearSendTime clears the value of the "send_time" field.
  3890. func (m *BatchMsgMutation) ClearSendTime() {
  3891. m.send_time = nil
  3892. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3893. }
  3894. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3895. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3896. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3897. return ok
  3898. }
  3899. // ResetSendTime resets all changes to the "send_time" field.
  3900. func (m *BatchMsgMutation) ResetSendTime() {
  3901. m.send_time = nil
  3902. delete(m.clearedFields, batchmsg.FieldSendTime)
  3903. }
  3904. // SetType sets the "type" field.
  3905. func (m *BatchMsgMutation) SetType(i int32) {
  3906. m._type = &i
  3907. m.add_type = nil
  3908. }
  3909. // GetType returns the value of the "type" field in the mutation.
  3910. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3911. v := m._type
  3912. if v == nil {
  3913. return
  3914. }
  3915. return *v, true
  3916. }
  3917. // OldType returns the old "type" field's value of the BatchMsg entity.
  3918. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3920. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  3921. if !m.op.Is(OpUpdateOne) {
  3922. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3923. }
  3924. if m.id == nil || m.oldValue == nil {
  3925. return v, errors.New("OldType requires an ID field in the mutation")
  3926. }
  3927. oldValue, err := m.oldValue(ctx)
  3928. if err != nil {
  3929. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3930. }
  3931. return oldValue.Type, nil
  3932. }
  3933. // AddType adds i to the "type" field.
  3934. func (m *BatchMsgMutation) AddType(i int32) {
  3935. if m.add_type != nil {
  3936. *m.add_type += i
  3937. } else {
  3938. m.add_type = &i
  3939. }
  3940. }
  3941. // AddedType returns the value that was added to the "type" field in this mutation.
  3942. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  3943. v := m.add_type
  3944. if v == nil {
  3945. return
  3946. }
  3947. return *v, true
  3948. }
  3949. // ClearType clears the value of the "type" field.
  3950. func (m *BatchMsgMutation) ClearType() {
  3951. m._type = nil
  3952. m.add_type = nil
  3953. m.clearedFields[batchmsg.FieldType] = struct{}{}
  3954. }
  3955. // TypeCleared returns if the "type" field was cleared in this mutation.
  3956. func (m *BatchMsgMutation) TypeCleared() bool {
  3957. _, ok := m.clearedFields[batchmsg.FieldType]
  3958. return ok
  3959. }
  3960. // ResetType resets all changes to the "type" field.
  3961. func (m *BatchMsgMutation) ResetType() {
  3962. m._type = nil
  3963. m.add_type = nil
  3964. delete(m.clearedFields, batchmsg.FieldType)
  3965. }
  3966. // SetOrganizationID sets the "organization_id" field.
  3967. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  3968. m.organization_id = &u
  3969. m.addorganization_id = nil
  3970. }
  3971. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3972. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  3973. v := m.organization_id
  3974. if v == nil {
  3975. return
  3976. }
  3977. return *v, true
  3978. }
  3979. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  3980. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3982. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3983. if !m.op.Is(OpUpdateOne) {
  3984. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3985. }
  3986. if m.id == nil || m.oldValue == nil {
  3987. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3988. }
  3989. oldValue, err := m.oldValue(ctx)
  3990. if err != nil {
  3991. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3992. }
  3993. return oldValue.OrganizationID, nil
  3994. }
  3995. // AddOrganizationID adds u to the "organization_id" field.
  3996. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  3997. if m.addorganization_id != nil {
  3998. *m.addorganization_id += u
  3999. } else {
  4000. m.addorganization_id = &u
  4001. }
  4002. }
  4003. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4004. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4005. v := m.addorganization_id
  4006. if v == nil {
  4007. return
  4008. }
  4009. return *v, true
  4010. }
  4011. // ResetOrganizationID resets all changes to the "organization_id" field.
  4012. func (m *BatchMsgMutation) ResetOrganizationID() {
  4013. m.organization_id = nil
  4014. m.addorganization_id = nil
  4015. }
  4016. // Where appends a list predicates to the BatchMsgMutation builder.
  4017. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4018. m.predicates = append(m.predicates, ps...)
  4019. }
  4020. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4021. // users can use type-assertion to append predicates that do not depend on any generated package.
  4022. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4023. p := make([]predicate.BatchMsg, len(ps))
  4024. for i := range ps {
  4025. p[i] = ps[i]
  4026. }
  4027. m.Where(p...)
  4028. }
  4029. // Op returns the operation name.
  4030. func (m *BatchMsgMutation) Op() Op {
  4031. return m.op
  4032. }
  4033. // SetOp allows setting the mutation operation.
  4034. func (m *BatchMsgMutation) SetOp(op Op) {
  4035. m.op = op
  4036. }
  4037. // Type returns the node type of this mutation (BatchMsg).
  4038. func (m *BatchMsgMutation) Type() string {
  4039. return m.typ
  4040. }
  4041. // Fields returns all fields that were changed during this mutation. Note that in
  4042. // order to get all numeric fields that were incremented/decremented, call
  4043. // AddedFields().
  4044. func (m *BatchMsgMutation) Fields() []string {
  4045. fields := make([]string, 0, 18)
  4046. if m.created_at != nil {
  4047. fields = append(fields, batchmsg.FieldCreatedAt)
  4048. }
  4049. if m.updated_at != nil {
  4050. fields = append(fields, batchmsg.FieldUpdatedAt)
  4051. }
  4052. if m.deleted_at != nil {
  4053. fields = append(fields, batchmsg.FieldDeletedAt)
  4054. }
  4055. if m.status != nil {
  4056. fields = append(fields, batchmsg.FieldStatus)
  4057. }
  4058. if m.batch_no != nil {
  4059. fields = append(fields, batchmsg.FieldBatchNo)
  4060. }
  4061. if m.task_name != nil {
  4062. fields = append(fields, batchmsg.FieldTaskName)
  4063. }
  4064. if m.fromwxid != nil {
  4065. fields = append(fields, batchmsg.FieldFromwxid)
  4066. }
  4067. if m.msg != nil {
  4068. fields = append(fields, batchmsg.FieldMsg)
  4069. }
  4070. if m.tag != nil {
  4071. fields = append(fields, batchmsg.FieldTag)
  4072. }
  4073. if m.tagids != nil {
  4074. fields = append(fields, batchmsg.FieldTagids)
  4075. }
  4076. if m.total != nil {
  4077. fields = append(fields, batchmsg.FieldTotal)
  4078. }
  4079. if m.success != nil {
  4080. fields = append(fields, batchmsg.FieldSuccess)
  4081. }
  4082. if m.fail != nil {
  4083. fields = append(fields, batchmsg.FieldFail)
  4084. }
  4085. if m.start_time != nil {
  4086. fields = append(fields, batchmsg.FieldStartTime)
  4087. }
  4088. if m.stop_time != nil {
  4089. fields = append(fields, batchmsg.FieldStopTime)
  4090. }
  4091. if m.send_time != nil {
  4092. fields = append(fields, batchmsg.FieldSendTime)
  4093. }
  4094. if m._type != nil {
  4095. fields = append(fields, batchmsg.FieldType)
  4096. }
  4097. if m.organization_id != nil {
  4098. fields = append(fields, batchmsg.FieldOrganizationID)
  4099. }
  4100. return fields
  4101. }
  4102. // Field returns the value of a field with the given name. The second boolean
  4103. // return value indicates that this field was not set, or was not defined in the
  4104. // schema.
  4105. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4106. switch name {
  4107. case batchmsg.FieldCreatedAt:
  4108. return m.CreatedAt()
  4109. case batchmsg.FieldUpdatedAt:
  4110. return m.UpdatedAt()
  4111. case batchmsg.FieldDeletedAt:
  4112. return m.DeletedAt()
  4113. case batchmsg.FieldStatus:
  4114. return m.Status()
  4115. case batchmsg.FieldBatchNo:
  4116. return m.BatchNo()
  4117. case batchmsg.FieldTaskName:
  4118. return m.TaskName()
  4119. case batchmsg.FieldFromwxid:
  4120. return m.Fromwxid()
  4121. case batchmsg.FieldMsg:
  4122. return m.Msg()
  4123. case batchmsg.FieldTag:
  4124. return m.Tag()
  4125. case batchmsg.FieldTagids:
  4126. return m.Tagids()
  4127. case batchmsg.FieldTotal:
  4128. return m.Total()
  4129. case batchmsg.FieldSuccess:
  4130. return m.Success()
  4131. case batchmsg.FieldFail:
  4132. return m.Fail()
  4133. case batchmsg.FieldStartTime:
  4134. return m.StartTime()
  4135. case batchmsg.FieldStopTime:
  4136. return m.StopTime()
  4137. case batchmsg.FieldSendTime:
  4138. return m.SendTime()
  4139. case batchmsg.FieldType:
  4140. return m.GetType()
  4141. case batchmsg.FieldOrganizationID:
  4142. return m.OrganizationID()
  4143. }
  4144. return nil, false
  4145. }
  4146. // OldField returns the old value of the field from the database. An error is
  4147. // returned if the mutation operation is not UpdateOne, or the query to the
  4148. // database failed.
  4149. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4150. switch name {
  4151. case batchmsg.FieldCreatedAt:
  4152. return m.OldCreatedAt(ctx)
  4153. case batchmsg.FieldUpdatedAt:
  4154. return m.OldUpdatedAt(ctx)
  4155. case batchmsg.FieldDeletedAt:
  4156. return m.OldDeletedAt(ctx)
  4157. case batchmsg.FieldStatus:
  4158. return m.OldStatus(ctx)
  4159. case batchmsg.FieldBatchNo:
  4160. return m.OldBatchNo(ctx)
  4161. case batchmsg.FieldTaskName:
  4162. return m.OldTaskName(ctx)
  4163. case batchmsg.FieldFromwxid:
  4164. return m.OldFromwxid(ctx)
  4165. case batchmsg.FieldMsg:
  4166. return m.OldMsg(ctx)
  4167. case batchmsg.FieldTag:
  4168. return m.OldTag(ctx)
  4169. case batchmsg.FieldTagids:
  4170. return m.OldTagids(ctx)
  4171. case batchmsg.FieldTotal:
  4172. return m.OldTotal(ctx)
  4173. case batchmsg.FieldSuccess:
  4174. return m.OldSuccess(ctx)
  4175. case batchmsg.FieldFail:
  4176. return m.OldFail(ctx)
  4177. case batchmsg.FieldStartTime:
  4178. return m.OldStartTime(ctx)
  4179. case batchmsg.FieldStopTime:
  4180. return m.OldStopTime(ctx)
  4181. case batchmsg.FieldSendTime:
  4182. return m.OldSendTime(ctx)
  4183. case batchmsg.FieldType:
  4184. return m.OldType(ctx)
  4185. case batchmsg.FieldOrganizationID:
  4186. return m.OldOrganizationID(ctx)
  4187. }
  4188. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4189. }
  4190. // SetField sets the value of a field with the given name. It returns an error if
  4191. // the field is not defined in the schema, or if the type mismatched the field
  4192. // type.
  4193. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4194. switch name {
  4195. case batchmsg.FieldCreatedAt:
  4196. v, ok := value.(time.Time)
  4197. if !ok {
  4198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4199. }
  4200. m.SetCreatedAt(v)
  4201. return nil
  4202. case batchmsg.FieldUpdatedAt:
  4203. v, ok := value.(time.Time)
  4204. if !ok {
  4205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4206. }
  4207. m.SetUpdatedAt(v)
  4208. return nil
  4209. case batchmsg.FieldDeletedAt:
  4210. v, ok := value.(time.Time)
  4211. if !ok {
  4212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4213. }
  4214. m.SetDeletedAt(v)
  4215. return nil
  4216. case batchmsg.FieldStatus:
  4217. v, ok := value.(uint8)
  4218. if !ok {
  4219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4220. }
  4221. m.SetStatus(v)
  4222. return nil
  4223. case batchmsg.FieldBatchNo:
  4224. v, ok := value.(string)
  4225. if !ok {
  4226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4227. }
  4228. m.SetBatchNo(v)
  4229. return nil
  4230. case batchmsg.FieldTaskName:
  4231. v, ok := value.(string)
  4232. if !ok {
  4233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4234. }
  4235. m.SetTaskName(v)
  4236. return nil
  4237. case batchmsg.FieldFromwxid:
  4238. v, ok := value.(string)
  4239. if !ok {
  4240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4241. }
  4242. m.SetFromwxid(v)
  4243. return nil
  4244. case batchmsg.FieldMsg:
  4245. v, ok := value.(string)
  4246. if !ok {
  4247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4248. }
  4249. m.SetMsg(v)
  4250. return nil
  4251. case batchmsg.FieldTag:
  4252. v, ok := value.(string)
  4253. if !ok {
  4254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4255. }
  4256. m.SetTag(v)
  4257. return nil
  4258. case batchmsg.FieldTagids:
  4259. v, ok := value.(string)
  4260. if !ok {
  4261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4262. }
  4263. m.SetTagids(v)
  4264. return nil
  4265. case batchmsg.FieldTotal:
  4266. v, ok := value.(int32)
  4267. if !ok {
  4268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4269. }
  4270. m.SetTotal(v)
  4271. return nil
  4272. case batchmsg.FieldSuccess:
  4273. v, ok := value.(int32)
  4274. if !ok {
  4275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4276. }
  4277. m.SetSuccess(v)
  4278. return nil
  4279. case batchmsg.FieldFail:
  4280. v, ok := value.(int32)
  4281. if !ok {
  4282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4283. }
  4284. m.SetFail(v)
  4285. return nil
  4286. case batchmsg.FieldStartTime:
  4287. v, ok := value.(time.Time)
  4288. if !ok {
  4289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4290. }
  4291. m.SetStartTime(v)
  4292. return nil
  4293. case batchmsg.FieldStopTime:
  4294. v, ok := value.(time.Time)
  4295. if !ok {
  4296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4297. }
  4298. m.SetStopTime(v)
  4299. return nil
  4300. case batchmsg.FieldSendTime:
  4301. v, ok := value.(time.Time)
  4302. if !ok {
  4303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4304. }
  4305. m.SetSendTime(v)
  4306. return nil
  4307. case batchmsg.FieldType:
  4308. v, ok := value.(int32)
  4309. if !ok {
  4310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4311. }
  4312. m.SetType(v)
  4313. return nil
  4314. case batchmsg.FieldOrganizationID:
  4315. v, ok := value.(uint64)
  4316. if !ok {
  4317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4318. }
  4319. m.SetOrganizationID(v)
  4320. return nil
  4321. }
  4322. return fmt.Errorf("unknown BatchMsg field %s", name)
  4323. }
  4324. // AddedFields returns all numeric fields that were incremented/decremented during
  4325. // this mutation.
  4326. func (m *BatchMsgMutation) AddedFields() []string {
  4327. var fields []string
  4328. if m.addstatus != nil {
  4329. fields = append(fields, batchmsg.FieldStatus)
  4330. }
  4331. if m.addtotal != nil {
  4332. fields = append(fields, batchmsg.FieldTotal)
  4333. }
  4334. if m.addsuccess != nil {
  4335. fields = append(fields, batchmsg.FieldSuccess)
  4336. }
  4337. if m.addfail != nil {
  4338. fields = append(fields, batchmsg.FieldFail)
  4339. }
  4340. if m.add_type != nil {
  4341. fields = append(fields, batchmsg.FieldType)
  4342. }
  4343. if m.addorganization_id != nil {
  4344. fields = append(fields, batchmsg.FieldOrganizationID)
  4345. }
  4346. return fields
  4347. }
  4348. // AddedField returns the numeric value that was incremented/decremented on a field
  4349. // with the given name. The second boolean return value indicates that this field
  4350. // was not set, or was not defined in the schema.
  4351. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4352. switch name {
  4353. case batchmsg.FieldStatus:
  4354. return m.AddedStatus()
  4355. case batchmsg.FieldTotal:
  4356. return m.AddedTotal()
  4357. case batchmsg.FieldSuccess:
  4358. return m.AddedSuccess()
  4359. case batchmsg.FieldFail:
  4360. return m.AddedFail()
  4361. case batchmsg.FieldType:
  4362. return m.AddedType()
  4363. case batchmsg.FieldOrganizationID:
  4364. return m.AddedOrganizationID()
  4365. }
  4366. return nil, false
  4367. }
  4368. // AddField adds the value to the field with the given name. It returns an error if
  4369. // the field is not defined in the schema, or if the type mismatched the field
  4370. // type.
  4371. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4372. switch name {
  4373. case batchmsg.FieldStatus:
  4374. v, ok := value.(int8)
  4375. if !ok {
  4376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4377. }
  4378. m.AddStatus(v)
  4379. return nil
  4380. case batchmsg.FieldTotal:
  4381. v, ok := value.(int32)
  4382. if !ok {
  4383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4384. }
  4385. m.AddTotal(v)
  4386. return nil
  4387. case batchmsg.FieldSuccess:
  4388. v, ok := value.(int32)
  4389. if !ok {
  4390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4391. }
  4392. m.AddSuccess(v)
  4393. return nil
  4394. case batchmsg.FieldFail:
  4395. v, ok := value.(int32)
  4396. if !ok {
  4397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4398. }
  4399. m.AddFail(v)
  4400. return nil
  4401. case batchmsg.FieldType:
  4402. v, ok := value.(int32)
  4403. if !ok {
  4404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4405. }
  4406. m.AddType(v)
  4407. return nil
  4408. case batchmsg.FieldOrganizationID:
  4409. v, ok := value.(int64)
  4410. if !ok {
  4411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4412. }
  4413. m.AddOrganizationID(v)
  4414. return nil
  4415. }
  4416. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4417. }
  4418. // ClearedFields returns all nullable fields that were cleared during this
  4419. // mutation.
  4420. func (m *BatchMsgMutation) ClearedFields() []string {
  4421. var fields []string
  4422. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4423. fields = append(fields, batchmsg.FieldDeletedAt)
  4424. }
  4425. if m.FieldCleared(batchmsg.FieldStatus) {
  4426. fields = append(fields, batchmsg.FieldStatus)
  4427. }
  4428. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4429. fields = append(fields, batchmsg.FieldBatchNo)
  4430. }
  4431. if m.FieldCleared(batchmsg.FieldTaskName) {
  4432. fields = append(fields, batchmsg.FieldTaskName)
  4433. }
  4434. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4435. fields = append(fields, batchmsg.FieldFromwxid)
  4436. }
  4437. if m.FieldCleared(batchmsg.FieldMsg) {
  4438. fields = append(fields, batchmsg.FieldMsg)
  4439. }
  4440. if m.FieldCleared(batchmsg.FieldTag) {
  4441. fields = append(fields, batchmsg.FieldTag)
  4442. }
  4443. if m.FieldCleared(batchmsg.FieldTagids) {
  4444. fields = append(fields, batchmsg.FieldTagids)
  4445. }
  4446. if m.FieldCleared(batchmsg.FieldTotal) {
  4447. fields = append(fields, batchmsg.FieldTotal)
  4448. }
  4449. if m.FieldCleared(batchmsg.FieldSuccess) {
  4450. fields = append(fields, batchmsg.FieldSuccess)
  4451. }
  4452. if m.FieldCleared(batchmsg.FieldFail) {
  4453. fields = append(fields, batchmsg.FieldFail)
  4454. }
  4455. if m.FieldCleared(batchmsg.FieldStartTime) {
  4456. fields = append(fields, batchmsg.FieldStartTime)
  4457. }
  4458. if m.FieldCleared(batchmsg.FieldStopTime) {
  4459. fields = append(fields, batchmsg.FieldStopTime)
  4460. }
  4461. if m.FieldCleared(batchmsg.FieldSendTime) {
  4462. fields = append(fields, batchmsg.FieldSendTime)
  4463. }
  4464. if m.FieldCleared(batchmsg.FieldType) {
  4465. fields = append(fields, batchmsg.FieldType)
  4466. }
  4467. return fields
  4468. }
  4469. // FieldCleared returns a boolean indicating if a field with the given name was
  4470. // cleared in this mutation.
  4471. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4472. _, ok := m.clearedFields[name]
  4473. return ok
  4474. }
  4475. // ClearField clears the value of the field with the given name. It returns an
  4476. // error if the field is not defined in the schema.
  4477. func (m *BatchMsgMutation) ClearField(name string) error {
  4478. switch name {
  4479. case batchmsg.FieldDeletedAt:
  4480. m.ClearDeletedAt()
  4481. return nil
  4482. case batchmsg.FieldStatus:
  4483. m.ClearStatus()
  4484. return nil
  4485. case batchmsg.FieldBatchNo:
  4486. m.ClearBatchNo()
  4487. return nil
  4488. case batchmsg.FieldTaskName:
  4489. m.ClearTaskName()
  4490. return nil
  4491. case batchmsg.FieldFromwxid:
  4492. m.ClearFromwxid()
  4493. return nil
  4494. case batchmsg.FieldMsg:
  4495. m.ClearMsg()
  4496. return nil
  4497. case batchmsg.FieldTag:
  4498. m.ClearTag()
  4499. return nil
  4500. case batchmsg.FieldTagids:
  4501. m.ClearTagids()
  4502. return nil
  4503. case batchmsg.FieldTotal:
  4504. m.ClearTotal()
  4505. return nil
  4506. case batchmsg.FieldSuccess:
  4507. m.ClearSuccess()
  4508. return nil
  4509. case batchmsg.FieldFail:
  4510. m.ClearFail()
  4511. return nil
  4512. case batchmsg.FieldStartTime:
  4513. m.ClearStartTime()
  4514. return nil
  4515. case batchmsg.FieldStopTime:
  4516. m.ClearStopTime()
  4517. return nil
  4518. case batchmsg.FieldSendTime:
  4519. m.ClearSendTime()
  4520. return nil
  4521. case batchmsg.FieldType:
  4522. m.ClearType()
  4523. return nil
  4524. }
  4525. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4526. }
  4527. // ResetField resets all changes in the mutation for the field with the given name.
  4528. // It returns an error if the field is not defined in the schema.
  4529. func (m *BatchMsgMutation) ResetField(name string) error {
  4530. switch name {
  4531. case batchmsg.FieldCreatedAt:
  4532. m.ResetCreatedAt()
  4533. return nil
  4534. case batchmsg.FieldUpdatedAt:
  4535. m.ResetUpdatedAt()
  4536. return nil
  4537. case batchmsg.FieldDeletedAt:
  4538. m.ResetDeletedAt()
  4539. return nil
  4540. case batchmsg.FieldStatus:
  4541. m.ResetStatus()
  4542. return nil
  4543. case batchmsg.FieldBatchNo:
  4544. m.ResetBatchNo()
  4545. return nil
  4546. case batchmsg.FieldTaskName:
  4547. m.ResetTaskName()
  4548. return nil
  4549. case batchmsg.FieldFromwxid:
  4550. m.ResetFromwxid()
  4551. return nil
  4552. case batchmsg.FieldMsg:
  4553. m.ResetMsg()
  4554. return nil
  4555. case batchmsg.FieldTag:
  4556. m.ResetTag()
  4557. return nil
  4558. case batchmsg.FieldTagids:
  4559. m.ResetTagids()
  4560. return nil
  4561. case batchmsg.FieldTotal:
  4562. m.ResetTotal()
  4563. return nil
  4564. case batchmsg.FieldSuccess:
  4565. m.ResetSuccess()
  4566. return nil
  4567. case batchmsg.FieldFail:
  4568. m.ResetFail()
  4569. return nil
  4570. case batchmsg.FieldStartTime:
  4571. m.ResetStartTime()
  4572. return nil
  4573. case batchmsg.FieldStopTime:
  4574. m.ResetStopTime()
  4575. return nil
  4576. case batchmsg.FieldSendTime:
  4577. m.ResetSendTime()
  4578. return nil
  4579. case batchmsg.FieldType:
  4580. m.ResetType()
  4581. return nil
  4582. case batchmsg.FieldOrganizationID:
  4583. m.ResetOrganizationID()
  4584. return nil
  4585. }
  4586. return fmt.Errorf("unknown BatchMsg field %s", name)
  4587. }
  4588. // AddedEdges returns all edge names that were set/added in this mutation.
  4589. func (m *BatchMsgMutation) AddedEdges() []string {
  4590. edges := make([]string, 0, 0)
  4591. return edges
  4592. }
  4593. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4594. // name in this mutation.
  4595. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4596. return nil
  4597. }
  4598. // RemovedEdges returns all edge names that were removed in this mutation.
  4599. func (m *BatchMsgMutation) RemovedEdges() []string {
  4600. edges := make([]string, 0, 0)
  4601. return edges
  4602. }
  4603. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4604. // the given name in this mutation.
  4605. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4606. return nil
  4607. }
  4608. // ClearedEdges returns all edge names that were cleared in this mutation.
  4609. func (m *BatchMsgMutation) ClearedEdges() []string {
  4610. edges := make([]string, 0, 0)
  4611. return edges
  4612. }
  4613. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4614. // was cleared in this mutation.
  4615. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4616. return false
  4617. }
  4618. // ClearEdge clears the value of the edge with the given name. It returns an error
  4619. // if that edge is not defined in the schema.
  4620. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4621. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4622. }
  4623. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4624. // It returns an error if the edge is not defined in the schema.
  4625. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4626. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4627. }
  4628. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4629. type CategoryMutation struct {
  4630. config
  4631. op Op
  4632. typ string
  4633. id *uint64
  4634. created_at *time.Time
  4635. updated_at *time.Time
  4636. deleted_at *time.Time
  4637. name *string
  4638. organization_id *uint64
  4639. addorganization_id *int64
  4640. clearedFields map[string]struct{}
  4641. done bool
  4642. oldValue func(context.Context) (*Category, error)
  4643. predicates []predicate.Category
  4644. }
  4645. var _ ent.Mutation = (*CategoryMutation)(nil)
  4646. // categoryOption allows management of the mutation configuration using functional options.
  4647. type categoryOption func(*CategoryMutation)
  4648. // newCategoryMutation creates new mutation for the Category entity.
  4649. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4650. m := &CategoryMutation{
  4651. config: c,
  4652. op: op,
  4653. typ: TypeCategory,
  4654. clearedFields: make(map[string]struct{}),
  4655. }
  4656. for _, opt := range opts {
  4657. opt(m)
  4658. }
  4659. return m
  4660. }
  4661. // withCategoryID sets the ID field of the mutation.
  4662. func withCategoryID(id uint64) categoryOption {
  4663. return func(m *CategoryMutation) {
  4664. var (
  4665. err error
  4666. once sync.Once
  4667. value *Category
  4668. )
  4669. m.oldValue = func(ctx context.Context) (*Category, error) {
  4670. once.Do(func() {
  4671. if m.done {
  4672. err = errors.New("querying old values post mutation is not allowed")
  4673. } else {
  4674. value, err = m.Client().Category.Get(ctx, id)
  4675. }
  4676. })
  4677. return value, err
  4678. }
  4679. m.id = &id
  4680. }
  4681. }
  4682. // withCategory sets the old Category of the mutation.
  4683. func withCategory(node *Category) categoryOption {
  4684. return func(m *CategoryMutation) {
  4685. m.oldValue = func(context.Context) (*Category, error) {
  4686. return node, nil
  4687. }
  4688. m.id = &node.ID
  4689. }
  4690. }
  4691. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4692. // executed in a transaction (ent.Tx), a transactional client is returned.
  4693. func (m CategoryMutation) Client() *Client {
  4694. client := &Client{config: m.config}
  4695. client.init()
  4696. return client
  4697. }
  4698. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4699. // it returns an error otherwise.
  4700. func (m CategoryMutation) Tx() (*Tx, error) {
  4701. if _, ok := m.driver.(*txDriver); !ok {
  4702. return nil, errors.New("ent: mutation is not running in a transaction")
  4703. }
  4704. tx := &Tx{config: m.config}
  4705. tx.init()
  4706. return tx, nil
  4707. }
  4708. // SetID sets the value of the id field. Note that this
  4709. // operation is only accepted on creation of Category entities.
  4710. func (m *CategoryMutation) SetID(id uint64) {
  4711. m.id = &id
  4712. }
  4713. // ID returns the ID value in the mutation. Note that the ID is only available
  4714. // if it was provided to the builder or after it was returned from the database.
  4715. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4716. if m.id == nil {
  4717. return
  4718. }
  4719. return *m.id, true
  4720. }
  4721. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4722. // That means, if the mutation is applied within a transaction with an isolation level such
  4723. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4724. // or updated by the mutation.
  4725. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4726. switch {
  4727. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4728. id, exists := m.ID()
  4729. if exists {
  4730. return []uint64{id}, nil
  4731. }
  4732. fallthrough
  4733. case m.op.Is(OpUpdate | OpDelete):
  4734. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4735. default:
  4736. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4737. }
  4738. }
  4739. // SetCreatedAt sets the "created_at" field.
  4740. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4741. m.created_at = &t
  4742. }
  4743. // CreatedAt returns the value of the "created_at" field in the mutation.
  4744. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4745. v := m.created_at
  4746. if v == nil {
  4747. return
  4748. }
  4749. return *v, true
  4750. }
  4751. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4752. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4754. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4755. if !m.op.Is(OpUpdateOne) {
  4756. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4757. }
  4758. if m.id == nil || m.oldValue == nil {
  4759. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4760. }
  4761. oldValue, err := m.oldValue(ctx)
  4762. if err != nil {
  4763. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4764. }
  4765. return oldValue.CreatedAt, nil
  4766. }
  4767. // ResetCreatedAt resets all changes to the "created_at" field.
  4768. func (m *CategoryMutation) ResetCreatedAt() {
  4769. m.created_at = nil
  4770. }
  4771. // SetUpdatedAt sets the "updated_at" field.
  4772. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4773. m.updated_at = &t
  4774. }
  4775. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4776. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4777. v := m.updated_at
  4778. if v == nil {
  4779. return
  4780. }
  4781. return *v, true
  4782. }
  4783. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4784. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4786. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4787. if !m.op.Is(OpUpdateOne) {
  4788. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4789. }
  4790. if m.id == nil || m.oldValue == nil {
  4791. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4792. }
  4793. oldValue, err := m.oldValue(ctx)
  4794. if err != nil {
  4795. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4796. }
  4797. return oldValue.UpdatedAt, nil
  4798. }
  4799. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4800. func (m *CategoryMutation) ResetUpdatedAt() {
  4801. m.updated_at = nil
  4802. }
  4803. // SetDeletedAt sets the "deleted_at" field.
  4804. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4805. m.deleted_at = &t
  4806. }
  4807. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4808. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4809. v := m.deleted_at
  4810. if v == nil {
  4811. return
  4812. }
  4813. return *v, true
  4814. }
  4815. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4816. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4818. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4819. if !m.op.Is(OpUpdateOne) {
  4820. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4821. }
  4822. if m.id == nil || m.oldValue == nil {
  4823. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4824. }
  4825. oldValue, err := m.oldValue(ctx)
  4826. if err != nil {
  4827. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4828. }
  4829. return oldValue.DeletedAt, nil
  4830. }
  4831. // ClearDeletedAt clears the value of the "deleted_at" field.
  4832. func (m *CategoryMutation) ClearDeletedAt() {
  4833. m.deleted_at = nil
  4834. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4835. }
  4836. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4837. func (m *CategoryMutation) DeletedAtCleared() bool {
  4838. _, ok := m.clearedFields[category.FieldDeletedAt]
  4839. return ok
  4840. }
  4841. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4842. func (m *CategoryMutation) ResetDeletedAt() {
  4843. m.deleted_at = nil
  4844. delete(m.clearedFields, category.FieldDeletedAt)
  4845. }
  4846. // SetName sets the "name" field.
  4847. func (m *CategoryMutation) SetName(s string) {
  4848. m.name = &s
  4849. }
  4850. // Name returns the value of the "name" field in the mutation.
  4851. func (m *CategoryMutation) Name() (r string, exists bool) {
  4852. v := m.name
  4853. if v == nil {
  4854. return
  4855. }
  4856. return *v, true
  4857. }
  4858. // OldName returns the old "name" field's value of the Category entity.
  4859. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4861. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4862. if !m.op.Is(OpUpdateOne) {
  4863. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4864. }
  4865. if m.id == nil || m.oldValue == nil {
  4866. return v, errors.New("OldName requires an ID field in the mutation")
  4867. }
  4868. oldValue, err := m.oldValue(ctx)
  4869. if err != nil {
  4870. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4871. }
  4872. return oldValue.Name, nil
  4873. }
  4874. // ResetName resets all changes to the "name" field.
  4875. func (m *CategoryMutation) ResetName() {
  4876. m.name = nil
  4877. }
  4878. // SetOrganizationID sets the "organization_id" field.
  4879. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4880. m.organization_id = &u
  4881. m.addorganization_id = nil
  4882. }
  4883. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4884. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4885. v := m.organization_id
  4886. if v == nil {
  4887. return
  4888. }
  4889. return *v, true
  4890. }
  4891. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4892. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4894. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4895. if !m.op.Is(OpUpdateOne) {
  4896. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4897. }
  4898. if m.id == nil || m.oldValue == nil {
  4899. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4900. }
  4901. oldValue, err := m.oldValue(ctx)
  4902. if err != nil {
  4903. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4904. }
  4905. return oldValue.OrganizationID, nil
  4906. }
  4907. // AddOrganizationID adds u to the "organization_id" field.
  4908. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4909. if m.addorganization_id != nil {
  4910. *m.addorganization_id += u
  4911. } else {
  4912. m.addorganization_id = &u
  4913. }
  4914. }
  4915. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4916. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  4917. v := m.addorganization_id
  4918. if v == nil {
  4919. return
  4920. }
  4921. return *v, true
  4922. }
  4923. // ResetOrganizationID resets all changes to the "organization_id" field.
  4924. func (m *CategoryMutation) ResetOrganizationID() {
  4925. m.organization_id = nil
  4926. m.addorganization_id = nil
  4927. }
  4928. // Where appends a list predicates to the CategoryMutation builder.
  4929. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  4930. m.predicates = append(m.predicates, ps...)
  4931. }
  4932. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  4933. // users can use type-assertion to append predicates that do not depend on any generated package.
  4934. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  4935. p := make([]predicate.Category, len(ps))
  4936. for i := range ps {
  4937. p[i] = ps[i]
  4938. }
  4939. m.Where(p...)
  4940. }
  4941. // Op returns the operation name.
  4942. func (m *CategoryMutation) Op() Op {
  4943. return m.op
  4944. }
  4945. // SetOp allows setting the mutation operation.
  4946. func (m *CategoryMutation) SetOp(op Op) {
  4947. m.op = op
  4948. }
  4949. // Type returns the node type of this mutation (Category).
  4950. func (m *CategoryMutation) Type() string {
  4951. return m.typ
  4952. }
  4953. // Fields returns all fields that were changed during this mutation. Note that in
  4954. // order to get all numeric fields that were incremented/decremented, call
  4955. // AddedFields().
  4956. func (m *CategoryMutation) Fields() []string {
  4957. fields := make([]string, 0, 5)
  4958. if m.created_at != nil {
  4959. fields = append(fields, category.FieldCreatedAt)
  4960. }
  4961. if m.updated_at != nil {
  4962. fields = append(fields, category.FieldUpdatedAt)
  4963. }
  4964. if m.deleted_at != nil {
  4965. fields = append(fields, category.FieldDeletedAt)
  4966. }
  4967. if m.name != nil {
  4968. fields = append(fields, category.FieldName)
  4969. }
  4970. if m.organization_id != nil {
  4971. fields = append(fields, category.FieldOrganizationID)
  4972. }
  4973. return fields
  4974. }
  4975. // Field returns the value of a field with the given name. The second boolean
  4976. // return value indicates that this field was not set, or was not defined in the
  4977. // schema.
  4978. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  4979. switch name {
  4980. case category.FieldCreatedAt:
  4981. return m.CreatedAt()
  4982. case category.FieldUpdatedAt:
  4983. return m.UpdatedAt()
  4984. case category.FieldDeletedAt:
  4985. return m.DeletedAt()
  4986. case category.FieldName:
  4987. return m.Name()
  4988. case category.FieldOrganizationID:
  4989. return m.OrganizationID()
  4990. }
  4991. return nil, false
  4992. }
  4993. // OldField returns the old value of the field from the database. An error is
  4994. // returned if the mutation operation is not UpdateOne, or the query to the
  4995. // database failed.
  4996. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4997. switch name {
  4998. case category.FieldCreatedAt:
  4999. return m.OldCreatedAt(ctx)
  5000. case category.FieldUpdatedAt:
  5001. return m.OldUpdatedAt(ctx)
  5002. case category.FieldDeletedAt:
  5003. return m.OldDeletedAt(ctx)
  5004. case category.FieldName:
  5005. return m.OldName(ctx)
  5006. case category.FieldOrganizationID:
  5007. return m.OldOrganizationID(ctx)
  5008. }
  5009. return nil, fmt.Errorf("unknown Category field %s", name)
  5010. }
  5011. // SetField sets the value of a field with the given name. It returns an error if
  5012. // the field is not defined in the schema, or if the type mismatched the field
  5013. // type.
  5014. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5015. switch name {
  5016. case category.FieldCreatedAt:
  5017. v, ok := value.(time.Time)
  5018. if !ok {
  5019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5020. }
  5021. m.SetCreatedAt(v)
  5022. return nil
  5023. case category.FieldUpdatedAt:
  5024. v, ok := value.(time.Time)
  5025. if !ok {
  5026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5027. }
  5028. m.SetUpdatedAt(v)
  5029. return nil
  5030. case category.FieldDeletedAt:
  5031. v, ok := value.(time.Time)
  5032. if !ok {
  5033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5034. }
  5035. m.SetDeletedAt(v)
  5036. return nil
  5037. case category.FieldName:
  5038. v, ok := value.(string)
  5039. if !ok {
  5040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5041. }
  5042. m.SetName(v)
  5043. return nil
  5044. case category.FieldOrganizationID:
  5045. v, ok := value.(uint64)
  5046. if !ok {
  5047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5048. }
  5049. m.SetOrganizationID(v)
  5050. return nil
  5051. }
  5052. return fmt.Errorf("unknown Category field %s", name)
  5053. }
  5054. // AddedFields returns all numeric fields that were incremented/decremented during
  5055. // this mutation.
  5056. func (m *CategoryMutation) AddedFields() []string {
  5057. var fields []string
  5058. if m.addorganization_id != nil {
  5059. fields = append(fields, category.FieldOrganizationID)
  5060. }
  5061. return fields
  5062. }
  5063. // AddedField returns the numeric value that was incremented/decremented on a field
  5064. // with the given name. The second boolean return value indicates that this field
  5065. // was not set, or was not defined in the schema.
  5066. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5067. switch name {
  5068. case category.FieldOrganizationID:
  5069. return m.AddedOrganizationID()
  5070. }
  5071. return nil, false
  5072. }
  5073. // AddField adds the value to the field with the given name. It returns an error if
  5074. // the field is not defined in the schema, or if the type mismatched the field
  5075. // type.
  5076. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5077. switch name {
  5078. case category.FieldOrganizationID:
  5079. v, ok := value.(int64)
  5080. if !ok {
  5081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5082. }
  5083. m.AddOrganizationID(v)
  5084. return nil
  5085. }
  5086. return fmt.Errorf("unknown Category numeric field %s", name)
  5087. }
  5088. // ClearedFields returns all nullable fields that were cleared during this
  5089. // mutation.
  5090. func (m *CategoryMutation) ClearedFields() []string {
  5091. var fields []string
  5092. if m.FieldCleared(category.FieldDeletedAt) {
  5093. fields = append(fields, category.FieldDeletedAt)
  5094. }
  5095. return fields
  5096. }
  5097. // FieldCleared returns a boolean indicating if a field with the given name was
  5098. // cleared in this mutation.
  5099. func (m *CategoryMutation) FieldCleared(name string) bool {
  5100. _, ok := m.clearedFields[name]
  5101. return ok
  5102. }
  5103. // ClearField clears the value of the field with the given name. It returns an
  5104. // error if the field is not defined in the schema.
  5105. func (m *CategoryMutation) ClearField(name string) error {
  5106. switch name {
  5107. case category.FieldDeletedAt:
  5108. m.ClearDeletedAt()
  5109. return nil
  5110. }
  5111. return fmt.Errorf("unknown Category nullable field %s", name)
  5112. }
  5113. // ResetField resets all changes in the mutation for the field with the given name.
  5114. // It returns an error if the field is not defined in the schema.
  5115. func (m *CategoryMutation) ResetField(name string) error {
  5116. switch name {
  5117. case category.FieldCreatedAt:
  5118. m.ResetCreatedAt()
  5119. return nil
  5120. case category.FieldUpdatedAt:
  5121. m.ResetUpdatedAt()
  5122. return nil
  5123. case category.FieldDeletedAt:
  5124. m.ResetDeletedAt()
  5125. return nil
  5126. case category.FieldName:
  5127. m.ResetName()
  5128. return nil
  5129. case category.FieldOrganizationID:
  5130. m.ResetOrganizationID()
  5131. return nil
  5132. }
  5133. return fmt.Errorf("unknown Category field %s", name)
  5134. }
  5135. // AddedEdges returns all edge names that were set/added in this mutation.
  5136. func (m *CategoryMutation) AddedEdges() []string {
  5137. edges := make([]string, 0, 0)
  5138. return edges
  5139. }
  5140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5141. // name in this mutation.
  5142. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5143. return nil
  5144. }
  5145. // RemovedEdges returns all edge names that were removed in this mutation.
  5146. func (m *CategoryMutation) RemovedEdges() []string {
  5147. edges := make([]string, 0, 0)
  5148. return edges
  5149. }
  5150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5151. // the given name in this mutation.
  5152. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5153. return nil
  5154. }
  5155. // ClearedEdges returns all edge names that were cleared in this mutation.
  5156. func (m *CategoryMutation) ClearedEdges() []string {
  5157. edges := make([]string, 0, 0)
  5158. return edges
  5159. }
  5160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5161. // was cleared in this mutation.
  5162. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5163. return false
  5164. }
  5165. // ClearEdge clears the value of the edge with the given name. It returns an error
  5166. // if that edge is not defined in the schema.
  5167. func (m *CategoryMutation) ClearEdge(name string) error {
  5168. return fmt.Errorf("unknown Category unique edge %s", name)
  5169. }
  5170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5171. // It returns an error if the edge is not defined in the schema.
  5172. func (m *CategoryMutation) ResetEdge(name string) error {
  5173. return fmt.Errorf("unknown Category edge %s", name)
  5174. }
  5175. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5176. type ChatRecordsMutation struct {
  5177. config
  5178. op Op
  5179. typ string
  5180. id *uint64
  5181. created_at *time.Time
  5182. updated_at *time.Time
  5183. deleted_at *time.Time
  5184. content *string
  5185. content_type *uint8
  5186. addcontent_type *int8
  5187. session_id *uint64
  5188. addsession_id *int64
  5189. user_id *uint64
  5190. adduser_id *int64
  5191. bot_id *uint64
  5192. addbot_id *int64
  5193. bot_type *uint8
  5194. addbot_type *int8
  5195. clearedFields map[string]struct{}
  5196. done bool
  5197. oldValue func(context.Context) (*ChatRecords, error)
  5198. predicates []predicate.ChatRecords
  5199. }
  5200. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5201. // chatrecordsOption allows management of the mutation configuration using functional options.
  5202. type chatrecordsOption func(*ChatRecordsMutation)
  5203. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5204. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5205. m := &ChatRecordsMutation{
  5206. config: c,
  5207. op: op,
  5208. typ: TypeChatRecords,
  5209. clearedFields: make(map[string]struct{}),
  5210. }
  5211. for _, opt := range opts {
  5212. opt(m)
  5213. }
  5214. return m
  5215. }
  5216. // withChatRecordsID sets the ID field of the mutation.
  5217. func withChatRecordsID(id uint64) chatrecordsOption {
  5218. return func(m *ChatRecordsMutation) {
  5219. var (
  5220. err error
  5221. once sync.Once
  5222. value *ChatRecords
  5223. )
  5224. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5225. once.Do(func() {
  5226. if m.done {
  5227. err = errors.New("querying old values post mutation is not allowed")
  5228. } else {
  5229. value, err = m.Client().ChatRecords.Get(ctx, id)
  5230. }
  5231. })
  5232. return value, err
  5233. }
  5234. m.id = &id
  5235. }
  5236. }
  5237. // withChatRecords sets the old ChatRecords of the mutation.
  5238. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5239. return func(m *ChatRecordsMutation) {
  5240. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5241. return node, nil
  5242. }
  5243. m.id = &node.ID
  5244. }
  5245. }
  5246. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5247. // executed in a transaction (ent.Tx), a transactional client is returned.
  5248. func (m ChatRecordsMutation) Client() *Client {
  5249. client := &Client{config: m.config}
  5250. client.init()
  5251. return client
  5252. }
  5253. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5254. // it returns an error otherwise.
  5255. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5256. if _, ok := m.driver.(*txDriver); !ok {
  5257. return nil, errors.New("ent: mutation is not running in a transaction")
  5258. }
  5259. tx := &Tx{config: m.config}
  5260. tx.init()
  5261. return tx, nil
  5262. }
  5263. // SetID sets the value of the id field. Note that this
  5264. // operation is only accepted on creation of ChatRecords entities.
  5265. func (m *ChatRecordsMutation) SetID(id uint64) {
  5266. m.id = &id
  5267. }
  5268. // ID returns the ID value in the mutation. Note that the ID is only available
  5269. // if it was provided to the builder or after it was returned from the database.
  5270. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5271. if m.id == nil {
  5272. return
  5273. }
  5274. return *m.id, true
  5275. }
  5276. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5277. // That means, if the mutation is applied within a transaction with an isolation level such
  5278. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5279. // or updated by the mutation.
  5280. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5281. switch {
  5282. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5283. id, exists := m.ID()
  5284. if exists {
  5285. return []uint64{id}, nil
  5286. }
  5287. fallthrough
  5288. case m.op.Is(OpUpdate | OpDelete):
  5289. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5290. default:
  5291. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5292. }
  5293. }
  5294. // SetCreatedAt sets the "created_at" field.
  5295. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5296. m.created_at = &t
  5297. }
  5298. // CreatedAt returns the value of the "created_at" field in the mutation.
  5299. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5300. v := m.created_at
  5301. if v == nil {
  5302. return
  5303. }
  5304. return *v, true
  5305. }
  5306. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5307. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5309. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5310. if !m.op.Is(OpUpdateOne) {
  5311. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5312. }
  5313. if m.id == nil || m.oldValue == nil {
  5314. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5315. }
  5316. oldValue, err := m.oldValue(ctx)
  5317. if err != nil {
  5318. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5319. }
  5320. return oldValue.CreatedAt, nil
  5321. }
  5322. // ResetCreatedAt resets all changes to the "created_at" field.
  5323. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5324. m.created_at = nil
  5325. }
  5326. // SetUpdatedAt sets the "updated_at" field.
  5327. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5328. m.updated_at = &t
  5329. }
  5330. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5331. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5332. v := m.updated_at
  5333. if v == nil {
  5334. return
  5335. }
  5336. return *v, true
  5337. }
  5338. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5339. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5341. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5342. if !m.op.Is(OpUpdateOne) {
  5343. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5344. }
  5345. if m.id == nil || m.oldValue == nil {
  5346. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5347. }
  5348. oldValue, err := m.oldValue(ctx)
  5349. if err != nil {
  5350. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5351. }
  5352. return oldValue.UpdatedAt, nil
  5353. }
  5354. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5355. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5356. m.updated_at = nil
  5357. }
  5358. // SetDeletedAt sets the "deleted_at" field.
  5359. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5360. m.deleted_at = &t
  5361. }
  5362. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5363. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5364. v := m.deleted_at
  5365. if v == nil {
  5366. return
  5367. }
  5368. return *v, true
  5369. }
  5370. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5371. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5373. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5374. if !m.op.Is(OpUpdateOne) {
  5375. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5376. }
  5377. if m.id == nil || m.oldValue == nil {
  5378. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5379. }
  5380. oldValue, err := m.oldValue(ctx)
  5381. if err != nil {
  5382. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5383. }
  5384. return oldValue.DeletedAt, nil
  5385. }
  5386. // ClearDeletedAt clears the value of the "deleted_at" field.
  5387. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5388. m.deleted_at = nil
  5389. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5390. }
  5391. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5392. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5393. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5394. return ok
  5395. }
  5396. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5397. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5398. m.deleted_at = nil
  5399. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5400. }
  5401. // SetContent sets the "content" field.
  5402. func (m *ChatRecordsMutation) SetContent(s string) {
  5403. m.content = &s
  5404. }
  5405. // Content returns the value of the "content" field in the mutation.
  5406. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5407. v := m.content
  5408. if v == nil {
  5409. return
  5410. }
  5411. return *v, true
  5412. }
  5413. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5414. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5416. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5417. if !m.op.Is(OpUpdateOne) {
  5418. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5419. }
  5420. if m.id == nil || m.oldValue == nil {
  5421. return v, errors.New("OldContent requires an ID field in the mutation")
  5422. }
  5423. oldValue, err := m.oldValue(ctx)
  5424. if err != nil {
  5425. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5426. }
  5427. return oldValue.Content, nil
  5428. }
  5429. // ResetContent resets all changes to the "content" field.
  5430. func (m *ChatRecordsMutation) ResetContent() {
  5431. m.content = nil
  5432. }
  5433. // SetContentType sets the "content_type" field.
  5434. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5435. m.content_type = &u
  5436. m.addcontent_type = nil
  5437. }
  5438. // ContentType returns the value of the "content_type" field in the mutation.
  5439. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5440. v := m.content_type
  5441. if v == nil {
  5442. return
  5443. }
  5444. return *v, true
  5445. }
  5446. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5447. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5449. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5450. if !m.op.Is(OpUpdateOne) {
  5451. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5452. }
  5453. if m.id == nil || m.oldValue == nil {
  5454. return v, errors.New("OldContentType requires an ID field in the mutation")
  5455. }
  5456. oldValue, err := m.oldValue(ctx)
  5457. if err != nil {
  5458. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5459. }
  5460. return oldValue.ContentType, nil
  5461. }
  5462. // AddContentType adds u to the "content_type" field.
  5463. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5464. if m.addcontent_type != nil {
  5465. *m.addcontent_type += u
  5466. } else {
  5467. m.addcontent_type = &u
  5468. }
  5469. }
  5470. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5471. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5472. v := m.addcontent_type
  5473. if v == nil {
  5474. return
  5475. }
  5476. return *v, true
  5477. }
  5478. // ResetContentType resets all changes to the "content_type" field.
  5479. func (m *ChatRecordsMutation) ResetContentType() {
  5480. m.content_type = nil
  5481. m.addcontent_type = nil
  5482. }
  5483. // SetSessionID sets the "session_id" field.
  5484. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5485. m.session_id = &u
  5486. m.addsession_id = nil
  5487. }
  5488. // SessionID returns the value of the "session_id" field in the mutation.
  5489. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5490. v := m.session_id
  5491. if v == nil {
  5492. return
  5493. }
  5494. return *v, true
  5495. }
  5496. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5497. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5499. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5500. if !m.op.Is(OpUpdateOne) {
  5501. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5502. }
  5503. if m.id == nil || m.oldValue == nil {
  5504. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5505. }
  5506. oldValue, err := m.oldValue(ctx)
  5507. if err != nil {
  5508. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5509. }
  5510. return oldValue.SessionID, nil
  5511. }
  5512. // AddSessionID adds u to the "session_id" field.
  5513. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5514. if m.addsession_id != nil {
  5515. *m.addsession_id += u
  5516. } else {
  5517. m.addsession_id = &u
  5518. }
  5519. }
  5520. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5521. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5522. v := m.addsession_id
  5523. if v == nil {
  5524. return
  5525. }
  5526. return *v, true
  5527. }
  5528. // ResetSessionID resets all changes to the "session_id" field.
  5529. func (m *ChatRecordsMutation) ResetSessionID() {
  5530. m.session_id = nil
  5531. m.addsession_id = nil
  5532. }
  5533. // SetUserID sets the "user_id" field.
  5534. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5535. m.user_id = &u
  5536. m.adduser_id = nil
  5537. }
  5538. // UserID returns the value of the "user_id" field in the mutation.
  5539. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5540. v := m.user_id
  5541. if v == nil {
  5542. return
  5543. }
  5544. return *v, true
  5545. }
  5546. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5547. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5549. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5550. if !m.op.Is(OpUpdateOne) {
  5551. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5552. }
  5553. if m.id == nil || m.oldValue == nil {
  5554. return v, errors.New("OldUserID requires an ID field in the mutation")
  5555. }
  5556. oldValue, err := m.oldValue(ctx)
  5557. if err != nil {
  5558. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5559. }
  5560. return oldValue.UserID, nil
  5561. }
  5562. // AddUserID adds u to the "user_id" field.
  5563. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5564. if m.adduser_id != nil {
  5565. *m.adduser_id += u
  5566. } else {
  5567. m.adduser_id = &u
  5568. }
  5569. }
  5570. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5571. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5572. v := m.adduser_id
  5573. if v == nil {
  5574. return
  5575. }
  5576. return *v, true
  5577. }
  5578. // ResetUserID resets all changes to the "user_id" field.
  5579. func (m *ChatRecordsMutation) ResetUserID() {
  5580. m.user_id = nil
  5581. m.adduser_id = nil
  5582. }
  5583. // SetBotID sets the "bot_id" field.
  5584. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5585. m.bot_id = &u
  5586. m.addbot_id = nil
  5587. }
  5588. // BotID returns the value of the "bot_id" field in the mutation.
  5589. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5590. v := m.bot_id
  5591. if v == nil {
  5592. return
  5593. }
  5594. return *v, true
  5595. }
  5596. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5597. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5599. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5600. if !m.op.Is(OpUpdateOne) {
  5601. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5602. }
  5603. if m.id == nil || m.oldValue == nil {
  5604. return v, errors.New("OldBotID requires an ID field in the mutation")
  5605. }
  5606. oldValue, err := m.oldValue(ctx)
  5607. if err != nil {
  5608. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5609. }
  5610. return oldValue.BotID, nil
  5611. }
  5612. // AddBotID adds u to the "bot_id" field.
  5613. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5614. if m.addbot_id != nil {
  5615. *m.addbot_id += u
  5616. } else {
  5617. m.addbot_id = &u
  5618. }
  5619. }
  5620. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5621. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5622. v := m.addbot_id
  5623. if v == nil {
  5624. return
  5625. }
  5626. return *v, true
  5627. }
  5628. // ResetBotID resets all changes to the "bot_id" field.
  5629. func (m *ChatRecordsMutation) ResetBotID() {
  5630. m.bot_id = nil
  5631. m.addbot_id = nil
  5632. }
  5633. // SetBotType sets the "bot_type" field.
  5634. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5635. m.bot_type = &u
  5636. m.addbot_type = nil
  5637. }
  5638. // BotType returns the value of the "bot_type" field in the mutation.
  5639. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5640. v := m.bot_type
  5641. if v == nil {
  5642. return
  5643. }
  5644. return *v, true
  5645. }
  5646. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5647. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5649. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5650. if !m.op.Is(OpUpdateOne) {
  5651. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5652. }
  5653. if m.id == nil || m.oldValue == nil {
  5654. return v, errors.New("OldBotType requires an ID field in the mutation")
  5655. }
  5656. oldValue, err := m.oldValue(ctx)
  5657. if err != nil {
  5658. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5659. }
  5660. return oldValue.BotType, nil
  5661. }
  5662. // AddBotType adds u to the "bot_type" field.
  5663. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5664. if m.addbot_type != nil {
  5665. *m.addbot_type += u
  5666. } else {
  5667. m.addbot_type = &u
  5668. }
  5669. }
  5670. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5671. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5672. v := m.addbot_type
  5673. if v == nil {
  5674. return
  5675. }
  5676. return *v, true
  5677. }
  5678. // ResetBotType resets all changes to the "bot_type" field.
  5679. func (m *ChatRecordsMutation) ResetBotType() {
  5680. m.bot_type = nil
  5681. m.addbot_type = nil
  5682. }
  5683. // Where appends a list predicates to the ChatRecordsMutation builder.
  5684. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5685. m.predicates = append(m.predicates, ps...)
  5686. }
  5687. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5688. // users can use type-assertion to append predicates that do not depend on any generated package.
  5689. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5690. p := make([]predicate.ChatRecords, len(ps))
  5691. for i := range ps {
  5692. p[i] = ps[i]
  5693. }
  5694. m.Where(p...)
  5695. }
  5696. // Op returns the operation name.
  5697. func (m *ChatRecordsMutation) Op() Op {
  5698. return m.op
  5699. }
  5700. // SetOp allows setting the mutation operation.
  5701. func (m *ChatRecordsMutation) SetOp(op Op) {
  5702. m.op = op
  5703. }
  5704. // Type returns the node type of this mutation (ChatRecords).
  5705. func (m *ChatRecordsMutation) Type() string {
  5706. return m.typ
  5707. }
  5708. // Fields returns all fields that were changed during this mutation. Note that in
  5709. // order to get all numeric fields that were incremented/decremented, call
  5710. // AddedFields().
  5711. func (m *ChatRecordsMutation) Fields() []string {
  5712. fields := make([]string, 0, 9)
  5713. if m.created_at != nil {
  5714. fields = append(fields, chatrecords.FieldCreatedAt)
  5715. }
  5716. if m.updated_at != nil {
  5717. fields = append(fields, chatrecords.FieldUpdatedAt)
  5718. }
  5719. if m.deleted_at != nil {
  5720. fields = append(fields, chatrecords.FieldDeletedAt)
  5721. }
  5722. if m.content != nil {
  5723. fields = append(fields, chatrecords.FieldContent)
  5724. }
  5725. if m.content_type != nil {
  5726. fields = append(fields, chatrecords.FieldContentType)
  5727. }
  5728. if m.session_id != nil {
  5729. fields = append(fields, chatrecords.FieldSessionID)
  5730. }
  5731. if m.user_id != nil {
  5732. fields = append(fields, chatrecords.FieldUserID)
  5733. }
  5734. if m.bot_id != nil {
  5735. fields = append(fields, chatrecords.FieldBotID)
  5736. }
  5737. if m.bot_type != nil {
  5738. fields = append(fields, chatrecords.FieldBotType)
  5739. }
  5740. return fields
  5741. }
  5742. // Field returns the value of a field with the given name. The second boolean
  5743. // return value indicates that this field was not set, or was not defined in the
  5744. // schema.
  5745. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5746. switch name {
  5747. case chatrecords.FieldCreatedAt:
  5748. return m.CreatedAt()
  5749. case chatrecords.FieldUpdatedAt:
  5750. return m.UpdatedAt()
  5751. case chatrecords.FieldDeletedAt:
  5752. return m.DeletedAt()
  5753. case chatrecords.FieldContent:
  5754. return m.Content()
  5755. case chatrecords.FieldContentType:
  5756. return m.ContentType()
  5757. case chatrecords.FieldSessionID:
  5758. return m.SessionID()
  5759. case chatrecords.FieldUserID:
  5760. return m.UserID()
  5761. case chatrecords.FieldBotID:
  5762. return m.BotID()
  5763. case chatrecords.FieldBotType:
  5764. return m.BotType()
  5765. }
  5766. return nil, false
  5767. }
  5768. // OldField returns the old value of the field from the database. An error is
  5769. // returned if the mutation operation is not UpdateOne, or the query to the
  5770. // database failed.
  5771. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5772. switch name {
  5773. case chatrecords.FieldCreatedAt:
  5774. return m.OldCreatedAt(ctx)
  5775. case chatrecords.FieldUpdatedAt:
  5776. return m.OldUpdatedAt(ctx)
  5777. case chatrecords.FieldDeletedAt:
  5778. return m.OldDeletedAt(ctx)
  5779. case chatrecords.FieldContent:
  5780. return m.OldContent(ctx)
  5781. case chatrecords.FieldContentType:
  5782. return m.OldContentType(ctx)
  5783. case chatrecords.FieldSessionID:
  5784. return m.OldSessionID(ctx)
  5785. case chatrecords.FieldUserID:
  5786. return m.OldUserID(ctx)
  5787. case chatrecords.FieldBotID:
  5788. return m.OldBotID(ctx)
  5789. case chatrecords.FieldBotType:
  5790. return m.OldBotType(ctx)
  5791. }
  5792. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5793. }
  5794. // SetField sets the value of a field with the given name. It returns an error if
  5795. // the field is not defined in the schema, or if the type mismatched the field
  5796. // type.
  5797. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5798. switch name {
  5799. case chatrecords.FieldCreatedAt:
  5800. v, ok := value.(time.Time)
  5801. if !ok {
  5802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5803. }
  5804. m.SetCreatedAt(v)
  5805. return nil
  5806. case chatrecords.FieldUpdatedAt:
  5807. v, ok := value.(time.Time)
  5808. if !ok {
  5809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5810. }
  5811. m.SetUpdatedAt(v)
  5812. return nil
  5813. case chatrecords.FieldDeletedAt:
  5814. v, ok := value.(time.Time)
  5815. if !ok {
  5816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5817. }
  5818. m.SetDeletedAt(v)
  5819. return nil
  5820. case chatrecords.FieldContent:
  5821. v, ok := value.(string)
  5822. if !ok {
  5823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5824. }
  5825. m.SetContent(v)
  5826. return nil
  5827. case chatrecords.FieldContentType:
  5828. v, ok := value.(uint8)
  5829. if !ok {
  5830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5831. }
  5832. m.SetContentType(v)
  5833. return nil
  5834. case chatrecords.FieldSessionID:
  5835. v, ok := value.(uint64)
  5836. if !ok {
  5837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5838. }
  5839. m.SetSessionID(v)
  5840. return nil
  5841. case chatrecords.FieldUserID:
  5842. v, ok := value.(uint64)
  5843. if !ok {
  5844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5845. }
  5846. m.SetUserID(v)
  5847. return nil
  5848. case chatrecords.FieldBotID:
  5849. v, ok := value.(uint64)
  5850. if !ok {
  5851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5852. }
  5853. m.SetBotID(v)
  5854. return nil
  5855. case chatrecords.FieldBotType:
  5856. v, ok := value.(uint8)
  5857. if !ok {
  5858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5859. }
  5860. m.SetBotType(v)
  5861. return nil
  5862. }
  5863. return fmt.Errorf("unknown ChatRecords field %s", name)
  5864. }
  5865. // AddedFields returns all numeric fields that were incremented/decremented during
  5866. // this mutation.
  5867. func (m *ChatRecordsMutation) AddedFields() []string {
  5868. var fields []string
  5869. if m.addcontent_type != nil {
  5870. fields = append(fields, chatrecords.FieldContentType)
  5871. }
  5872. if m.addsession_id != nil {
  5873. fields = append(fields, chatrecords.FieldSessionID)
  5874. }
  5875. if m.adduser_id != nil {
  5876. fields = append(fields, chatrecords.FieldUserID)
  5877. }
  5878. if m.addbot_id != nil {
  5879. fields = append(fields, chatrecords.FieldBotID)
  5880. }
  5881. if m.addbot_type != nil {
  5882. fields = append(fields, chatrecords.FieldBotType)
  5883. }
  5884. return fields
  5885. }
  5886. // AddedField returns the numeric value that was incremented/decremented on a field
  5887. // with the given name. The second boolean return value indicates that this field
  5888. // was not set, or was not defined in the schema.
  5889. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5890. switch name {
  5891. case chatrecords.FieldContentType:
  5892. return m.AddedContentType()
  5893. case chatrecords.FieldSessionID:
  5894. return m.AddedSessionID()
  5895. case chatrecords.FieldUserID:
  5896. return m.AddedUserID()
  5897. case chatrecords.FieldBotID:
  5898. return m.AddedBotID()
  5899. case chatrecords.FieldBotType:
  5900. return m.AddedBotType()
  5901. }
  5902. return nil, false
  5903. }
  5904. // AddField adds the value to the field with the given name. It returns an error if
  5905. // the field is not defined in the schema, or if the type mismatched the field
  5906. // type.
  5907. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5908. switch name {
  5909. case chatrecords.FieldContentType:
  5910. v, ok := value.(int8)
  5911. if !ok {
  5912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5913. }
  5914. m.AddContentType(v)
  5915. return nil
  5916. case chatrecords.FieldSessionID:
  5917. v, ok := value.(int64)
  5918. if !ok {
  5919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5920. }
  5921. m.AddSessionID(v)
  5922. return nil
  5923. case chatrecords.FieldUserID:
  5924. v, ok := value.(int64)
  5925. if !ok {
  5926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5927. }
  5928. m.AddUserID(v)
  5929. return nil
  5930. case chatrecords.FieldBotID:
  5931. v, ok := value.(int64)
  5932. if !ok {
  5933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5934. }
  5935. m.AddBotID(v)
  5936. return nil
  5937. case chatrecords.FieldBotType:
  5938. v, ok := value.(int8)
  5939. if !ok {
  5940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5941. }
  5942. m.AddBotType(v)
  5943. return nil
  5944. }
  5945. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  5946. }
  5947. // ClearedFields returns all nullable fields that were cleared during this
  5948. // mutation.
  5949. func (m *ChatRecordsMutation) ClearedFields() []string {
  5950. var fields []string
  5951. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  5952. fields = append(fields, chatrecords.FieldDeletedAt)
  5953. }
  5954. return fields
  5955. }
  5956. // FieldCleared returns a boolean indicating if a field with the given name was
  5957. // cleared in this mutation.
  5958. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  5959. _, ok := m.clearedFields[name]
  5960. return ok
  5961. }
  5962. // ClearField clears the value of the field with the given name. It returns an
  5963. // error if the field is not defined in the schema.
  5964. func (m *ChatRecordsMutation) ClearField(name string) error {
  5965. switch name {
  5966. case chatrecords.FieldDeletedAt:
  5967. m.ClearDeletedAt()
  5968. return nil
  5969. }
  5970. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  5971. }
  5972. // ResetField resets all changes in the mutation for the field with the given name.
  5973. // It returns an error if the field is not defined in the schema.
  5974. func (m *ChatRecordsMutation) ResetField(name string) error {
  5975. switch name {
  5976. case chatrecords.FieldCreatedAt:
  5977. m.ResetCreatedAt()
  5978. return nil
  5979. case chatrecords.FieldUpdatedAt:
  5980. m.ResetUpdatedAt()
  5981. return nil
  5982. case chatrecords.FieldDeletedAt:
  5983. m.ResetDeletedAt()
  5984. return nil
  5985. case chatrecords.FieldContent:
  5986. m.ResetContent()
  5987. return nil
  5988. case chatrecords.FieldContentType:
  5989. m.ResetContentType()
  5990. return nil
  5991. case chatrecords.FieldSessionID:
  5992. m.ResetSessionID()
  5993. return nil
  5994. case chatrecords.FieldUserID:
  5995. m.ResetUserID()
  5996. return nil
  5997. case chatrecords.FieldBotID:
  5998. m.ResetBotID()
  5999. return nil
  6000. case chatrecords.FieldBotType:
  6001. m.ResetBotType()
  6002. return nil
  6003. }
  6004. return fmt.Errorf("unknown ChatRecords field %s", name)
  6005. }
  6006. // AddedEdges returns all edge names that were set/added in this mutation.
  6007. func (m *ChatRecordsMutation) AddedEdges() []string {
  6008. edges := make([]string, 0, 0)
  6009. return edges
  6010. }
  6011. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6012. // name in this mutation.
  6013. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6014. return nil
  6015. }
  6016. // RemovedEdges returns all edge names that were removed in this mutation.
  6017. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6018. edges := make([]string, 0, 0)
  6019. return edges
  6020. }
  6021. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6022. // the given name in this mutation.
  6023. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6024. return nil
  6025. }
  6026. // ClearedEdges returns all edge names that were cleared in this mutation.
  6027. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6028. edges := make([]string, 0, 0)
  6029. return edges
  6030. }
  6031. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6032. // was cleared in this mutation.
  6033. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6034. return false
  6035. }
  6036. // ClearEdge clears the value of the edge with the given name. It returns an error
  6037. // if that edge is not defined in the schema.
  6038. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6039. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6040. }
  6041. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6042. // It returns an error if the edge is not defined in the schema.
  6043. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6044. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6045. }
  6046. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6047. type ChatSessionMutation struct {
  6048. config
  6049. op Op
  6050. typ string
  6051. id *uint64
  6052. created_at *time.Time
  6053. updated_at *time.Time
  6054. deleted_at *time.Time
  6055. name *string
  6056. user_id *uint64
  6057. adduser_id *int64
  6058. bot_id *uint64
  6059. addbot_id *int64
  6060. bot_type *uint8
  6061. addbot_type *int8
  6062. clearedFields map[string]struct{}
  6063. done bool
  6064. oldValue func(context.Context) (*ChatSession, error)
  6065. predicates []predicate.ChatSession
  6066. }
  6067. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6068. // chatsessionOption allows management of the mutation configuration using functional options.
  6069. type chatsessionOption func(*ChatSessionMutation)
  6070. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6071. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6072. m := &ChatSessionMutation{
  6073. config: c,
  6074. op: op,
  6075. typ: TypeChatSession,
  6076. clearedFields: make(map[string]struct{}),
  6077. }
  6078. for _, opt := range opts {
  6079. opt(m)
  6080. }
  6081. return m
  6082. }
  6083. // withChatSessionID sets the ID field of the mutation.
  6084. func withChatSessionID(id uint64) chatsessionOption {
  6085. return func(m *ChatSessionMutation) {
  6086. var (
  6087. err error
  6088. once sync.Once
  6089. value *ChatSession
  6090. )
  6091. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6092. once.Do(func() {
  6093. if m.done {
  6094. err = errors.New("querying old values post mutation is not allowed")
  6095. } else {
  6096. value, err = m.Client().ChatSession.Get(ctx, id)
  6097. }
  6098. })
  6099. return value, err
  6100. }
  6101. m.id = &id
  6102. }
  6103. }
  6104. // withChatSession sets the old ChatSession of the mutation.
  6105. func withChatSession(node *ChatSession) chatsessionOption {
  6106. return func(m *ChatSessionMutation) {
  6107. m.oldValue = func(context.Context) (*ChatSession, error) {
  6108. return node, nil
  6109. }
  6110. m.id = &node.ID
  6111. }
  6112. }
  6113. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6114. // executed in a transaction (ent.Tx), a transactional client is returned.
  6115. func (m ChatSessionMutation) Client() *Client {
  6116. client := &Client{config: m.config}
  6117. client.init()
  6118. return client
  6119. }
  6120. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6121. // it returns an error otherwise.
  6122. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6123. if _, ok := m.driver.(*txDriver); !ok {
  6124. return nil, errors.New("ent: mutation is not running in a transaction")
  6125. }
  6126. tx := &Tx{config: m.config}
  6127. tx.init()
  6128. return tx, nil
  6129. }
  6130. // SetID sets the value of the id field. Note that this
  6131. // operation is only accepted on creation of ChatSession entities.
  6132. func (m *ChatSessionMutation) SetID(id uint64) {
  6133. m.id = &id
  6134. }
  6135. // ID returns the ID value in the mutation. Note that the ID is only available
  6136. // if it was provided to the builder or after it was returned from the database.
  6137. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6138. if m.id == nil {
  6139. return
  6140. }
  6141. return *m.id, true
  6142. }
  6143. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6144. // That means, if the mutation is applied within a transaction with an isolation level such
  6145. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6146. // or updated by the mutation.
  6147. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6148. switch {
  6149. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6150. id, exists := m.ID()
  6151. if exists {
  6152. return []uint64{id}, nil
  6153. }
  6154. fallthrough
  6155. case m.op.Is(OpUpdate | OpDelete):
  6156. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6157. default:
  6158. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6159. }
  6160. }
  6161. // SetCreatedAt sets the "created_at" field.
  6162. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6163. m.created_at = &t
  6164. }
  6165. // CreatedAt returns the value of the "created_at" field in the mutation.
  6166. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6167. v := m.created_at
  6168. if v == nil {
  6169. return
  6170. }
  6171. return *v, true
  6172. }
  6173. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6174. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6176. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6177. if !m.op.Is(OpUpdateOne) {
  6178. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6179. }
  6180. if m.id == nil || m.oldValue == nil {
  6181. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6182. }
  6183. oldValue, err := m.oldValue(ctx)
  6184. if err != nil {
  6185. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6186. }
  6187. return oldValue.CreatedAt, nil
  6188. }
  6189. // ResetCreatedAt resets all changes to the "created_at" field.
  6190. func (m *ChatSessionMutation) ResetCreatedAt() {
  6191. m.created_at = nil
  6192. }
  6193. // SetUpdatedAt sets the "updated_at" field.
  6194. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6195. m.updated_at = &t
  6196. }
  6197. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6198. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6199. v := m.updated_at
  6200. if v == nil {
  6201. return
  6202. }
  6203. return *v, true
  6204. }
  6205. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6206. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6208. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6209. if !m.op.Is(OpUpdateOne) {
  6210. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6211. }
  6212. if m.id == nil || m.oldValue == nil {
  6213. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6214. }
  6215. oldValue, err := m.oldValue(ctx)
  6216. if err != nil {
  6217. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6218. }
  6219. return oldValue.UpdatedAt, nil
  6220. }
  6221. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6222. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6223. m.updated_at = nil
  6224. }
  6225. // SetDeletedAt sets the "deleted_at" field.
  6226. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6227. m.deleted_at = &t
  6228. }
  6229. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6230. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6231. v := m.deleted_at
  6232. if v == nil {
  6233. return
  6234. }
  6235. return *v, true
  6236. }
  6237. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6238. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6240. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6241. if !m.op.Is(OpUpdateOne) {
  6242. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6243. }
  6244. if m.id == nil || m.oldValue == nil {
  6245. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6246. }
  6247. oldValue, err := m.oldValue(ctx)
  6248. if err != nil {
  6249. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6250. }
  6251. return oldValue.DeletedAt, nil
  6252. }
  6253. // ClearDeletedAt clears the value of the "deleted_at" field.
  6254. func (m *ChatSessionMutation) ClearDeletedAt() {
  6255. m.deleted_at = nil
  6256. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6257. }
  6258. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6259. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6260. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6261. return ok
  6262. }
  6263. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6264. func (m *ChatSessionMutation) ResetDeletedAt() {
  6265. m.deleted_at = nil
  6266. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6267. }
  6268. // SetName sets the "name" field.
  6269. func (m *ChatSessionMutation) SetName(s string) {
  6270. m.name = &s
  6271. }
  6272. // Name returns the value of the "name" field in the mutation.
  6273. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6274. v := m.name
  6275. if v == nil {
  6276. return
  6277. }
  6278. return *v, true
  6279. }
  6280. // OldName returns the old "name" field's value of the ChatSession entity.
  6281. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6283. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6284. if !m.op.Is(OpUpdateOne) {
  6285. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6286. }
  6287. if m.id == nil || m.oldValue == nil {
  6288. return v, errors.New("OldName requires an ID field in the mutation")
  6289. }
  6290. oldValue, err := m.oldValue(ctx)
  6291. if err != nil {
  6292. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6293. }
  6294. return oldValue.Name, nil
  6295. }
  6296. // ResetName resets all changes to the "name" field.
  6297. func (m *ChatSessionMutation) ResetName() {
  6298. m.name = nil
  6299. }
  6300. // SetUserID sets the "user_id" field.
  6301. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6302. m.user_id = &u
  6303. m.adduser_id = nil
  6304. }
  6305. // UserID returns the value of the "user_id" field in the mutation.
  6306. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6307. v := m.user_id
  6308. if v == nil {
  6309. return
  6310. }
  6311. return *v, true
  6312. }
  6313. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6314. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6316. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6317. if !m.op.Is(OpUpdateOne) {
  6318. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6319. }
  6320. if m.id == nil || m.oldValue == nil {
  6321. return v, errors.New("OldUserID requires an ID field in the mutation")
  6322. }
  6323. oldValue, err := m.oldValue(ctx)
  6324. if err != nil {
  6325. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6326. }
  6327. return oldValue.UserID, nil
  6328. }
  6329. // AddUserID adds u to the "user_id" field.
  6330. func (m *ChatSessionMutation) AddUserID(u int64) {
  6331. if m.adduser_id != nil {
  6332. *m.adduser_id += u
  6333. } else {
  6334. m.adduser_id = &u
  6335. }
  6336. }
  6337. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6338. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6339. v := m.adduser_id
  6340. if v == nil {
  6341. return
  6342. }
  6343. return *v, true
  6344. }
  6345. // ResetUserID resets all changes to the "user_id" field.
  6346. func (m *ChatSessionMutation) ResetUserID() {
  6347. m.user_id = nil
  6348. m.adduser_id = nil
  6349. }
  6350. // SetBotID sets the "bot_id" field.
  6351. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6352. m.bot_id = &u
  6353. m.addbot_id = nil
  6354. }
  6355. // BotID returns the value of the "bot_id" field in the mutation.
  6356. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6357. v := m.bot_id
  6358. if v == nil {
  6359. return
  6360. }
  6361. return *v, true
  6362. }
  6363. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6364. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6366. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6367. if !m.op.Is(OpUpdateOne) {
  6368. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6369. }
  6370. if m.id == nil || m.oldValue == nil {
  6371. return v, errors.New("OldBotID requires an ID field in the mutation")
  6372. }
  6373. oldValue, err := m.oldValue(ctx)
  6374. if err != nil {
  6375. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6376. }
  6377. return oldValue.BotID, nil
  6378. }
  6379. // AddBotID adds u to the "bot_id" field.
  6380. func (m *ChatSessionMutation) AddBotID(u int64) {
  6381. if m.addbot_id != nil {
  6382. *m.addbot_id += u
  6383. } else {
  6384. m.addbot_id = &u
  6385. }
  6386. }
  6387. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6388. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6389. v := m.addbot_id
  6390. if v == nil {
  6391. return
  6392. }
  6393. return *v, true
  6394. }
  6395. // ResetBotID resets all changes to the "bot_id" field.
  6396. func (m *ChatSessionMutation) ResetBotID() {
  6397. m.bot_id = nil
  6398. m.addbot_id = nil
  6399. }
  6400. // SetBotType sets the "bot_type" field.
  6401. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6402. m.bot_type = &u
  6403. m.addbot_type = nil
  6404. }
  6405. // BotType returns the value of the "bot_type" field in the mutation.
  6406. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6407. v := m.bot_type
  6408. if v == nil {
  6409. return
  6410. }
  6411. return *v, true
  6412. }
  6413. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6414. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6416. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6417. if !m.op.Is(OpUpdateOne) {
  6418. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6419. }
  6420. if m.id == nil || m.oldValue == nil {
  6421. return v, errors.New("OldBotType requires an ID field in the mutation")
  6422. }
  6423. oldValue, err := m.oldValue(ctx)
  6424. if err != nil {
  6425. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6426. }
  6427. return oldValue.BotType, nil
  6428. }
  6429. // AddBotType adds u to the "bot_type" field.
  6430. func (m *ChatSessionMutation) AddBotType(u int8) {
  6431. if m.addbot_type != nil {
  6432. *m.addbot_type += u
  6433. } else {
  6434. m.addbot_type = &u
  6435. }
  6436. }
  6437. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6438. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6439. v := m.addbot_type
  6440. if v == nil {
  6441. return
  6442. }
  6443. return *v, true
  6444. }
  6445. // ResetBotType resets all changes to the "bot_type" field.
  6446. func (m *ChatSessionMutation) ResetBotType() {
  6447. m.bot_type = nil
  6448. m.addbot_type = nil
  6449. }
  6450. // Where appends a list predicates to the ChatSessionMutation builder.
  6451. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6452. m.predicates = append(m.predicates, ps...)
  6453. }
  6454. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6455. // users can use type-assertion to append predicates that do not depend on any generated package.
  6456. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6457. p := make([]predicate.ChatSession, len(ps))
  6458. for i := range ps {
  6459. p[i] = ps[i]
  6460. }
  6461. m.Where(p...)
  6462. }
  6463. // Op returns the operation name.
  6464. func (m *ChatSessionMutation) Op() Op {
  6465. return m.op
  6466. }
  6467. // SetOp allows setting the mutation operation.
  6468. func (m *ChatSessionMutation) SetOp(op Op) {
  6469. m.op = op
  6470. }
  6471. // Type returns the node type of this mutation (ChatSession).
  6472. func (m *ChatSessionMutation) Type() string {
  6473. return m.typ
  6474. }
  6475. // Fields returns all fields that were changed during this mutation. Note that in
  6476. // order to get all numeric fields that were incremented/decremented, call
  6477. // AddedFields().
  6478. func (m *ChatSessionMutation) Fields() []string {
  6479. fields := make([]string, 0, 7)
  6480. if m.created_at != nil {
  6481. fields = append(fields, chatsession.FieldCreatedAt)
  6482. }
  6483. if m.updated_at != nil {
  6484. fields = append(fields, chatsession.FieldUpdatedAt)
  6485. }
  6486. if m.deleted_at != nil {
  6487. fields = append(fields, chatsession.FieldDeletedAt)
  6488. }
  6489. if m.name != nil {
  6490. fields = append(fields, chatsession.FieldName)
  6491. }
  6492. if m.user_id != nil {
  6493. fields = append(fields, chatsession.FieldUserID)
  6494. }
  6495. if m.bot_id != nil {
  6496. fields = append(fields, chatsession.FieldBotID)
  6497. }
  6498. if m.bot_type != nil {
  6499. fields = append(fields, chatsession.FieldBotType)
  6500. }
  6501. return fields
  6502. }
  6503. // Field returns the value of a field with the given name. The second boolean
  6504. // return value indicates that this field was not set, or was not defined in the
  6505. // schema.
  6506. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6507. switch name {
  6508. case chatsession.FieldCreatedAt:
  6509. return m.CreatedAt()
  6510. case chatsession.FieldUpdatedAt:
  6511. return m.UpdatedAt()
  6512. case chatsession.FieldDeletedAt:
  6513. return m.DeletedAt()
  6514. case chatsession.FieldName:
  6515. return m.Name()
  6516. case chatsession.FieldUserID:
  6517. return m.UserID()
  6518. case chatsession.FieldBotID:
  6519. return m.BotID()
  6520. case chatsession.FieldBotType:
  6521. return m.BotType()
  6522. }
  6523. return nil, false
  6524. }
  6525. // OldField returns the old value of the field from the database. An error is
  6526. // returned if the mutation operation is not UpdateOne, or the query to the
  6527. // database failed.
  6528. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6529. switch name {
  6530. case chatsession.FieldCreatedAt:
  6531. return m.OldCreatedAt(ctx)
  6532. case chatsession.FieldUpdatedAt:
  6533. return m.OldUpdatedAt(ctx)
  6534. case chatsession.FieldDeletedAt:
  6535. return m.OldDeletedAt(ctx)
  6536. case chatsession.FieldName:
  6537. return m.OldName(ctx)
  6538. case chatsession.FieldUserID:
  6539. return m.OldUserID(ctx)
  6540. case chatsession.FieldBotID:
  6541. return m.OldBotID(ctx)
  6542. case chatsession.FieldBotType:
  6543. return m.OldBotType(ctx)
  6544. }
  6545. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6546. }
  6547. // SetField sets the value of a field with the given name. It returns an error if
  6548. // the field is not defined in the schema, or if the type mismatched the field
  6549. // type.
  6550. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6551. switch name {
  6552. case chatsession.FieldCreatedAt:
  6553. v, ok := value.(time.Time)
  6554. if !ok {
  6555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6556. }
  6557. m.SetCreatedAt(v)
  6558. return nil
  6559. case chatsession.FieldUpdatedAt:
  6560. v, ok := value.(time.Time)
  6561. if !ok {
  6562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6563. }
  6564. m.SetUpdatedAt(v)
  6565. return nil
  6566. case chatsession.FieldDeletedAt:
  6567. v, ok := value.(time.Time)
  6568. if !ok {
  6569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6570. }
  6571. m.SetDeletedAt(v)
  6572. return nil
  6573. case chatsession.FieldName:
  6574. v, ok := value.(string)
  6575. if !ok {
  6576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6577. }
  6578. m.SetName(v)
  6579. return nil
  6580. case chatsession.FieldUserID:
  6581. v, ok := value.(uint64)
  6582. if !ok {
  6583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6584. }
  6585. m.SetUserID(v)
  6586. return nil
  6587. case chatsession.FieldBotID:
  6588. v, ok := value.(uint64)
  6589. if !ok {
  6590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6591. }
  6592. m.SetBotID(v)
  6593. return nil
  6594. case chatsession.FieldBotType:
  6595. v, ok := value.(uint8)
  6596. if !ok {
  6597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6598. }
  6599. m.SetBotType(v)
  6600. return nil
  6601. }
  6602. return fmt.Errorf("unknown ChatSession field %s", name)
  6603. }
  6604. // AddedFields returns all numeric fields that were incremented/decremented during
  6605. // this mutation.
  6606. func (m *ChatSessionMutation) AddedFields() []string {
  6607. var fields []string
  6608. if m.adduser_id != nil {
  6609. fields = append(fields, chatsession.FieldUserID)
  6610. }
  6611. if m.addbot_id != nil {
  6612. fields = append(fields, chatsession.FieldBotID)
  6613. }
  6614. if m.addbot_type != nil {
  6615. fields = append(fields, chatsession.FieldBotType)
  6616. }
  6617. return fields
  6618. }
  6619. // AddedField returns the numeric value that was incremented/decremented on a field
  6620. // with the given name. The second boolean return value indicates that this field
  6621. // was not set, or was not defined in the schema.
  6622. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6623. switch name {
  6624. case chatsession.FieldUserID:
  6625. return m.AddedUserID()
  6626. case chatsession.FieldBotID:
  6627. return m.AddedBotID()
  6628. case chatsession.FieldBotType:
  6629. return m.AddedBotType()
  6630. }
  6631. return nil, false
  6632. }
  6633. // AddField adds the value to the field with the given name. It returns an error if
  6634. // the field is not defined in the schema, or if the type mismatched the field
  6635. // type.
  6636. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6637. switch name {
  6638. case chatsession.FieldUserID:
  6639. v, ok := value.(int64)
  6640. if !ok {
  6641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6642. }
  6643. m.AddUserID(v)
  6644. return nil
  6645. case chatsession.FieldBotID:
  6646. v, ok := value.(int64)
  6647. if !ok {
  6648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6649. }
  6650. m.AddBotID(v)
  6651. return nil
  6652. case chatsession.FieldBotType:
  6653. v, ok := value.(int8)
  6654. if !ok {
  6655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6656. }
  6657. m.AddBotType(v)
  6658. return nil
  6659. }
  6660. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6661. }
  6662. // ClearedFields returns all nullable fields that were cleared during this
  6663. // mutation.
  6664. func (m *ChatSessionMutation) ClearedFields() []string {
  6665. var fields []string
  6666. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6667. fields = append(fields, chatsession.FieldDeletedAt)
  6668. }
  6669. return fields
  6670. }
  6671. // FieldCleared returns a boolean indicating if a field with the given name was
  6672. // cleared in this mutation.
  6673. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6674. _, ok := m.clearedFields[name]
  6675. return ok
  6676. }
  6677. // ClearField clears the value of the field with the given name. It returns an
  6678. // error if the field is not defined in the schema.
  6679. func (m *ChatSessionMutation) ClearField(name string) error {
  6680. switch name {
  6681. case chatsession.FieldDeletedAt:
  6682. m.ClearDeletedAt()
  6683. return nil
  6684. }
  6685. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6686. }
  6687. // ResetField resets all changes in the mutation for the field with the given name.
  6688. // It returns an error if the field is not defined in the schema.
  6689. func (m *ChatSessionMutation) ResetField(name string) error {
  6690. switch name {
  6691. case chatsession.FieldCreatedAt:
  6692. m.ResetCreatedAt()
  6693. return nil
  6694. case chatsession.FieldUpdatedAt:
  6695. m.ResetUpdatedAt()
  6696. return nil
  6697. case chatsession.FieldDeletedAt:
  6698. m.ResetDeletedAt()
  6699. return nil
  6700. case chatsession.FieldName:
  6701. m.ResetName()
  6702. return nil
  6703. case chatsession.FieldUserID:
  6704. m.ResetUserID()
  6705. return nil
  6706. case chatsession.FieldBotID:
  6707. m.ResetBotID()
  6708. return nil
  6709. case chatsession.FieldBotType:
  6710. m.ResetBotType()
  6711. return nil
  6712. }
  6713. return fmt.Errorf("unknown ChatSession field %s", name)
  6714. }
  6715. // AddedEdges returns all edge names that were set/added in this mutation.
  6716. func (m *ChatSessionMutation) AddedEdges() []string {
  6717. edges := make([]string, 0, 0)
  6718. return edges
  6719. }
  6720. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6721. // name in this mutation.
  6722. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6723. return nil
  6724. }
  6725. // RemovedEdges returns all edge names that were removed in this mutation.
  6726. func (m *ChatSessionMutation) RemovedEdges() []string {
  6727. edges := make([]string, 0, 0)
  6728. return edges
  6729. }
  6730. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6731. // the given name in this mutation.
  6732. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6733. return nil
  6734. }
  6735. // ClearedEdges returns all edge names that were cleared in this mutation.
  6736. func (m *ChatSessionMutation) ClearedEdges() []string {
  6737. edges := make([]string, 0, 0)
  6738. return edges
  6739. }
  6740. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6741. // was cleared in this mutation.
  6742. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6743. return false
  6744. }
  6745. // ClearEdge clears the value of the edge with the given name. It returns an error
  6746. // if that edge is not defined in the schema.
  6747. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6748. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6749. }
  6750. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6751. // It returns an error if the edge is not defined in the schema.
  6752. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6753. return fmt.Errorf("unknown ChatSession edge %s", name)
  6754. }
  6755. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6756. type ContactMutation struct {
  6757. config
  6758. op Op
  6759. typ string
  6760. id *uint64
  6761. created_at *time.Time
  6762. updated_at *time.Time
  6763. status *uint8
  6764. addstatus *int8
  6765. deleted_at *time.Time
  6766. wx_wxid *string
  6767. _type *int
  6768. add_type *int
  6769. wxid *string
  6770. account *string
  6771. nickname *string
  6772. markname *string
  6773. headimg *string
  6774. sex *int
  6775. addsex *int
  6776. starrole *string
  6777. dontseeit *int
  6778. adddontseeit *int
  6779. dontseeme *int
  6780. adddontseeme *int
  6781. lag *string
  6782. gid *string
  6783. gname *string
  6784. v3 *string
  6785. organization_id *uint64
  6786. addorganization_id *int64
  6787. clearedFields map[string]struct{}
  6788. contact_relationships map[uint64]struct{}
  6789. removedcontact_relationships map[uint64]struct{}
  6790. clearedcontact_relationships bool
  6791. contact_messages map[uint64]struct{}
  6792. removedcontact_messages map[uint64]struct{}
  6793. clearedcontact_messages bool
  6794. done bool
  6795. oldValue func(context.Context) (*Contact, error)
  6796. predicates []predicate.Contact
  6797. }
  6798. var _ ent.Mutation = (*ContactMutation)(nil)
  6799. // contactOption allows management of the mutation configuration using functional options.
  6800. type contactOption func(*ContactMutation)
  6801. // newContactMutation creates new mutation for the Contact entity.
  6802. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6803. m := &ContactMutation{
  6804. config: c,
  6805. op: op,
  6806. typ: TypeContact,
  6807. clearedFields: make(map[string]struct{}),
  6808. }
  6809. for _, opt := range opts {
  6810. opt(m)
  6811. }
  6812. return m
  6813. }
  6814. // withContactID sets the ID field of the mutation.
  6815. func withContactID(id uint64) contactOption {
  6816. return func(m *ContactMutation) {
  6817. var (
  6818. err error
  6819. once sync.Once
  6820. value *Contact
  6821. )
  6822. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6823. once.Do(func() {
  6824. if m.done {
  6825. err = errors.New("querying old values post mutation is not allowed")
  6826. } else {
  6827. value, err = m.Client().Contact.Get(ctx, id)
  6828. }
  6829. })
  6830. return value, err
  6831. }
  6832. m.id = &id
  6833. }
  6834. }
  6835. // withContact sets the old Contact of the mutation.
  6836. func withContact(node *Contact) contactOption {
  6837. return func(m *ContactMutation) {
  6838. m.oldValue = func(context.Context) (*Contact, error) {
  6839. return node, nil
  6840. }
  6841. m.id = &node.ID
  6842. }
  6843. }
  6844. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6845. // executed in a transaction (ent.Tx), a transactional client is returned.
  6846. func (m ContactMutation) Client() *Client {
  6847. client := &Client{config: m.config}
  6848. client.init()
  6849. return client
  6850. }
  6851. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6852. // it returns an error otherwise.
  6853. func (m ContactMutation) Tx() (*Tx, error) {
  6854. if _, ok := m.driver.(*txDriver); !ok {
  6855. return nil, errors.New("ent: mutation is not running in a transaction")
  6856. }
  6857. tx := &Tx{config: m.config}
  6858. tx.init()
  6859. return tx, nil
  6860. }
  6861. // SetID sets the value of the id field. Note that this
  6862. // operation is only accepted on creation of Contact entities.
  6863. func (m *ContactMutation) SetID(id uint64) {
  6864. m.id = &id
  6865. }
  6866. // ID returns the ID value in the mutation. Note that the ID is only available
  6867. // if it was provided to the builder or after it was returned from the database.
  6868. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6869. if m.id == nil {
  6870. return
  6871. }
  6872. return *m.id, true
  6873. }
  6874. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6875. // That means, if the mutation is applied within a transaction with an isolation level such
  6876. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6877. // or updated by the mutation.
  6878. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6879. switch {
  6880. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6881. id, exists := m.ID()
  6882. if exists {
  6883. return []uint64{id}, nil
  6884. }
  6885. fallthrough
  6886. case m.op.Is(OpUpdate | OpDelete):
  6887. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6888. default:
  6889. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6890. }
  6891. }
  6892. // SetCreatedAt sets the "created_at" field.
  6893. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6894. m.created_at = &t
  6895. }
  6896. // CreatedAt returns the value of the "created_at" field in the mutation.
  6897. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6898. v := m.created_at
  6899. if v == nil {
  6900. return
  6901. }
  6902. return *v, true
  6903. }
  6904. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6905. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6907. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6908. if !m.op.Is(OpUpdateOne) {
  6909. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6910. }
  6911. if m.id == nil || m.oldValue == nil {
  6912. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6913. }
  6914. oldValue, err := m.oldValue(ctx)
  6915. if err != nil {
  6916. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6917. }
  6918. return oldValue.CreatedAt, nil
  6919. }
  6920. // ResetCreatedAt resets all changes to the "created_at" field.
  6921. func (m *ContactMutation) ResetCreatedAt() {
  6922. m.created_at = nil
  6923. }
  6924. // SetUpdatedAt sets the "updated_at" field.
  6925. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  6926. m.updated_at = &t
  6927. }
  6928. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6929. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  6930. v := m.updated_at
  6931. if v == nil {
  6932. return
  6933. }
  6934. return *v, true
  6935. }
  6936. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  6937. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6939. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6940. if !m.op.Is(OpUpdateOne) {
  6941. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6942. }
  6943. if m.id == nil || m.oldValue == nil {
  6944. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6945. }
  6946. oldValue, err := m.oldValue(ctx)
  6947. if err != nil {
  6948. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6949. }
  6950. return oldValue.UpdatedAt, nil
  6951. }
  6952. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6953. func (m *ContactMutation) ResetUpdatedAt() {
  6954. m.updated_at = nil
  6955. }
  6956. // SetStatus sets the "status" field.
  6957. func (m *ContactMutation) SetStatus(u uint8) {
  6958. m.status = &u
  6959. m.addstatus = nil
  6960. }
  6961. // Status returns the value of the "status" field in the mutation.
  6962. func (m *ContactMutation) Status() (r uint8, exists bool) {
  6963. v := m.status
  6964. if v == nil {
  6965. return
  6966. }
  6967. return *v, true
  6968. }
  6969. // OldStatus returns the old "status" field's value of the Contact entity.
  6970. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6972. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6973. if !m.op.Is(OpUpdateOne) {
  6974. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6975. }
  6976. if m.id == nil || m.oldValue == nil {
  6977. return v, errors.New("OldStatus requires an ID field in the mutation")
  6978. }
  6979. oldValue, err := m.oldValue(ctx)
  6980. if err != nil {
  6981. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6982. }
  6983. return oldValue.Status, nil
  6984. }
  6985. // AddStatus adds u to the "status" field.
  6986. func (m *ContactMutation) AddStatus(u int8) {
  6987. if m.addstatus != nil {
  6988. *m.addstatus += u
  6989. } else {
  6990. m.addstatus = &u
  6991. }
  6992. }
  6993. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6994. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  6995. v := m.addstatus
  6996. if v == nil {
  6997. return
  6998. }
  6999. return *v, true
  7000. }
  7001. // ClearStatus clears the value of the "status" field.
  7002. func (m *ContactMutation) ClearStatus() {
  7003. m.status = nil
  7004. m.addstatus = nil
  7005. m.clearedFields[contact.FieldStatus] = struct{}{}
  7006. }
  7007. // StatusCleared returns if the "status" field was cleared in this mutation.
  7008. func (m *ContactMutation) StatusCleared() bool {
  7009. _, ok := m.clearedFields[contact.FieldStatus]
  7010. return ok
  7011. }
  7012. // ResetStatus resets all changes to the "status" field.
  7013. func (m *ContactMutation) ResetStatus() {
  7014. m.status = nil
  7015. m.addstatus = nil
  7016. delete(m.clearedFields, contact.FieldStatus)
  7017. }
  7018. // SetDeletedAt sets the "deleted_at" field.
  7019. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7020. m.deleted_at = &t
  7021. }
  7022. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7023. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7024. v := m.deleted_at
  7025. if v == nil {
  7026. return
  7027. }
  7028. return *v, true
  7029. }
  7030. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7031. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7033. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7034. if !m.op.Is(OpUpdateOne) {
  7035. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7036. }
  7037. if m.id == nil || m.oldValue == nil {
  7038. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7039. }
  7040. oldValue, err := m.oldValue(ctx)
  7041. if err != nil {
  7042. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7043. }
  7044. return oldValue.DeletedAt, nil
  7045. }
  7046. // ClearDeletedAt clears the value of the "deleted_at" field.
  7047. func (m *ContactMutation) ClearDeletedAt() {
  7048. m.deleted_at = nil
  7049. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7050. }
  7051. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7052. func (m *ContactMutation) DeletedAtCleared() bool {
  7053. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7054. return ok
  7055. }
  7056. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7057. func (m *ContactMutation) ResetDeletedAt() {
  7058. m.deleted_at = nil
  7059. delete(m.clearedFields, contact.FieldDeletedAt)
  7060. }
  7061. // SetWxWxid sets the "wx_wxid" field.
  7062. func (m *ContactMutation) SetWxWxid(s string) {
  7063. m.wx_wxid = &s
  7064. }
  7065. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7066. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7067. v := m.wx_wxid
  7068. if v == nil {
  7069. return
  7070. }
  7071. return *v, true
  7072. }
  7073. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7074. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7076. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7077. if !m.op.Is(OpUpdateOne) {
  7078. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7079. }
  7080. if m.id == nil || m.oldValue == nil {
  7081. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7082. }
  7083. oldValue, err := m.oldValue(ctx)
  7084. if err != nil {
  7085. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7086. }
  7087. return oldValue.WxWxid, nil
  7088. }
  7089. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7090. func (m *ContactMutation) ResetWxWxid() {
  7091. m.wx_wxid = nil
  7092. }
  7093. // SetType sets the "type" field.
  7094. func (m *ContactMutation) SetType(i int) {
  7095. m._type = &i
  7096. m.add_type = nil
  7097. }
  7098. // GetType returns the value of the "type" field in the mutation.
  7099. func (m *ContactMutation) GetType() (r int, exists bool) {
  7100. v := m._type
  7101. if v == nil {
  7102. return
  7103. }
  7104. return *v, true
  7105. }
  7106. // OldType returns the old "type" field's value of the Contact entity.
  7107. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7109. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7110. if !m.op.Is(OpUpdateOne) {
  7111. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7112. }
  7113. if m.id == nil || m.oldValue == nil {
  7114. return v, errors.New("OldType requires an ID field in the mutation")
  7115. }
  7116. oldValue, err := m.oldValue(ctx)
  7117. if err != nil {
  7118. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7119. }
  7120. return oldValue.Type, nil
  7121. }
  7122. // AddType adds i to the "type" field.
  7123. func (m *ContactMutation) AddType(i int) {
  7124. if m.add_type != nil {
  7125. *m.add_type += i
  7126. } else {
  7127. m.add_type = &i
  7128. }
  7129. }
  7130. // AddedType returns the value that was added to the "type" field in this mutation.
  7131. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7132. v := m.add_type
  7133. if v == nil {
  7134. return
  7135. }
  7136. return *v, true
  7137. }
  7138. // ClearType clears the value of the "type" field.
  7139. func (m *ContactMutation) ClearType() {
  7140. m._type = nil
  7141. m.add_type = nil
  7142. m.clearedFields[contact.FieldType] = struct{}{}
  7143. }
  7144. // TypeCleared returns if the "type" field was cleared in this mutation.
  7145. func (m *ContactMutation) TypeCleared() bool {
  7146. _, ok := m.clearedFields[contact.FieldType]
  7147. return ok
  7148. }
  7149. // ResetType resets all changes to the "type" field.
  7150. func (m *ContactMutation) ResetType() {
  7151. m._type = nil
  7152. m.add_type = nil
  7153. delete(m.clearedFields, contact.FieldType)
  7154. }
  7155. // SetWxid sets the "wxid" field.
  7156. func (m *ContactMutation) SetWxid(s string) {
  7157. m.wxid = &s
  7158. }
  7159. // Wxid returns the value of the "wxid" field in the mutation.
  7160. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7161. v := m.wxid
  7162. if v == nil {
  7163. return
  7164. }
  7165. return *v, true
  7166. }
  7167. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7168. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7170. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7171. if !m.op.Is(OpUpdateOne) {
  7172. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7173. }
  7174. if m.id == nil || m.oldValue == nil {
  7175. return v, errors.New("OldWxid requires an ID field in the mutation")
  7176. }
  7177. oldValue, err := m.oldValue(ctx)
  7178. if err != nil {
  7179. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7180. }
  7181. return oldValue.Wxid, nil
  7182. }
  7183. // ResetWxid resets all changes to the "wxid" field.
  7184. func (m *ContactMutation) ResetWxid() {
  7185. m.wxid = nil
  7186. }
  7187. // SetAccount sets the "account" field.
  7188. func (m *ContactMutation) SetAccount(s string) {
  7189. m.account = &s
  7190. }
  7191. // Account returns the value of the "account" field in the mutation.
  7192. func (m *ContactMutation) Account() (r string, exists bool) {
  7193. v := m.account
  7194. if v == nil {
  7195. return
  7196. }
  7197. return *v, true
  7198. }
  7199. // OldAccount returns the old "account" field's value of the Contact entity.
  7200. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7202. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7203. if !m.op.Is(OpUpdateOne) {
  7204. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7205. }
  7206. if m.id == nil || m.oldValue == nil {
  7207. return v, errors.New("OldAccount requires an ID field in the mutation")
  7208. }
  7209. oldValue, err := m.oldValue(ctx)
  7210. if err != nil {
  7211. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7212. }
  7213. return oldValue.Account, nil
  7214. }
  7215. // ResetAccount resets all changes to the "account" field.
  7216. func (m *ContactMutation) ResetAccount() {
  7217. m.account = nil
  7218. }
  7219. // SetNickname sets the "nickname" field.
  7220. func (m *ContactMutation) SetNickname(s string) {
  7221. m.nickname = &s
  7222. }
  7223. // Nickname returns the value of the "nickname" field in the mutation.
  7224. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7225. v := m.nickname
  7226. if v == nil {
  7227. return
  7228. }
  7229. return *v, true
  7230. }
  7231. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7232. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7234. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7235. if !m.op.Is(OpUpdateOne) {
  7236. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7237. }
  7238. if m.id == nil || m.oldValue == nil {
  7239. return v, errors.New("OldNickname requires an ID field in the mutation")
  7240. }
  7241. oldValue, err := m.oldValue(ctx)
  7242. if err != nil {
  7243. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7244. }
  7245. return oldValue.Nickname, nil
  7246. }
  7247. // ResetNickname resets all changes to the "nickname" field.
  7248. func (m *ContactMutation) ResetNickname() {
  7249. m.nickname = nil
  7250. }
  7251. // SetMarkname sets the "markname" field.
  7252. func (m *ContactMutation) SetMarkname(s string) {
  7253. m.markname = &s
  7254. }
  7255. // Markname returns the value of the "markname" field in the mutation.
  7256. func (m *ContactMutation) Markname() (r string, exists bool) {
  7257. v := m.markname
  7258. if v == nil {
  7259. return
  7260. }
  7261. return *v, true
  7262. }
  7263. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7264. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7266. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7267. if !m.op.Is(OpUpdateOne) {
  7268. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7269. }
  7270. if m.id == nil || m.oldValue == nil {
  7271. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7272. }
  7273. oldValue, err := m.oldValue(ctx)
  7274. if err != nil {
  7275. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7276. }
  7277. return oldValue.Markname, nil
  7278. }
  7279. // ResetMarkname resets all changes to the "markname" field.
  7280. func (m *ContactMutation) ResetMarkname() {
  7281. m.markname = nil
  7282. }
  7283. // SetHeadimg sets the "headimg" field.
  7284. func (m *ContactMutation) SetHeadimg(s string) {
  7285. m.headimg = &s
  7286. }
  7287. // Headimg returns the value of the "headimg" field in the mutation.
  7288. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7289. v := m.headimg
  7290. if v == nil {
  7291. return
  7292. }
  7293. return *v, true
  7294. }
  7295. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7296. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7298. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7299. if !m.op.Is(OpUpdateOne) {
  7300. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7301. }
  7302. if m.id == nil || m.oldValue == nil {
  7303. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7304. }
  7305. oldValue, err := m.oldValue(ctx)
  7306. if err != nil {
  7307. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7308. }
  7309. return oldValue.Headimg, nil
  7310. }
  7311. // ResetHeadimg resets all changes to the "headimg" field.
  7312. func (m *ContactMutation) ResetHeadimg() {
  7313. m.headimg = nil
  7314. }
  7315. // SetSex sets the "sex" field.
  7316. func (m *ContactMutation) SetSex(i int) {
  7317. m.sex = &i
  7318. m.addsex = nil
  7319. }
  7320. // Sex returns the value of the "sex" field in the mutation.
  7321. func (m *ContactMutation) Sex() (r int, exists bool) {
  7322. v := m.sex
  7323. if v == nil {
  7324. return
  7325. }
  7326. return *v, true
  7327. }
  7328. // OldSex returns the old "sex" field's value of the Contact entity.
  7329. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7331. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7332. if !m.op.Is(OpUpdateOne) {
  7333. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7334. }
  7335. if m.id == nil || m.oldValue == nil {
  7336. return v, errors.New("OldSex requires an ID field in the mutation")
  7337. }
  7338. oldValue, err := m.oldValue(ctx)
  7339. if err != nil {
  7340. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7341. }
  7342. return oldValue.Sex, nil
  7343. }
  7344. // AddSex adds i to the "sex" field.
  7345. func (m *ContactMutation) AddSex(i int) {
  7346. if m.addsex != nil {
  7347. *m.addsex += i
  7348. } else {
  7349. m.addsex = &i
  7350. }
  7351. }
  7352. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7353. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7354. v := m.addsex
  7355. if v == nil {
  7356. return
  7357. }
  7358. return *v, true
  7359. }
  7360. // ResetSex resets all changes to the "sex" field.
  7361. func (m *ContactMutation) ResetSex() {
  7362. m.sex = nil
  7363. m.addsex = nil
  7364. }
  7365. // SetStarrole sets the "starrole" field.
  7366. func (m *ContactMutation) SetStarrole(s string) {
  7367. m.starrole = &s
  7368. }
  7369. // Starrole returns the value of the "starrole" field in the mutation.
  7370. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7371. v := m.starrole
  7372. if v == nil {
  7373. return
  7374. }
  7375. return *v, true
  7376. }
  7377. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7378. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7380. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7381. if !m.op.Is(OpUpdateOne) {
  7382. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7383. }
  7384. if m.id == nil || m.oldValue == nil {
  7385. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7386. }
  7387. oldValue, err := m.oldValue(ctx)
  7388. if err != nil {
  7389. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7390. }
  7391. return oldValue.Starrole, nil
  7392. }
  7393. // ResetStarrole resets all changes to the "starrole" field.
  7394. func (m *ContactMutation) ResetStarrole() {
  7395. m.starrole = nil
  7396. }
  7397. // SetDontseeit sets the "dontseeit" field.
  7398. func (m *ContactMutation) SetDontseeit(i int) {
  7399. m.dontseeit = &i
  7400. m.adddontseeit = nil
  7401. }
  7402. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7403. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7404. v := m.dontseeit
  7405. if v == nil {
  7406. return
  7407. }
  7408. return *v, true
  7409. }
  7410. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7411. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7413. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7414. if !m.op.Is(OpUpdateOne) {
  7415. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7416. }
  7417. if m.id == nil || m.oldValue == nil {
  7418. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7419. }
  7420. oldValue, err := m.oldValue(ctx)
  7421. if err != nil {
  7422. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7423. }
  7424. return oldValue.Dontseeit, nil
  7425. }
  7426. // AddDontseeit adds i to the "dontseeit" field.
  7427. func (m *ContactMutation) AddDontseeit(i int) {
  7428. if m.adddontseeit != nil {
  7429. *m.adddontseeit += i
  7430. } else {
  7431. m.adddontseeit = &i
  7432. }
  7433. }
  7434. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7435. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7436. v := m.adddontseeit
  7437. if v == nil {
  7438. return
  7439. }
  7440. return *v, true
  7441. }
  7442. // ResetDontseeit resets all changes to the "dontseeit" field.
  7443. func (m *ContactMutation) ResetDontseeit() {
  7444. m.dontseeit = nil
  7445. m.adddontseeit = nil
  7446. }
  7447. // SetDontseeme sets the "dontseeme" field.
  7448. func (m *ContactMutation) SetDontseeme(i int) {
  7449. m.dontseeme = &i
  7450. m.adddontseeme = nil
  7451. }
  7452. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7453. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7454. v := m.dontseeme
  7455. if v == nil {
  7456. return
  7457. }
  7458. return *v, true
  7459. }
  7460. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7461. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7463. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7464. if !m.op.Is(OpUpdateOne) {
  7465. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7466. }
  7467. if m.id == nil || m.oldValue == nil {
  7468. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7469. }
  7470. oldValue, err := m.oldValue(ctx)
  7471. if err != nil {
  7472. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7473. }
  7474. return oldValue.Dontseeme, nil
  7475. }
  7476. // AddDontseeme adds i to the "dontseeme" field.
  7477. func (m *ContactMutation) AddDontseeme(i int) {
  7478. if m.adddontseeme != nil {
  7479. *m.adddontseeme += i
  7480. } else {
  7481. m.adddontseeme = &i
  7482. }
  7483. }
  7484. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7485. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7486. v := m.adddontseeme
  7487. if v == nil {
  7488. return
  7489. }
  7490. return *v, true
  7491. }
  7492. // ResetDontseeme resets all changes to the "dontseeme" field.
  7493. func (m *ContactMutation) ResetDontseeme() {
  7494. m.dontseeme = nil
  7495. m.adddontseeme = nil
  7496. }
  7497. // SetLag sets the "lag" field.
  7498. func (m *ContactMutation) SetLag(s string) {
  7499. m.lag = &s
  7500. }
  7501. // Lag returns the value of the "lag" field in the mutation.
  7502. func (m *ContactMutation) Lag() (r string, exists bool) {
  7503. v := m.lag
  7504. if v == nil {
  7505. return
  7506. }
  7507. return *v, true
  7508. }
  7509. // OldLag returns the old "lag" field's value of the Contact entity.
  7510. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7512. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7513. if !m.op.Is(OpUpdateOne) {
  7514. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7515. }
  7516. if m.id == nil || m.oldValue == nil {
  7517. return v, errors.New("OldLag requires an ID field in the mutation")
  7518. }
  7519. oldValue, err := m.oldValue(ctx)
  7520. if err != nil {
  7521. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7522. }
  7523. return oldValue.Lag, nil
  7524. }
  7525. // ResetLag resets all changes to the "lag" field.
  7526. func (m *ContactMutation) ResetLag() {
  7527. m.lag = nil
  7528. }
  7529. // SetGid sets the "gid" field.
  7530. func (m *ContactMutation) SetGid(s string) {
  7531. m.gid = &s
  7532. }
  7533. // Gid returns the value of the "gid" field in the mutation.
  7534. func (m *ContactMutation) Gid() (r string, exists bool) {
  7535. v := m.gid
  7536. if v == nil {
  7537. return
  7538. }
  7539. return *v, true
  7540. }
  7541. // OldGid returns the old "gid" field's value of the Contact entity.
  7542. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7544. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7545. if !m.op.Is(OpUpdateOne) {
  7546. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7547. }
  7548. if m.id == nil || m.oldValue == nil {
  7549. return v, errors.New("OldGid requires an ID field in the mutation")
  7550. }
  7551. oldValue, err := m.oldValue(ctx)
  7552. if err != nil {
  7553. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7554. }
  7555. return oldValue.Gid, nil
  7556. }
  7557. // ResetGid resets all changes to the "gid" field.
  7558. func (m *ContactMutation) ResetGid() {
  7559. m.gid = nil
  7560. }
  7561. // SetGname sets the "gname" field.
  7562. func (m *ContactMutation) SetGname(s string) {
  7563. m.gname = &s
  7564. }
  7565. // Gname returns the value of the "gname" field in the mutation.
  7566. func (m *ContactMutation) Gname() (r string, exists bool) {
  7567. v := m.gname
  7568. if v == nil {
  7569. return
  7570. }
  7571. return *v, true
  7572. }
  7573. // OldGname returns the old "gname" field's value of the Contact entity.
  7574. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7576. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7577. if !m.op.Is(OpUpdateOne) {
  7578. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7579. }
  7580. if m.id == nil || m.oldValue == nil {
  7581. return v, errors.New("OldGname requires an ID field in the mutation")
  7582. }
  7583. oldValue, err := m.oldValue(ctx)
  7584. if err != nil {
  7585. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7586. }
  7587. return oldValue.Gname, nil
  7588. }
  7589. // ResetGname resets all changes to the "gname" field.
  7590. func (m *ContactMutation) ResetGname() {
  7591. m.gname = nil
  7592. }
  7593. // SetV3 sets the "v3" field.
  7594. func (m *ContactMutation) SetV3(s string) {
  7595. m.v3 = &s
  7596. }
  7597. // V3 returns the value of the "v3" field in the mutation.
  7598. func (m *ContactMutation) V3() (r string, exists bool) {
  7599. v := m.v3
  7600. if v == nil {
  7601. return
  7602. }
  7603. return *v, true
  7604. }
  7605. // OldV3 returns the old "v3" field's value of the Contact entity.
  7606. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7608. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7609. if !m.op.Is(OpUpdateOne) {
  7610. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7611. }
  7612. if m.id == nil || m.oldValue == nil {
  7613. return v, errors.New("OldV3 requires an ID field in the mutation")
  7614. }
  7615. oldValue, err := m.oldValue(ctx)
  7616. if err != nil {
  7617. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7618. }
  7619. return oldValue.V3, nil
  7620. }
  7621. // ResetV3 resets all changes to the "v3" field.
  7622. func (m *ContactMutation) ResetV3() {
  7623. m.v3 = nil
  7624. }
  7625. // SetOrganizationID sets the "organization_id" field.
  7626. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7627. m.organization_id = &u
  7628. m.addorganization_id = nil
  7629. }
  7630. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7631. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7632. v := m.organization_id
  7633. if v == nil {
  7634. return
  7635. }
  7636. return *v, true
  7637. }
  7638. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7639. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7641. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7642. if !m.op.Is(OpUpdateOne) {
  7643. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7644. }
  7645. if m.id == nil || m.oldValue == nil {
  7646. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7647. }
  7648. oldValue, err := m.oldValue(ctx)
  7649. if err != nil {
  7650. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7651. }
  7652. return oldValue.OrganizationID, nil
  7653. }
  7654. // AddOrganizationID adds u to the "organization_id" field.
  7655. func (m *ContactMutation) AddOrganizationID(u int64) {
  7656. if m.addorganization_id != nil {
  7657. *m.addorganization_id += u
  7658. } else {
  7659. m.addorganization_id = &u
  7660. }
  7661. }
  7662. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7663. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7664. v := m.addorganization_id
  7665. if v == nil {
  7666. return
  7667. }
  7668. return *v, true
  7669. }
  7670. // ClearOrganizationID clears the value of the "organization_id" field.
  7671. func (m *ContactMutation) ClearOrganizationID() {
  7672. m.organization_id = nil
  7673. m.addorganization_id = nil
  7674. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7675. }
  7676. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7677. func (m *ContactMutation) OrganizationIDCleared() bool {
  7678. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7679. return ok
  7680. }
  7681. // ResetOrganizationID resets all changes to the "organization_id" field.
  7682. func (m *ContactMutation) ResetOrganizationID() {
  7683. m.organization_id = nil
  7684. m.addorganization_id = nil
  7685. delete(m.clearedFields, contact.FieldOrganizationID)
  7686. }
  7687. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7688. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7689. if m.contact_relationships == nil {
  7690. m.contact_relationships = make(map[uint64]struct{})
  7691. }
  7692. for i := range ids {
  7693. m.contact_relationships[ids[i]] = struct{}{}
  7694. }
  7695. }
  7696. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7697. func (m *ContactMutation) ClearContactRelationships() {
  7698. m.clearedcontact_relationships = true
  7699. }
  7700. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7701. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7702. return m.clearedcontact_relationships
  7703. }
  7704. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7705. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7706. if m.removedcontact_relationships == nil {
  7707. m.removedcontact_relationships = make(map[uint64]struct{})
  7708. }
  7709. for i := range ids {
  7710. delete(m.contact_relationships, ids[i])
  7711. m.removedcontact_relationships[ids[i]] = struct{}{}
  7712. }
  7713. }
  7714. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7715. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7716. for id := range m.removedcontact_relationships {
  7717. ids = append(ids, id)
  7718. }
  7719. return
  7720. }
  7721. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7722. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7723. for id := range m.contact_relationships {
  7724. ids = append(ids, id)
  7725. }
  7726. return
  7727. }
  7728. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7729. func (m *ContactMutation) ResetContactRelationships() {
  7730. m.contact_relationships = nil
  7731. m.clearedcontact_relationships = false
  7732. m.removedcontact_relationships = nil
  7733. }
  7734. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7735. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7736. if m.contact_messages == nil {
  7737. m.contact_messages = make(map[uint64]struct{})
  7738. }
  7739. for i := range ids {
  7740. m.contact_messages[ids[i]] = struct{}{}
  7741. }
  7742. }
  7743. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7744. func (m *ContactMutation) ClearContactMessages() {
  7745. m.clearedcontact_messages = true
  7746. }
  7747. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7748. func (m *ContactMutation) ContactMessagesCleared() bool {
  7749. return m.clearedcontact_messages
  7750. }
  7751. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7752. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7753. if m.removedcontact_messages == nil {
  7754. m.removedcontact_messages = make(map[uint64]struct{})
  7755. }
  7756. for i := range ids {
  7757. delete(m.contact_messages, ids[i])
  7758. m.removedcontact_messages[ids[i]] = struct{}{}
  7759. }
  7760. }
  7761. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7762. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7763. for id := range m.removedcontact_messages {
  7764. ids = append(ids, id)
  7765. }
  7766. return
  7767. }
  7768. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7769. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7770. for id := range m.contact_messages {
  7771. ids = append(ids, id)
  7772. }
  7773. return
  7774. }
  7775. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7776. func (m *ContactMutation) ResetContactMessages() {
  7777. m.contact_messages = nil
  7778. m.clearedcontact_messages = false
  7779. m.removedcontact_messages = nil
  7780. }
  7781. // Where appends a list predicates to the ContactMutation builder.
  7782. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7783. m.predicates = append(m.predicates, ps...)
  7784. }
  7785. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7786. // users can use type-assertion to append predicates that do not depend on any generated package.
  7787. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7788. p := make([]predicate.Contact, len(ps))
  7789. for i := range ps {
  7790. p[i] = ps[i]
  7791. }
  7792. m.Where(p...)
  7793. }
  7794. // Op returns the operation name.
  7795. func (m *ContactMutation) Op() Op {
  7796. return m.op
  7797. }
  7798. // SetOp allows setting the mutation operation.
  7799. func (m *ContactMutation) SetOp(op Op) {
  7800. m.op = op
  7801. }
  7802. // Type returns the node type of this mutation (Contact).
  7803. func (m *ContactMutation) Type() string {
  7804. return m.typ
  7805. }
  7806. // Fields returns all fields that were changed during this mutation. Note that in
  7807. // order to get all numeric fields that were incremented/decremented, call
  7808. // AddedFields().
  7809. func (m *ContactMutation) Fields() []string {
  7810. fields := make([]string, 0, 20)
  7811. if m.created_at != nil {
  7812. fields = append(fields, contact.FieldCreatedAt)
  7813. }
  7814. if m.updated_at != nil {
  7815. fields = append(fields, contact.FieldUpdatedAt)
  7816. }
  7817. if m.status != nil {
  7818. fields = append(fields, contact.FieldStatus)
  7819. }
  7820. if m.deleted_at != nil {
  7821. fields = append(fields, contact.FieldDeletedAt)
  7822. }
  7823. if m.wx_wxid != nil {
  7824. fields = append(fields, contact.FieldWxWxid)
  7825. }
  7826. if m._type != nil {
  7827. fields = append(fields, contact.FieldType)
  7828. }
  7829. if m.wxid != nil {
  7830. fields = append(fields, contact.FieldWxid)
  7831. }
  7832. if m.account != nil {
  7833. fields = append(fields, contact.FieldAccount)
  7834. }
  7835. if m.nickname != nil {
  7836. fields = append(fields, contact.FieldNickname)
  7837. }
  7838. if m.markname != nil {
  7839. fields = append(fields, contact.FieldMarkname)
  7840. }
  7841. if m.headimg != nil {
  7842. fields = append(fields, contact.FieldHeadimg)
  7843. }
  7844. if m.sex != nil {
  7845. fields = append(fields, contact.FieldSex)
  7846. }
  7847. if m.starrole != nil {
  7848. fields = append(fields, contact.FieldStarrole)
  7849. }
  7850. if m.dontseeit != nil {
  7851. fields = append(fields, contact.FieldDontseeit)
  7852. }
  7853. if m.dontseeme != nil {
  7854. fields = append(fields, contact.FieldDontseeme)
  7855. }
  7856. if m.lag != nil {
  7857. fields = append(fields, contact.FieldLag)
  7858. }
  7859. if m.gid != nil {
  7860. fields = append(fields, contact.FieldGid)
  7861. }
  7862. if m.gname != nil {
  7863. fields = append(fields, contact.FieldGname)
  7864. }
  7865. if m.v3 != nil {
  7866. fields = append(fields, contact.FieldV3)
  7867. }
  7868. if m.organization_id != nil {
  7869. fields = append(fields, contact.FieldOrganizationID)
  7870. }
  7871. return fields
  7872. }
  7873. // Field returns the value of a field with the given name. The second boolean
  7874. // return value indicates that this field was not set, or was not defined in the
  7875. // schema.
  7876. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7877. switch name {
  7878. case contact.FieldCreatedAt:
  7879. return m.CreatedAt()
  7880. case contact.FieldUpdatedAt:
  7881. return m.UpdatedAt()
  7882. case contact.FieldStatus:
  7883. return m.Status()
  7884. case contact.FieldDeletedAt:
  7885. return m.DeletedAt()
  7886. case contact.FieldWxWxid:
  7887. return m.WxWxid()
  7888. case contact.FieldType:
  7889. return m.GetType()
  7890. case contact.FieldWxid:
  7891. return m.Wxid()
  7892. case contact.FieldAccount:
  7893. return m.Account()
  7894. case contact.FieldNickname:
  7895. return m.Nickname()
  7896. case contact.FieldMarkname:
  7897. return m.Markname()
  7898. case contact.FieldHeadimg:
  7899. return m.Headimg()
  7900. case contact.FieldSex:
  7901. return m.Sex()
  7902. case contact.FieldStarrole:
  7903. return m.Starrole()
  7904. case contact.FieldDontseeit:
  7905. return m.Dontseeit()
  7906. case contact.FieldDontseeme:
  7907. return m.Dontseeme()
  7908. case contact.FieldLag:
  7909. return m.Lag()
  7910. case contact.FieldGid:
  7911. return m.Gid()
  7912. case contact.FieldGname:
  7913. return m.Gname()
  7914. case contact.FieldV3:
  7915. return m.V3()
  7916. case contact.FieldOrganizationID:
  7917. return m.OrganizationID()
  7918. }
  7919. return nil, false
  7920. }
  7921. // OldField returns the old value of the field from the database. An error is
  7922. // returned if the mutation operation is not UpdateOne, or the query to the
  7923. // database failed.
  7924. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7925. switch name {
  7926. case contact.FieldCreatedAt:
  7927. return m.OldCreatedAt(ctx)
  7928. case contact.FieldUpdatedAt:
  7929. return m.OldUpdatedAt(ctx)
  7930. case contact.FieldStatus:
  7931. return m.OldStatus(ctx)
  7932. case contact.FieldDeletedAt:
  7933. return m.OldDeletedAt(ctx)
  7934. case contact.FieldWxWxid:
  7935. return m.OldWxWxid(ctx)
  7936. case contact.FieldType:
  7937. return m.OldType(ctx)
  7938. case contact.FieldWxid:
  7939. return m.OldWxid(ctx)
  7940. case contact.FieldAccount:
  7941. return m.OldAccount(ctx)
  7942. case contact.FieldNickname:
  7943. return m.OldNickname(ctx)
  7944. case contact.FieldMarkname:
  7945. return m.OldMarkname(ctx)
  7946. case contact.FieldHeadimg:
  7947. return m.OldHeadimg(ctx)
  7948. case contact.FieldSex:
  7949. return m.OldSex(ctx)
  7950. case contact.FieldStarrole:
  7951. return m.OldStarrole(ctx)
  7952. case contact.FieldDontseeit:
  7953. return m.OldDontseeit(ctx)
  7954. case contact.FieldDontseeme:
  7955. return m.OldDontseeme(ctx)
  7956. case contact.FieldLag:
  7957. return m.OldLag(ctx)
  7958. case contact.FieldGid:
  7959. return m.OldGid(ctx)
  7960. case contact.FieldGname:
  7961. return m.OldGname(ctx)
  7962. case contact.FieldV3:
  7963. return m.OldV3(ctx)
  7964. case contact.FieldOrganizationID:
  7965. return m.OldOrganizationID(ctx)
  7966. }
  7967. return nil, fmt.Errorf("unknown Contact field %s", name)
  7968. }
  7969. // SetField sets the value of a field with the given name. It returns an error if
  7970. // the field is not defined in the schema, or if the type mismatched the field
  7971. // type.
  7972. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  7973. switch name {
  7974. case contact.FieldCreatedAt:
  7975. v, ok := value.(time.Time)
  7976. if !ok {
  7977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7978. }
  7979. m.SetCreatedAt(v)
  7980. return nil
  7981. case contact.FieldUpdatedAt:
  7982. v, ok := value.(time.Time)
  7983. if !ok {
  7984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7985. }
  7986. m.SetUpdatedAt(v)
  7987. return nil
  7988. case contact.FieldStatus:
  7989. v, ok := value.(uint8)
  7990. if !ok {
  7991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7992. }
  7993. m.SetStatus(v)
  7994. return nil
  7995. case contact.FieldDeletedAt:
  7996. v, ok := value.(time.Time)
  7997. if !ok {
  7998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7999. }
  8000. m.SetDeletedAt(v)
  8001. return nil
  8002. case contact.FieldWxWxid:
  8003. v, ok := value.(string)
  8004. if !ok {
  8005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8006. }
  8007. m.SetWxWxid(v)
  8008. return nil
  8009. case contact.FieldType:
  8010. v, ok := value.(int)
  8011. if !ok {
  8012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8013. }
  8014. m.SetType(v)
  8015. return nil
  8016. case contact.FieldWxid:
  8017. v, ok := value.(string)
  8018. if !ok {
  8019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8020. }
  8021. m.SetWxid(v)
  8022. return nil
  8023. case contact.FieldAccount:
  8024. v, ok := value.(string)
  8025. if !ok {
  8026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8027. }
  8028. m.SetAccount(v)
  8029. return nil
  8030. case contact.FieldNickname:
  8031. v, ok := value.(string)
  8032. if !ok {
  8033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8034. }
  8035. m.SetNickname(v)
  8036. return nil
  8037. case contact.FieldMarkname:
  8038. v, ok := value.(string)
  8039. if !ok {
  8040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8041. }
  8042. m.SetMarkname(v)
  8043. return nil
  8044. case contact.FieldHeadimg:
  8045. v, ok := value.(string)
  8046. if !ok {
  8047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8048. }
  8049. m.SetHeadimg(v)
  8050. return nil
  8051. case contact.FieldSex:
  8052. v, ok := value.(int)
  8053. if !ok {
  8054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8055. }
  8056. m.SetSex(v)
  8057. return nil
  8058. case contact.FieldStarrole:
  8059. v, ok := value.(string)
  8060. if !ok {
  8061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8062. }
  8063. m.SetStarrole(v)
  8064. return nil
  8065. case contact.FieldDontseeit:
  8066. v, ok := value.(int)
  8067. if !ok {
  8068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8069. }
  8070. m.SetDontseeit(v)
  8071. return nil
  8072. case contact.FieldDontseeme:
  8073. v, ok := value.(int)
  8074. if !ok {
  8075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8076. }
  8077. m.SetDontseeme(v)
  8078. return nil
  8079. case contact.FieldLag:
  8080. v, ok := value.(string)
  8081. if !ok {
  8082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8083. }
  8084. m.SetLag(v)
  8085. return nil
  8086. case contact.FieldGid:
  8087. v, ok := value.(string)
  8088. if !ok {
  8089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8090. }
  8091. m.SetGid(v)
  8092. return nil
  8093. case contact.FieldGname:
  8094. v, ok := value.(string)
  8095. if !ok {
  8096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8097. }
  8098. m.SetGname(v)
  8099. return nil
  8100. case contact.FieldV3:
  8101. v, ok := value.(string)
  8102. if !ok {
  8103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8104. }
  8105. m.SetV3(v)
  8106. return nil
  8107. case contact.FieldOrganizationID:
  8108. v, ok := value.(uint64)
  8109. if !ok {
  8110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8111. }
  8112. m.SetOrganizationID(v)
  8113. return nil
  8114. }
  8115. return fmt.Errorf("unknown Contact field %s", name)
  8116. }
  8117. // AddedFields returns all numeric fields that were incremented/decremented during
  8118. // this mutation.
  8119. func (m *ContactMutation) AddedFields() []string {
  8120. var fields []string
  8121. if m.addstatus != nil {
  8122. fields = append(fields, contact.FieldStatus)
  8123. }
  8124. if m.add_type != nil {
  8125. fields = append(fields, contact.FieldType)
  8126. }
  8127. if m.addsex != nil {
  8128. fields = append(fields, contact.FieldSex)
  8129. }
  8130. if m.adddontseeit != nil {
  8131. fields = append(fields, contact.FieldDontseeit)
  8132. }
  8133. if m.adddontseeme != nil {
  8134. fields = append(fields, contact.FieldDontseeme)
  8135. }
  8136. if m.addorganization_id != nil {
  8137. fields = append(fields, contact.FieldOrganizationID)
  8138. }
  8139. return fields
  8140. }
  8141. // AddedField returns the numeric value that was incremented/decremented on a field
  8142. // with the given name. The second boolean return value indicates that this field
  8143. // was not set, or was not defined in the schema.
  8144. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8145. switch name {
  8146. case contact.FieldStatus:
  8147. return m.AddedStatus()
  8148. case contact.FieldType:
  8149. return m.AddedType()
  8150. case contact.FieldSex:
  8151. return m.AddedSex()
  8152. case contact.FieldDontseeit:
  8153. return m.AddedDontseeit()
  8154. case contact.FieldDontseeme:
  8155. return m.AddedDontseeme()
  8156. case contact.FieldOrganizationID:
  8157. return m.AddedOrganizationID()
  8158. }
  8159. return nil, false
  8160. }
  8161. // AddField adds the value to the field with the given name. It returns an error if
  8162. // the field is not defined in the schema, or if the type mismatched the field
  8163. // type.
  8164. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8165. switch name {
  8166. case contact.FieldStatus:
  8167. v, ok := value.(int8)
  8168. if !ok {
  8169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8170. }
  8171. m.AddStatus(v)
  8172. return nil
  8173. case contact.FieldType:
  8174. v, ok := value.(int)
  8175. if !ok {
  8176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8177. }
  8178. m.AddType(v)
  8179. return nil
  8180. case contact.FieldSex:
  8181. v, ok := value.(int)
  8182. if !ok {
  8183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8184. }
  8185. m.AddSex(v)
  8186. return nil
  8187. case contact.FieldDontseeit:
  8188. v, ok := value.(int)
  8189. if !ok {
  8190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8191. }
  8192. m.AddDontseeit(v)
  8193. return nil
  8194. case contact.FieldDontseeme:
  8195. v, ok := value.(int)
  8196. if !ok {
  8197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8198. }
  8199. m.AddDontseeme(v)
  8200. return nil
  8201. case contact.FieldOrganizationID:
  8202. v, ok := value.(int64)
  8203. if !ok {
  8204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8205. }
  8206. m.AddOrganizationID(v)
  8207. return nil
  8208. }
  8209. return fmt.Errorf("unknown Contact numeric field %s", name)
  8210. }
  8211. // ClearedFields returns all nullable fields that were cleared during this
  8212. // mutation.
  8213. func (m *ContactMutation) ClearedFields() []string {
  8214. var fields []string
  8215. if m.FieldCleared(contact.FieldStatus) {
  8216. fields = append(fields, contact.FieldStatus)
  8217. }
  8218. if m.FieldCleared(contact.FieldDeletedAt) {
  8219. fields = append(fields, contact.FieldDeletedAt)
  8220. }
  8221. if m.FieldCleared(contact.FieldType) {
  8222. fields = append(fields, contact.FieldType)
  8223. }
  8224. if m.FieldCleared(contact.FieldOrganizationID) {
  8225. fields = append(fields, contact.FieldOrganizationID)
  8226. }
  8227. return fields
  8228. }
  8229. // FieldCleared returns a boolean indicating if a field with the given name was
  8230. // cleared in this mutation.
  8231. func (m *ContactMutation) FieldCleared(name string) bool {
  8232. _, ok := m.clearedFields[name]
  8233. return ok
  8234. }
  8235. // ClearField clears the value of the field with the given name. It returns an
  8236. // error if the field is not defined in the schema.
  8237. func (m *ContactMutation) ClearField(name string) error {
  8238. switch name {
  8239. case contact.FieldStatus:
  8240. m.ClearStatus()
  8241. return nil
  8242. case contact.FieldDeletedAt:
  8243. m.ClearDeletedAt()
  8244. return nil
  8245. case contact.FieldType:
  8246. m.ClearType()
  8247. return nil
  8248. case contact.FieldOrganizationID:
  8249. m.ClearOrganizationID()
  8250. return nil
  8251. }
  8252. return fmt.Errorf("unknown Contact nullable field %s", name)
  8253. }
  8254. // ResetField resets all changes in the mutation for the field with the given name.
  8255. // It returns an error if the field is not defined in the schema.
  8256. func (m *ContactMutation) ResetField(name string) error {
  8257. switch name {
  8258. case contact.FieldCreatedAt:
  8259. m.ResetCreatedAt()
  8260. return nil
  8261. case contact.FieldUpdatedAt:
  8262. m.ResetUpdatedAt()
  8263. return nil
  8264. case contact.FieldStatus:
  8265. m.ResetStatus()
  8266. return nil
  8267. case contact.FieldDeletedAt:
  8268. m.ResetDeletedAt()
  8269. return nil
  8270. case contact.FieldWxWxid:
  8271. m.ResetWxWxid()
  8272. return nil
  8273. case contact.FieldType:
  8274. m.ResetType()
  8275. return nil
  8276. case contact.FieldWxid:
  8277. m.ResetWxid()
  8278. return nil
  8279. case contact.FieldAccount:
  8280. m.ResetAccount()
  8281. return nil
  8282. case contact.FieldNickname:
  8283. m.ResetNickname()
  8284. return nil
  8285. case contact.FieldMarkname:
  8286. m.ResetMarkname()
  8287. return nil
  8288. case contact.FieldHeadimg:
  8289. m.ResetHeadimg()
  8290. return nil
  8291. case contact.FieldSex:
  8292. m.ResetSex()
  8293. return nil
  8294. case contact.FieldStarrole:
  8295. m.ResetStarrole()
  8296. return nil
  8297. case contact.FieldDontseeit:
  8298. m.ResetDontseeit()
  8299. return nil
  8300. case contact.FieldDontseeme:
  8301. m.ResetDontseeme()
  8302. return nil
  8303. case contact.FieldLag:
  8304. m.ResetLag()
  8305. return nil
  8306. case contact.FieldGid:
  8307. m.ResetGid()
  8308. return nil
  8309. case contact.FieldGname:
  8310. m.ResetGname()
  8311. return nil
  8312. case contact.FieldV3:
  8313. m.ResetV3()
  8314. return nil
  8315. case contact.FieldOrganizationID:
  8316. m.ResetOrganizationID()
  8317. return nil
  8318. }
  8319. return fmt.Errorf("unknown Contact field %s", name)
  8320. }
  8321. // AddedEdges returns all edge names that were set/added in this mutation.
  8322. func (m *ContactMutation) AddedEdges() []string {
  8323. edges := make([]string, 0, 2)
  8324. if m.contact_relationships != nil {
  8325. edges = append(edges, contact.EdgeContactRelationships)
  8326. }
  8327. if m.contact_messages != nil {
  8328. edges = append(edges, contact.EdgeContactMessages)
  8329. }
  8330. return edges
  8331. }
  8332. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8333. // name in this mutation.
  8334. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8335. switch name {
  8336. case contact.EdgeContactRelationships:
  8337. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8338. for id := range m.contact_relationships {
  8339. ids = append(ids, id)
  8340. }
  8341. return ids
  8342. case contact.EdgeContactMessages:
  8343. ids := make([]ent.Value, 0, len(m.contact_messages))
  8344. for id := range m.contact_messages {
  8345. ids = append(ids, id)
  8346. }
  8347. return ids
  8348. }
  8349. return nil
  8350. }
  8351. // RemovedEdges returns all edge names that were removed in this mutation.
  8352. func (m *ContactMutation) RemovedEdges() []string {
  8353. edges := make([]string, 0, 2)
  8354. if m.removedcontact_relationships != nil {
  8355. edges = append(edges, contact.EdgeContactRelationships)
  8356. }
  8357. if m.removedcontact_messages != nil {
  8358. edges = append(edges, contact.EdgeContactMessages)
  8359. }
  8360. return edges
  8361. }
  8362. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8363. // the given name in this mutation.
  8364. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8365. switch name {
  8366. case contact.EdgeContactRelationships:
  8367. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8368. for id := range m.removedcontact_relationships {
  8369. ids = append(ids, id)
  8370. }
  8371. return ids
  8372. case contact.EdgeContactMessages:
  8373. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8374. for id := range m.removedcontact_messages {
  8375. ids = append(ids, id)
  8376. }
  8377. return ids
  8378. }
  8379. return nil
  8380. }
  8381. // ClearedEdges returns all edge names that were cleared in this mutation.
  8382. func (m *ContactMutation) ClearedEdges() []string {
  8383. edges := make([]string, 0, 2)
  8384. if m.clearedcontact_relationships {
  8385. edges = append(edges, contact.EdgeContactRelationships)
  8386. }
  8387. if m.clearedcontact_messages {
  8388. edges = append(edges, contact.EdgeContactMessages)
  8389. }
  8390. return edges
  8391. }
  8392. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8393. // was cleared in this mutation.
  8394. func (m *ContactMutation) EdgeCleared(name string) bool {
  8395. switch name {
  8396. case contact.EdgeContactRelationships:
  8397. return m.clearedcontact_relationships
  8398. case contact.EdgeContactMessages:
  8399. return m.clearedcontact_messages
  8400. }
  8401. return false
  8402. }
  8403. // ClearEdge clears the value of the edge with the given name. It returns an error
  8404. // if that edge is not defined in the schema.
  8405. func (m *ContactMutation) ClearEdge(name string) error {
  8406. switch name {
  8407. }
  8408. return fmt.Errorf("unknown Contact unique edge %s", name)
  8409. }
  8410. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8411. // It returns an error if the edge is not defined in the schema.
  8412. func (m *ContactMutation) ResetEdge(name string) error {
  8413. switch name {
  8414. case contact.EdgeContactRelationships:
  8415. m.ResetContactRelationships()
  8416. return nil
  8417. case contact.EdgeContactMessages:
  8418. m.ResetContactMessages()
  8419. return nil
  8420. }
  8421. return fmt.Errorf("unknown Contact edge %s", name)
  8422. }
  8423. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8424. type EmployeeMutation struct {
  8425. config
  8426. op Op
  8427. typ string
  8428. id *uint64
  8429. created_at *time.Time
  8430. updated_at *time.Time
  8431. deleted_at *time.Time
  8432. title *string
  8433. avatar *string
  8434. tags *string
  8435. hire_count *int
  8436. addhire_count *int
  8437. service_count *int
  8438. addservice_count *int
  8439. achievement_count *int
  8440. addachievement_count *int
  8441. intro *string
  8442. estimate *string
  8443. skill *string
  8444. ability_type *string
  8445. scene *string
  8446. switch_in *string
  8447. video_url *string
  8448. organization_id *uint64
  8449. addorganization_id *int64
  8450. category_id *uint64
  8451. addcategory_id *int64
  8452. api_base *string
  8453. api_key *string
  8454. ai_info *string
  8455. is_vip *int
  8456. addis_vip *int
  8457. clearedFields map[string]struct{}
  8458. em_work_experiences map[uint64]struct{}
  8459. removedem_work_experiences map[uint64]struct{}
  8460. clearedem_work_experiences bool
  8461. em_tutorial map[uint64]struct{}
  8462. removedem_tutorial map[uint64]struct{}
  8463. clearedem_tutorial bool
  8464. done bool
  8465. oldValue func(context.Context) (*Employee, error)
  8466. predicates []predicate.Employee
  8467. }
  8468. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8469. // employeeOption allows management of the mutation configuration using functional options.
  8470. type employeeOption func(*EmployeeMutation)
  8471. // newEmployeeMutation creates new mutation for the Employee entity.
  8472. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8473. m := &EmployeeMutation{
  8474. config: c,
  8475. op: op,
  8476. typ: TypeEmployee,
  8477. clearedFields: make(map[string]struct{}),
  8478. }
  8479. for _, opt := range opts {
  8480. opt(m)
  8481. }
  8482. return m
  8483. }
  8484. // withEmployeeID sets the ID field of the mutation.
  8485. func withEmployeeID(id uint64) employeeOption {
  8486. return func(m *EmployeeMutation) {
  8487. var (
  8488. err error
  8489. once sync.Once
  8490. value *Employee
  8491. )
  8492. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8493. once.Do(func() {
  8494. if m.done {
  8495. err = errors.New("querying old values post mutation is not allowed")
  8496. } else {
  8497. value, err = m.Client().Employee.Get(ctx, id)
  8498. }
  8499. })
  8500. return value, err
  8501. }
  8502. m.id = &id
  8503. }
  8504. }
  8505. // withEmployee sets the old Employee of the mutation.
  8506. func withEmployee(node *Employee) employeeOption {
  8507. return func(m *EmployeeMutation) {
  8508. m.oldValue = func(context.Context) (*Employee, error) {
  8509. return node, nil
  8510. }
  8511. m.id = &node.ID
  8512. }
  8513. }
  8514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8515. // executed in a transaction (ent.Tx), a transactional client is returned.
  8516. func (m EmployeeMutation) Client() *Client {
  8517. client := &Client{config: m.config}
  8518. client.init()
  8519. return client
  8520. }
  8521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8522. // it returns an error otherwise.
  8523. func (m EmployeeMutation) Tx() (*Tx, error) {
  8524. if _, ok := m.driver.(*txDriver); !ok {
  8525. return nil, errors.New("ent: mutation is not running in a transaction")
  8526. }
  8527. tx := &Tx{config: m.config}
  8528. tx.init()
  8529. return tx, nil
  8530. }
  8531. // SetID sets the value of the id field. Note that this
  8532. // operation is only accepted on creation of Employee entities.
  8533. func (m *EmployeeMutation) SetID(id uint64) {
  8534. m.id = &id
  8535. }
  8536. // ID returns the ID value in the mutation. Note that the ID is only available
  8537. // if it was provided to the builder or after it was returned from the database.
  8538. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8539. if m.id == nil {
  8540. return
  8541. }
  8542. return *m.id, true
  8543. }
  8544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8545. // That means, if the mutation is applied within a transaction with an isolation level such
  8546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8547. // or updated by the mutation.
  8548. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8549. switch {
  8550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8551. id, exists := m.ID()
  8552. if exists {
  8553. return []uint64{id}, nil
  8554. }
  8555. fallthrough
  8556. case m.op.Is(OpUpdate | OpDelete):
  8557. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8558. default:
  8559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8560. }
  8561. }
  8562. // SetCreatedAt sets the "created_at" field.
  8563. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8564. m.created_at = &t
  8565. }
  8566. // CreatedAt returns the value of the "created_at" field in the mutation.
  8567. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8568. v := m.created_at
  8569. if v == nil {
  8570. return
  8571. }
  8572. return *v, true
  8573. }
  8574. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8575. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8577. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8578. if !m.op.Is(OpUpdateOne) {
  8579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8580. }
  8581. if m.id == nil || m.oldValue == nil {
  8582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8583. }
  8584. oldValue, err := m.oldValue(ctx)
  8585. if err != nil {
  8586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8587. }
  8588. return oldValue.CreatedAt, nil
  8589. }
  8590. // ResetCreatedAt resets all changes to the "created_at" field.
  8591. func (m *EmployeeMutation) ResetCreatedAt() {
  8592. m.created_at = nil
  8593. }
  8594. // SetUpdatedAt sets the "updated_at" field.
  8595. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8596. m.updated_at = &t
  8597. }
  8598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8599. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8600. v := m.updated_at
  8601. if v == nil {
  8602. return
  8603. }
  8604. return *v, true
  8605. }
  8606. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8607. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8609. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8610. if !m.op.Is(OpUpdateOne) {
  8611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8612. }
  8613. if m.id == nil || m.oldValue == nil {
  8614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8615. }
  8616. oldValue, err := m.oldValue(ctx)
  8617. if err != nil {
  8618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8619. }
  8620. return oldValue.UpdatedAt, nil
  8621. }
  8622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8623. func (m *EmployeeMutation) ResetUpdatedAt() {
  8624. m.updated_at = nil
  8625. }
  8626. // SetDeletedAt sets the "deleted_at" field.
  8627. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8628. m.deleted_at = &t
  8629. }
  8630. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8631. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8632. v := m.deleted_at
  8633. if v == nil {
  8634. return
  8635. }
  8636. return *v, true
  8637. }
  8638. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8639. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8641. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8642. if !m.op.Is(OpUpdateOne) {
  8643. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8644. }
  8645. if m.id == nil || m.oldValue == nil {
  8646. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8647. }
  8648. oldValue, err := m.oldValue(ctx)
  8649. if err != nil {
  8650. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8651. }
  8652. return oldValue.DeletedAt, nil
  8653. }
  8654. // ClearDeletedAt clears the value of the "deleted_at" field.
  8655. func (m *EmployeeMutation) ClearDeletedAt() {
  8656. m.deleted_at = nil
  8657. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8658. }
  8659. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8660. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8661. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8662. return ok
  8663. }
  8664. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8665. func (m *EmployeeMutation) ResetDeletedAt() {
  8666. m.deleted_at = nil
  8667. delete(m.clearedFields, employee.FieldDeletedAt)
  8668. }
  8669. // SetTitle sets the "title" field.
  8670. func (m *EmployeeMutation) SetTitle(s string) {
  8671. m.title = &s
  8672. }
  8673. // Title returns the value of the "title" field in the mutation.
  8674. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8675. v := m.title
  8676. if v == nil {
  8677. return
  8678. }
  8679. return *v, true
  8680. }
  8681. // OldTitle returns the old "title" field's value of the Employee entity.
  8682. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8684. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8685. if !m.op.Is(OpUpdateOne) {
  8686. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8687. }
  8688. if m.id == nil || m.oldValue == nil {
  8689. return v, errors.New("OldTitle requires an ID field in the mutation")
  8690. }
  8691. oldValue, err := m.oldValue(ctx)
  8692. if err != nil {
  8693. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8694. }
  8695. return oldValue.Title, nil
  8696. }
  8697. // ResetTitle resets all changes to the "title" field.
  8698. func (m *EmployeeMutation) ResetTitle() {
  8699. m.title = nil
  8700. }
  8701. // SetAvatar sets the "avatar" field.
  8702. func (m *EmployeeMutation) SetAvatar(s string) {
  8703. m.avatar = &s
  8704. }
  8705. // Avatar returns the value of the "avatar" field in the mutation.
  8706. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8707. v := m.avatar
  8708. if v == nil {
  8709. return
  8710. }
  8711. return *v, true
  8712. }
  8713. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8714. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8716. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8717. if !m.op.Is(OpUpdateOne) {
  8718. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8719. }
  8720. if m.id == nil || m.oldValue == nil {
  8721. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8722. }
  8723. oldValue, err := m.oldValue(ctx)
  8724. if err != nil {
  8725. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8726. }
  8727. return oldValue.Avatar, nil
  8728. }
  8729. // ResetAvatar resets all changes to the "avatar" field.
  8730. func (m *EmployeeMutation) ResetAvatar() {
  8731. m.avatar = nil
  8732. }
  8733. // SetTags sets the "tags" field.
  8734. func (m *EmployeeMutation) SetTags(s string) {
  8735. m.tags = &s
  8736. }
  8737. // Tags returns the value of the "tags" field in the mutation.
  8738. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8739. v := m.tags
  8740. if v == nil {
  8741. return
  8742. }
  8743. return *v, true
  8744. }
  8745. // OldTags returns the old "tags" field's value of the Employee entity.
  8746. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8748. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8749. if !m.op.Is(OpUpdateOne) {
  8750. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8751. }
  8752. if m.id == nil || m.oldValue == nil {
  8753. return v, errors.New("OldTags requires an ID field in the mutation")
  8754. }
  8755. oldValue, err := m.oldValue(ctx)
  8756. if err != nil {
  8757. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8758. }
  8759. return oldValue.Tags, nil
  8760. }
  8761. // ResetTags resets all changes to the "tags" field.
  8762. func (m *EmployeeMutation) ResetTags() {
  8763. m.tags = nil
  8764. }
  8765. // SetHireCount sets the "hire_count" field.
  8766. func (m *EmployeeMutation) SetHireCount(i int) {
  8767. m.hire_count = &i
  8768. m.addhire_count = nil
  8769. }
  8770. // HireCount returns the value of the "hire_count" field in the mutation.
  8771. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8772. v := m.hire_count
  8773. if v == nil {
  8774. return
  8775. }
  8776. return *v, true
  8777. }
  8778. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8779. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8781. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8782. if !m.op.Is(OpUpdateOne) {
  8783. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8784. }
  8785. if m.id == nil || m.oldValue == nil {
  8786. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8787. }
  8788. oldValue, err := m.oldValue(ctx)
  8789. if err != nil {
  8790. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8791. }
  8792. return oldValue.HireCount, nil
  8793. }
  8794. // AddHireCount adds i to the "hire_count" field.
  8795. func (m *EmployeeMutation) AddHireCount(i int) {
  8796. if m.addhire_count != nil {
  8797. *m.addhire_count += i
  8798. } else {
  8799. m.addhire_count = &i
  8800. }
  8801. }
  8802. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8803. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8804. v := m.addhire_count
  8805. if v == nil {
  8806. return
  8807. }
  8808. return *v, true
  8809. }
  8810. // ResetHireCount resets all changes to the "hire_count" field.
  8811. func (m *EmployeeMutation) ResetHireCount() {
  8812. m.hire_count = nil
  8813. m.addhire_count = nil
  8814. }
  8815. // SetServiceCount sets the "service_count" field.
  8816. func (m *EmployeeMutation) SetServiceCount(i int) {
  8817. m.service_count = &i
  8818. m.addservice_count = nil
  8819. }
  8820. // ServiceCount returns the value of the "service_count" field in the mutation.
  8821. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8822. v := m.service_count
  8823. if v == nil {
  8824. return
  8825. }
  8826. return *v, true
  8827. }
  8828. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8829. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8831. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8832. if !m.op.Is(OpUpdateOne) {
  8833. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8834. }
  8835. if m.id == nil || m.oldValue == nil {
  8836. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8837. }
  8838. oldValue, err := m.oldValue(ctx)
  8839. if err != nil {
  8840. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8841. }
  8842. return oldValue.ServiceCount, nil
  8843. }
  8844. // AddServiceCount adds i to the "service_count" field.
  8845. func (m *EmployeeMutation) AddServiceCount(i int) {
  8846. if m.addservice_count != nil {
  8847. *m.addservice_count += i
  8848. } else {
  8849. m.addservice_count = &i
  8850. }
  8851. }
  8852. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8853. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8854. v := m.addservice_count
  8855. if v == nil {
  8856. return
  8857. }
  8858. return *v, true
  8859. }
  8860. // ResetServiceCount resets all changes to the "service_count" field.
  8861. func (m *EmployeeMutation) ResetServiceCount() {
  8862. m.service_count = nil
  8863. m.addservice_count = nil
  8864. }
  8865. // SetAchievementCount sets the "achievement_count" field.
  8866. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8867. m.achievement_count = &i
  8868. m.addachievement_count = nil
  8869. }
  8870. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8871. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8872. v := m.achievement_count
  8873. if v == nil {
  8874. return
  8875. }
  8876. return *v, true
  8877. }
  8878. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8879. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8881. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8882. if !m.op.Is(OpUpdateOne) {
  8883. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8884. }
  8885. if m.id == nil || m.oldValue == nil {
  8886. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8887. }
  8888. oldValue, err := m.oldValue(ctx)
  8889. if err != nil {
  8890. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8891. }
  8892. return oldValue.AchievementCount, nil
  8893. }
  8894. // AddAchievementCount adds i to the "achievement_count" field.
  8895. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8896. if m.addachievement_count != nil {
  8897. *m.addachievement_count += i
  8898. } else {
  8899. m.addachievement_count = &i
  8900. }
  8901. }
  8902. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8903. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8904. v := m.addachievement_count
  8905. if v == nil {
  8906. return
  8907. }
  8908. return *v, true
  8909. }
  8910. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8911. func (m *EmployeeMutation) ResetAchievementCount() {
  8912. m.achievement_count = nil
  8913. m.addachievement_count = nil
  8914. }
  8915. // SetIntro sets the "intro" field.
  8916. func (m *EmployeeMutation) SetIntro(s string) {
  8917. m.intro = &s
  8918. }
  8919. // Intro returns the value of the "intro" field in the mutation.
  8920. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  8921. v := m.intro
  8922. if v == nil {
  8923. return
  8924. }
  8925. return *v, true
  8926. }
  8927. // OldIntro returns the old "intro" field's value of the Employee entity.
  8928. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8930. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  8931. if !m.op.Is(OpUpdateOne) {
  8932. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  8933. }
  8934. if m.id == nil || m.oldValue == nil {
  8935. return v, errors.New("OldIntro requires an ID field in the mutation")
  8936. }
  8937. oldValue, err := m.oldValue(ctx)
  8938. if err != nil {
  8939. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  8940. }
  8941. return oldValue.Intro, nil
  8942. }
  8943. // ResetIntro resets all changes to the "intro" field.
  8944. func (m *EmployeeMutation) ResetIntro() {
  8945. m.intro = nil
  8946. }
  8947. // SetEstimate sets the "estimate" field.
  8948. func (m *EmployeeMutation) SetEstimate(s string) {
  8949. m.estimate = &s
  8950. }
  8951. // Estimate returns the value of the "estimate" field in the mutation.
  8952. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  8953. v := m.estimate
  8954. if v == nil {
  8955. return
  8956. }
  8957. return *v, true
  8958. }
  8959. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  8960. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8962. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  8963. if !m.op.Is(OpUpdateOne) {
  8964. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  8965. }
  8966. if m.id == nil || m.oldValue == nil {
  8967. return v, errors.New("OldEstimate requires an ID field in the mutation")
  8968. }
  8969. oldValue, err := m.oldValue(ctx)
  8970. if err != nil {
  8971. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  8972. }
  8973. return oldValue.Estimate, nil
  8974. }
  8975. // ResetEstimate resets all changes to the "estimate" field.
  8976. func (m *EmployeeMutation) ResetEstimate() {
  8977. m.estimate = nil
  8978. }
  8979. // SetSkill sets the "skill" field.
  8980. func (m *EmployeeMutation) SetSkill(s string) {
  8981. m.skill = &s
  8982. }
  8983. // Skill returns the value of the "skill" field in the mutation.
  8984. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  8985. v := m.skill
  8986. if v == nil {
  8987. return
  8988. }
  8989. return *v, true
  8990. }
  8991. // OldSkill returns the old "skill" field's value of the Employee entity.
  8992. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8994. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  8995. if !m.op.Is(OpUpdateOne) {
  8996. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  8997. }
  8998. if m.id == nil || m.oldValue == nil {
  8999. return v, errors.New("OldSkill requires an ID field in the mutation")
  9000. }
  9001. oldValue, err := m.oldValue(ctx)
  9002. if err != nil {
  9003. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9004. }
  9005. return oldValue.Skill, nil
  9006. }
  9007. // ResetSkill resets all changes to the "skill" field.
  9008. func (m *EmployeeMutation) ResetSkill() {
  9009. m.skill = nil
  9010. }
  9011. // SetAbilityType sets the "ability_type" field.
  9012. func (m *EmployeeMutation) SetAbilityType(s string) {
  9013. m.ability_type = &s
  9014. }
  9015. // AbilityType returns the value of the "ability_type" field in the mutation.
  9016. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9017. v := m.ability_type
  9018. if v == nil {
  9019. return
  9020. }
  9021. return *v, true
  9022. }
  9023. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9024. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9026. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9027. if !m.op.Is(OpUpdateOne) {
  9028. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9029. }
  9030. if m.id == nil || m.oldValue == nil {
  9031. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9032. }
  9033. oldValue, err := m.oldValue(ctx)
  9034. if err != nil {
  9035. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9036. }
  9037. return oldValue.AbilityType, nil
  9038. }
  9039. // ResetAbilityType resets all changes to the "ability_type" field.
  9040. func (m *EmployeeMutation) ResetAbilityType() {
  9041. m.ability_type = nil
  9042. }
  9043. // SetScene sets the "scene" field.
  9044. func (m *EmployeeMutation) SetScene(s string) {
  9045. m.scene = &s
  9046. }
  9047. // Scene returns the value of the "scene" field in the mutation.
  9048. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9049. v := m.scene
  9050. if v == nil {
  9051. return
  9052. }
  9053. return *v, true
  9054. }
  9055. // OldScene returns the old "scene" field's value of the Employee entity.
  9056. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9058. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9059. if !m.op.Is(OpUpdateOne) {
  9060. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9061. }
  9062. if m.id == nil || m.oldValue == nil {
  9063. return v, errors.New("OldScene requires an ID field in the mutation")
  9064. }
  9065. oldValue, err := m.oldValue(ctx)
  9066. if err != nil {
  9067. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9068. }
  9069. return oldValue.Scene, nil
  9070. }
  9071. // ResetScene resets all changes to the "scene" field.
  9072. func (m *EmployeeMutation) ResetScene() {
  9073. m.scene = nil
  9074. }
  9075. // SetSwitchIn sets the "switch_in" field.
  9076. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9077. m.switch_in = &s
  9078. }
  9079. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9080. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9081. v := m.switch_in
  9082. if v == nil {
  9083. return
  9084. }
  9085. return *v, true
  9086. }
  9087. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9088. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9090. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9091. if !m.op.Is(OpUpdateOne) {
  9092. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9093. }
  9094. if m.id == nil || m.oldValue == nil {
  9095. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9096. }
  9097. oldValue, err := m.oldValue(ctx)
  9098. if err != nil {
  9099. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9100. }
  9101. return oldValue.SwitchIn, nil
  9102. }
  9103. // ResetSwitchIn resets all changes to the "switch_in" field.
  9104. func (m *EmployeeMutation) ResetSwitchIn() {
  9105. m.switch_in = nil
  9106. }
  9107. // SetVideoURL sets the "video_url" field.
  9108. func (m *EmployeeMutation) SetVideoURL(s string) {
  9109. m.video_url = &s
  9110. }
  9111. // VideoURL returns the value of the "video_url" field in the mutation.
  9112. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9113. v := m.video_url
  9114. if v == nil {
  9115. return
  9116. }
  9117. return *v, true
  9118. }
  9119. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9120. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9122. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9123. if !m.op.Is(OpUpdateOne) {
  9124. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9125. }
  9126. if m.id == nil || m.oldValue == nil {
  9127. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9128. }
  9129. oldValue, err := m.oldValue(ctx)
  9130. if err != nil {
  9131. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9132. }
  9133. return oldValue.VideoURL, nil
  9134. }
  9135. // ResetVideoURL resets all changes to the "video_url" field.
  9136. func (m *EmployeeMutation) ResetVideoURL() {
  9137. m.video_url = nil
  9138. }
  9139. // SetOrganizationID sets the "organization_id" field.
  9140. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9141. m.organization_id = &u
  9142. m.addorganization_id = nil
  9143. }
  9144. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9145. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9146. v := m.organization_id
  9147. if v == nil {
  9148. return
  9149. }
  9150. return *v, true
  9151. }
  9152. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9153. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9155. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9156. if !m.op.Is(OpUpdateOne) {
  9157. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9158. }
  9159. if m.id == nil || m.oldValue == nil {
  9160. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9161. }
  9162. oldValue, err := m.oldValue(ctx)
  9163. if err != nil {
  9164. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9165. }
  9166. return oldValue.OrganizationID, nil
  9167. }
  9168. // AddOrganizationID adds u to the "organization_id" field.
  9169. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9170. if m.addorganization_id != nil {
  9171. *m.addorganization_id += u
  9172. } else {
  9173. m.addorganization_id = &u
  9174. }
  9175. }
  9176. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9177. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9178. v := m.addorganization_id
  9179. if v == nil {
  9180. return
  9181. }
  9182. return *v, true
  9183. }
  9184. // ResetOrganizationID resets all changes to the "organization_id" field.
  9185. func (m *EmployeeMutation) ResetOrganizationID() {
  9186. m.organization_id = nil
  9187. m.addorganization_id = nil
  9188. }
  9189. // SetCategoryID sets the "category_id" field.
  9190. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9191. m.category_id = &u
  9192. m.addcategory_id = nil
  9193. }
  9194. // CategoryID returns the value of the "category_id" field in the mutation.
  9195. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9196. v := m.category_id
  9197. if v == nil {
  9198. return
  9199. }
  9200. return *v, true
  9201. }
  9202. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9203. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9205. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9206. if !m.op.Is(OpUpdateOne) {
  9207. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9208. }
  9209. if m.id == nil || m.oldValue == nil {
  9210. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9211. }
  9212. oldValue, err := m.oldValue(ctx)
  9213. if err != nil {
  9214. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9215. }
  9216. return oldValue.CategoryID, nil
  9217. }
  9218. // AddCategoryID adds u to the "category_id" field.
  9219. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9220. if m.addcategory_id != nil {
  9221. *m.addcategory_id += u
  9222. } else {
  9223. m.addcategory_id = &u
  9224. }
  9225. }
  9226. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9227. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9228. v := m.addcategory_id
  9229. if v == nil {
  9230. return
  9231. }
  9232. return *v, true
  9233. }
  9234. // ResetCategoryID resets all changes to the "category_id" field.
  9235. func (m *EmployeeMutation) ResetCategoryID() {
  9236. m.category_id = nil
  9237. m.addcategory_id = nil
  9238. }
  9239. // SetAPIBase sets the "api_base" field.
  9240. func (m *EmployeeMutation) SetAPIBase(s string) {
  9241. m.api_base = &s
  9242. }
  9243. // APIBase returns the value of the "api_base" field in the mutation.
  9244. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9245. v := m.api_base
  9246. if v == nil {
  9247. return
  9248. }
  9249. return *v, true
  9250. }
  9251. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9252. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9254. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9255. if !m.op.Is(OpUpdateOne) {
  9256. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9257. }
  9258. if m.id == nil || m.oldValue == nil {
  9259. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9260. }
  9261. oldValue, err := m.oldValue(ctx)
  9262. if err != nil {
  9263. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9264. }
  9265. return oldValue.APIBase, nil
  9266. }
  9267. // ResetAPIBase resets all changes to the "api_base" field.
  9268. func (m *EmployeeMutation) ResetAPIBase() {
  9269. m.api_base = nil
  9270. }
  9271. // SetAPIKey sets the "api_key" field.
  9272. func (m *EmployeeMutation) SetAPIKey(s string) {
  9273. m.api_key = &s
  9274. }
  9275. // APIKey returns the value of the "api_key" field in the mutation.
  9276. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9277. v := m.api_key
  9278. if v == nil {
  9279. return
  9280. }
  9281. return *v, true
  9282. }
  9283. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9284. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9286. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9287. if !m.op.Is(OpUpdateOne) {
  9288. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9289. }
  9290. if m.id == nil || m.oldValue == nil {
  9291. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9292. }
  9293. oldValue, err := m.oldValue(ctx)
  9294. if err != nil {
  9295. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9296. }
  9297. return oldValue.APIKey, nil
  9298. }
  9299. // ResetAPIKey resets all changes to the "api_key" field.
  9300. func (m *EmployeeMutation) ResetAPIKey() {
  9301. m.api_key = nil
  9302. }
  9303. // SetAiInfo sets the "ai_info" field.
  9304. func (m *EmployeeMutation) SetAiInfo(s string) {
  9305. m.ai_info = &s
  9306. }
  9307. // AiInfo returns the value of the "ai_info" field in the mutation.
  9308. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9309. v := m.ai_info
  9310. if v == nil {
  9311. return
  9312. }
  9313. return *v, true
  9314. }
  9315. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9316. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9318. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9319. if !m.op.Is(OpUpdateOne) {
  9320. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9321. }
  9322. if m.id == nil || m.oldValue == nil {
  9323. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9324. }
  9325. oldValue, err := m.oldValue(ctx)
  9326. if err != nil {
  9327. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9328. }
  9329. return oldValue.AiInfo, nil
  9330. }
  9331. // ClearAiInfo clears the value of the "ai_info" field.
  9332. func (m *EmployeeMutation) ClearAiInfo() {
  9333. m.ai_info = nil
  9334. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9335. }
  9336. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9337. func (m *EmployeeMutation) AiInfoCleared() bool {
  9338. _, ok := m.clearedFields[employee.FieldAiInfo]
  9339. return ok
  9340. }
  9341. // ResetAiInfo resets all changes to the "ai_info" field.
  9342. func (m *EmployeeMutation) ResetAiInfo() {
  9343. m.ai_info = nil
  9344. delete(m.clearedFields, employee.FieldAiInfo)
  9345. }
  9346. // SetIsVip sets the "is_vip" field.
  9347. func (m *EmployeeMutation) SetIsVip(i int) {
  9348. m.is_vip = &i
  9349. m.addis_vip = nil
  9350. }
  9351. // IsVip returns the value of the "is_vip" field in the mutation.
  9352. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9353. v := m.is_vip
  9354. if v == nil {
  9355. return
  9356. }
  9357. return *v, true
  9358. }
  9359. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9360. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9362. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9363. if !m.op.Is(OpUpdateOne) {
  9364. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9365. }
  9366. if m.id == nil || m.oldValue == nil {
  9367. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9368. }
  9369. oldValue, err := m.oldValue(ctx)
  9370. if err != nil {
  9371. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9372. }
  9373. return oldValue.IsVip, nil
  9374. }
  9375. // AddIsVip adds i to the "is_vip" field.
  9376. func (m *EmployeeMutation) AddIsVip(i int) {
  9377. if m.addis_vip != nil {
  9378. *m.addis_vip += i
  9379. } else {
  9380. m.addis_vip = &i
  9381. }
  9382. }
  9383. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9384. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9385. v := m.addis_vip
  9386. if v == nil {
  9387. return
  9388. }
  9389. return *v, true
  9390. }
  9391. // ResetIsVip resets all changes to the "is_vip" field.
  9392. func (m *EmployeeMutation) ResetIsVip() {
  9393. m.is_vip = nil
  9394. m.addis_vip = nil
  9395. }
  9396. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9397. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9398. if m.em_work_experiences == nil {
  9399. m.em_work_experiences = make(map[uint64]struct{})
  9400. }
  9401. for i := range ids {
  9402. m.em_work_experiences[ids[i]] = struct{}{}
  9403. }
  9404. }
  9405. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9406. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9407. m.clearedem_work_experiences = true
  9408. }
  9409. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9410. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9411. return m.clearedem_work_experiences
  9412. }
  9413. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9414. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9415. if m.removedem_work_experiences == nil {
  9416. m.removedem_work_experiences = make(map[uint64]struct{})
  9417. }
  9418. for i := range ids {
  9419. delete(m.em_work_experiences, ids[i])
  9420. m.removedem_work_experiences[ids[i]] = struct{}{}
  9421. }
  9422. }
  9423. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9424. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9425. for id := range m.removedem_work_experiences {
  9426. ids = append(ids, id)
  9427. }
  9428. return
  9429. }
  9430. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9431. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9432. for id := range m.em_work_experiences {
  9433. ids = append(ids, id)
  9434. }
  9435. return
  9436. }
  9437. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9438. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9439. m.em_work_experiences = nil
  9440. m.clearedem_work_experiences = false
  9441. m.removedem_work_experiences = nil
  9442. }
  9443. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9444. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9445. if m.em_tutorial == nil {
  9446. m.em_tutorial = make(map[uint64]struct{})
  9447. }
  9448. for i := range ids {
  9449. m.em_tutorial[ids[i]] = struct{}{}
  9450. }
  9451. }
  9452. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9453. func (m *EmployeeMutation) ClearEmTutorial() {
  9454. m.clearedem_tutorial = true
  9455. }
  9456. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9457. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9458. return m.clearedem_tutorial
  9459. }
  9460. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9461. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9462. if m.removedem_tutorial == nil {
  9463. m.removedem_tutorial = make(map[uint64]struct{})
  9464. }
  9465. for i := range ids {
  9466. delete(m.em_tutorial, ids[i])
  9467. m.removedem_tutorial[ids[i]] = struct{}{}
  9468. }
  9469. }
  9470. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9471. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9472. for id := range m.removedem_tutorial {
  9473. ids = append(ids, id)
  9474. }
  9475. return
  9476. }
  9477. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9478. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9479. for id := range m.em_tutorial {
  9480. ids = append(ids, id)
  9481. }
  9482. return
  9483. }
  9484. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9485. func (m *EmployeeMutation) ResetEmTutorial() {
  9486. m.em_tutorial = nil
  9487. m.clearedem_tutorial = false
  9488. m.removedem_tutorial = nil
  9489. }
  9490. // Where appends a list predicates to the EmployeeMutation builder.
  9491. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9492. m.predicates = append(m.predicates, ps...)
  9493. }
  9494. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9495. // users can use type-assertion to append predicates that do not depend on any generated package.
  9496. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9497. p := make([]predicate.Employee, len(ps))
  9498. for i := range ps {
  9499. p[i] = ps[i]
  9500. }
  9501. m.Where(p...)
  9502. }
  9503. // Op returns the operation name.
  9504. func (m *EmployeeMutation) Op() Op {
  9505. return m.op
  9506. }
  9507. // SetOp allows setting the mutation operation.
  9508. func (m *EmployeeMutation) SetOp(op Op) {
  9509. m.op = op
  9510. }
  9511. // Type returns the node type of this mutation (Employee).
  9512. func (m *EmployeeMutation) Type() string {
  9513. return m.typ
  9514. }
  9515. // Fields returns all fields that were changed during this mutation. Note that in
  9516. // order to get all numeric fields that were incremented/decremented, call
  9517. // AddedFields().
  9518. func (m *EmployeeMutation) Fields() []string {
  9519. fields := make([]string, 0, 22)
  9520. if m.created_at != nil {
  9521. fields = append(fields, employee.FieldCreatedAt)
  9522. }
  9523. if m.updated_at != nil {
  9524. fields = append(fields, employee.FieldUpdatedAt)
  9525. }
  9526. if m.deleted_at != nil {
  9527. fields = append(fields, employee.FieldDeletedAt)
  9528. }
  9529. if m.title != nil {
  9530. fields = append(fields, employee.FieldTitle)
  9531. }
  9532. if m.avatar != nil {
  9533. fields = append(fields, employee.FieldAvatar)
  9534. }
  9535. if m.tags != nil {
  9536. fields = append(fields, employee.FieldTags)
  9537. }
  9538. if m.hire_count != nil {
  9539. fields = append(fields, employee.FieldHireCount)
  9540. }
  9541. if m.service_count != nil {
  9542. fields = append(fields, employee.FieldServiceCount)
  9543. }
  9544. if m.achievement_count != nil {
  9545. fields = append(fields, employee.FieldAchievementCount)
  9546. }
  9547. if m.intro != nil {
  9548. fields = append(fields, employee.FieldIntro)
  9549. }
  9550. if m.estimate != nil {
  9551. fields = append(fields, employee.FieldEstimate)
  9552. }
  9553. if m.skill != nil {
  9554. fields = append(fields, employee.FieldSkill)
  9555. }
  9556. if m.ability_type != nil {
  9557. fields = append(fields, employee.FieldAbilityType)
  9558. }
  9559. if m.scene != nil {
  9560. fields = append(fields, employee.FieldScene)
  9561. }
  9562. if m.switch_in != nil {
  9563. fields = append(fields, employee.FieldSwitchIn)
  9564. }
  9565. if m.video_url != nil {
  9566. fields = append(fields, employee.FieldVideoURL)
  9567. }
  9568. if m.organization_id != nil {
  9569. fields = append(fields, employee.FieldOrganizationID)
  9570. }
  9571. if m.category_id != nil {
  9572. fields = append(fields, employee.FieldCategoryID)
  9573. }
  9574. if m.api_base != nil {
  9575. fields = append(fields, employee.FieldAPIBase)
  9576. }
  9577. if m.api_key != nil {
  9578. fields = append(fields, employee.FieldAPIKey)
  9579. }
  9580. if m.ai_info != nil {
  9581. fields = append(fields, employee.FieldAiInfo)
  9582. }
  9583. if m.is_vip != nil {
  9584. fields = append(fields, employee.FieldIsVip)
  9585. }
  9586. return fields
  9587. }
  9588. // Field returns the value of a field with the given name. The second boolean
  9589. // return value indicates that this field was not set, or was not defined in the
  9590. // schema.
  9591. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9592. switch name {
  9593. case employee.FieldCreatedAt:
  9594. return m.CreatedAt()
  9595. case employee.FieldUpdatedAt:
  9596. return m.UpdatedAt()
  9597. case employee.FieldDeletedAt:
  9598. return m.DeletedAt()
  9599. case employee.FieldTitle:
  9600. return m.Title()
  9601. case employee.FieldAvatar:
  9602. return m.Avatar()
  9603. case employee.FieldTags:
  9604. return m.Tags()
  9605. case employee.FieldHireCount:
  9606. return m.HireCount()
  9607. case employee.FieldServiceCount:
  9608. return m.ServiceCount()
  9609. case employee.FieldAchievementCount:
  9610. return m.AchievementCount()
  9611. case employee.FieldIntro:
  9612. return m.Intro()
  9613. case employee.FieldEstimate:
  9614. return m.Estimate()
  9615. case employee.FieldSkill:
  9616. return m.Skill()
  9617. case employee.FieldAbilityType:
  9618. return m.AbilityType()
  9619. case employee.FieldScene:
  9620. return m.Scene()
  9621. case employee.FieldSwitchIn:
  9622. return m.SwitchIn()
  9623. case employee.FieldVideoURL:
  9624. return m.VideoURL()
  9625. case employee.FieldOrganizationID:
  9626. return m.OrganizationID()
  9627. case employee.FieldCategoryID:
  9628. return m.CategoryID()
  9629. case employee.FieldAPIBase:
  9630. return m.APIBase()
  9631. case employee.FieldAPIKey:
  9632. return m.APIKey()
  9633. case employee.FieldAiInfo:
  9634. return m.AiInfo()
  9635. case employee.FieldIsVip:
  9636. return m.IsVip()
  9637. }
  9638. return nil, false
  9639. }
  9640. // OldField returns the old value of the field from the database. An error is
  9641. // returned if the mutation operation is not UpdateOne, or the query to the
  9642. // database failed.
  9643. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9644. switch name {
  9645. case employee.FieldCreatedAt:
  9646. return m.OldCreatedAt(ctx)
  9647. case employee.FieldUpdatedAt:
  9648. return m.OldUpdatedAt(ctx)
  9649. case employee.FieldDeletedAt:
  9650. return m.OldDeletedAt(ctx)
  9651. case employee.FieldTitle:
  9652. return m.OldTitle(ctx)
  9653. case employee.FieldAvatar:
  9654. return m.OldAvatar(ctx)
  9655. case employee.FieldTags:
  9656. return m.OldTags(ctx)
  9657. case employee.FieldHireCount:
  9658. return m.OldHireCount(ctx)
  9659. case employee.FieldServiceCount:
  9660. return m.OldServiceCount(ctx)
  9661. case employee.FieldAchievementCount:
  9662. return m.OldAchievementCount(ctx)
  9663. case employee.FieldIntro:
  9664. return m.OldIntro(ctx)
  9665. case employee.FieldEstimate:
  9666. return m.OldEstimate(ctx)
  9667. case employee.FieldSkill:
  9668. return m.OldSkill(ctx)
  9669. case employee.FieldAbilityType:
  9670. return m.OldAbilityType(ctx)
  9671. case employee.FieldScene:
  9672. return m.OldScene(ctx)
  9673. case employee.FieldSwitchIn:
  9674. return m.OldSwitchIn(ctx)
  9675. case employee.FieldVideoURL:
  9676. return m.OldVideoURL(ctx)
  9677. case employee.FieldOrganizationID:
  9678. return m.OldOrganizationID(ctx)
  9679. case employee.FieldCategoryID:
  9680. return m.OldCategoryID(ctx)
  9681. case employee.FieldAPIBase:
  9682. return m.OldAPIBase(ctx)
  9683. case employee.FieldAPIKey:
  9684. return m.OldAPIKey(ctx)
  9685. case employee.FieldAiInfo:
  9686. return m.OldAiInfo(ctx)
  9687. case employee.FieldIsVip:
  9688. return m.OldIsVip(ctx)
  9689. }
  9690. return nil, fmt.Errorf("unknown Employee field %s", name)
  9691. }
  9692. // SetField sets the value of a field with the given name. It returns an error if
  9693. // the field is not defined in the schema, or if the type mismatched the field
  9694. // type.
  9695. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9696. switch name {
  9697. case employee.FieldCreatedAt:
  9698. v, ok := value.(time.Time)
  9699. if !ok {
  9700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9701. }
  9702. m.SetCreatedAt(v)
  9703. return nil
  9704. case employee.FieldUpdatedAt:
  9705. v, ok := value.(time.Time)
  9706. if !ok {
  9707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9708. }
  9709. m.SetUpdatedAt(v)
  9710. return nil
  9711. case employee.FieldDeletedAt:
  9712. v, ok := value.(time.Time)
  9713. if !ok {
  9714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9715. }
  9716. m.SetDeletedAt(v)
  9717. return nil
  9718. case employee.FieldTitle:
  9719. v, ok := value.(string)
  9720. if !ok {
  9721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9722. }
  9723. m.SetTitle(v)
  9724. return nil
  9725. case employee.FieldAvatar:
  9726. v, ok := value.(string)
  9727. if !ok {
  9728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9729. }
  9730. m.SetAvatar(v)
  9731. return nil
  9732. case employee.FieldTags:
  9733. v, ok := value.(string)
  9734. if !ok {
  9735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9736. }
  9737. m.SetTags(v)
  9738. return nil
  9739. case employee.FieldHireCount:
  9740. v, ok := value.(int)
  9741. if !ok {
  9742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9743. }
  9744. m.SetHireCount(v)
  9745. return nil
  9746. case employee.FieldServiceCount:
  9747. v, ok := value.(int)
  9748. if !ok {
  9749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9750. }
  9751. m.SetServiceCount(v)
  9752. return nil
  9753. case employee.FieldAchievementCount:
  9754. v, ok := value.(int)
  9755. if !ok {
  9756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9757. }
  9758. m.SetAchievementCount(v)
  9759. return nil
  9760. case employee.FieldIntro:
  9761. v, ok := value.(string)
  9762. if !ok {
  9763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9764. }
  9765. m.SetIntro(v)
  9766. return nil
  9767. case employee.FieldEstimate:
  9768. v, ok := value.(string)
  9769. if !ok {
  9770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9771. }
  9772. m.SetEstimate(v)
  9773. return nil
  9774. case employee.FieldSkill:
  9775. v, ok := value.(string)
  9776. if !ok {
  9777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9778. }
  9779. m.SetSkill(v)
  9780. return nil
  9781. case employee.FieldAbilityType:
  9782. v, ok := value.(string)
  9783. if !ok {
  9784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9785. }
  9786. m.SetAbilityType(v)
  9787. return nil
  9788. case employee.FieldScene:
  9789. v, ok := value.(string)
  9790. if !ok {
  9791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9792. }
  9793. m.SetScene(v)
  9794. return nil
  9795. case employee.FieldSwitchIn:
  9796. v, ok := value.(string)
  9797. if !ok {
  9798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9799. }
  9800. m.SetSwitchIn(v)
  9801. return nil
  9802. case employee.FieldVideoURL:
  9803. v, ok := value.(string)
  9804. if !ok {
  9805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9806. }
  9807. m.SetVideoURL(v)
  9808. return nil
  9809. case employee.FieldOrganizationID:
  9810. v, ok := value.(uint64)
  9811. if !ok {
  9812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9813. }
  9814. m.SetOrganizationID(v)
  9815. return nil
  9816. case employee.FieldCategoryID:
  9817. v, ok := value.(uint64)
  9818. if !ok {
  9819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9820. }
  9821. m.SetCategoryID(v)
  9822. return nil
  9823. case employee.FieldAPIBase:
  9824. v, ok := value.(string)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetAPIBase(v)
  9829. return nil
  9830. case employee.FieldAPIKey:
  9831. v, ok := value.(string)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetAPIKey(v)
  9836. return nil
  9837. case employee.FieldAiInfo:
  9838. v, ok := value.(string)
  9839. if !ok {
  9840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9841. }
  9842. m.SetAiInfo(v)
  9843. return nil
  9844. case employee.FieldIsVip:
  9845. v, ok := value.(int)
  9846. if !ok {
  9847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9848. }
  9849. m.SetIsVip(v)
  9850. return nil
  9851. }
  9852. return fmt.Errorf("unknown Employee field %s", name)
  9853. }
  9854. // AddedFields returns all numeric fields that were incremented/decremented during
  9855. // this mutation.
  9856. func (m *EmployeeMutation) AddedFields() []string {
  9857. var fields []string
  9858. if m.addhire_count != nil {
  9859. fields = append(fields, employee.FieldHireCount)
  9860. }
  9861. if m.addservice_count != nil {
  9862. fields = append(fields, employee.FieldServiceCount)
  9863. }
  9864. if m.addachievement_count != nil {
  9865. fields = append(fields, employee.FieldAchievementCount)
  9866. }
  9867. if m.addorganization_id != nil {
  9868. fields = append(fields, employee.FieldOrganizationID)
  9869. }
  9870. if m.addcategory_id != nil {
  9871. fields = append(fields, employee.FieldCategoryID)
  9872. }
  9873. if m.addis_vip != nil {
  9874. fields = append(fields, employee.FieldIsVip)
  9875. }
  9876. return fields
  9877. }
  9878. // AddedField returns the numeric value that was incremented/decremented on a field
  9879. // with the given name. The second boolean return value indicates that this field
  9880. // was not set, or was not defined in the schema.
  9881. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  9882. switch name {
  9883. case employee.FieldHireCount:
  9884. return m.AddedHireCount()
  9885. case employee.FieldServiceCount:
  9886. return m.AddedServiceCount()
  9887. case employee.FieldAchievementCount:
  9888. return m.AddedAchievementCount()
  9889. case employee.FieldOrganizationID:
  9890. return m.AddedOrganizationID()
  9891. case employee.FieldCategoryID:
  9892. return m.AddedCategoryID()
  9893. case employee.FieldIsVip:
  9894. return m.AddedIsVip()
  9895. }
  9896. return nil, false
  9897. }
  9898. // AddField adds the value to the field with the given name. It returns an error if
  9899. // the field is not defined in the schema, or if the type mismatched the field
  9900. // type.
  9901. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  9902. switch name {
  9903. case employee.FieldHireCount:
  9904. v, ok := value.(int)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.AddHireCount(v)
  9909. return nil
  9910. case employee.FieldServiceCount:
  9911. v, ok := value.(int)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.AddServiceCount(v)
  9916. return nil
  9917. case employee.FieldAchievementCount:
  9918. v, ok := value.(int)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.AddAchievementCount(v)
  9923. return nil
  9924. case employee.FieldOrganizationID:
  9925. v, ok := value.(int64)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.AddOrganizationID(v)
  9930. return nil
  9931. case employee.FieldCategoryID:
  9932. v, ok := value.(int64)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.AddCategoryID(v)
  9937. return nil
  9938. case employee.FieldIsVip:
  9939. v, ok := value.(int)
  9940. if !ok {
  9941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9942. }
  9943. m.AddIsVip(v)
  9944. return nil
  9945. }
  9946. return fmt.Errorf("unknown Employee numeric field %s", name)
  9947. }
  9948. // ClearedFields returns all nullable fields that were cleared during this
  9949. // mutation.
  9950. func (m *EmployeeMutation) ClearedFields() []string {
  9951. var fields []string
  9952. if m.FieldCleared(employee.FieldDeletedAt) {
  9953. fields = append(fields, employee.FieldDeletedAt)
  9954. }
  9955. if m.FieldCleared(employee.FieldAiInfo) {
  9956. fields = append(fields, employee.FieldAiInfo)
  9957. }
  9958. return fields
  9959. }
  9960. // FieldCleared returns a boolean indicating if a field with the given name was
  9961. // cleared in this mutation.
  9962. func (m *EmployeeMutation) FieldCleared(name string) bool {
  9963. _, ok := m.clearedFields[name]
  9964. return ok
  9965. }
  9966. // ClearField clears the value of the field with the given name. It returns an
  9967. // error if the field is not defined in the schema.
  9968. func (m *EmployeeMutation) ClearField(name string) error {
  9969. switch name {
  9970. case employee.FieldDeletedAt:
  9971. m.ClearDeletedAt()
  9972. return nil
  9973. case employee.FieldAiInfo:
  9974. m.ClearAiInfo()
  9975. return nil
  9976. }
  9977. return fmt.Errorf("unknown Employee nullable field %s", name)
  9978. }
  9979. // ResetField resets all changes in the mutation for the field with the given name.
  9980. // It returns an error if the field is not defined in the schema.
  9981. func (m *EmployeeMutation) ResetField(name string) error {
  9982. switch name {
  9983. case employee.FieldCreatedAt:
  9984. m.ResetCreatedAt()
  9985. return nil
  9986. case employee.FieldUpdatedAt:
  9987. m.ResetUpdatedAt()
  9988. return nil
  9989. case employee.FieldDeletedAt:
  9990. m.ResetDeletedAt()
  9991. return nil
  9992. case employee.FieldTitle:
  9993. m.ResetTitle()
  9994. return nil
  9995. case employee.FieldAvatar:
  9996. m.ResetAvatar()
  9997. return nil
  9998. case employee.FieldTags:
  9999. m.ResetTags()
  10000. return nil
  10001. case employee.FieldHireCount:
  10002. m.ResetHireCount()
  10003. return nil
  10004. case employee.FieldServiceCount:
  10005. m.ResetServiceCount()
  10006. return nil
  10007. case employee.FieldAchievementCount:
  10008. m.ResetAchievementCount()
  10009. return nil
  10010. case employee.FieldIntro:
  10011. m.ResetIntro()
  10012. return nil
  10013. case employee.FieldEstimate:
  10014. m.ResetEstimate()
  10015. return nil
  10016. case employee.FieldSkill:
  10017. m.ResetSkill()
  10018. return nil
  10019. case employee.FieldAbilityType:
  10020. m.ResetAbilityType()
  10021. return nil
  10022. case employee.FieldScene:
  10023. m.ResetScene()
  10024. return nil
  10025. case employee.FieldSwitchIn:
  10026. m.ResetSwitchIn()
  10027. return nil
  10028. case employee.FieldVideoURL:
  10029. m.ResetVideoURL()
  10030. return nil
  10031. case employee.FieldOrganizationID:
  10032. m.ResetOrganizationID()
  10033. return nil
  10034. case employee.FieldCategoryID:
  10035. m.ResetCategoryID()
  10036. return nil
  10037. case employee.FieldAPIBase:
  10038. m.ResetAPIBase()
  10039. return nil
  10040. case employee.FieldAPIKey:
  10041. m.ResetAPIKey()
  10042. return nil
  10043. case employee.FieldAiInfo:
  10044. m.ResetAiInfo()
  10045. return nil
  10046. case employee.FieldIsVip:
  10047. m.ResetIsVip()
  10048. return nil
  10049. }
  10050. return fmt.Errorf("unknown Employee field %s", name)
  10051. }
  10052. // AddedEdges returns all edge names that were set/added in this mutation.
  10053. func (m *EmployeeMutation) AddedEdges() []string {
  10054. edges := make([]string, 0, 2)
  10055. if m.em_work_experiences != nil {
  10056. edges = append(edges, employee.EdgeEmWorkExperiences)
  10057. }
  10058. if m.em_tutorial != nil {
  10059. edges = append(edges, employee.EdgeEmTutorial)
  10060. }
  10061. return edges
  10062. }
  10063. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10064. // name in this mutation.
  10065. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10066. switch name {
  10067. case employee.EdgeEmWorkExperiences:
  10068. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10069. for id := range m.em_work_experiences {
  10070. ids = append(ids, id)
  10071. }
  10072. return ids
  10073. case employee.EdgeEmTutorial:
  10074. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10075. for id := range m.em_tutorial {
  10076. ids = append(ids, id)
  10077. }
  10078. return ids
  10079. }
  10080. return nil
  10081. }
  10082. // RemovedEdges returns all edge names that were removed in this mutation.
  10083. func (m *EmployeeMutation) RemovedEdges() []string {
  10084. edges := make([]string, 0, 2)
  10085. if m.removedem_work_experiences != nil {
  10086. edges = append(edges, employee.EdgeEmWorkExperiences)
  10087. }
  10088. if m.removedem_tutorial != nil {
  10089. edges = append(edges, employee.EdgeEmTutorial)
  10090. }
  10091. return edges
  10092. }
  10093. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10094. // the given name in this mutation.
  10095. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10096. switch name {
  10097. case employee.EdgeEmWorkExperiences:
  10098. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10099. for id := range m.removedem_work_experiences {
  10100. ids = append(ids, id)
  10101. }
  10102. return ids
  10103. case employee.EdgeEmTutorial:
  10104. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10105. for id := range m.removedem_tutorial {
  10106. ids = append(ids, id)
  10107. }
  10108. return ids
  10109. }
  10110. return nil
  10111. }
  10112. // ClearedEdges returns all edge names that were cleared in this mutation.
  10113. func (m *EmployeeMutation) ClearedEdges() []string {
  10114. edges := make([]string, 0, 2)
  10115. if m.clearedem_work_experiences {
  10116. edges = append(edges, employee.EdgeEmWorkExperiences)
  10117. }
  10118. if m.clearedem_tutorial {
  10119. edges = append(edges, employee.EdgeEmTutorial)
  10120. }
  10121. return edges
  10122. }
  10123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10124. // was cleared in this mutation.
  10125. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10126. switch name {
  10127. case employee.EdgeEmWorkExperiences:
  10128. return m.clearedem_work_experiences
  10129. case employee.EdgeEmTutorial:
  10130. return m.clearedem_tutorial
  10131. }
  10132. return false
  10133. }
  10134. // ClearEdge clears the value of the edge with the given name. It returns an error
  10135. // if that edge is not defined in the schema.
  10136. func (m *EmployeeMutation) ClearEdge(name string) error {
  10137. switch name {
  10138. }
  10139. return fmt.Errorf("unknown Employee unique edge %s", name)
  10140. }
  10141. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10142. // It returns an error if the edge is not defined in the schema.
  10143. func (m *EmployeeMutation) ResetEdge(name string) error {
  10144. switch name {
  10145. case employee.EdgeEmWorkExperiences:
  10146. m.ResetEmWorkExperiences()
  10147. return nil
  10148. case employee.EdgeEmTutorial:
  10149. m.ResetEmTutorial()
  10150. return nil
  10151. }
  10152. return fmt.Errorf("unknown Employee edge %s", name)
  10153. }
  10154. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10155. type EmployeeConfigMutation struct {
  10156. config
  10157. op Op
  10158. typ string
  10159. id *uint64
  10160. created_at *time.Time
  10161. updated_at *time.Time
  10162. deleted_at *time.Time
  10163. stype *string
  10164. title *string
  10165. photo *string
  10166. organization_id *uint64
  10167. addorganization_id *int64
  10168. clearedFields map[string]struct{}
  10169. done bool
  10170. oldValue func(context.Context) (*EmployeeConfig, error)
  10171. predicates []predicate.EmployeeConfig
  10172. }
  10173. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10174. // employeeconfigOption allows management of the mutation configuration using functional options.
  10175. type employeeconfigOption func(*EmployeeConfigMutation)
  10176. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10177. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10178. m := &EmployeeConfigMutation{
  10179. config: c,
  10180. op: op,
  10181. typ: TypeEmployeeConfig,
  10182. clearedFields: make(map[string]struct{}),
  10183. }
  10184. for _, opt := range opts {
  10185. opt(m)
  10186. }
  10187. return m
  10188. }
  10189. // withEmployeeConfigID sets the ID field of the mutation.
  10190. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10191. return func(m *EmployeeConfigMutation) {
  10192. var (
  10193. err error
  10194. once sync.Once
  10195. value *EmployeeConfig
  10196. )
  10197. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10198. once.Do(func() {
  10199. if m.done {
  10200. err = errors.New("querying old values post mutation is not allowed")
  10201. } else {
  10202. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10203. }
  10204. })
  10205. return value, err
  10206. }
  10207. m.id = &id
  10208. }
  10209. }
  10210. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10211. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10212. return func(m *EmployeeConfigMutation) {
  10213. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10214. return node, nil
  10215. }
  10216. m.id = &node.ID
  10217. }
  10218. }
  10219. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10220. // executed in a transaction (ent.Tx), a transactional client is returned.
  10221. func (m EmployeeConfigMutation) Client() *Client {
  10222. client := &Client{config: m.config}
  10223. client.init()
  10224. return client
  10225. }
  10226. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10227. // it returns an error otherwise.
  10228. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10229. if _, ok := m.driver.(*txDriver); !ok {
  10230. return nil, errors.New("ent: mutation is not running in a transaction")
  10231. }
  10232. tx := &Tx{config: m.config}
  10233. tx.init()
  10234. return tx, nil
  10235. }
  10236. // SetID sets the value of the id field. Note that this
  10237. // operation is only accepted on creation of EmployeeConfig entities.
  10238. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10239. m.id = &id
  10240. }
  10241. // ID returns the ID value in the mutation. Note that the ID is only available
  10242. // if it was provided to the builder or after it was returned from the database.
  10243. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10244. if m.id == nil {
  10245. return
  10246. }
  10247. return *m.id, true
  10248. }
  10249. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10250. // That means, if the mutation is applied within a transaction with an isolation level such
  10251. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10252. // or updated by the mutation.
  10253. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10254. switch {
  10255. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10256. id, exists := m.ID()
  10257. if exists {
  10258. return []uint64{id}, nil
  10259. }
  10260. fallthrough
  10261. case m.op.Is(OpUpdate | OpDelete):
  10262. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10263. default:
  10264. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10265. }
  10266. }
  10267. // SetCreatedAt sets the "created_at" field.
  10268. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10269. m.created_at = &t
  10270. }
  10271. // CreatedAt returns the value of the "created_at" field in the mutation.
  10272. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10273. v := m.created_at
  10274. if v == nil {
  10275. return
  10276. }
  10277. return *v, true
  10278. }
  10279. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10280. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10282. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10283. if !m.op.Is(OpUpdateOne) {
  10284. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10285. }
  10286. if m.id == nil || m.oldValue == nil {
  10287. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10288. }
  10289. oldValue, err := m.oldValue(ctx)
  10290. if err != nil {
  10291. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10292. }
  10293. return oldValue.CreatedAt, nil
  10294. }
  10295. // ResetCreatedAt resets all changes to the "created_at" field.
  10296. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10297. m.created_at = nil
  10298. }
  10299. // SetUpdatedAt sets the "updated_at" field.
  10300. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10301. m.updated_at = &t
  10302. }
  10303. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10304. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10305. v := m.updated_at
  10306. if v == nil {
  10307. return
  10308. }
  10309. return *v, true
  10310. }
  10311. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10312. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10314. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10315. if !m.op.Is(OpUpdateOne) {
  10316. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10317. }
  10318. if m.id == nil || m.oldValue == nil {
  10319. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10320. }
  10321. oldValue, err := m.oldValue(ctx)
  10322. if err != nil {
  10323. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10324. }
  10325. return oldValue.UpdatedAt, nil
  10326. }
  10327. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10328. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10329. m.updated_at = nil
  10330. }
  10331. // SetDeletedAt sets the "deleted_at" field.
  10332. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10333. m.deleted_at = &t
  10334. }
  10335. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10336. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10337. v := m.deleted_at
  10338. if v == nil {
  10339. return
  10340. }
  10341. return *v, true
  10342. }
  10343. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10344. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10346. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10347. if !m.op.Is(OpUpdateOne) {
  10348. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10349. }
  10350. if m.id == nil || m.oldValue == nil {
  10351. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10352. }
  10353. oldValue, err := m.oldValue(ctx)
  10354. if err != nil {
  10355. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10356. }
  10357. return oldValue.DeletedAt, nil
  10358. }
  10359. // ClearDeletedAt clears the value of the "deleted_at" field.
  10360. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10361. m.deleted_at = nil
  10362. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10363. }
  10364. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10365. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10366. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10367. return ok
  10368. }
  10369. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10370. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10371. m.deleted_at = nil
  10372. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10373. }
  10374. // SetStype sets the "stype" field.
  10375. func (m *EmployeeConfigMutation) SetStype(s string) {
  10376. m.stype = &s
  10377. }
  10378. // Stype returns the value of the "stype" field in the mutation.
  10379. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10380. v := m.stype
  10381. if v == nil {
  10382. return
  10383. }
  10384. return *v, true
  10385. }
  10386. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10387. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10389. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10390. if !m.op.Is(OpUpdateOne) {
  10391. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10392. }
  10393. if m.id == nil || m.oldValue == nil {
  10394. return v, errors.New("OldStype requires an ID field in the mutation")
  10395. }
  10396. oldValue, err := m.oldValue(ctx)
  10397. if err != nil {
  10398. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10399. }
  10400. return oldValue.Stype, nil
  10401. }
  10402. // ResetStype resets all changes to the "stype" field.
  10403. func (m *EmployeeConfigMutation) ResetStype() {
  10404. m.stype = nil
  10405. }
  10406. // SetTitle sets the "title" field.
  10407. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10408. m.title = &s
  10409. }
  10410. // Title returns the value of the "title" field in the mutation.
  10411. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10412. v := m.title
  10413. if v == nil {
  10414. return
  10415. }
  10416. return *v, true
  10417. }
  10418. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10419. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10421. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10422. if !m.op.Is(OpUpdateOne) {
  10423. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10424. }
  10425. if m.id == nil || m.oldValue == nil {
  10426. return v, errors.New("OldTitle requires an ID field in the mutation")
  10427. }
  10428. oldValue, err := m.oldValue(ctx)
  10429. if err != nil {
  10430. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10431. }
  10432. return oldValue.Title, nil
  10433. }
  10434. // ResetTitle resets all changes to the "title" field.
  10435. func (m *EmployeeConfigMutation) ResetTitle() {
  10436. m.title = nil
  10437. }
  10438. // SetPhoto sets the "photo" field.
  10439. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10440. m.photo = &s
  10441. }
  10442. // Photo returns the value of the "photo" field in the mutation.
  10443. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10444. v := m.photo
  10445. if v == nil {
  10446. return
  10447. }
  10448. return *v, true
  10449. }
  10450. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10451. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10453. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10454. if !m.op.Is(OpUpdateOne) {
  10455. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10456. }
  10457. if m.id == nil || m.oldValue == nil {
  10458. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10459. }
  10460. oldValue, err := m.oldValue(ctx)
  10461. if err != nil {
  10462. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10463. }
  10464. return oldValue.Photo, nil
  10465. }
  10466. // ResetPhoto resets all changes to the "photo" field.
  10467. func (m *EmployeeConfigMutation) ResetPhoto() {
  10468. m.photo = nil
  10469. }
  10470. // SetOrganizationID sets the "organization_id" field.
  10471. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10472. m.organization_id = &u
  10473. m.addorganization_id = nil
  10474. }
  10475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10476. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10477. v := m.organization_id
  10478. if v == nil {
  10479. return
  10480. }
  10481. return *v, true
  10482. }
  10483. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10484. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10486. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10487. if !m.op.Is(OpUpdateOne) {
  10488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10489. }
  10490. if m.id == nil || m.oldValue == nil {
  10491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10492. }
  10493. oldValue, err := m.oldValue(ctx)
  10494. if err != nil {
  10495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10496. }
  10497. return oldValue.OrganizationID, nil
  10498. }
  10499. // AddOrganizationID adds u to the "organization_id" field.
  10500. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10501. if m.addorganization_id != nil {
  10502. *m.addorganization_id += u
  10503. } else {
  10504. m.addorganization_id = &u
  10505. }
  10506. }
  10507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10508. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10509. v := m.addorganization_id
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // ClearOrganizationID clears the value of the "organization_id" field.
  10516. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10517. m.organization_id = nil
  10518. m.addorganization_id = nil
  10519. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10520. }
  10521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10522. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10523. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10524. return ok
  10525. }
  10526. // ResetOrganizationID resets all changes to the "organization_id" field.
  10527. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10528. m.organization_id = nil
  10529. m.addorganization_id = nil
  10530. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10531. }
  10532. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10533. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10534. m.predicates = append(m.predicates, ps...)
  10535. }
  10536. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10537. // users can use type-assertion to append predicates that do not depend on any generated package.
  10538. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10539. p := make([]predicate.EmployeeConfig, len(ps))
  10540. for i := range ps {
  10541. p[i] = ps[i]
  10542. }
  10543. m.Where(p...)
  10544. }
  10545. // Op returns the operation name.
  10546. func (m *EmployeeConfigMutation) Op() Op {
  10547. return m.op
  10548. }
  10549. // SetOp allows setting the mutation operation.
  10550. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10551. m.op = op
  10552. }
  10553. // Type returns the node type of this mutation (EmployeeConfig).
  10554. func (m *EmployeeConfigMutation) Type() string {
  10555. return m.typ
  10556. }
  10557. // Fields returns all fields that were changed during this mutation. Note that in
  10558. // order to get all numeric fields that were incremented/decremented, call
  10559. // AddedFields().
  10560. func (m *EmployeeConfigMutation) Fields() []string {
  10561. fields := make([]string, 0, 7)
  10562. if m.created_at != nil {
  10563. fields = append(fields, employeeconfig.FieldCreatedAt)
  10564. }
  10565. if m.updated_at != nil {
  10566. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10567. }
  10568. if m.deleted_at != nil {
  10569. fields = append(fields, employeeconfig.FieldDeletedAt)
  10570. }
  10571. if m.stype != nil {
  10572. fields = append(fields, employeeconfig.FieldStype)
  10573. }
  10574. if m.title != nil {
  10575. fields = append(fields, employeeconfig.FieldTitle)
  10576. }
  10577. if m.photo != nil {
  10578. fields = append(fields, employeeconfig.FieldPhoto)
  10579. }
  10580. if m.organization_id != nil {
  10581. fields = append(fields, employeeconfig.FieldOrganizationID)
  10582. }
  10583. return fields
  10584. }
  10585. // Field returns the value of a field with the given name. The second boolean
  10586. // return value indicates that this field was not set, or was not defined in the
  10587. // schema.
  10588. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10589. switch name {
  10590. case employeeconfig.FieldCreatedAt:
  10591. return m.CreatedAt()
  10592. case employeeconfig.FieldUpdatedAt:
  10593. return m.UpdatedAt()
  10594. case employeeconfig.FieldDeletedAt:
  10595. return m.DeletedAt()
  10596. case employeeconfig.FieldStype:
  10597. return m.Stype()
  10598. case employeeconfig.FieldTitle:
  10599. return m.Title()
  10600. case employeeconfig.FieldPhoto:
  10601. return m.Photo()
  10602. case employeeconfig.FieldOrganizationID:
  10603. return m.OrganizationID()
  10604. }
  10605. return nil, false
  10606. }
  10607. // OldField returns the old value of the field from the database. An error is
  10608. // returned if the mutation operation is not UpdateOne, or the query to the
  10609. // database failed.
  10610. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10611. switch name {
  10612. case employeeconfig.FieldCreatedAt:
  10613. return m.OldCreatedAt(ctx)
  10614. case employeeconfig.FieldUpdatedAt:
  10615. return m.OldUpdatedAt(ctx)
  10616. case employeeconfig.FieldDeletedAt:
  10617. return m.OldDeletedAt(ctx)
  10618. case employeeconfig.FieldStype:
  10619. return m.OldStype(ctx)
  10620. case employeeconfig.FieldTitle:
  10621. return m.OldTitle(ctx)
  10622. case employeeconfig.FieldPhoto:
  10623. return m.OldPhoto(ctx)
  10624. case employeeconfig.FieldOrganizationID:
  10625. return m.OldOrganizationID(ctx)
  10626. }
  10627. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10628. }
  10629. // SetField sets the value of a field with the given name. It returns an error if
  10630. // the field is not defined in the schema, or if the type mismatched the field
  10631. // type.
  10632. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10633. switch name {
  10634. case employeeconfig.FieldCreatedAt:
  10635. v, ok := value.(time.Time)
  10636. if !ok {
  10637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10638. }
  10639. m.SetCreatedAt(v)
  10640. return nil
  10641. case employeeconfig.FieldUpdatedAt:
  10642. v, ok := value.(time.Time)
  10643. if !ok {
  10644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10645. }
  10646. m.SetUpdatedAt(v)
  10647. return nil
  10648. case employeeconfig.FieldDeletedAt:
  10649. v, ok := value.(time.Time)
  10650. if !ok {
  10651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10652. }
  10653. m.SetDeletedAt(v)
  10654. return nil
  10655. case employeeconfig.FieldStype:
  10656. v, ok := value.(string)
  10657. if !ok {
  10658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10659. }
  10660. m.SetStype(v)
  10661. return nil
  10662. case employeeconfig.FieldTitle:
  10663. v, ok := value.(string)
  10664. if !ok {
  10665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10666. }
  10667. m.SetTitle(v)
  10668. return nil
  10669. case employeeconfig.FieldPhoto:
  10670. v, ok := value.(string)
  10671. if !ok {
  10672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10673. }
  10674. m.SetPhoto(v)
  10675. return nil
  10676. case employeeconfig.FieldOrganizationID:
  10677. v, ok := value.(uint64)
  10678. if !ok {
  10679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10680. }
  10681. m.SetOrganizationID(v)
  10682. return nil
  10683. }
  10684. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10685. }
  10686. // AddedFields returns all numeric fields that were incremented/decremented during
  10687. // this mutation.
  10688. func (m *EmployeeConfigMutation) AddedFields() []string {
  10689. var fields []string
  10690. if m.addorganization_id != nil {
  10691. fields = append(fields, employeeconfig.FieldOrganizationID)
  10692. }
  10693. return fields
  10694. }
  10695. // AddedField returns the numeric value that was incremented/decremented on a field
  10696. // with the given name. The second boolean return value indicates that this field
  10697. // was not set, or was not defined in the schema.
  10698. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10699. switch name {
  10700. case employeeconfig.FieldOrganizationID:
  10701. return m.AddedOrganizationID()
  10702. }
  10703. return nil, false
  10704. }
  10705. // AddField adds the value to the field with the given name. It returns an error if
  10706. // the field is not defined in the schema, or if the type mismatched the field
  10707. // type.
  10708. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10709. switch name {
  10710. case employeeconfig.FieldOrganizationID:
  10711. v, ok := value.(int64)
  10712. if !ok {
  10713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10714. }
  10715. m.AddOrganizationID(v)
  10716. return nil
  10717. }
  10718. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10719. }
  10720. // ClearedFields returns all nullable fields that were cleared during this
  10721. // mutation.
  10722. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10723. var fields []string
  10724. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10725. fields = append(fields, employeeconfig.FieldDeletedAt)
  10726. }
  10727. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10728. fields = append(fields, employeeconfig.FieldOrganizationID)
  10729. }
  10730. return fields
  10731. }
  10732. // FieldCleared returns a boolean indicating if a field with the given name was
  10733. // cleared in this mutation.
  10734. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10735. _, ok := m.clearedFields[name]
  10736. return ok
  10737. }
  10738. // ClearField clears the value of the field with the given name. It returns an
  10739. // error if the field is not defined in the schema.
  10740. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10741. switch name {
  10742. case employeeconfig.FieldDeletedAt:
  10743. m.ClearDeletedAt()
  10744. return nil
  10745. case employeeconfig.FieldOrganizationID:
  10746. m.ClearOrganizationID()
  10747. return nil
  10748. }
  10749. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10750. }
  10751. // ResetField resets all changes in the mutation for the field with the given name.
  10752. // It returns an error if the field is not defined in the schema.
  10753. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10754. switch name {
  10755. case employeeconfig.FieldCreatedAt:
  10756. m.ResetCreatedAt()
  10757. return nil
  10758. case employeeconfig.FieldUpdatedAt:
  10759. m.ResetUpdatedAt()
  10760. return nil
  10761. case employeeconfig.FieldDeletedAt:
  10762. m.ResetDeletedAt()
  10763. return nil
  10764. case employeeconfig.FieldStype:
  10765. m.ResetStype()
  10766. return nil
  10767. case employeeconfig.FieldTitle:
  10768. m.ResetTitle()
  10769. return nil
  10770. case employeeconfig.FieldPhoto:
  10771. m.ResetPhoto()
  10772. return nil
  10773. case employeeconfig.FieldOrganizationID:
  10774. m.ResetOrganizationID()
  10775. return nil
  10776. }
  10777. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10778. }
  10779. // AddedEdges returns all edge names that were set/added in this mutation.
  10780. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10781. edges := make([]string, 0, 0)
  10782. return edges
  10783. }
  10784. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10785. // name in this mutation.
  10786. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10787. return nil
  10788. }
  10789. // RemovedEdges returns all edge names that were removed in this mutation.
  10790. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10791. edges := make([]string, 0, 0)
  10792. return edges
  10793. }
  10794. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10795. // the given name in this mutation.
  10796. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10797. return nil
  10798. }
  10799. // ClearedEdges returns all edge names that were cleared in this mutation.
  10800. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10801. edges := make([]string, 0, 0)
  10802. return edges
  10803. }
  10804. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10805. // was cleared in this mutation.
  10806. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10807. return false
  10808. }
  10809. // ClearEdge clears the value of the edge with the given name. It returns an error
  10810. // if that edge is not defined in the schema.
  10811. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10812. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10813. }
  10814. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10815. // It returns an error if the edge is not defined in the schema.
  10816. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10817. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10818. }
  10819. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10820. type LabelMutation struct {
  10821. config
  10822. op Op
  10823. typ string
  10824. id *uint64
  10825. created_at *time.Time
  10826. updated_at *time.Time
  10827. status *uint8
  10828. addstatus *int8
  10829. _type *int
  10830. add_type *int
  10831. name *string
  10832. from *int
  10833. addfrom *int
  10834. mode *int
  10835. addmode *int
  10836. conditions *string
  10837. organization_id *uint64
  10838. addorganization_id *int64
  10839. clearedFields map[string]struct{}
  10840. label_relationships map[uint64]struct{}
  10841. removedlabel_relationships map[uint64]struct{}
  10842. clearedlabel_relationships bool
  10843. done bool
  10844. oldValue func(context.Context) (*Label, error)
  10845. predicates []predicate.Label
  10846. }
  10847. var _ ent.Mutation = (*LabelMutation)(nil)
  10848. // labelOption allows management of the mutation configuration using functional options.
  10849. type labelOption func(*LabelMutation)
  10850. // newLabelMutation creates new mutation for the Label entity.
  10851. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10852. m := &LabelMutation{
  10853. config: c,
  10854. op: op,
  10855. typ: TypeLabel,
  10856. clearedFields: make(map[string]struct{}),
  10857. }
  10858. for _, opt := range opts {
  10859. opt(m)
  10860. }
  10861. return m
  10862. }
  10863. // withLabelID sets the ID field of the mutation.
  10864. func withLabelID(id uint64) labelOption {
  10865. return func(m *LabelMutation) {
  10866. var (
  10867. err error
  10868. once sync.Once
  10869. value *Label
  10870. )
  10871. m.oldValue = func(ctx context.Context) (*Label, error) {
  10872. once.Do(func() {
  10873. if m.done {
  10874. err = errors.New("querying old values post mutation is not allowed")
  10875. } else {
  10876. value, err = m.Client().Label.Get(ctx, id)
  10877. }
  10878. })
  10879. return value, err
  10880. }
  10881. m.id = &id
  10882. }
  10883. }
  10884. // withLabel sets the old Label of the mutation.
  10885. func withLabel(node *Label) labelOption {
  10886. return func(m *LabelMutation) {
  10887. m.oldValue = func(context.Context) (*Label, error) {
  10888. return node, nil
  10889. }
  10890. m.id = &node.ID
  10891. }
  10892. }
  10893. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10894. // executed in a transaction (ent.Tx), a transactional client is returned.
  10895. func (m LabelMutation) Client() *Client {
  10896. client := &Client{config: m.config}
  10897. client.init()
  10898. return client
  10899. }
  10900. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10901. // it returns an error otherwise.
  10902. func (m LabelMutation) Tx() (*Tx, error) {
  10903. if _, ok := m.driver.(*txDriver); !ok {
  10904. return nil, errors.New("ent: mutation is not running in a transaction")
  10905. }
  10906. tx := &Tx{config: m.config}
  10907. tx.init()
  10908. return tx, nil
  10909. }
  10910. // SetID sets the value of the id field. Note that this
  10911. // operation is only accepted on creation of Label entities.
  10912. func (m *LabelMutation) SetID(id uint64) {
  10913. m.id = &id
  10914. }
  10915. // ID returns the ID value in the mutation. Note that the ID is only available
  10916. // if it was provided to the builder or after it was returned from the database.
  10917. func (m *LabelMutation) ID() (id uint64, exists bool) {
  10918. if m.id == nil {
  10919. return
  10920. }
  10921. return *m.id, true
  10922. }
  10923. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10924. // That means, if the mutation is applied within a transaction with an isolation level such
  10925. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10926. // or updated by the mutation.
  10927. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  10928. switch {
  10929. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10930. id, exists := m.ID()
  10931. if exists {
  10932. return []uint64{id}, nil
  10933. }
  10934. fallthrough
  10935. case m.op.Is(OpUpdate | OpDelete):
  10936. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  10937. default:
  10938. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10939. }
  10940. }
  10941. // SetCreatedAt sets the "created_at" field.
  10942. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  10943. m.created_at = &t
  10944. }
  10945. // CreatedAt returns the value of the "created_at" field in the mutation.
  10946. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  10947. v := m.created_at
  10948. if v == nil {
  10949. return
  10950. }
  10951. return *v, true
  10952. }
  10953. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  10954. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10956. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10957. if !m.op.Is(OpUpdateOne) {
  10958. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10959. }
  10960. if m.id == nil || m.oldValue == nil {
  10961. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10962. }
  10963. oldValue, err := m.oldValue(ctx)
  10964. if err != nil {
  10965. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10966. }
  10967. return oldValue.CreatedAt, nil
  10968. }
  10969. // ResetCreatedAt resets all changes to the "created_at" field.
  10970. func (m *LabelMutation) ResetCreatedAt() {
  10971. m.created_at = nil
  10972. }
  10973. // SetUpdatedAt sets the "updated_at" field.
  10974. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  10975. m.updated_at = &t
  10976. }
  10977. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10978. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  10979. v := m.updated_at
  10980. if v == nil {
  10981. return
  10982. }
  10983. return *v, true
  10984. }
  10985. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  10986. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  10987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10988. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10989. if !m.op.Is(OpUpdateOne) {
  10990. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10991. }
  10992. if m.id == nil || m.oldValue == nil {
  10993. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10994. }
  10995. oldValue, err := m.oldValue(ctx)
  10996. if err != nil {
  10997. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10998. }
  10999. return oldValue.UpdatedAt, nil
  11000. }
  11001. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11002. func (m *LabelMutation) ResetUpdatedAt() {
  11003. m.updated_at = nil
  11004. }
  11005. // SetStatus sets the "status" field.
  11006. func (m *LabelMutation) SetStatus(u uint8) {
  11007. m.status = &u
  11008. m.addstatus = nil
  11009. }
  11010. // Status returns the value of the "status" field in the mutation.
  11011. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11012. v := m.status
  11013. if v == nil {
  11014. return
  11015. }
  11016. return *v, true
  11017. }
  11018. // OldStatus returns the old "status" field's value of the Label entity.
  11019. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11021. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11022. if !m.op.Is(OpUpdateOne) {
  11023. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11024. }
  11025. if m.id == nil || m.oldValue == nil {
  11026. return v, errors.New("OldStatus requires an ID field in the mutation")
  11027. }
  11028. oldValue, err := m.oldValue(ctx)
  11029. if err != nil {
  11030. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11031. }
  11032. return oldValue.Status, nil
  11033. }
  11034. // AddStatus adds u to the "status" field.
  11035. func (m *LabelMutation) AddStatus(u int8) {
  11036. if m.addstatus != nil {
  11037. *m.addstatus += u
  11038. } else {
  11039. m.addstatus = &u
  11040. }
  11041. }
  11042. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11043. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11044. v := m.addstatus
  11045. if v == nil {
  11046. return
  11047. }
  11048. return *v, true
  11049. }
  11050. // ClearStatus clears the value of the "status" field.
  11051. func (m *LabelMutation) ClearStatus() {
  11052. m.status = nil
  11053. m.addstatus = nil
  11054. m.clearedFields[label.FieldStatus] = struct{}{}
  11055. }
  11056. // StatusCleared returns if the "status" field was cleared in this mutation.
  11057. func (m *LabelMutation) StatusCleared() bool {
  11058. _, ok := m.clearedFields[label.FieldStatus]
  11059. return ok
  11060. }
  11061. // ResetStatus resets all changes to the "status" field.
  11062. func (m *LabelMutation) ResetStatus() {
  11063. m.status = nil
  11064. m.addstatus = nil
  11065. delete(m.clearedFields, label.FieldStatus)
  11066. }
  11067. // SetType sets the "type" field.
  11068. func (m *LabelMutation) SetType(i int) {
  11069. m._type = &i
  11070. m.add_type = nil
  11071. }
  11072. // GetType returns the value of the "type" field in the mutation.
  11073. func (m *LabelMutation) GetType() (r int, exists bool) {
  11074. v := m._type
  11075. if v == nil {
  11076. return
  11077. }
  11078. return *v, true
  11079. }
  11080. // OldType returns the old "type" field's value of the Label entity.
  11081. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11083. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11084. if !m.op.Is(OpUpdateOne) {
  11085. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11086. }
  11087. if m.id == nil || m.oldValue == nil {
  11088. return v, errors.New("OldType requires an ID field in the mutation")
  11089. }
  11090. oldValue, err := m.oldValue(ctx)
  11091. if err != nil {
  11092. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11093. }
  11094. return oldValue.Type, nil
  11095. }
  11096. // AddType adds i to the "type" field.
  11097. func (m *LabelMutation) AddType(i int) {
  11098. if m.add_type != nil {
  11099. *m.add_type += i
  11100. } else {
  11101. m.add_type = &i
  11102. }
  11103. }
  11104. // AddedType returns the value that was added to the "type" field in this mutation.
  11105. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11106. v := m.add_type
  11107. if v == nil {
  11108. return
  11109. }
  11110. return *v, true
  11111. }
  11112. // ResetType resets all changes to the "type" field.
  11113. func (m *LabelMutation) ResetType() {
  11114. m._type = nil
  11115. m.add_type = nil
  11116. }
  11117. // SetName sets the "name" field.
  11118. func (m *LabelMutation) SetName(s string) {
  11119. m.name = &s
  11120. }
  11121. // Name returns the value of the "name" field in the mutation.
  11122. func (m *LabelMutation) Name() (r string, exists bool) {
  11123. v := m.name
  11124. if v == nil {
  11125. return
  11126. }
  11127. return *v, true
  11128. }
  11129. // OldName returns the old "name" field's value of the Label entity.
  11130. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11132. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11133. if !m.op.Is(OpUpdateOne) {
  11134. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11135. }
  11136. if m.id == nil || m.oldValue == nil {
  11137. return v, errors.New("OldName requires an ID field in the mutation")
  11138. }
  11139. oldValue, err := m.oldValue(ctx)
  11140. if err != nil {
  11141. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11142. }
  11143. return oldValue.Name, nil
  11144. }
  11145. // ResetName resets all changes to the "name" field.
  11146. func (m *LabelMutation) ResetName() {
  11147. m.name = nil
  11148. }
  11149. // SetFrom sets the "from" field.
  11150. func (m *LabelMutation) SetFrom(i int) {
  11151. m.from = &i
  11152. m.addfrom = nil
  11153. }
  11154. // From returns the value of the "from" field in the mutation.
  11155. func (m *LabelMutation) From() (r int, exists bool) {
  11156. v := m.from
  11157. if v == nil {
  11158. return
  11159. }
  11160. return *v, true
  11161. }
  11162. // OldFrom returns the old "from" field's value of the Label entity.
  11163. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11165. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11166. if !m.op.Is(OpUpdateOne) {
  11167. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11168. }
  11169. if m.id == nil || m.oldValue == nil {
  11170. return v, errors.New("OldFrom requires an ID field in the mutation")
  11171. }
  11172. oldValue, err := m.oldValue(ctx)
  11173. if err != nil {
  11174. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11175. }
  11176. return oldValue.From, nil
  11177. }
  11178. // AddFrom adds i to the "from" field.
  11179. func (m *LabelMutation) AddFrom(i int) {
  11180. if m.addfrom != nil {
  11181. *m.addfrom += i
  11182. } else {
  11183. m.addfrom = &i
  11184. }
  11185. }
  11186. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11187. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11188. v := m.addfrom
  11189. if v == nil {
  11190. return
  11191. }
  11192. return *v, true
  11193. }
  11194. // ResetFrom resets all changes to the "from" field.
  11195. func (m *LabelMutation) ResetFrom() {
  11196. m.from = nil
  11197. m.addfrom = nil
  11198. }
  11199. // SetMode sets the "mode" field.
  11200. func (m *LabelMutation) SetMode(i int) {
  11201. m.mode = &i
  11202. m.addmode = nil
  11203. }
  11204. // Mode returns the value of the "mode" field in the mutation.
  11205. func (m *LabelMutation) Mode() (r int, exists bool) {
  11206. v := m.mode
  11207. if v == nil {
  11208. return
  11209. }
  11210. return *v, true
  11211. }
  11212. // OldMode returns the old "mode" field's value of the Label entity.
  11213. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11215. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11216. if !m.op.Is(OpUpdateOne) {
  11217. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11218. }
  11219. if m.id == nil || m.oldValue == nil {
  11220. return v, errors.New("OldMode requires an ID field in the mutation")
  11221. }
  11222. oldValue, err := m.oldValue(ctx)
  11223. if err != nil {
  11224. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11225. }
  11226. return oldValue.Mode, nil
  11227. }
  11228. // AddMode adds i to the "mode" field.
  11229. func (m *LabelMutation) AddMode(i int) {
  11230. if m.addmode != nil {
  11231. *m.addmode += i
  11232. } else {
  11233. m.addmode = &i
  11234. }
  11235. }
  11236. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11237. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11238. v := m.addmode
  11239. if v == nil {
  11240. return
  11241. }
  11242. return *v, true
  11243. }
  11244. // ResetMode resets all changes to the "mode" field.
  11245. func (m *LabelMutation) ResetMode() {
  11246. m.mode = nil
  11247. m.addmode = nil
  11248. }
  11249. // SetConditions sets the "conditions" field.
  11250. func (m *LabelMutation) SetConditions(s string) {
  11251. m.conditions = &s
  11252. }
  11253. // Conditions returns the value of the "conditions" field in the mutation.
  11254. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11255. v := m.conditions
  11256. if v == nil {
  11257. return
  11258. }
  11259. return *v, true
  11260. }
  11261. // OldConditions returns the old "conditions" field's value of the Label entity.
  11262. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11264. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11265. if !m.op.Is(OpUpdateOne) {
  11266. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11267. }
  11268. if m.id == nil || m.oldValue == nil {
  11269. return v, errors.New("OldConditions requires an ID field in the mutation")
  11270. }
  11271. oldValue, err := m.oldValue(ctx)
  11272. if err != nil {
  11273. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11274. }
  11275. return oldValue.Conditions, nil
  11276. }
  11277. // ClearConditions clears the value of the "conditions" field.
  11278. func (m *LabelMutation) ClearConditions() {
  11279. m.conditions = nil
  11280. m.clearedFields[label.FieldConditions] = struct{}{}
  11281. }
  11282. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11283. func (m *LabelMutation) ConditionsCleared() bool {
  11284. _, ok := m.clearedFields[label.FieldConditions]
  11285. return ok
  11286. }
  11287. // ResetConditions resets all changes to the "conditions" field.
  11288. func (m *LabelMutation) ResetConditions() {
  11289. m.conditions = nil
  11290. delete(m.clearedFields, label.FieldConditions)
  11291. }
  11292. // SetOrganizationID sets the "organization_id" field.
  11293. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11294. m.organization_id = &u
  11295. m.addorganization_id = nil
  11296. }
  11297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11298. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11299. v := m.organization_id
  11300. if v == nil {
  11301. return
  11302. }
  11303. return *v, true
  11304. }
  11305. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11306. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11308. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11309. if !m.op.Is(OpUpdateOne) {
  11310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11311. }
  11312. if m.id == nil || m.oldValue == nil {
  11313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11314. }
  11315. oldValue, err := m.oldValue(ctx)
  11316. if err != nil {
  11317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11318. }
  11319. return oldValue.OrganizationID, nil
  11320. }
  11321. // AddOrganizationID adds u to the "organization_id" field.
  11322. func (m *LabelMutation) AddOrganizationID(u int64) {
  11323. if m.addorganization_id != nil {
  11324. *m.addorganization_id += u
  11325. } else {
  11326. m.addorganization_id = &u
  11327. }
  11328. }
  11329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11330. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11331. v := m.addorganization_id
  11332. if v == nil {
  11333. return
  11334. }
  11335. return *v, true
  11336. }
  11337. // ClearOrganizationID clears the value of the "organization_id" field.
  11338. func (m *LabelMutation) ClearOrganizationID() {
  11339. m.organization_id = nil
  11340. m.addorganization_id = nil
  11341. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11342. }
  11343. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11344. func (m *LabelMutation) OrganizationIDCleared() bool {
  11345. _, ok := m.clearedFields[label.FieldOrganizationID]
  11346. return ok
  11347. }
  11348. // ResetOrganizationID resets all changes to the "organization_id" field.
  11349. func (m *LabelMutation) ResetOrganizationID() {
  11350. m.organization_id = nil
  11351. m.addorganization_id = nil
  11352. delete(m.clearedFields, label.FieldOrganizationID)
  11353. }
  11354. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11355. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11356. if m.label_relationships == nil {
  11357. m.label_relationships = make(map[uint64]struct{})
  11358. }
  11359. for i := range ids {
  11360. m.label_relationships[ids[i]] = struct{}{}
  11361. }
  11362. }
  11363. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11364. func (m *LabelMutation) ClearLabelRelationships() {
  11365. m.clearedlabel_relationships = true
  11366. }
  11367. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11368. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11369. return m.clearedlabel_relationships
  11370. }
  11371. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11372. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11373. if m.removedlabel_relationships == nil {
  11374. m.removedlabel_relationships = make(map[uint64]struct{})
  11375. }
  11376. for i := range ids {
  11377. delete(m.label_relationships, ids[i])
  11378. m.removedlabel_relationships[ids[i]] = struct{}{}
  11379. }
  11380. }
  11381. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11382. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11383. for id := range m.removedlabel_relationships {
  11384. ids = append(ids, id)
  11385. }
  11386. return
  11387. }
  11388. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11389. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11390. for id := range m.label_relationships {
  11391. ids = append(ids, id)
  11392. }
  11393. return
  11394. }
  11395. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11396. func (m *LabelMutation) ResetLabelRelationships() {
  11397. m.label_relationships = nil
  11398. m.clearedlabel_relationships = false
  11399. m.removedlabel_relationships = nil
  11400. }
  11401. // Where appends a list predicates to the LabelMutation builder.
  11402. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11403. m.predicates = append(m.predicates, ps...)
  11404. }
  11405. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11406. // users can use type-assertion to append predicates that do not depend on any generated package.
  11407. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11408. p := make([]predicate.Label, len(ps))
  11409. for i := range ps {
  11410. p[i] = ps[i]
  11411. }
  11412. m.Where(p...)
  11413. }
  11414. // Op returns the operation name.
  11415. func (m *LabelMutation) Op() Op {
  11416. return m.op
  11417. }
  11418. // SetOp allows setting the mutation operation.
  11419. func (m *LabelMutation) SetOp(op Op) {
  11420. m.op = op
  11421. }
  11422. // Type returns the node type of this mutation (Label).
  11423. func (m *LabelMutation) Type() string {
  11424. return m.typ
  11425. }
  11426. // Fields returns all fields that were changed during this mutation. Note that in
  11427. // order to get all numeric fields that were incremented/decremented, call
  11428. // AddedFields().
  11429. func (m *LabelMutation) Fields() []string {
  11430. fields := make([]string, 0, 9)
  11431. if m.created_at != nil {
  11432. fields = append(fields, label.FieldCreatedAt)
  11433. }
  11434. if m.updated_at != nil {
  11435. fields = append(fields, label.FieldUpdatedAt)
  11436. }
  11437. if m.status != nil {
  11438. fields = append(fields, label.FieldStatus)
  11439. }
  11440. if m._type != nil {
  11441. fields = append(fields, label.FieldType)
  11442. }
  11443. if m.name != nil {
  11444. fields = append(fields, label.FieldName)
  11445. }
  11446. if m.from != nil {
  11447. fields = append(fields, label.FieldFrom)
  11448. }
  11449. if m.mode != nil {
  11450. fields = append(fields, label.FieldMode)
  11451. }
  11452. if m.conditions != nil {
  11453. fields = append(fields, label.FieldConditions)
  11454. }
  11455. if m.organization_id != nil {
  11456. fields = append(fields, label.FieldOrganizationID)
  11457. }
  11458. return fields
  11459. }
  11460. // Field returns the value of a field with the given name. The second boolean
  11461. // return value indicates that this field was not set, or was not defined in the
  11462. // schema.
  11463. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11464. switch name {
  11465. case label.FieldCreatedAt:
  11466. return m.CreatedAt()
  11467. case label.FieldUpdatedAt:
  11468. return m.UpdatedAt()
  11469. case label.FieldStatus:
  11470. return m.Status()
  11471. case label.FieldType:
  11472. return m.GetType()
  11473. case label.FieldName:
  11474. return m.Name()
  11475. case label.FieldFrom:
  11476. return m.From()
  11477. case label.FieldMode:
  11478. return m.Mode()
  11479. case label.FieldConditions:
  11480. return m.Conditions()
  11481. case label.FieldOrganizationID:
  11482. return m.OrganizationID()
  11483. }
  11484. return nil, false
  11485. }
  11486. // OldField returns the old value of the field from the database. An error is
  11487. // returned if the mutation operation is not UpdateOne, or the query to the
  11488. // database failed.
  11489. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11490. switch name {
  11491. case label.FieldCreatedAt:
  11492. return m.OldCreatedAt(ctx)
  11493. case label.FieldUpdatedAt:
  11494. return m.OldUpdatedAt(ctx)
  11495. case label.FieldStatus:
  11496. return m.OldStatus(ctx)
  11497. case label.FieldType:
  11498. return m.OldType(ctx)
  11499. case label.FieldName:
  11500. return m.OldName(ctx)
  11501. case label.FieldFrom:
  11502. return m.OldFrom(ctx)
  11503. case label.FieldMode:
  11504. return m.OldMode(ctx)
  11505. case label.FieldConditions:
  11506. return m.OldConditions(ctx)
  11507. case label.FieldOrganizationID:
  11508. return m.OldOrganizationID(ctx)
  11509. }
  11510. return nil, fmt.Errorf("unknown Label field %s", name)
  11511. }
  11512. // SetField sets the value of a field with the given name. It returns an error if
  11513. // the field is not defined in the schema, or if the type mismatched the field
  11514. // type.
  11515. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11516. switch name {
  11517. case label.FieldCreatedAt:
  11518. v, ok := value.(time.Time)
  11519. if !ok {
  11520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11521. }
  11522. m.SetCreatedAt(v)
  11523. return nil
  11524. case label.FieldUpdatedAt:
  11525. v, ok := value.(time.Time)
  11526. if !ok {
  11527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11528. }
  11529. m.SetUpdatedAt(v)
  11530. return nil
  11531. case label.FieldStatus:
  11532. v, ok := value.(uint8)
  11533. if !ok {
  11534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11535. }
  11536. m.SetStatus(v)
  11537. return nil
  11538. case label.FieldType:
  11539. v, ok := value.(int)
  11540. if !ok {
  11541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11542. }
  11543. m.SetType(v)
  11544. return nil
  11545. case label.FieldName:
  11546. v, ok := value.(string)
  11547. if !ok {
  11548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11549. }
  11550. m.SetName(v)
  11551. return nil
  11552. case label.FieldFrom:
  11553. v, ok := value.(int)
  11554. if !ok {
  11555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11556. }
  11557. m.SetFrom(v)
  11558. return nil
  11559. case label.FieldMode:
  11560. v, ok := value.(int)
  11561. if !ok {
  11562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11563. }
  11564. m.SetMode(v)
  11565. return nil
  11566. case label.FieldConditions:
  11567. v, ok := value.(string)
  11568. if !ok {
  11569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11570. }
  11571. m.SetConditions(v)
  11572. return nil
  11573. case label.FieldOrganizationID:
  11574. v, ok := value.(uint64)
  11575. if !ok {
  11576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11577. }
  11578. m.SetOrganizationID(v)
  11579. return nil
  11580. }
  11581. return fmt.Errorf("unknown Label field %s", name)
  11582. }
  11583. // AddedFields returns all numeric fields that were incremented/decremented during
  11584. // this mutation.
  11585. func (m *LabelMutation) AddedFields() []string {
  11586. var fields []string
  11587. if m.addstatus != nil {
  11588. fields = append(fields, label.FieldStatus)
  11589. }
  11590. if m.add_type != nil {
  11591. fields = append(fields, label.FieldType)
  11592. }
  11593. if m.addfrom != nil {
  11594. fields = append(fields, label.FieldFrom)
  11595. }
  11596. if m.addmode != nil {
  11597. fields = append(fields, label.FieldMode)
  11598. }
  11599. if m.addorganization_id != nil {
  11600. fields = append(fields, label.FieldOrganizationID)
  11601. }
  11602. return fields
  11603. }
  11604. // AddedField returns the numeric value that was incremented/decremented on a field
  11605. // with the given name. The second boolean return value indicates that this field
  11606. // was not set, or was not defined in the schema.
  11607. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11608. switch name {
  11609. case label.FieldStatus:
  11610. return m.AddedStatus()
  11611. case label.FieldType:
  11612. return m.AddedType()
  11613. case label.FieldFrom:
  11614. return m.AddedFrom()
  11615. case label.FieldMode:
  11616. return m.AddedMode()
  11617. case label.FieldOrganizationID:
  11618. return m.AddedOrganizationID()
  11619. }
  11620. return nil, false
  11621. }
  11622. // AddField adds the value to the field with the given name. It returns an error if
  11623. // the field is not defined in the schema, or if the type mismatched the field
  11624. // type.
  11625. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11626. switch name {
  11627. case label.FieldStatus:
  11628. v, ok := value.(int8)
  11629. if !ok {
  11630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11631. }
  11632. m.AddStatus(v)
  11633. return nil
  11634. case label.FieldType:
  11635. v, ok := value.(int)
  11636. if !ok {
  11637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11638. }
  11639. m.AddType(v)
  11640. return nil
  11641. case label.FieldFrom:
  11642. v, ok := value.(int)
  11643. if !ok {
  11644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11645. }
  11646. m.AddFrom(v)
  11647. return nil
  11648. case label.FieldMode:
  11649. v, ok := value.(int)
  11650. if !ok {
  11651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11652. }
  11653. m.AddMode(v)
  11654. return nil
  11655. case label.FieldOrganizationID:
  11656. v, ok := value.(int64)
  11657. if !ok {
  11658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11659. }
  11660. m.AddOrganizationID(v)
  11661. return nil
  11662. }
  11663. return fmt.Errorf("unknown Label numeric field %s", name)
  11664. }
  11665. // ClearedFields returns all nullable fields that were cleared during this
  11666. // mutation.
  11667. func (m *LabelMutation) ClearedFields() []string {
  11668. var fields []string
  11669. if m.FieldCleared(label.FieldStatus) {
  11670. fields = append(fields, label.FieldStatus)
  11671. }
  11672. if m.FieldCleared(label.FieldConditions) {
  11673. fields = append(fields, label.FieldConditions)
  11674. }
  11675. if m.FieldCleared(label.FieldOrganizationID) {
  11676. fields = append(fields, label.FieldOrganizationID)
  11677. }
  11678. return fields
  11679. }
  11680. // FieldCleared returns a boolean indicating if a field with the given name was
  11681. // cleared in this mutation.
  11682. func (m *LabelMutation) FieldCleared(name string) bool {
  11683. _, ok := m.clearedFields[name]
  11684. return ok
  11685. }
  11686. // ClearField clears the value of the field with the given name. It returns an
  11687. // error if the field is not defined in the schema.
  11688. func (m *LabelMutation) ClearField(name string) error {
  11689. switch name {
  11690. case label.FieldStatus:
  11691. m.ClearStatus()
  11692. return nil
  11693. case label.FieldConditions:
  11694. m.ClearConditions()
  11695. return nil
  11696. case label.FieldOrganizationID:
  11697. m.ClearOrganizationID()
  11698. return nil
  11699. }
  11700. return fmt.Errorf("unknown Label nullable field %s", name)
  11701. }
  11702. // ResetField resets all changes in the mutation for the field with the given name.
  11703. // It returns an error if the field is not defined in the schema.
  11704. func (m *LabelMutation) ResetField(name string) error {
  11705. switch name {
  11706. case label.FieldCreatedAt:
  11707. m.ResetCreatedAt()
  11708. return nil
  11709. case label.FieldUpdatedAt:
  11710. m.ResetUpdatedAt()
  11711. return nil
  11712. case label.FieldStatus:
  11713. m.ResetStatus()
  11714. return nil
  11715. case label.FieldType:
  11716. m.ResetType()
  11717. return nil
  11718. case label.FieldName:
  11719. m.ResetName()
  11720. return nil
  11721. case label.FieldFrom:
  11722. m.ResetFrom()
  11723. return nil
  11724. case label.FieldMode:
  11725. m.ResetMode()
  11726. return nil
  11727. case label.FieldConditions:
  11728. m.ResetConditions()
  11729. return nil
  11730. case label.FieldOrganizationID:
  11731. m.ResetOrganizationID()
  11732. return nil
  11733. }
  11734. return fmt.Errorf("unknown Label field %s", name)
  11735. }
  11736. // AddedEdges returns all edge names that were set/added in this mutation.
  11737. func (m *LabelMutation) AddedEdges() []string {
  11738. edges := make([]string, 0, 1)
  11739. if m.label_relationships != nil {
  11740. edges = append(edges, label.EdgeLabelRelationships)
  11741. }
  11742. return edges
  11743. }
  11744. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11745. // name in this mutation.
  11746. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11747. switch name {
  11748. case label.EdgeLabelRelationships:
  11749. ids := make([]ent.Value, 0, len(m.label_relationships))
  11750. for id := range m.label_relationships {
  11751. ids = append(ids, id)
  11752. }
  11753. return ids
  11754. }
  11755. return nil
  11756. }
  11757. // RemovedEdges returns all edge names that were removed in this mutation.
  11758. func (m *LabelMutation) RemovedEdges() []string {
  11759. edges := make([]string, 0, 1)
  11760. if m.removedlabel_relationships != nil {
  11761. edges = append(edges, label.EdgeLabelRelationships)
  11762. }
  11763. return edges
  11764. }
  11765. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11766. // the given name in this mutation.
  11767. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11768. switch name {
  11769. case label.EdgeLabelRelationships:
  11770. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11771. for id := range m.removedlabel_relationships {
  11772. ids = append(ids, id)
  11773. }
  11774. return ids
  11775. }
  11776. return nil
  11777. }
  11778. // ClearedEdges returns all edge names that were cleared in this mutation.
  11779. func (m *LabelMutation) ClearedEdges() []string {
  11780. edges := make([]string, 0, 1)
  11781. if m.clearedlabel_relationships {
  11782. edges = append(edges, label.EdgeLabelRelationships)
  11783. }
  11784. return edges
  11785. }
  11786. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11787. // was cleared in this mutation.
  11788. func (m *LabelMutation) EdgeCleared(name string) bool {
  11789. switch name {
  11790. case label.EdgeLabelRelationships:
  11791. return m.clearedlabel_relationships
  11792. }
  11793. return false
  11794. }
  11795. // ClearEdge clears the value of the edge with the given name. It returns an error
  11796. // if that edge is not defined in the schema.
  11797. func (m *LabelMutation) ClearEdge(name string) error {
  11798. switch name {
  11799. }
  11800. return fmt.Errorf("unknown Label unique edge %s", name)
  11801. }
  11802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11803. // It returns an error if the edge is not defined in the schema.
  11804. func (m *LabelMutation) ResetEdge(name string) error {
  11805. switch name {
  11806. case label.EdgeLabelRelationships:
  11807. m.ResetLabelRelationships()
  11808. return nil
  11809. }
  11810. return fmt.Errorf("unknown Label edge %s", name)
  11811. }
  11812. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11813. type LabelRelationshipMutation struct {
  11814. config
  11815. op Op
  11816. typ string
  11817. id *uint64
  11818. created_at *time.Time
  11819. updated_at *time.Time
  11820. status *uint8
  11821. addstatus *int8
  11822. deleted_at *time.Time
  11823. organization_id *uint64
  11824. addorganization_id *int64
  11825. clearedFields map[string]struct{}
  11826. contacts *uint64
  11827. clearedcontacts bool
  11828. labels *uint64
  11829. clearedlabels bool
  11830. done bool
  11831. oldValue func(context.Context) (*LabelRelationship, error)
  11832. predicates []predicate.LabelRelationship
  11833. }
  11834. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11835. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11836. type labelrelationshipOption func(*LabelRelationshipMutation)
  11837. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11838. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11839. m := &LabelRelationshipMutation{
  11840. config: c,
  11841. op: op,
  11842. typ: TypeLabelRelationship,
  11843. clearedFields: make(map[string]struct{}),
  11844. }
  11845. for _, opt := range opts {
  11846. opt(m)
  11847. }
  11848. return m
  11849. }
  11850. // withLabelRelationshipID sets the ID field of the mutation.
  11851. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11852. return func(m *LabelRelationshipMutation) {
  11853. var (
  11854. err error
  11855. once sync.Once
  11856. value *LabelRelationship
  11857. )
  11858. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11859. once.Do(func() {
  11860. if m.done {
  11861. err = errors.New("querying old values post mutation is not allowed")
  11862. } else {
  11863. value, err = m.Client().LabelRelationship.Get(ctx, id)
  11864. }
  11865. })
  11866. return value, err
  11867. }
  11868. m.id = &id
  11869. }
  11870. }
  11871. // withLabelRelationship sets the old LabelRelationship of the mutation.
  11872. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  11873. return func(m *LabelRelationshipMutation) {
  11874. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  11875. return node, nil
  11876. }
  11877. m.id = &node.ID
  11878. }
  11879. }
  11880. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11881. // executed in a transaction (ent.Tx), a transactional client is returned.
  11882. func (m LabelRelationshipMutation) Client() *Client {
  11883. client := &Client{config: m.config}
  11884. client.init()
  11885. return client
  11886. }
  11887. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11888. // it returns an error otherwise.
  11889. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  11890. if _, ok := m.driver.(*txDriver); !ok {
  11891. return nil, errors.New("ent: mutation is not running in a transaction")
  11892. }
  11893. tx := &Tx{config: m.config}
  11894. tx.init()
  11895. return tx, nil
  11896. }
  11897. // SetID sets the value of the id field. Note that this
  11898. // operation is only accepted on creation of LabelRelationship entities.
  11899. func (m *LabelRelationshipMutation) SetID(id uint64) {
  11900. m.id = &id
  11901. }
  11902. // ID returns the ID value in the mutation. Note that the ID is only available
  11903. // if it was provided to the builder or after it was returned from the database.
  11904. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  11905. if m.id == nil {
  11906. return
  11907. }
  11908. return *m.id, true
  11909. }
  11910. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11911. // That means, if the mutation is applied within a transaction with an isolation level such
  11912. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11913. // or updated by the mutation.
  11914. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  11915. switch {
  11916. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11917. id, exists := m.ID()
  11918. if exists {
  11919. return []uint64{id}, nil
  11920. }
  11921. fallthrough
  11922. case m.op.Is(OpUpdate | OpDelete):
  11923. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  11924. default:
  11925. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11926. }
  11927. }
  11928. // SetCreatedAt sets the "created_at" field.
  11929. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  11930. m.created_at = &t
  11931. }
  11932. // CreatedAt returns the value of the "created_at" field in the mutation.
  11933. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  11934. v := m.created_at
  11935. if v == nil {
  11936. return
  11937. }
  11938. return *v, true
  11939. }
  11940. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  11941. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11943. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11944. if !m.op.Is(OpUpdateOne) {
  11945. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11946. }
  11947. if m.id == nil || m.oldValue == nil {
  11948. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11949. }
  11950. oldValue, err := m.oldValue(ctx)
  11951. if err != nil {
  11952. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11953. }
  11954. return oldValue.CreatedAt, nil
  11955. }
  11956. // ResetCreatedAt resets all changes to the "created_at" field.
  11957. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  11958. m.created_at = nil
  11959. }
  11960. // SetUpdatedAt sets the "updated_at" field.
  11961. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  11962. m.updated_at = &t
  11963. }
  11964. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11965. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  11966. v := m.updated_at
  11967. if v == nil {
  11968. return
  11969. }
  11970. return *v, true
  11971. }
  11972. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  11973. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  11974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11975. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11976. if !m.op.Is(OpUpdateOne) {
  11977. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11978. }
  11979. if m.id == nil || m.oldValue == nil {
  11980. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11981. }
  11982. oldValue, err := m.oldValue(ctx)
  11983. if err != nil {
  11984. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11985. }
  11986. return oldValue.UpdatedAt, nil
  11987. }
  11988. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11989. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  11990. m.updated_at = nil
  11991. }
  11992. // SetStatus sets the "status" field.
  11993. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  11994. m.status = &u
  11995. m.addstatus = nil
  11996. }
  11997. // Status returns the value of the "status" field in the mutation.
  11998. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  11999. v := m.status
  12000. if v == nil {
  12001. return
  12002. }
  12003. return *v, true
  12004. }
  12005. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12006. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12008. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12009. if !m.op.Is(OpUpdateOne) {
  12010. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12011. }
  12012. if m.id == nil || m.oldValue == nil {
  12013. return v, errors.New("OldStatus requires an ID field in the mutation")
  12014. }
  12015. oldValue, err := m.oldValue(ctx)
  12016. if err != nil {
  12017. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12018. }
  12019. return oldValue.Status, nil
  12020. }
  12021. // AddStatus adds u to the "status" field.
  12022. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12023. if m.addstatus != nil {
  12024. *m.addstatus += u
  12025. } else {
  12026. m.addstatus = &u
  12027. }
  12028. }
  12029. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12030. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12031. v := m.addstatus
  12032. if v == nil {
  12033. return
  12034. }
  12035. return *v, true
  12036. }
  12037. // ClearStatus clears the value of the "status" field.
  12038. func (m *LabelRelationshipMutation) ClearStatus() {
  12039. m.status = nil
  12040. m.addstatus = nil
  12041. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12042. }
  12043. // StatusCleared returns if the "status" field was cleared in this mutation.
  12044. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12045. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12046. return ok
  12047. }
  12048. // ResetStatus resets all changes to the "status" field.
  12049. func (m *LabelRelationshipMutation) ResetStatus() {
  12050. m.status = nil
  12051. m.addstatus = nil
  12052. delete(m.clearedFields, labelrelationship.FieldStatus)
  12053. }
  12054. // SetDeletedAt sets the "deleted_at" field.
  12055. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12056. m.deleted_at = &t
  12057. }
  12058. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12059. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12060. v := m.deleted_at
  12061. if v == nil {
  12062. return
  12063. }
  12064. return *v, true
  12065. }
  12066. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12067. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12069. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12070. if !m.op.Is(OpUpdateOne) {
  12071. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12072. }
  12073. if m.id == nil || m.oldValue == nil {
  12074. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12075. }
  12076. oldValue, err := m.oldValue(ctx)
  12077. if err != nil {
  12078. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12079. }
  12080. return oldValue.DeletedAt, nil
  12081. }
  12082. // ClearDeletedAt clears the value of the "deleted_at" field.
  12083. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12084. m.deleted_at = nil
  12085. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12086. }
  12087. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12088. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12089. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12090. return ok
  12091. }
  12092. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12093. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12094. m.deleted_at = nil
  12095. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12096. }
  12097. // SetLabelID sets the "label_id" field.
  12098. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12099. m.labels = &u
  12100. }
  12101. // LabelID returns the value of the "label_id" field in the mutation.
  12102. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12103. v := m.labels
  12104. if v == nil {
  12105. return
  12106. }
  12107. return *v, true
  12108. }
  12109. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12110. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12112. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12113. if !m.op.Is(OpUpdateOne) {
  12114. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12115. }
  12116. if m.id == nil || m.oldValue == nil {
  12117. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12118. }
  12119. oldValue, err := m.oldValue(ctx)
  12120. if err != nil {
  12121. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12122. }
  12123. return oldValue.LabelID, nil
  12124. }
  12125. // ResetLabelID resets all changes to the "label_id" field.
  12126. func (m *LabelRelationshipMutation) ResetLabelID() {
  12127. m.labels = nil
  12128. }
  12129. // SetContactID sets the "contact_id" field.
  12130. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12131. m.contacts = &u
  12132. }
  12133. // ContactID returns the value of the "contact_id" field in the mutation.
  12134. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12135. v := m.contacts
  12136. if v == nil {
  12137. return
  12138. }
  12139. return *v, true
  12140. }
  12141. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12142. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12144. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12145. if !m.op.Is(OpUpdateOne) {
  12146. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12147. }
  12148. if m.id == nil || m.oldValue == nil {
  12149. return v, errors.New("OldContactID requires an ID field in the mutation")
  12150. }
  12151. oldValue, err := m.oldValue(ctx)
  12152. if err != nil {
  12153. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12154. }
  12155. return oldValue.ContactID, nil
  12156. }
  12157. // ResetContactID resets all changes to the "contact_id" field.
  12158. func (m *LabelRelationshipMutation) ResetContactID() {
  12159. m.contacts = nil
  12160. }
  12161. // SetOrganizationID sets the "organization_id" field.
  12162. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12163. m.organization_id = &u
  12164. m.addorganization_id = nil
  12165. }
  12166. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12167. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12168. v := m.organization_id
  12169. if v == nil {
  12170. return
  12171. }
  12172. return *v, true
  12173. }
  12174. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12175. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12177. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12178. if !m.op.Is(OpUpdateOne) {
  12179. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12180. }
  12181. if m.id == nil || m.oldValue == nil {
  12182. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12183. }
  12184. oldValue, err := m.oldValue(ctx)
  12185. if err != nil {
  12186. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12187. }
  12188. return oldValue.OrganizationID, nil
  12189. }
  12190. // AddOrganizationID adds u to the "organization_id" field.
  12191. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12192. if m.addorganization_id != nil {
  12193. *m.addorganization_id += u
  12194. } else {
  12195. m.addorganization_id = &u
  12196. }
  12197. }
  12198. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12199. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12200. v := m.addorganization_id
  12201. if v == nil {
  12202. return
  12203. }
  12204. return *v, true
  12205. }
  12206. // ClearOrganizationID clears the value of the "organization_id" field.
  12207. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12208. m.organization_id = nil
  12209. m.addorganization_id = nil
  12210. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12211. }
  12212. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12213. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12214. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12215. return ok
  12216. }
  12217. // ResetOrganizationID resets all changes to the "organization_id" field.
  12218. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12219. m.organization_id = nil
  12220. m.addorganization_id = nil
  12221. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12222. }
  12223. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12224. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12225. m.contacts = &id
  12226. }
  12227. // ClearContacts clears the "contacts" edge to the Contact entity.
  12228. func (m *LabelRelationshipMutation) ClearContacts() {
  12229. m.clearedcontacts = true
  12230. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12231. }
  12232. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12233. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12234. return m.clearedcontacts
  12235. }
  12236. // ContactsID returns the "contacts" edge ID in the mutation.
  12237. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12238. if m.contacts != nil {
  12239. return *m.contacts, true
  12240. }
  12241. return
  12242. }
  12243. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12244. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12245. // ContactsID instead. It exists only for internal usage by the builders.
  12246. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12247. if id := m.contacts; id != nil {
  12248. ids = append(ids, *id)
  12249. }
  12250. return
  12251. }
  12252. // ResetContacts resets all changes to the "contacts" edge.
  12253. func (m *LabelRelationshipMutation) ResetContacts() {
  12254. m.contacts = nil
  12255. m.clearedcontacts = false
  12256. }
  12257. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12258. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12259. m.labels = &id
  12260. }
  12261. // ClearLabels clears the "labels" edge to the Label entity.
  12262. func (m *LabelRelationshipMutation) ClearLabels() {
  12263. m.clearedlabels = true
  12264. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12265. }
  12266. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12267. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12268. return m.clearedlabels
  12269. }
  12270. // LabelsID returns the "labels" edge ID in the mutation.
  12271. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12272. if m.labels != nil {
  12273. return *m.labels, true
  12274. }
  12275. return
  12276. }
  12277. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12278. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12279. // LabelsID instead. It exists only for internal usage by the builders.
  12280. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12281. if id := m.labels; id != nil {
  12282. ids = append(ids, *id)
  12283. }
  12284. return
  12285. }
  12286. // ResetLabels resets all changes to the "labels" edge.
  12287. func (m *LabelRelationshipMutation) ResetLabels() {
  12288. m.labels = nil
  12289. m.clearedlabels = false
  12290. }
  12291. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12292. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12293. m.predicates = append(m.predicates, ps...)
  12294. }
  12295. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12296. // users can use type-assertion to append predicates that do not depend on any generated package.
  12297. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12298. p := make([]predicate.LabelRelationship, len(ps))
  12299. for i := range ps {
  12300. p[i] = ps[i]
  12301. }
  12302. m.Where(p...)
  12303. }
  12304. // Op returns the operation name.
  12305. func (m *LabelRelationshipMutation) Op() Op {
  12306. return m.op
  12307. }
  12308. // SetOp allows setting the mutation operation.
  12309. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12310. m.op = op
  12311. }
  12312. // Type returns the node type of this mutation (LabelRelationship).
  12313. func (m *LabelRelationshipMutation) Type() string {
  12314. return m.typ
  12315. }
  12316. // Fields returns all fields that were changed during this mutation. Note that in
  12317. // order to get all numeric fields that were incremented/decremented, call
  12318. // AddedFields().
  12319. func (m *LabelRelationshipMutation) Fields() []string {
  12320. fields := make([]string, 0, 7)
  12321. if m.created_at != nil {
  12322. fields = append(fields, labelrelationship.FieldCreatedAt)
  12323. }
  12324. if m.updated_at != nil {
  12325. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12326. }
  12327. if m.status != nil {
  12328. fields = append(fields, labelrelationship.FieldStatus)
  12329. }
  12330. if m.deleted_at != nil {
  12331. fields = append(fields, labelrelationship.FieldDeletedAt)
  12332. }
  12333. if m.labels != nil {
  12334. fields = append(fields, labelrelationship.FieldLabelID)
  12335. }
  12336. if m.contacts != nil {
  12337. fields = append(fields, labelrelationship.FieldContactID)
  12338. }
  12339. if m.organization_id != nil {
  12340. fields = append(fields, labelrelationship.FieldOrganizationID)
  12341. }
  12342. return fields
  12343. }
  12344. // Field returns the value of a field with the given name. The second boolean
  12345. // return value indicates that this field was not set, or was not defined in the
  12346. // schema.
  12347. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12348. switch name {
  12349. case labelrelationship.FieldCreatedAt:
  12350. return m.CreatedAt()
  12351. case labelrelationship.FieldUpdatedAt:
  12352. return m.UpdatedAt()
  12353. case labelrelationship.FieldStatus:
  12354. return m.Status()
  12355. case labelrelationship.FieldDeletedAt:
  12356. return m.DeletedAt()
  12357. case labelrelationship.FieldLabelID:
  12358. return m.LabelID()
  12359. case labelrelationship.FieldContactID:
  12360. return m.ContactID()
  12361. case labelrelationship.FieldOrganizationID:
  12362. return m.OrganizationID()
  12363. }
  12364. return nil, false
  12365. }
  12366. // OldField returns the old value of the field from the database. An error is
  12367. // returned if the mutation operation is not UpdateOne, or the query to the
  12368. // database failed.
  12369. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12370. switch name {
  12371. case labelrelationship.FieldCreatedAt:
  12372. return m.OldCreatedAt(ctx)
  12373. case labelrelationship.FieldUpdatedAt:
  12374. return m.OldUpdatedAt(ctx)
  12375. case labelrelationship.FieldStatus:
  12376. return m.OldStatus(ctx)
  12377. case labelrelationship.FieldDeletedAt:
  12378. return m.OldDeletedAt(ctx)
  12379. case labelrelationship.FieldLabelID:
  12380. return m.OldLabelID(ctx)
  12381. case labelrelationship.FieldContactID:
  12382. return m.OldContactID(ctx)
  12383. case labelrelationship.FieldOrganizationID:
  12384. return m.OldOrganizationID(ctx)
  12385. }
  12386. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12387. }
  12388. // SetField sets the value of a field with the given name. It returns an error if
  12389. // the field is not defined in the schema, or if the type mismatched the field
  12390. // type.
  12391. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12392. switch name {
  12393. case labelrelationship.FieldCreatedAt:
  12394. v, ok := value.(time.Time)
  12395. if !ok {
  12396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12397. }
  12398. m.SetCreatedAt(v)
  12399. return nil
  12400. case labelrelationship.FieldUpdatedAt:
  12401. v, ok := value.(time.Time)
  12402. if !ok {
  12403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12404. }
  12405. m.SetUpdatedAt(v)
  12406. return nil
  12407. case labelrelationship.FieldStatus:
  12408. v, ok := value.(uint8)
  12409. if !ok {
  12410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12411. }
  12412. m.SetStatus(v)
  12413. return nil
  12414. case labelrelationship.FieldDeletedAt:
  12415. v, ok := value.(time.Time)
  12416. if !ok {
  12417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12418. }
  12419. m.SetDeletedAt(v)
  12420. return nil
  12421. case labelrelationship.FieldLabelID:
  12422. v, ok := value.(uint64)
  12423. if !ok {
  12424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12425. }
  12426. m.SetLabelID(v)
  12427. return nil
  12428. case labelrelationship.FieldContactID:
  12429. v, ok := value.(uint64)
  12430. if !ok {
  12431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12432. }
  12433. m.SetContactID(v)
  12434. return nil
  12435. case labelrelationship.FieldOrganizationID:
  12436. v, ok := value.(uint64)
  12437. if !ok {
  12438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12439. }
  12440. m.SetOrganizationID(v)
  12441. return nil
  12442. }
  12443. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12444. }
  12445. // AddedFields returns all numeric fields that were incremented/decremented during
  12446. // this mutation.
  12447. func (m *LabelRelationshipMutation) AddedFields() []string {
  12448. var fields []string
  12449. if m.addstatus != nil {
  12450. fields = append(fields, labelrelationship.FieldStatus)
  12451. }
  12452. if m.addorganization_id != nil {
  12453. fields = append(fields, labelrelationship.FieldOrganizationID)
  12454. }
  12455. return fields
  12456. }
  12457. // AddedField returns the numeric value that was incremented/decremented on a field
  12458. // with the given name. The second boolean return value indicates that this field
  12459. // was not set, or was not defined in the schema.
  12460. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12461. switch name {
  12462. case labelrelationship.FieldStatus:
  12463. return m.AddedStatus()
  12464. case labelrelationship.FieldOrganizationID:
  12465. return m.AddedOrganizationID()
  12466. }
  12467. return nil, false
  12468. }
  12469. // AddField adds the value to the field with the given name. It returns an error if
  12470. // the field is not defined in the schema, or if the type mismatched the field
  12471. // type.
  12472. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12473. switch name {
  12474. case labelrelationship.FieldStatus:
  12475. v, ok := value.(int8)
  12476. if !ok {
  12477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12478. }
  12479. m.AddStatus(v)
  12480. return nil
  12481. case labelrelationship.FieldOrganizationID:
  12482. v, ok := value.(int64)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.AddOrganizationID(v)
  12487. return nil
  12488. }
  12489. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12490. }
  12491. // ClearedFields returns all nullable fields that were cleared during this
  12492. // mutation.
  12493. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12494. var fields []string
  12495. if m.FieldCleared(labelrelationship.FieldStatus) {
  12496. fields = append(fields, labelrelationship.FieldStatus)
  12497. }
  12498. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12499. fields = append(fields, labelrelationship.FieldDeletedAt)
  12500. }
  12501. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12502. fields = append(fields, labelrelationship.FieldOrganizationID)
  12503. }
  12504. return fields
  12505. }
  12506. // FieldCleared returns a boolean indicating if a field with the given name was
  12507. // cleared in this mutation.
  12508. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12509. _, ok := m.clearedFields[name]
  12510. return ok
  12511. }
  12512. // ClearField clears the value of the field with the given name. It returns an
  12513. // error if the field is not defined in the schema.
  12514. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12515. switch name {
  12516. case labelrelationship.FieldStatus:
  12517. m.ClearStatus()
  12518. return nil
  12519. case labelrelationship.FieldDeletedAt:
  12520. m.ClearDeletedAt()
  12521. return nil
  12522. case labelrelationship.FieldOrganizationID:
  12523. m.ClearOrganizationID()
  12524. return nil
  12525. }
  12526. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12527. }
  12528. // ResetField resets all changes in the mutation for the field with the given name.
  12529. // It returns an error if the field is not defined in the schema.
  12530. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12531. switch name {
  12532. case labelrelationship.FieldCreatedAt:
  12533. m.ResetCreatedAt()
  12534. return nil
  12535. case labelrelationship.FieldUpdatedAt:
  12536. m.ResetUpdatedAt()
  12537. return nil
  12538. case labelrelationship.FieldStatus:
  12539. m.ResetStatus()
  12540. return nil
  12541. case labelrelationship.FieldDeletedAt:
  12542. m.ResetDeletedAt()
  12543. return nil
  12544. case labelrelationship.FieldLabelID:
  12545. m.ResetLabelID()
  12546. return nil
  12547. case labelrelationship.FieldContactID:
  12548. m.ResetContactID()
  12549. return nil
  12550. case labelrelationship.FieldOrganizationID:
  12551. m.ResetOrganizationID()
  12552. return nil
  12553. }
  12554. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12555. }
  12556. // AddedEdges returns all edge names that were set/added in this mutation.
  12557. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12558. edges := make([]string, 0, 2)
  12559. if m.contacts != nil {
  12560. edges = append(edges, labelrelationship.EdgeContacts)
  12561. }
  12562. if m.labels != nil {
  12563. edges = append(edges, labelrelationship.EdgeLabels)
  12564. }
  12565. return edges
  12566. }
  12567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12568. // name in this mutation.
  12569. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12570. switch name {
  12571. case labelrelationship.EdgeContacts:
  12572. if id := m.contacts; id != nil {
  12573. return []ent.Value{*id}
  12574. }
  12575. case labelrelationship.EdgeLabels:
  12576. if id := m.labels; id != nil {
  12577. return []ent.Value{*id}
  12578. }
  12579. }
  12580. return nil
  12581. }
  12582. // RemovedEdges returns all edge names that were removed in this mutation.
  12583. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12584. edges := make([]string, 0, 2)
  12585. return edges
  12586. }
  12587. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12588. // the given name in this mutation.
  12589. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12590. return nil
  12591. }
  12592. // ClearedEdges returns all edge names that were cleared in this mutation.
  12593. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12594. edges := make([]string, 0, 2)
  12595. if m.clearedcontacts {
  12596. edges = append(edges, labelrelationship.EdgeContacts)
  12597. }
  12598. if m.clearedlabels {
  12599. edges = append(edges, labelrelationship.EdgeLabels)
  12600. }
  12601. return edges
  12602. }
  12603. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12604. // was cleared in this mutation.
  12605. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12606. switch name {
  12607. case labelrelationship.EdgeContacts:
  12608. return m.clearedcontacts
  12609. case labelrelationship.EdgeLabels:
  12610. return m.clearedlabels
  12611. }
  12612. return false
  12613. }
  12614. // ClearEdge clears the value of the edge with the given name. It returns an error
  12615. // if that edge is not defined in the schema.
  12616. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12617. switch name {
  12618. case labelrelationship.EdgeContacts:
  12619. m.ClearContacts()
  12620. return nil
  12621. case labelrelationship.EdgeLabels:
  12622. m.ClearLabels()
  12623. return nil
  12624. }
  12625. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12626. }
  12627. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12628. // It returns an error if the edge is not defined in the schema.
  12629. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12630. switch name {
  12631. case labelrelationship.EdgeContacts:
  12632. m.ResetContacts()
  12633. return nil
  12634. case labelrelationship.EdgeLabels:
  12635. m.ResetLabels()
  12636. return nil
  12637. }
  12638. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12639. }
  12640. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12641. type MessageMutation struct {
  12642. config
  12643. op Op
  12644. typ string
  12645. id *int
  12646. wx_wxid *string
  12647. wxid *string
  12648. content *string
  12649. clearedFields map[string]struct{}
  12650. done bool
  12651. oldValue func(context.Context) (*Message, error)
  12652. predicates []predicate.Message
  12653. }
  12654. var _ ent.Mutation = (*MessageMutation)(nil)
  12655. // messageOption allows management of the mutation configuration using functional options.
  12656. type messageOption func(*MessageMutation)
  12657. // newMessageMutation creates new mutation for the Message entity.
  12658. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12659. m := &MessageMutation{
  12660. config: c,
  12661. op: op,
  12662. typ: TypeMessage,
  12663. clearedFields: make(map[string]struct{}),
  12664. }
  12665. for _, opt := range opts {
  12666. opt(m)
  12667. }
  12668. return m
  12669. }
  12670. // withMessageID sets the ID field of the mutation.
  12671. func withMessageID(id int) messageOption {
  12672. return func(m *MessageMutation) {
  12673. var (
  12674. err error
  12675. once sync.Once
  12676. value *Message
  12677. )
  12678. m.oldValue = func(ctx context.Context) (*Message, error) {
  12679. once.Do(func() {
  12680. if m.done {
  12681. err = errors.New("querying old values post mutation is not allowed")
  12682. } else {
  12683. value, err = m.Client().Message.Get(ctx, id)
  12684. }
  12685. })
  12686. return value, err
  12687. }
  12688. m.id = &id
  12689. }
  12690. }
  12691. // withMessage sets the old Message of the mutation.
  12692. func withMessage(node *Message) messageOption {
  12693. return func(m *MessageMutation) {
  12694. m.oldValue = func(context.Context) (*Message, error) {
  12695. return node, nil
  12696. }
  12697. m.id = &node.ID
  12698. }
  12699. }
  12700. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12701. // executed in a transaction (ent.Tx), a transactional client is returned.
  12702. func (m MessageMutation) Client() *Client {
  12703. client := &Client{config: m.config}
  12704. client.init()
  12705. return client
  12706. }
  12707. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12708. // it returns an error otherwise.
  12709. func (m MessageMutation) Tx() (*Tx, error) {
  12710. if _, ok := m.driver.(*txDriver); !ok {
  12711. return nil, errors.New("ent: mutation is not running in a transaction")
  12712. }
  12713. tx := &Tx{config: m.config}
  12714. tx.init()
  12715. return tx, nil
  12716. }
  12717. // ID returns the ID value in the mutation. Note that the ID is only available
  12718. // if it was provided to the builder or after it was returned from the database.
  12719. func (m *MessageMutation) ID() (id int, exists bool) {
  12720. if m.id == nil {
  12721. return
  12722. }
  12723. return *m.id, true
  12724. }
  12725. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12726. // That means, if the mutation is applied within a transaction with an isolation level such
  12727. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12728. // or updated by the mutation.
  12729. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12730. switch {
  12731. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12732. id, exists := m.ID()
  12733. if exists {
  12734. return []int{id}, nil
  12735. }
  12736. fallthrough
  12737. case m.op.Is(OpUpdate | OpDelete):
  12738. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12739. default:
  12740. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12741. }
  12742. }
  12743. // SetWxWxid sets the "wx_wxid" field.
  12744. func (m *MessageMutation) SetWxWxid(s string) {
  12745. m.wx_wxid = &s
  12746. }
  12747. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12748. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12749. v := m.wx_wxid
  12750. if v == nil {
  12751. return
  12752. }
  12753. return *v, true
  12754. }
  12755. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12756. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12758. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12759. if !m.op.Is(OpUpdateOne) {
  12760. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12761. }
  12762. if m.id == nil || m.oldValue == nil {
  12763. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12764. }
  12765. oldValue, err := m.oldValue(ctx)
  12766. if err != nil {
  12767. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12768. }
  12769. return oldValue.WxWxid, nil
  12770. }
  12771. // ClearWxWxid clears the value of the "wx_wxid" field.
  12772. func (m *MessageMutation) ClearWxWxid() {
  12773. m.wx_wxid = nil
  12774. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12775. }
  12776. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12777. func (m *MessageMutation) WxWxidCleared() bool {
  12778. _, ok := m.clearedFields[message.FieldWxWxid]
  12779. return ok
  12780. }
  12781. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12782. func (m *MessageMutation) ResetWxWxid() {
  12783. m.wx_wxid = nil
  12784. delete(m.clearedFields, message.FieldWxWxid)
  12785. }
  12786. // SetWxid sets the "wxid" field.
  12787. func (m *MessageMutation) SetWxid(s string) {
  12788. m.wxid = &s
  12789. }
  12790. // Wxid returns the value of the "wxid" field in the mutation.
  12791. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12792. v := m.wxid
  12793. if v == nil {
  12794. return
  12795. }
  12796. return *v, true
  12797. }
  12798. // OldWxid returns the old "wxid" field's value of the Message entity.
  12799. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12801. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12802. if !m.op.Is(OpUpdateOne) {
  12803. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12804. }
  12805. if m.id == nil || m.oldValue == nil {
  12806. return v, errors.New("OldWxid requires an ID field in the mutation")
  12807. }
  12808. oldValue, err := m.oldValue(ctx)
  12809. if err != nil {
  12810. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12811. }
  12812. return oldValue.Wxid, nil
  12813. }
  12814. // ResetWxid resets all changes to the "wxid" field.
  12815. func (m *MessageMutation) ResetWxid() {
  12816. m.wxid = nil
  12817. }
  12818. // SetContent sets the "content" field.
  12819. func (m *MessageMutation) SetContent(s string) {
  12820. m.content = &s
  12821. }
  12822. // Content returns the value of the "content" field in the mutation.
  12823. func (m *MessageMutation) Content() (r string, exists bool) {
  12824. v := m.content
  12825. if v == nil {
  12826. return
  12827. }
  12828. return *v, true
  12829. }
  12830. // OldContent returns the old "content" field's value of the Message entity.
  12831. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12833. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12834. if !m.op.Is(OpUpdateOne) {
  12835. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12836. }
  12837. if m.id == nil || m.oldValue == nil {
  12838. return v, errors.New("OldContent requires an ID field in the mutation")
  12839. }
  12840. oldValue, err := m.oldValue(ctx)
  12841. if err != nil {
  12842. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12843. }
  12844. return oldValue.Content, nil
  12845. }
  12846. // ResetContent resets all changes to the "content" field.
  12847. func (m *MessageMutation) ResetContent() {
  12848. m.content = nil
  12849. }
  12850. // Where appends a list predicates to the MessageMutation builder.
  12851. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12852. m.predicates = append(m.predicates, ps...)
  12853. }
  12854. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12855. // users can use type-assertion to append predicates that do not depend on any generated package.
  12856. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12857. p := make([]predicate.Message, len(ps))
  12858. for i := range ps {
  12859. p[i] = ps[i]
  12860. }
  12861. m.Where(p...)
  12862. }
  12863. // Op returns the operation name.
  12864. func (m *MessageMutation) Op() Op {
  12865. return m.op
  12866. }
  12867. // SetOp allows setting the mutation operation.
  12868. func (m *MessageMutation) SetOp(op Op) {
  12869. m.op = op
  12870. }
  12871. // Type returns the node type of this mutation (Message).
  12872. func (m *MessageMutation) Type() string {
  12873. return m.typ
  12874. }
  12875. // Fields returns all fields that were changed during this mutation. Note that in
  12876. // order to get all numeric fields that were incremented/decremented, call
  12877. // AddedFields().
  12878. func (m *MessageMutation) Fields() []string {
  12879. fields := make([]string, 0, 3)
  12880. if m.wx_wxid != nil {
  12881. fields = append(fields, message.FieldWxWxid)
  12882. }
  12883. if m.wxid != nil {
  12884. fields = append(fields, message.FieldWxid)
  12885. }
  12886. if m.content != nil {
  12887. fields = append(fields, message.FieldContent)
  12888. }
  12889. return fields
  12890. }
  12891. // Field returns the value of a field with the given name. The second boolean
  12892. // return value indicates that this field was not set, or was not defined in the
  12893. // schema.
  12894. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  12895. switch name {
  12896. case message.FieldWxWxid:
  12897. return m.WxWxid()
  12898. case message.FieldWxid:
  12899. return m.Wxid()
  12900. case message.FieldContent:
  12901. return m.Content()
  12902. }
  12903. return nil, false
  12904. }
  12905. // OldField returns the old value of the field from the database. An error is
  12906. // returned if the mutation operation is not UpdateOne, or the query to the
  12907. // database failed.
  12908. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12909. switch name {
  12910. case message.FieldWxWxid:
  12911. return m.OldWxWxid(ctx)
  12912. case message.FieldWxid:
  12913. return m.OldWxid(ctx)
  12914. case message.FieldContent:
  12915. return m.OldContent(ctx)
  12916. }
  12917. return nil, fmt.Errorf("unknown Message field %s", name)
  12918. }
  12919. // SetField sets the value of a field with the given name. It returns an error if
  12920. // the field is not defined in the schema, or if the type mismatched the field
  12921. // type.
  12922. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  12923. switch name {
  12924. case message.FieldWxWxid:
  12925. v, ok := value.(string)
  12926. if !ok {
  12927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12928. }
  12929. m.SetWxWxid(v)
  12930. return nil
  12931. case message.FieldWxid:
  12932. v, ok := value.(string)
  12933. if !ok {
  12934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12935. }
  12936. m.SetWxid(v)
  12937. return nil
  12938. case message.FieldContent:
  12939. v, ok := value.(string)
  12940. if !ok {
  12941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12942. }
  12943. m.SetContent(v)
  12944. return nil
  12945. }
  12946. return fmt.Errorf("unknown Message field %s", name)
  12947. }
  12948. // AddedFields returns all numeric fields that were incremented/decremented during
  12949. // this mutation.
  12950. func (m *MessageMutation) AddedFields() []string {
  12951. return nil
  12952. }
  12953. // AddedField returns the numeric value that was incremented/decremented on a field
  12954. // with the given name. The second boolean return value indicates that this field
  12955. // was not set, or was not defined in the schema.
  12956. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  12957. return nil, false
  12958. }
  12959. // AddField adds the value to the field with the given name. It returns an error if
  12960. // the field is not defined in the schema, or if the type mismatched the field
  12961. // type.
  12962. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  12963. switch name {
  12964. }
  12965. return fmt.Errorf("unknown Message numeric field %s", name)
  12966. }
  12967. // ClearedFields returns all nullable fields that were cleared during this
  12968. // mutation.
  12969. func (m *MessageMutation) ClearedFields() []string {
  12970. var fields []string
  12971. if m.FieldCleared(message.FieldWxWxid) {
  12972. fields = append(fields, message.FieldWxWxid)
  12973. }
  12974. return fields
  12975. }
  12976. // FieldCleared returns a boolean indicating if a field with the given name was
  12977. // cleared in this mutation.
  12978. func (m *MessageMutation) FieldCleared(name string) bool {
  12979. _, ok := m.clearedFields[name]
  12980. return ok
  12981. }
  12982. // ClearField clears the value of the field with the given name. It returns an
  12983. // error if the field is not defined in the schema.
  12984. func (m *MessageMutation) ClearField(name string) error {
  12985. switch name {
  12986. case message.FieldWxWxid:
  12987. m.ClearWxWxid()
  12988. return nil
  12989. }
  12990. return fmt.Errorf("unknown Message nullable field %s", name)
  12991. }
  12992. // ResetField resets all changes in the mutation for the field with the given name.
  12993. // It returns an error if the field is not defined in the schema.
  12994. func (m *MessageMutation) ResetField(name string) error {
  12995. switch name {
  12996. case message.FieldWxWxid:
  12997. m.ResetWxWxid()
  12998. return nil
  12999. case message.FieldWxid:
  13000. m.ResetWxid()
  13001. return nil
  13002. case message.FieldContent:
  13003. m.ResetContent()
  13004. return nil
  13005. }
  13006. return fmt.Errorf("unknown Message field %s", name)
  13007. }
  13008. // AddedEdges returns all edge names that were set/added in this mutation.
  13009. func (m *MessageMutation) AddedEdges() []string {
  13010. edges := make([]string, 0, 0)
  13011. return edges
  13012. }
  13013. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13014. // name in this mutation.
  13015. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13016. return nil
  13017. }
  13018. // RemovedEdges returns all edge names that were removed in this mutation.
  13019. func (m *MessageMutation) RemovedEdges() []string {
  13020. edges := make([]string, 0, 0)
  13021. return edges
  13022. }
  13023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13024. // the given name in this mutation.
  13025. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13026. return nil
  13027. }
  13028. // ClearedEdges returns all edge names that were cleared in this mutation.
  13029. func (m *MessageMutation) ClearedEdges() []string {
  13030. edges := make([]string, 0, 0)
  13031. return edges
  13032. }
  13033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13034. // was cleared in this mutation.
  13035. func (m *MessageMutation) EdgeCleared(name string) bool {
  13036. return false
  13037. }
  13038. // ClearEdge clears the value of the edge with the given name. It returns an error
  13039. // if that edge is not defined in the schema.
  13040. func (m *MessageMutation) ClearEdge(name string) error {
  13041. return fmt.Errorf("unknown Message unique edge %s", name)
  13042. }
  13043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13044. // It returns an error if the edge is not defined in the schema.
  13045. func (m *MessageMutation) ResetEdge(name string) error {
  13046. return fmt.Errorf("unknown Message edge %s", name)
  13047. }
  13048. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13049. type MessageRecordsMutation struct {
  13050. config
  13051. op Op
  13052. typ string
  13053. id *uint64
  13054. created_at *time.Time
  13055. updated_at *time.Time
  13056. status *uint8
  13057. addstatus *int8
  13058. bot_wxid *string
  13059. contact_type *int
  13060. addcontact_type *int
  13061. contact_wxid *string
  13062. content_type *int
  13063. addcontent_type *int
  13064. content *string
  13065. meta *custom_types.Meta
  13066. error_detail *string
  13067. send_time *time.Time
  13068. source_type *int
  13069. addsource_type *int
  13070. organization_id *uint64
  13071. addorganization_id *int64
  13072. clearedFields map[string]struct{}
  13073. sop_stage *uint64
  13074. clearedsop_stage bool
  13075. sop_node *uint64
  13076. clearedsop_node bool
  13077. message_contact *uint64
  13078. clearedmessage_contact bool
  13079. done bool
  13080. oldValue func(context.Context) (*MessageRecords, error)
  13081. predicates []predicate.MessageRecords
  13082. }
  13083. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13084. // messagerecordsOption allows management of the mutation configuration using functional options.
  13085. type messagerecordsOption func(*MessageRecordsMutation)
  13086. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13087. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13088. m := &MessageRecordsMutation{
  13089. config: c,
  13090. op: op,
  13091. typ: TypeMessageRecords,
  13092. clearedFields: make(map[string]struct{}),
  13093. }
  13094. for _, opt := range opts {
  13095. opt(m)
  13096. }
  13097. return m
  13098. }
  13099. // withMessageRecordsID sets the ID field of the mutation.
  13100. func withMessageRecordsID(id uint64) messagerecordsOption {
  13101. return func(m *MessageRecordsMutation) {
  13102. var (
  13103. err error
  13104. once sync.Once
  13105. value *MessageRecords
  13106. )
  13107. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13108. once.Do(func() {
  13109. if m.done {
  13110. err = errors.New("querying old values post mutation is not allowed")
  13111. } else {
  13112. value, err = m.Client().MessageRecords.Get(ctx, id)
  13113. }
  13114. })
  13115. return value, err
  13116. }
  13117. m.id = &id
  13118. }
  13119. }
  13120. // withMessageRecords sets the old MessageRecords of the mutation.
  13121. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13122. return func(m *MessageRecordsMutation) {
  13123. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13124. return node, nil
  13125. }
  13126. m.id = &node.ID
  13127. }
  13128. }
  13129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13130. // executed in a transaction (ent.Tx), a transactional client is returned.
  13131. func (m MessageRecordsMutation) Client() *Client {
  13132. client := &Client{config: m.config}
  13133. client.init()
  13134. return client
  13135. }
  13136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13137. // it returns an error otherwise.
  13138. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13139. if _, ok := m.driver.(*txDriver); !ok {
  13140. return nil, errors.New("ent: mutation is not running in a transaction")
  13141. }
  13142. tx := &Tx{config: m.config}
  13143. tx.init()
  13144. return tx, nil
  13145. }
  13146. // SetID sets the value of the id field. Note that this
  13147. // operation is only accepted on creation of MessageRecords entities.
  13148. func (m *MessageRecordsMutation) SetID(id uint64) {
  13149. m.id = &id
  13150. }
  13151. // ID returns the ID value in the mutation. Note that the ID is only available
  13152. // if it was provided to the builder or after it was returned from the database.
  13153. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13154. if m.id == nil {
  13155. return
  13156. }
  13157. return *m.id, true
  13158. }
  13159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13160. // That means, if the mutation is applied within a transaction with an isolation level such
  13161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13162. // or updated by the mutation.
  13163. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13164. switch {
  13165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13166. id, exists := m.ID()
  13167. if exists {
  13168. return []uint64{id}, nil
  13169. }
  13170. fallthrough
  13171. case m.op.Is(OpUpdate | OpDelete):
  13172. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13173. default:
  13174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13175. }
  13176. }
  13177. // SetCreatedAt sets the "created_at" field.
  13178. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13179. m.created_at = &t
  13180. }
  13181. // CreatedAt returns the value of the "created_at" field in the mutation.
  13182. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13183. v := m.created_at
  13184. if v == nil {
  13185. return
  13186. }
  13187. return *v, true
  13188. }
  13189. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13190. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13192. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13193. if !m.op.Is(OpUpdateOne) {
  13194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13195. }
  13196. if m.id == nil || m.oldValue == nil {
  13197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13198. }
  13199. oldValue, err := m.oldValue(ctx)
  13200. if err != nil {
  13201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13202. }
  13203. return oldValue.CreatedAt, nil
  13204. }
  13205. // ResetCreatedAt resets all changes to the "created_at" field.
  13206. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13207. m.created_at = nil
  13208. }
  13209. // SetUpdatedAt sets the "updated_at" field.
  13210. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13211. m.updated_at = &t
  13212. }
  13213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13214. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13215. v := m.updated_at
  13216. if v == nil {
  13217. return
  13218. }
  13219. return *v, true
  13220. }
  13221. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13222. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13224. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13225. if !m.op.Is(OpUpdateOne) {
  13226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13227. }
  13228. if m.id == nil || m.oldValue == nil {
  13229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13230. }
  13231. oldValue, err := m.oldValue(ctx)
  13232. if err != nil {
  13233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13234. }
  13235. return oldValue.UpdatedAt, nil
  13236. }
  13237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13238. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13239. m.updated_at = nil
  13240. }
  13241. // SetStatus sets the "status" field.
  13242. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13243. m.status = &u
  13244. m.addstatus = nil
  13245. }
  13246. // Status returns the value of the "status" field in the mutation.
  13247. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13248. v := m.status
  13249. if v == nil {
  13250. return
  13251. }
  13252. return *v, true
  13253. }
  13254. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13257. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13258. if !m.op.Is(OpUpdateOne) {
  13259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13260. }
  13261. if m.id == nil || m.oldValue == nil {
  13262. return v, errors.New("OldStatus requires an ID field in the mutation")
  13263. }
  13264. oldValue, err := m.oldValue(ctx)
  13265. if err != nil {
  13266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13267. }
  13268. return oldValue.Status, nil
  13269. }
  13270. // AddStatus adds u to the "status" field.
  13271. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13272. if m.addstatus != nil {
  13273. *m.addstatus += u
  13274. } else {
  13275. m.addstatus = &u
  13276. }
  13277. }
  13278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13279. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13280. v := m.addstatus
  13281. if v == nil {
  13282. return
  13283. }
  13284. return *v, true
  13285. }
  13286. // ClearStatus clears the value of the "status" field.
  13287. func (m *MessageRecordsMutation) ClearStatus() {
  13288. m.status = nil
  13289. m.addstatus = nil
  13290. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13291. }
  13292. // StatusCleared returns if the "status" field was cleared in this mutation.
  13293. func (m *MessageRecordsMutation) StatusCleared() bool {
  13294. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13295. return ok
  13296. }
  13297. // ResetStatus resets all changes to the "status" field.
  13298. func (m *MessageRecordsMutation) ResetStatus() {
  13299. m.status = nil
  13300. m.addstatus = nil
  13301. delete(m.clearedFields, messagerecords.FieldStatus)
  13302. }
  13303. // SetBotWxid sets the "bot_wxid" field.
  13304. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13305. m.bot_wxid = &s
  13306. }
  13307. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13308. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13309. v := m.bot_wxid
  13310. if v == nil {
  13311. return
  13312. }
  13313. return *v, true
  13314. }
  13315. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13316. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13318. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13319. if !m.op.Is(OpUpdateOne) {
  13320. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13321. }
  13322. if m.id == nil || m.oldValue == nil {
  13323. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13324. }
  13325. oldValue, err := m.oldValue(ctx)
  13326. if err != nil {
  13327. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13328. }
  13329. return oldValue.BotWxid, nil
  13330. }
  13331. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13332. func (m *MessageRecordsMutation) ResetBotWxid() {
  13333. m.bot_wxid = nil
  13334. }
  13335. // SetContactID sets the "contact_id" field.
  13336. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13337. m.message_contact = &u
  13338. }
  13339. // ContactID returns the value of the "contact_id" field in the mutation.
  13340. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13341. v := m.message_contact
  13342. if v == nil {
  13343. return
  13344. }
  13345. return *v, true
  13346. }
  13347. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13348. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13350. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13351. if !m.op.Is(OpUpdateOne) {
  13352. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13353. }
  13354. if m.id == nil || m.oldValue == nil {
  13355. return v, errors.New("OldContactID requires an ID field in the mutation")
  13356. }
  13357. oldValue, err := m.oldValue(ctx)
  13358. if err != nil {
  13359. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13360. }
  13361. return oldValue.ContactID, nil
  13362. }
  13363. // ClearContactID clears the value of the "contact_id" field.
  13364. func (m *MessageRecordsMutation) ClearContactID() {
  13365. m.message_contact = nil
  13366. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13367. }
  13368. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13369. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13370. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13371. return ok
  13372. }
  13373. // ResetContactID resets all changes to the "contact_id" field.
  13374. func (m *MessageRecordsMutation) ResetContactID() {
  13375. m.message_contact = nil
  13376. delete(m.clearedFields, messagerecords.FieldContactID)
  13377. }
  13378. // SetContactType sets the "contact_type" field.
  13379. func (m *MessageRecordsMutation) SetContactType(i int) {
  13380. m.contact_type = &i
  13381. m.addcontact_type = nil
  13382. }
  13383. // ContactType returns the value of the "contact_type" field in the mutation.
  13384. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13385. v := m.contact_type
  13386. if v == nil {
  13387. return
  13388. }
  13389. return *v, true
  13390. }
  13391. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13392. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13394. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13395. if !m.op.Is(OpUpdateOne) {
  13396. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13397. }
  13398. if m.id == nil || m.oldValue == nil {
  13399. return v, errors.New("OldContactType requires an ID field in the mutation")
  13400. }
  13401. oldValue, err := m.oldValue(ctx)
  13402. if err != nil {
  13403. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13404. }
  13405. return oldValue.ContactType, nil
  13406. }
  13407. // AddContactType adds i to the "contact_type" field.
  13408. func (m *MessageRecordsMutation) AddContactType(i int) {
  13409. if m.addcontact_type != nil {
  13410. *m.addcontact_type += i
  13411. } else {
  13412. m.addcontact_type = &i
  13413. }
  13414. }
  13415. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13416. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13417. v := m.addcontact_type
  13418. if v == nil {
  13419. return
  13420. }
  13421. return *v, true
  13422. }
  13423. // ResetContactType resets all changes to the "contact_type" field.
  13424. func (m *MessageRecordsMutation) ResetContactType() {
  13425. m.contact_type = nil
  13426. m.addcontact_type = nil
  13427. }
  13428. // SetContactWxid sets the "contact_wxid" field.
  13429. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13430. m.contact_wxid = &s
  13431. }
  13432. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13433. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13434. v := m.contact_wxid
  13435. if v == nil {
  13436. return
  13437. }
  13438. return *v, true
  13439. }
  13440. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13441. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13443. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13444. if !m.op.Is(OpUpdateOne) {
  13445. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13446. }
  13447. if m.id == nil || m.oldValue == nil {
  13448. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13449. }
  13450. oldValue, err := m.oldValue(ctx)
  13451. if err != nil {
  13452. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13453. }
  13454. return oldValue.ContactWxid, nil
  13455. }
  13456. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13457. func (m *MessageRecordsMutation) ResetContactWxid() {
  13458. m.contact_wxid = nil
  13459. }
  13460. // SetContentType sets the "content_type" field.
  13461. func (m *MessageRecordsMutation) SetContentType(i int) {
  13462. m.content_type = &i
  13463. m.addcontent_type = nil
  13464. }
  13465. // ContentType returns the value of the "content_type" field in the mutation.
  13466. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13467. v := m.content_type
  13468. if v == nil {
  13469. return
  13470. }
  13471. return *v, true
  13472. }
  13473. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13474. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13476. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13477. if !m.op.Is(OpUpdateOne) {
  13478. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13479. }
  13480. if m.id == nil || m.oldValue == nil {
  13481. return v, errors.New("OldContentType requires an ID field in the mutation")
  13482. }
  13483. oldValue, err := m.oldValue(ctx)
  13484. if err != nil {
  13485. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13486. }
  13487. return oldValue.ContentType, nil
  13488. }
  13489. // AddContentType adds i to the "content_type" field.
  13490. func (m *MessageRecordsMutation) AddContentType(i int) {
  13491. if m.addcontent_type != nil {
  13492. *m.addcontent_type += i
  13493. } else {
  13494. m.addcontent_type = &i
  13495. }
  13496. }
  13497. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13498. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13499. v := m.addcontent_type
  13500. if v == nil {
  13501. return
  13502. }
  13503. return *v, true
  13504. }
  13505. // ResetContentType resets all changes to the "content_type" field.
  13506. func (m *MessageRecordsMutation) ResetContentType() {
  13507. m.content_type = nil
  13508. m.addcontent_type = nil
  13509. }
  13510. // SetContent sets the "content" field.
  13511. func (m *MessageRecordsMutation) SetContent(s string) {
  13512. m.content = &s
  13513. }
  13514. // Content returns the value of the "content" field in the mutation.
  13515. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13516. v := m.content
  13517. if v == nil {
  13518. return
  13519. }
  13520. return *v, true
  13521. }
  13522. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13523. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13525. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13526. if !m.op.Is(OpUpdateOne) {
  13527. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13528. }
  13529. if m.id == nil || m.oldValue == nil {
  13530. return v, errors.New("OldContent requires an ID field in the mutation")
  13531. }
  13532. oldValue, err := m.oldValue(ctx)
  13533. if err != nil {
  13534. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13535. }
  13536. return oldValue.Content, nil
  13537. }
  13538. // ResetContent resets all changes to the "content" field.
  13539. func (m *MessageRecordsMutation) ResetContent() {
  13540. m.content = nil
  13541. }
  13542. // SetMeta sets the "meta" field.
  13543. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13544. m.meta = &ct
  13545. }
  13546. // Meta returns the value of the "meta" field in the mutation.
  13547. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13548. v := m.meta
  13549. if v == nil {
  13550. return
  13551. }
  13552. return *v, true
  13553. }
  13554. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13555. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13557. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13558. if !m.op.Is(OpUpdateOne) {
  13559. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13560. }
  13561. if m.id == nil || m.oldValue == nil {
  13562. return v, errors.New("OldMeta requires an ID field in the mutation")
  13563. }
  13564. oldValue, err := m.oldValue(ctx)
  13565. if err != nil {
  13566. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13567. }
  13568. return oldValue.Meta, nil
  13569. }
  13570. // ClearMeta clears the value of the "meta" field.
  13571. func (m *MessageRecordsMutation) ClearMeta() {
  13572. m.meta = nil
  13573. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13574. }
  13575. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13576. func (m *MessageRecordsMutation) MetaCleared() bool {
  13577. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13578. return ok
  13579. }
  13580. // ResetMeta resets all changes to the "meta" field.
  13581. func (m *MessageRecordsMutation) ResetMeta() {
  13582. m.meta = nil
  13583. delete(m.clearedFields, messagerecords.FieldMeta)
  13584. }
  13585. // SetErrorDetail sets the "error_detail" field.
  13586. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13587. m.error_detail = &s
  13588. }
  13589. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13590. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13591. v := m.error_detail
  13592. if v == nil {
  13593. return
  13594. }
  13595. return *v, true
  13596. }
  13597. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13598. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13600. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13601. if !m.op.Is(OpUpdateOne) {
  13602. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13603. }
  13604. if m.id == nil || m.oldValue == nil {
  13605. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13606. }
  13607. oldValue, err := m.oldValue(ctx)
  13608. if err != nil {
  13609. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13610. }
  13611. return oldValue.ErrorDetail, nil
  13612. }
  13613. // ResetErrorDetail resets all changes to the "error_detail" field.
  13614. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13615. m.error_detail = nil
  13616. }
  13617. // SetSendTime sets the "send_time" field.
  13618. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13619. m.send_time = &t
  13620. }
  13621. // SendTime returns the value of the "send_time" field in the mutation.
  13622. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13623. v := m.send_time
  13624. if v == nil {
  13625. return
  13626. }
  13627. return *v, true
  13628. }
  13629. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13630. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13632. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13633. if !m.op.Is(OpUpdateOne) {
  13634. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13635. }
  13636. if m.id == nil || m.oldValue == nil {
  13637. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13638. }
  13639. oldValue, err := m.oldValue(ctx)
  13640. if err != nil {
  13641. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13642. }
  13643. return oldValue.SendTime, nil
  13644. }
  13645. // ClearSendTime clears the value of the "send_time" field.
  13646. func (m *MessageRecordsMutation) ClearSendTime() {
  13647. m.send_time = nil
  13648. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13649. }
  13650. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13651. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13652. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13653. return ok
  13654. }
  13655. // ResetSendTime resets all changes to the "send_time" field.
  13656. func (m *MessageRecordsMutation) ResetSendTime() {
  13657. m.send_time = nil
  13658. delete(m.clearedFields, messagerecords.FieldSendTime)
  13659. }
  13660. // SetSourceType sets the "source_type" field.
  13661. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13662. m.source_type = &i
  13663. m.addsource_type = nil
  13664. }
  13665. // SourceType returns the value of the "source_type" field in the mutation.
  13666. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13667. v := m.source_type
  13668. if v == nil {
  13669. return
  13670. }
  13671. return *v, true
  13672. }
  13673. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13674. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13676. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13677. if !m.op.Is(OpUpdateOne) {
  13678. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13679. }
  13680. if m.id == nil || m.oldValue == nil {
  13681. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13682. }
  13683. oldValue, err := m.oldValue(ctx)
  13684. if err != nil {
  13685. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13686. }
  13687. return oldValue.SourceType, nil
  13688. }
  13689. // AddSourceType adds i to the "source_type" field.
  13690. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13691. if m.addsource_type != nil {
  13692. *m.addsource_type += i
  13693. } else {
  13694. m.addsource_type = &i
  13695. }
  13696. }
  13697. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13698. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13699. v := m.addsource_type
  13700. if v == nil {
  13701. return
  13702. }
  13703. return *v, true
  13704. }
  13705. // ResetSourceType resets all changes to the "source_type" field.
  13706. func (m *MessageRecordsMutation) ResetSourceType() {
  13707. m.source_type = nil
  13708. m.addsource_type = nil
  13709. }
  13710. // SetSourceID sets the "source_id" field.
  13711. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13712. m.sop_stage = &u
  13713. }
  13714. // SourceID returns the value of the "source_id" field in the mutation.
  13715. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13716. v := m.sop_stage
  13717. if v == nil {
  13718. return
  13719. }
  13720. return *v, true
  13721. }
  13722. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13723. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13725. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13726. if !m.op.Is(OpUpdateOne) {
  13727. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13728. }
  13729. if m.id == nil || m.oldValue == nil {
  13730. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13731. }
  13732. oldValue, err := m.oldValue(ctx)
  13733. if err != nil {
  13734. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13735. }
  13736. return oldValue.SourceID, nil
  13737. }
  13738. // ClearSourceID clears the value of the "source_id" field.
  13739. func (m *MessageRecordsMutation) ClearSourceID() {
  13740. m.sop_stage = nil
  13741. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13742. }
  13743. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13744. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13745. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13746. return ok
  13747. }
  13748. // ResetSourceID resets all changes to the "source_id" field.
  13749. func (m *MessageRecordsMutation) ResetSourceID() {
  13750. m.sop_stage = nil
  13751. delete(m.clearedFields, messagerecords.FieldSourceID)
  13752. }
  13753. // SetSubSourceID sets the "sub_source_id" field.
  13754. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13755. m.sop_node = &u
  13756. }
  13757. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13758. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13759. v := m.sop_node
  13760. if v == nil {
  13761. return
  13762. }
  13763. return *v, true
  13764. }
  13765. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13766. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13768. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13769. if !m.op.Is(OpUpdateOne) {
  13770. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13771. }
  13772. if m.id == nil || m.oldValue == nil {
  13773. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13774. }
  13775. oldValue, err := m.oldValue(ctx)
  13776. if err != nil {
  13777. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13778. }
  13779. return oldValue.SubSourceID, nil
  13780. }
  13781. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13782. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13783. m.sop_node = nil
  13784. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13785. }
  13786. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13787. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13788. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13789. return ok
  13790. }
  13791. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13792. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13793. m.sop_node = nil
  13794. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13795. }
  13796. // SetOrganizationID sets the "organization_id" field.
  13797. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13798. m.organization_id = &u
  13799. m.addorganization_id = nil
  13800. }
  13801. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13802. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13803. v := m.organization_id
  13804. if v == nil {
  13805. return
  13806. }
  13807. return *v, true
  13808. }
  13809. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13810. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13812. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13813. if !m.op.Is(OpUpdateOne) {
  13814. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13815. }
  13816. if m.id == nil || m.oldValue == nil {
  13817. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13818. }
  13819. oldValue, err := m.oldValue(ctx)
  13820. if err != nil {
  13821. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13822. }
  13823. return oldValue.OrganizationID, nil
  13824. }
  13825. // AddOrganizationID adds u to the "organization_id" field.
  13826. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13827. if m.addorganization_id != nil {
  13828. *m.addorganization_id += u
  13829. } else {
  13830. m.addorganization_id = &u
  13831. }
  13832. }
  13833. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13834. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13835. v := m.addorganization_id
  13836. if v == nil {
  13837. return
  13838. }
  13839. return *v, true
  13840. }
  13841. // ClearOrganizationID clears the value of the "organization_id" field.
  13842. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13843. m.organization_id = nil
  13844. m.addorganization_id = nil
  13845. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13846. }
  13847. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13848. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13849. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13850. return ok
  13851. }
  13852. // ResetOrganizationID resets all changes to the "organization_id" field.
  13853. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13854. m.organization_id = nil
  13855. m.addorganization_id = nil
  13856. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13857. }
  13858. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13859. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13860. m.sop_stage = &id
  13861. }
  13862. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13863. func (m *MessageRecordsMutation) ClearSopStage() {
  13864. m.clearedsop_stage = true
  13865. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13866. }
  13867. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  13868. func (m *MessageRecordsMutation) SopStageCleared() bool {
  13869. return m.SourceIDCleared() || m.clearedsop_stage
  13870. }
  13871. // SopStageID returns the "sop_stage" edge ID in the mutation.
  13872. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  13873. if m.sop_stage != nil {
  13874. return *m.sop_stage, true
  13875. }
  13876. return
  13877. }
  13878. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  13879. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13880. // SopStageID instead. It exists only for internal usage by the builders.
  13881. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  13882. if id := m.sop_stage; id != nil {
  13883. ids = append(ids, *id)
  13884. }
  13885. return
  13886. }
  13887. // ResetSopStage resets all changes to the "sop_stage" edge.
  13888. func (m *MessageRecordsMutation) ResetSopStage() {
  13889. m.sop_stage = nil
  13890. m.clearedsop_stage = false
  13891. }
  13892. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  13893. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  13894. m.sop_node = &id
  13895. }
  13896. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  13897. func (m *MessageRecordsMutation) ClearSopNode() {
  13898. m.clearedsop_node = true
  13899. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13900. }
  13901. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  13902. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  13903. return m.SubSourceIDCleared() || m.clearedsop_node
  13904. }
  13905. // SopNodeID returns the "sop_node" edge ID in the mutation.
  13906. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  13907. if m.sop_node != nil {
  13908. return *m.sop_node, true
  13909. }
  13910. return
  13911. }
  13912. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  13913. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13914. // SopNodeID instead. It exists only for internal usage by the builders.
  13915. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  13916. if id := m.sop_node; id != nil {
  13917. ids = append(ids, *id)
  13918. }
  13919. return
  13920. }
  13921. // ResetSopNode resets all changes to the "sop_node" edge.
  13922. func (m *MessageRecordsMutation) ResetSopNode() {
  13923. m.sop_node = nil
  13924. m.clearedsop_node = false
  13925. }
  13926. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  13927. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  13928. m.message_contact = &id
  13929. }
  13930. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  13931. func (m *MessageRecordsMutation) ClearMessageContact() {
  13932. m.clearedmessage_contact = true
  13933. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13934. }
  13935. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  13936. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  13937. return m.ContactIDCleared() || m.clearedmessage_contact
  13938. }
  13939. // MessageContactID returns the "message_contact" edge ID in the mutation.
  13940. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  13941. if m.message_contact != nil {
  13942. return *m.message_contact, true
  13943. }
  13944. return
  13945. }
  13946. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  13947. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13948. // MessageContactID instead. It exists only for internal usage by the builders.
  13949. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  13950. if id := m.message_contact; id != nil {
  13951. ids = append(ids, *id)
  13952. }
  13953. return
  13954. }
  13955. // ResetMessageContact resets all changes to the "message_contact" edge.
  13956. func (m *MessageRecordsMutation) ResetMessageContact() {
  13957. m.message_contact = nil
  13958. m.clearedmessage_contact = false
  13959. }
  13960. // Where appends a list predicates to the MessageRecordsMutation builder.
  13961. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  13962. m.predicates = append(m.predicates, ps...)
  13963. }
  13964. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  13965. // users can use type-assertion to append predicates that do not depend on any generated package.
  13966. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  13967. p := make([]predicate.MessageRecords, len(ps))
  13968. for i := range ps {
  13969. p[i] = ps[i]
  13970. }
  13971. m.Where(p...)
  13972. }
  13973. // Op returns the operation name.
  13974. func (m *MessageRecordsMutation) Op() Op {
  13975. return m.op
  13976. }
  13977. // SetOp allows setting the mutation operation.
  13978. func (m *MessageRecordsMutation) SetOp(op Op) {
  13979. m.op = op
  13980. }
  13981. // Type returns the node type of this mutation (MessageRecords).
  13982. func (m *MessageRecordsMutation) Type() string {
  13983. return m.typ
  13984. }
  13985. // Fields returns all fields that were changed during this mutation. Note that in
  13986. // order to get all numeric fields that were incremented/decremented, call
  13987. // AddedFields().
  13988. func (m *MessageRecordsMutation) Fields() []string {
  13989. fields := make([]string, 0, 16)
  13990. if m.created_at != nil {
  13991. fields = append(fields, messagerecords.FieldCreatedAt)
  13992. }
  13993. if m.updated_at != nil {
  13994. fields = append(fields, messagerecords.FieldUpdatedAt)
  13995. }
  13996. if m.status != nil {
  13997. fields = append(fields, messagerecords.FieldStatus)
  13998. }
  13999. if m.bot_wxid != nil {
  14000. fields = append(fields, messagerecords.FieldBotWxid)
  14001. }
  14002. if m.message_contact != nil {
  14003. fields = append(fields, messagerecords.FieldContactID)
  14004. }
  14005. if m.contact_type != nil {
  14006. fields = append(fields, messagerecords.FieldContactType)
  14007. }
  14008. if m.contact_wxid != nil {
  14009. fields = append(fields, messagerecords.FieldContactWxid)
  14010. }
  14011. if m.content_type != nil {
  14012. fields = append(fields, messagerecords.FieldContentType)
  14013. }
  14014. if m.content != nil {
  14015. fields = append(fields, messagerecords.FieldContent)
  14016. }
  14017. if m.meta != nil {
  14018. fields = append(fields, messagerecords.FieldMeta)
  14019. }
  14020. if m.error_detail != nil {
  14021. fields = append(fields, messagerecords.FieldErrorDetail)
  14022. }
  14023. if m.send_time != nil {
  14024. fields = append(fields, messagerecords.FieldSendTime)
  14025. }
  14026. if m.source_type != nil {
  14027. fields = append(fields, messagerecords.FieldSourceType)
  14028. }
  14029. if m.sop_stage != nil {
  14030. fields = append(fields, messagerecords.FieldSourceID)
  14031. }
  14032. if m.sop_node != nil {
  14033. fields = append(fields, messagerecords.FieldSubSourceID)
  14034. }
  14035. if m.organization_id != nil {
  14036. fields = append(fields, messagerecords.FieldOrganizationID)
  14037. }
  14038. return fields
  14039. }
  14040. // Field returns the value of a field with the given name. The second boolean
  14041. // return value indicates that this field was not set, or was not defined in the
  14042. // schema.
  14043. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14044. switch name {
  14045. case messagerecords.FieldCreatedAt:
  14046. return m.CreatedAt()
  14047. case messagerecords.FieldUpdatedAt:
  14048. return m.UpdatedAt()
  14049. case messagerecords.FieldStatus:
  14050. return m.Status()
  14051. case messagerecords.FieldBotWxid:
  14052. return m.BotWxid()
  14053. case messagerecords.FieldContactID:
  14054. return m.ContactID()
  14055. case messagerecords.FieldContactType:
  14056. return m.ContactType()
  14057. case messagerecords.FieldContactWxid:
  14058. return m.ContactWxid()
  14059. case messagerecords.FieldContentType:
  14060. return m.ContentType()
  14061. case messagerecords.FieldContent:
  14062. return m.Content()
  14063. case messagerecords.FieldMeta:
  14064. return m.Meta()
  14065. case messagerecords.FieldErrorDetail:
  14066. return m.ErrorDetail()
  14067. case messagerecords.FieldSendTime:
  14068. return m.SendTime()
  14069. case messagerecords.FieldSourceType:
  14070. return m.SourceType()
  14071. case messagerecords.FieldSourceID:
  14072. return m.SourceID()
  14073. case messagerecords.FieldSubSourceID:
  14074. return m.SubSourceID()
  14075. case messagerecords.FieldOrganizationID:
  14076. return m.OrganizationID()
  14077. }
  14078. return nil, false
  14079. }
  14080. // OldField returns the old value of the field from the database. An error is
  14081. // returned if the mutation operation is not UpdateOne, or the query to the
  14082. // database failed.
  14083. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14084. switch name {
  14085. case messagerecords.FieldCreatedAt:
  14086. return m.OldCreatedAt(ctx)
  14087. case messagerecords.FieldUpdatedAt:
  14088. return m.OldUpdatedAt(ctx)
  14089. case messagerecords.FieldStatus:
  14090. return m.OldStatus(ctx)
  14091. case messagerecords.FieldBotWxid:
  14092. return m.OldBotWxid(ctx)
  14093. case messagerecords.FieldContactID:
  14094. return m.OldContactID(ctx)
  14095. case messagerecords.FieldContactType:
  14096. return m.OldContactType(ctx)
  14097. case messagerecords.FieldContactWxid:
  14098. return m.OldContactWxid(ctx)
  14099. case messagerecords.FieldContentType:
  14100. return m.OldContentType(ctx)
  14101. case messagerecords.FieldContent:
  14102. return m.OldContent(ctx)
  14103. case messagerecords.FieldMeta:
  14104. return m.OldMeta(ctx)
  14105. case messagerecords.FieldErrorDetail:
  14106. return m.OldErrorDetail(ctx)
  14107. case messagerecords.FieldSendTime:
  14108. return m.OldSendTime(ctx)
  14109. case messagerecords.FieldSourceType:
  14110. return m.OldSourceType(ctx)
  14111. case messagerecords.FieldSourceID:
  14112. return m.OldSourceID(ctx)
  14113. case messagerecords.FieldSubSourceID:
  14114. return m.OldSubSourceID(ctx)
  14115. case messagerecords.FieldOrganizationID:
  14116. return m.OldOrganizationID(ctx)
  14117. }
  14118. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14119. }
  14120. // SetField sets the value of a field with the given name. It returns an error if
  14121. // the field is not defined in the schema, or if the type mismatched the field
  14122. // type.
  14123. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14124. switch name {
  14125. case messagerecords.FieldCreatedAt:
  14126. v, ok := value.(time.Time)
  14127. if !ok {
  14128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14129. }
  14130. m.SetCreatedAt(v)
  14131. return nil
  14132. case messagerecords.FieldUpdatedAt:
  14133. v, ok := value.(time.Time)
  14134. if !ok {
  14135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14136. }
  14137. m.SetUpdatedAt(v)
  14138. return nil
  14139. case messagerecords.FieldStatus:
  14140. v, ok := value.(uint8)
  14141. if !ok {
  14142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14143. }
  14144. m.SetStatus(v)
  14145. return nil
  14146. case messagerecords.FieldBotWxid:
  14147. v, ok := value.(string)
  14148. if !ok {
  14149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14150. }
  14151. m.SetBotWxid(v)
  14152. return nil
  14153. case messagerecords.FieldContactID:
  14154. v, ok := value.(uint64)
  14155. if !ok {
  14156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14157. }
  14158. m.SetContactID(v)
  14159. return nil
  14160. case messagerecords.FieldContactType:
  14161. v, ok := value.(int)
  14162. if !ok {
  14163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14164. }
  14165. m.SetContactType(v)
  14166. return nil
  14167. case messagerecords.FieldContactWxid:
  14168. v, ok := value.(string)
  14169. if !ok {
  14170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14171. }
  14172. m.SetContactWxid(v)
  14173. return nil
  14174. case messagerecords.FieldContentType:
  14175. v, ok := value.(int)
  14176. if !ok {
  14177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14178. }
  14179. m.SetContentType(v)
  14180. return nil
  14181. case messagerecords.FieldContent:
  14182. v, ok := value.(string)
  14183. if !ok {
  14184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14185. }
  14186. m.SetContent(v)
  14187. return nil
  14188. case messagerecords.FieldMeta:
  14189. v, ok := value.(custom_types.Meta)
  14190. if !ok {
  14191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14192. }
  14193. m.SetMeta(v)
  14194. return nil
  14195. case messagerecords.FieldErrorDetail:
  14196. v, ok := value.(string)
  14197. if !ok {
  14198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14199. }
  14200. m.SetErrorDetail(v)
  14201. return nil
  14202. case messagerecords.FieldSendTime:
  14203. v, ok := value.(time.Time)
  14204. if !ok {
  14205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14206. }
  14207. m.SetSendTime(v)
  14208. return nil
  14209. case messagerecords.FieldSourceType:
  14210. v, ok := value.(int)
  14211. if !ok {
  14212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14213. }
  14214. m.SetSourceType(v)
  14215. return nil
  14216. case messagerecords.FieldSourceID:
  14217. v, ok := value.(uint64)
  14218. if !ok {
  14219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14220. }
  14221. m.SetSourceID(v)
  14222. return nil
  14223. case messagerecords.FieldSubSourceID:
  14224. v, ok := value.(uint64)
  14225. if !ok {
  14226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14227. }
  14228. m.SetSubSourceID(v)
  14229. return nil
  14230. case messagerecords.FieldOrganizationID:
  14231. v, ok := value.(uint64)
  14232. if !ok {
  14233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14234. }
  14235. m.SetOrganizationID(v)
  14236. return nil
  14237. }
  14238. return fmt.Errorf("unknown MessageRecords field %s", name)
  14239. }
  14240. // AddedFields returns all numeric fields that were incremented/decremented during
  14241. // this mutation.
  14242. func (m *MessageRecordsMutation) AddedFields() []string {
  14243. var fields []string
  14244. if m.addstatus != nil {
  14245. fields = append(fields, messagerecords.FieldStatus)
  14246. }
  14247. if m.addcontact_type != nil {
  14248. fields = append(fields, messagerecords.FieldContactType)
  14249. }
  14250. if m.addcontent_type != nil {
  14251. fields = append(fields, messagerecords.FieldContentType)
  14252. }
  14253. if m.addsource_type != nil {
  14254. fields = append(fields, messagerecords.FieldSourceType)
  14255. }
  14256. if m.addorganization_id != nil {
  14257. fields = append(fields, messagerecords.FieldOrganizationID)
  14258. }
  14259. return fields
  14260. }
  14261. // AddedField returns the numeric value that was incremented/decremented on a field
  14262. // with the given name. The second boolean return value indicates that this field
  14263. // was not set, or was not defined in the schema.
  14264. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14265. switch name {
  14266. case messagerecords.FieldStatus:
  14267. return m.AddedStatus()
  14268. case messagerecords.FieldContactType:
  14269. return m.AddedContactType()
  14270. case messagerecords.FieldContentType:
  14271. return m.AddedContentType()
  14272. case messagerecords.FieldSourceType:
  14273. return m.AddedSourceType()
  14274. case messagerecords.FieldOrganizationID:
  14275. return m.AddedOrganizationID()
  14276. }
  14277. return nil, false
  14278. }
  14279. // AddField adds the value to the field with the given name. It returns an error if
  14280. // the field is not defined in the schema, or if the type mismatched the field
  14281. // type.
  14282. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14283. switch name {
  14284. case messagerecords.FieldStatus:
  14285. v, ok := value.(int8)
  14286. if !ok {
  14287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14288. }
  14289. m.AddStatus(v)
  14290. return nil
  14291. case messagerecords.FieldContactType:
  14292. v, ok := value.(int)
  14293. if !ok {
  14294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14295. }
  14296. m.AddContactType(v)
  14297. return nil
  14298. case messagerecords.FieldContentType:
  14299. v, ok := value.(int)
  14300. if !ok {
  14301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14302. }
  14303. m.AddContentType(v)
  14304. return nil
  14305. case messagerecords.FieldSourceType:
  14306. v, ok := value.(int)
  14307. if !ok {
  14308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14309. }
  14310. m.AddSourceType(v)
  14311. return nil
  14312. case messagerecords.FieldOrganizationID:
  14313. v, ok := value.(int64)
  14314. if !ok {
  14315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14316. }
  14317. m.AddOrganizationID(v)
  14318. return nil
  14319. }
  14320. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14321. }
  14322. // ClearedFields returns all nullable fields that were cleared during this
  14323. // mutation.
  14324. func (m *MessageRecordsMutation) ClearedFields() []string {
  14325. var fields []string
  14326. if m.FieldCleared(messagerecords.FieldStatus) {
  14327. fields = append(fields, messagerecords.FieldStatus)
  14328. }
  14329. if m.FieldCleared(messagerecords.FieldContactID) {
  14330. fields = append(fields, messagerecords.FieldContactID)
  14331. }
  14332. if m.FieldCleared(messagerecords.FieldMeta) {
  14333. fields = append(fields, messagerecords.FieldMeta)
  14334. }
  14335. if m.FieldCleared(messagerecords.FieldSendTime) {
  14336. fields = append(fields, messagerecords.FieldSendTime)
  14337. }
  14338. if m.FieldCleared(messagerecords.FieldSourceID) {
  14339. fields = append(fields, messagerecords.FieldSourceID)
  14340. }
  14341. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14342. fields = append(fields, messagerecords.FieldSubSourceID)
  14343. }
  14344. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14345. fields = append(fields, messagerecords.FieldOrganizationID)
  14346. }
  14347. return fields
  14348. }
  14349. // FieldCleared returns a boolean indicating if a field with the given name was
  14350. // cleared in this mutation.
  14351. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14352. _, ok := m.clearedFields[name]
  14353. return ok
  14354. }
  14355. // ClearField clears the value of the field with the given name. It returns an
  14356. // error if the field is not defined in the schema.
  14357. func (m *MessageRecordsMutation) ClearField(name string) error {
  14358. switch name {
  14359. case messagerecords.FieldStatus:
  14360. m.ClearStatus()
  14361. return nil
  14362. case messagerecords.FieldContactID:
  14363. m.ClearContactID()
  14364. return nil
  14365. case messagerecords.FieldMeta:
  14366. m.ClearMeta()
  14367. return nil
  14368. case messagerecords.FieldSendTime:
  14369. m.ClearSendTime()
  14370. return nil
  14371. case messagerecords.FieldSourceID:
  14372. m.ClearSourceID()
  14373. return nil
  14374. case messagerecords.FieldSubSourceID:
  14375. m.ClearSubSourceID()
  14376. return nil
  14377. case messagerecords.FieldOrganizationID:
  14378. m.ClearOrganizationID()
  14379. return nil
  14380. }
  14381. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14382. }
  14383. // ResetField resets all changes in the mutation for the field with the given name.
  14384. // It returns an error if the field is not defined in the schema.
  14385. func (m *MessageRecordsMutation) ResetField(name string) error {
  14386. switch name {
  14387. case messagerecords.FieldCreatedAt:
  14388. m.ResetCreatedAt()
  14389. return nil
  14390. case messagerecords.FieldUpdatedAt:
  14391. m.ResetUpdatedAt()
  14392. return nil
  14393. case messagerecords.FieldStatus:
  14394. m.ResetStatus()
  14395. return nil
  14396. case messagerecords.FieldBotWxid:
  14397. m.ResetBotWxid()
  14398. return nil
  14399. case messagerecords.FieldContactID:
  14400. m.ResetContactID()
  14401. return nil
  14402. case messagerecords.FieldContactType:
  14403. m.ResetContactType()
  14404. return nil
  14405. case messagerecords.FieldContactWxid:
  14406. m.ResetContactWxid()
  14407. return nil
  14408. case messagerecords.FieldContentType:
  14409. m.ResetContentType()
  14410. return nil
  14411. case messagerecords.FieldContent:
  14412. m.ResetContent()
  14413. return nil
  14414. case messagerecords.FieldMeta:
  14415. m.ResetMeta()
  14416. return nil
  14417. case messagerecords.FieldErrorDetail:
  14418. m.ResetErrorDetail()
  14419. return nil
  14420. case messagerecords.FieldSendTime:
  14421. m.ResetSendTime()
  14422. return nil
  14423. case messagerecords.FieldSourceType:
  14424. m.ResetSourceType()
  14425. return nil
  14426. case messagerecords.FieldSourceID:
  14427. m.ResetSourceID()
  14428. return nil
  14429. case messagerecords.FieldSubSourceID:
  14430. m.ResetSubSourceID()
  14431. return nil
  14432. case messagerecords.FieldOrganizationID:
  14433. m.ResetOrganizationID()
  14434. return nil
  14435. }
  14436. return fmt.Errorf("unknown MessageRecords field %s", name)
  14437. }
  14438. // AddedEdges returns all edge names that were set/added in this mutation.
  14439. func (m *MessageRecordsMutation) AddedEdges() []string {
  14440. edges := make([]string, 0, 3)
  14441. if m.sop_stage != nil {
  14442. edges = append(edges, messagerecords.EdgeSopStage)
  14443. }
  14444. if m.sop_node != nil {
  14445. edges = append(edges, messagerecords.EdgeSopNode)
  14446. }
  14447. if m.message_contact != nil {
  14448. edges = append(edges, messagerecords.EdgeMessageContact)
  14449. }
  14450. return edges
  14451. }
  14452. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14453. // name in this mutation.
  14454. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14455. switch name {
  14456. case messagerecords.EdgeSopStage:
  14457. if id := m.sop_stage; id != nil {
  14458. return []ent.Value{*id}
  14459. }
  14460. case messagerecords.EdgeSopNode:
  14461. if id := m.sop_node; id != nil {
  14462. return []ent.Value{*id}
  14463. }
  14464. case messagerecords.EdgeMessageContact:
  14465. if id := m.message_contact; id != nil {
  14466. return []ent.Value{*id}
  14467. }
  14468. }
  14469. return nil
  14470. }
  14471. // RemovedEdges returns all edge names that were removed in this mutation.
  14472. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14473. edges := make([]string, 0, 3)
  14474. return edges
  14475. }
  14476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14477. // the given name in this mutation.
  14478. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14479. return nil
  14480. }
  14481. // ClearedEdges returns all edge names that were cleared in this mutation.
  14482. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14483. edges := make([]string, 0, 3)
  14484. if m.clearedsop_stage {
  14485. edges = append(edges, messagerecords.EdgeSopStage)
  14486. }
  14487. if m.clearedsop_node {
  14488. edges = append(edges, messagerecords.EdgeSopNode)
  14489. }
  14490. if m.clearedmessage_contact {
  14491. edges = append(edges, messagerecords.EdgeMessageContact)
  14492. }
  14493. return edges
  14494. }
  14495. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14496. // was cleared in this mutation.
  14497. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14498. switch name {
  14499. case messagerecords.EdgeSopStage:
  14500. return m.clearedsop_stage
  14501. case messagerecords.EdgeSopNode:
  14502. return m.clearedsop_node
  14503. case messagerecords.EdgeMessageContact:
  14504. return m.clearedmessage_contact
  14505. }
  14506. return false
  14507. }
  14508. // ClearEdge clears the value of the edge with the given name. It returns an error
  14509. // if that edge is not defined in the schema.
  14510. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14511. switch name {
  14512. case messagerecords.EdgeSopStage:
  14513. m.ClearSopStage()
  14514. return nil
  14515. case messagerecords.EdgeSopNode:
  14516. m.ClearSopNode()
  14517. return nil
  14518. case messagerecords.EdgeMessageContact:
  14519. m.ClearMessageContact()
  14520. return nil
  14521. }
  14522. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14523. }
  14524. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14525. // It returns an error if the edge is not defined in the schema.
  14526. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14527. switch name {
  14528. case messagerecords.EdgeSopStage:
  14529. m.ResetSopStage()
  14530. return nil
  14531. case messagerecords.EdgeSopNode:
  14532. m.ResetSopNode()
  14533. return nil
  14534. case messagerecords.EdgeMessageContact:
  14535. m.ResetMessageContact()
  14536. return nil
  14537. }
  14538. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14539. }
  14540. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14541. type MsgMutation struct {
  14542. config
  14543. op Op
  14544. typ string
  14545. id *uint64
  14546. created_at *time.Time
  14547. updated_at *time.Time
  14548. deleted_at *time.Time
  14549. status *uint8
  14550. addstatus *int8
  14551. fromwxid *string
  14552. toid *string
  14553. msgtype *int32
  14554. addmsgtype *int32
  14555. msg *string
  14556. batch_no *string
  14557. clearedFields map[string]struct{}
  14558. done bool
  14559. oldValue func(context.Context) (*Msg, error)
  14560. predicates []predicate.Msg
  14561. }
  14562. var _ ent.Mutation = (*MsgMutation)(nil)
  14563. // msgOption allows management of the mutation configuration using functional options.
  14564. type msgOption func(*MsgMutation)
  14565. // newMsgMutation creates new mutation for the Msg entity.
  14566. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14567. m := &MsgMutation{
  14568. config: c,
  14569. op: op,
  14570. typ: TypeMsg,
  14571. clearedFields: make(map[string]struct{}),
  14572. }
  14573. for _, opt := range opts {
  14574. opt(m)
  14575. }
  14576. return m
  14577. }
  14578. // withMsgID sets the ID field of the mutation.
  14579. func withMsgID(id uint64) msgOption {
  14580. return func(m *MsgMutation) {
  14581. var (
  14582. err error
  14583. once sync.Once
  14584. value *Msg
  14585. )
  14586. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14587. once.Do(func() {
  14588. if m.done {
  14589. err = errors.New("querying old values post mutation is not allowed")
  14590. } else {
  14591. value, err = m.Client().Msg.Get(ctx, id)
  14592. }
  14593. })
  14594. return value, err
  14595. }
  14596. m.id = &id
  14597. }
  14598. }
  14599. // withMsg sets the old Msg of the mutation.
  14600. func withMsg(node *Msg) msgOption {
  14601. return func(m *MsgMutation) {
  14602. m.oldValue = func(context.Context) (*Msg, error) {
  14603. return node, nil
  14604. }
  14605. m.id = &node.ID
  14606. }
  14607. }
  14608. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14609. // executed in a transaction (ent.Tx), a transactional client is returned.
  14610. func (m MsgMutation) Client() *Client {
  14611. client := &Client{config: m.config}
  14612. client.init()
  14613. return client
  14614. }
  14615. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14616. // it returns an error otherwise.
  14617. func (m MsgMutation) Tx() (*Tx, error) {
  14618. if _, ok := m.driver.(*txDriver); !ok {
  14619. return nil, errors.New("ent: mutation is not running in a transaction")
  14620. }
  14621. tx := &Tx{config: m.config}
  14622. tx.init()
  14623. return tx, nil
  14624. }
  14625. // SetID sets the value of the id field. Note that this
  14626. // operation is only accepted on creation of Msg entities.
  14627. func (m *MsgMutation) SetID(id uint64) {
  14628. m.id = &id
  14629. }
  14630. // ID returns the ID value in the mutation. Note that the ID is only available
  14631. // if it was provided to the builder or after it was returned from the database.
  14632. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14633. if m.id == nil {
  14634. return
  14635. }
  14636. return *m.id, true
  14637. }
  14638. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14639. // That means, if the mutation is applied within a transaction with an isolation level such
  14640. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14641. // or updated by the mutation.
  14642. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14643. switch {
  14644. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14645. id, exists := m.ID()
  14646. if exists {
  14647. return []uint64{id}, nil
  14648. }
  14649. fallthrough
  14650. case m.op.Is(OpUpdate | OpDelete):
  14651. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14652. default:
  14653. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14654. }
  14655. }
  14656. // SetCreatedAt sets the "created_at" field.
  14657. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14658. m.created_at = &t
  14659. }
  14660. // CreatedAt returns the value of the "created_at" field in the mutation.
  14661. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14662. v := m.created_at
  14663. if v == nil {
  14664. return
  14665. }
  14666. return *v, true
  14667. }
  14668. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14669. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14671. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14672. if !m.op.Is(OpUpdateOne) {
  14673. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14674. }
  14675. if m.id == nil || m.oldValue == nil {
  14676. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14677. }
  14678. oldValue, err := m.oldValue(ctx)
  14679. if err != nil {
  14680. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14681. }
  14682. return oldValue.CreatedAt, nil
  14683. }
  14684. // ResetCreatedAt resets all changes to the "created_at" field.
  14685. func (m *MsgMutation) ResetCreatedAt() {
  14686. m.created_at = nil
  14687. }
  14688. // SetUpdatedAt sets the "updated_at" field.
  14689. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14690. m.updated_at = &t
  14691. }
  14692. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14693. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14694. v := m.updated_at
  14695. if v == nil {
  14696. return
  14697. }
  14698. return *v, true
  14699. }
  14700. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14701. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14703. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14704. if !m.op.Is(OpUpdateOne) {
  14705. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14706. }
  14707. if m.id == nil || m.oldValue == nil {
  14708. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14709. }
  14710. oldValue, err := m.oldValue(ctx)
  14711. if err != nil {
  14712. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14713. }
  14714. return oldValue.UpdatedAt, nil
  14715. }
  14716. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14717. func (m *MsgMutation) ResetUpdatedAt() {
  14718. m.updated_at = nil
  14719. }
  14720. // SetDeletedAt sets the "deleted_at" field.
  14721. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14722. m.deleted_at = &t
  14723. }
  14724. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14725. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14726. v := m.deleted_at
  14727. if v == nil {
  14728. return
  14729. }
  14730. return *v, true
  14731. }
  14732. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14733. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14735. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14736. if !m.op.Is(OpUpdateOne) {
  14737. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14738. }
  14739. if m.id == nil || m.oldValue == nil {
  14740. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14741. }
  14742. oldValue, err := m.oldValue(ctx)
  14743. if err != nil {
  14744. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14745. }
  14746. return oldValue.DeletedAt, nil
  14747. }
  14748. // ClearDeletedAt clears the value of the "deleted_at" field.
  14749. func (m *MsgMutation) ClearDeletedAt() {
  14750. m.deleted_at = nil
  14751. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14752. }
  14753. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14754. func (m *MsgMutation) DeletedAtCleared() bool {
  14755. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14756. return ok
  14757. }
  14758. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14759. func (m *MsgMutation) ResetDeletedAt() {
  14760. m.deleted_at = nil
  14761. delete(m.clearedFields, msg.FieldDeletedAt)
  14762. }
  14763. // SetStatus sets the "status" field.
  14764. func (m *MsgMutation) SetStatus(u uint8) {
  14765. m.status = &u
  14766. m.addstatus = nil
  14767. }
  14768. // Status returns the value of the "status" field in the mutation.
  14769. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14770. v := m.status
  14771. if v == nil {
  14772. return
  14773. }
  14774. return *v, true
  14775. }
  14776. // OldStatus returns the old "status" field's value of the Msg entity.
  14777. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14779. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14780. if !m.op.Is(OpUpdateOne) {
  14781. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14782. }
  14783. if m.id == nil || m.oldValue == nil {
  14784. return v, errors.New("OldStatus requires an ID field in the mutation")
  14785. }
  14786. oldValue, err := m.oldValue(ctx)
  14787. if err != nil {
  14788. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14789. }
  14790. return oldValue.Status, nil
  14791. }
  14792. // AddStatus adds u to the "status" field.
  14793. func (m *MsgMutation) AddStatus(u int8) {
  14794. if m.addstatus != nil {
  14795. *m.addstatus += u
  14796. } else {
  14797. m.addstatus = &u
  14798. }
  14799. }
  14800. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14801. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14802. v := m.addstatus
  14803. if v == nil {
  14804. return
  14805. }
  14806. return *v, true
  14807. }
  14808. // ClearStatus clears the value of the "status" field.
  14809. func (m *MsgMutation) ClearStatus() {
  14810. m.status = nil
  14811. m.addstatus = nil
  14812. m.clearedFields[msg.FieldStatus] = struct{}{}
  14813. }
  14814. // StatusCleared returns if the "status" field was cleared in this mutation.
  14815. func (m *MsgMutation) StatusCleared() bool {
  14816. _, ok := m.clearedFields[msg.FieldStatus]
  14817. return ok
  14818. }
  14819. // ResetStatus resets all changes to the "status" field.
  14820. func (m *MsgMutation) ResetStatus() {
  14821. m.status = nil
  14822. m.addstatus = nil
  14823. delete(m.clearedFields, msg.FieldStatus)
  14824. }
  14825. // SetFromwxid sets the "fromwxid" field.
  14826. func (m *MsgMutation) SetFromwxid(s string) {
  14827. m.fromwxid = &s
  14828. }
  14829. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14830. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14831. v := m.fromwxid
  14832. if v == nil {
  14833. return
  14834. }
  14835. return *v, true
  14836. }
  14837. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14838. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14840. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14841. if !m.op.Is(OpUpdateOne) {
  14842. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14843. }
  14844. if m.id == nil || m.oldValue == nil {
  14845. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14846. }
  14847. oldValue, err := m.oldValue(ctx)
  14848. if err != nil {
  14849. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14850. }
  14851. return oldValue.Fromwxid, nil
  14852. }
  14853. // ClearFromwxid clears the value of the "fromwxid" field.
  14854. func (m *MsgMutation) ClearFromwxid() {
  14855. m.fromwxid = nil
  14856. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14857. }
  14858. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14859. func (m *MsgMutation) FromwxidCleared() bool {
  14860. _, ok := m.clearedFields[msg.FieldFromwxid]
  14861. return ok
  14862. }
  14863. // ResetFromwxid resets all changes to the "fromwxid" field.
  14864. func (m *MsgMutation) ResetFromwxid() {
  14865. m.fromwxid = nil
  14866. delete(m.clearedFields, msg.FieldFromwxid)
  14867. }
  14868. // SetToid sets the "toid" field.
  14869. func (m *MsgMutation) SetToid(s string) {
  14870. m.toid = &s
  14871. }
  14872. // Toid returns the value of the "toid" field in the mutation.
  14873. func (m *MsgMutation) Toid() (r string, exists bool) {
  14874. v := m.toid
  14875. if v == nil {
  14876. return
  14877. }
  14878. return *v, true
  14879. }
  14880. // OldToid returns the old "toid" field's value of the Msg entity.
  14881. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14883. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  14884. if !m.op.Is(OpUpdateOne) {
  14885. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  14886. }
  14887. if m.id == nil || m.oldValue == nil {
  14888. return v, errors.New("OldToid requires an ID field in the mutation")
  14889. }
  14890. oldValue, err := m.oldValue(ctx)
  14891. if err != nil {
  14892. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  14893. }
  14894. return oldValue.Toid, nil
  14895. }
  14896. // ClearToid clears the value of the "toid" field.
  14897. func (m *MsgMutation) ClearToid() {
  14898. m.toid = nil
  14899. m.clearedFields[msg.FieldToid] = struct{}{}
  14900. }
  14901. // ToidCleared returns if the "toid" field was cleared in this mutation.
  14902. func (m *MsgMutation) ToidCleared() bool {
  14903. _, ok := m.clearedFields[msg.FieldToid]
  14904. return ok
  14905. }
  14906. // ResetToid resets all changes to the "toid" field.
  14907. func (m *MsgMutation) ResetToid() {
  14908. m.toid = nil
  14909. delete(m.clearedFields, msg.FieldToid)
  14910. }
  14911. // SetMsgtype sets the "msgtype" field.
  14912. func (m *MsgMutation) SetMsgtype(i int32) {
  14913. m.msgtype = &i
  14914. m.addmsgtype = nil
  14915. }
  14916. // Msgtype returns the value of the "msgtype" field in the mutation.
  14917. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  14918. v := m.msgtype
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  14925. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14927. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  14928. if !m.op.Is(OpUpdateOne) {
  14929. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  14930. }
  14931. if m.id == nil || m.oldValue == nil {
  14932. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  14933. }
  14934. oldValue, err := m.oldValue(ctx)
  14935. if err != nil {
  14936. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  14937. }
  14938. return oldValue.Msgtype, nil
  14939. }
  14940. // AddMsgtype adds i to the "msgtype" field.
  14941. func (m *MsgMutation) AddMsgtype(i int32) {
  14942. if m.addmsgtype != nil {
  14943. *m.addmsgtype += i
  14944. } else {
  14945. m.addmsgtype = &i
  14946. }
  14947. }
  14948. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  14949. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  14950. v := m.addmsgtype
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // ClearMsgtype clears the value of the "msgtype" field.
  14957. func (m *MsgMutation) ClearMsgtype() {
  14958. m.msgtype = nil
  14959. m.addmsgtype = nil
  14960. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  14961. }
  14962. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  14963. func (m *MsgMutation) MsgtypeCleared() bool {
  14964. _, ok := m.clearedFields[msg.FieldMsgtype]
  14965. return ok
  14966. }
  14967. // ResetMsgtype resets all changes to the "msgtype" field.
  14968. func (m *MsgMutation) ResetMsgtype() {
  14969. m.msgtype = nil
  14970. m.addmsgtype = nil
  14971. delete(m.clearedFields, msg.FieldMsgtype)
  14972. }
  14973. // SetMsg sets the "msg" field.
  14974. func (m *MsgMutation) SetMsg(s string) {
  14975. m.msg = &s
  14976. }
  14977. // Msg returns the value of the "msg" field in the mutation.
  14978. func (m *MsgMutation) Msg() (r string, exists bool) {
  14979. v := m.msg
  14980. if v == nil {
  14981. return
  14982. }
  14983. return *v, true
  14984. }
  14985. // OldMsg returns the old "msg" field's value of the Msg entity.
  14986. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14988. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  14989. if !m.op.Is(OpUpdateOne) {
  14990. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  14991. }
  14992. if m.id == nil || m.oldValue == nil {
  14993. return v, errors.New("OldMsg requires an ID field in the mutation")
  14994. }
  14995. oldValue, err := m.oldValue(ctx)
  14996. if err != nil {
  14997. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  14998. }
  14999. return oldValue.Msg, nil
  15000. }
  15001. // ClearMsg clears the value of the "msg" field.
  15002. func (m *MsgMutation) ClearMsg() {
  15003. m.msg = nil
  15004. m.clearedFields[msg.FieldMsg] = struct{}{}
  15005. }
  15006. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15007. func (m *MsgMutation) MsgCleared() bool {
  15008. _, ok := m.clearedFields[msg.FieldMsg]
  15009. return ok
  15010. }
  15011. // ResetMsg resets all changes to the "msg" field.
  15012. func (m *MsgMutation) ResetMsg() {
  15013. m.msg = nil
  15014. delete(m.clearedFields, msg.FieldMsg)
  15015. }
  15016. // SetBatchNo sets the "batch_no" field.
  15017. func (m *MsgMutation) SetBatchNo(s string) {
  15018. m.batch_no = &s
  15019. }
  15020. // BatchNo returns the value of the "batch_no" field in the mutation.
  15021. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15022. v := m.batch_no
  15023. if v == nil {
  15024. return
  15025. }
  15026. return *v, true
  15027. }
  15028. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15029. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15031. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15032. if !m.op.Is(OpUpdateOne) {
  15033. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15034. }
  15035. if m.id == nil || m.oldValue == nil {
  15036. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15037. }
  15038. oldValue, err := m.oldValue(ctx)
  15039. if err != nil {
  15040. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15041. }
  15042. return oldValue.BatchNo, nil
  15043. }
  15044. // ClearBatchNo clears the value of the "batch_no" field.
  15045. func (m *MsgMutation) ClearBatchNo() {
  15046. m.batch_no = nil
  15047. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15048. }
  15049. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15050. func (m *MsgMutation) BatchNoCleared() bool {
  15051. _, ok := m.clearedFields[msg.FieldBatchNo]
  15052. return ok
  15053. }
  15054. // ResetBatchNo resets all changes to the "batch_no" field.
  15055. func (m *MsgMutation) ResetBatchNo() {
  15056. m.batch_no = nil
  15057. delete(m.clearedFields, msg.FieldBatchNo)
  15058. }
  15059. // Where appends a list predicates to the MsgMutation builder.
  15060. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15061. m.predicates = append(m.predicates, ps...)
  15062. }
  15063. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15064. // users can use type-assertion to append predicates that do not depend on any generated package.
  15065. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15066. p := make([]predicate.Msg, len(ps))
  15067. for i := range ps {
  15068. p[i] = ps[i]
  15069. }
  15070. m.Where(p...)
  15071. }
  15072. // Op returns the operation name.
  15073. func (m *MsgMutation) Op() Op {
  15074. return m.op
  15075. }
  15076. // SetOp allows setting the mutation operation.
  15077. func (m *MsgMutation) SetOp(op Op) {
  15078. m.op = op
  15079. }
  15080. // Type returns the node type of this mutation (Msg).
  15081. func (m *MsgMutation) Type() string {
  15082. return m.typ
  15083. }
  15084. // Fields returns all fields that were changed during this mutation. Note that in
  15085. // order to get all numeric fields that were incremented/decremented, call
  15086. // AddedFields().
  15087. func (m *MsgMutation) Fields() []string {
  15088. fields := make([]string, 0, 9)
  15089. if m.created_at != nil {
  15090. fields = append(fields, msg.FieldCreatedAt)
  15091. }
  15092. if m.updated_at != nil {
  15093. fields = append(fields, msg.FieldUpdatedAt)
  15094. }
  15095. if m.deleted_at != nil {
  15096. fields = append(fields, msg.FieldDeletedAt)
  15097. }
  15098. if m.status != nil {
  15099. fields = append(fields, msg.FieldStatus)
  15100. }
  15101. if m.fromwxid != nil {
  15102. fields = append(fields, msg.FieldFromwxid)
  15103. }
  15104. if m.toid != nil {
  15105. fields = append(fields, msg.FieldToid)
  15106. }
  15107. if m.msgtype != nil {
  15108. fields = append(fields, msg.FieldMsgtype)
  15109. }
  15110. if m.msg != nil {
  15111. fields = append(fields, msg.FieldMsg)
  15112. }
  15113. if m.batch_no != nil {
  15114. fields = append(fields, msg.FieldBatchNo)
  15115. }
  15116. return fields
  15117. }
  15118. // Field returns the value of a field with the given name. The second boolean
  15119. // return value indicates that this field was not set, or was not defined in the
  15120. // schema.
  15121. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15122. switch name {
  15123. case msg.FieldCreatedAt:
  15124. return m.CreatedAt()
  15125. case msg.FieldUpdatedAt:
  15126. return m.UpdatedAt()
  15127. case msg.FieldDeletedAt:
  15128. return m.DeletedAt()
  15129. case msg.FieldStatus:
  15130. return m.Status()
  15131. case msg.FieldFromwxid:
  15132. return m.Fromwxid()
  15133. case msg.FieldToid:
  15134. return m.Toid()
  15135. case msg.FieldMsgtype:
  15136. return m.Msgtype()
  15137. case msg.FieldMsg:
  15138. return m.Msg()
  15139. case msg.FieldBatchNo:
  15140. return m.BatchNo()
  15141. }
  15142. return nil, false
  15143. }
  15144. // OldField returns the old value of the field from the database. An error is
  15145. // returned if the mutation operation is not UpdateOne, or the query to the
  15146. // database failed.
  15147. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15148. switch name {
  15149. case msg.FieldCreatedAt:
  15150. return m.OldCreatedAt(ctx)
  15151. case msg.FieldUpdatedAt:
  15152. return m.OldUpdatedAt(ctx)
  15153. case msg.FieldDeletedAt:
  15154. return m.OldDeletedAt(ctx)
  15155. case msg.FieldStatus:
  15156. return m.OldStatus(ctx)
  15157. case msg.FieldFromwxid:
  15158. return m.OldFromwxid(ctx)
  15159. case msg.FieldToid:
  15160. return m.OldToid(ctx)
  15161. case msg.FieldMsgtype:
  15162. return m.OldMsgtype(ctx)
  15163. case msg.FieldMsg:
  15164. return m.OldMsg(ctx)
  15165. case msg.FieldBatchNo:
  15166. return m.OldBatchNo(ctx)
  15167. }
  15168. return nil, fmt.Errorf("unknown Msg field %s", name)
  15169. }
  15170. // SetField sets the value of a field with the given name. It returns an error if
  15171. // the field is not defined in the schema, or if the type mismatched the field
  15172. // type.
  15173. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15174. switch name {
  15175. case msg.FieldCreatedAt:
  15176. v, ok := value.(time.Time)
  15177. if !ok {
  15178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15179. }
  15180. m.SetCreatedAt(v)
  15181. return nil
  15182. case msg.FieldUpdatedAt:
  15183. v, ok := value.(time.Time)
  15184. if !ok {
  15185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15186. }
  15187. m.SetUpdatedAt(v)
  15188. return nil
  15189. case msg.FieldDeletedAt:
  15190. v, ok := value.(time.Time)
  15191. if !ok {
  15192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15193. }
  15194. m.SetDeletedAt(v)
  15195. return nil
  15196. case msg.FieldStatus:
  15197. v, ok := value.(uint8)
  15198. if !ok {
  15199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15200. }
  15201. m.SetStatus(v)
  15202. return nil
  15203. case msg.FieldFromwxid:
  15204. v, ok := value.(string)
  15205. if !ok {
  15206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15207. }
  15208. m.SetFromwxid(v)
  15209. return nil
  15210. case msg.FieldToid:
  15211. v, ok := value.(string)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.SetToid(v)
  15216. return nil
  15217. case msg.FieldMsgtype:
  15218. v, ok := value.(int32)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.SetMsgtype(v)
  15223. return nil
  15224. case msg.FieldMsg:
  15225. v, ok := value.(string)
  15226. if !ok {
  15227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15228. }
  15229. m.SetMsg(v)
  15230. return nil
  15231. case msg.FieldBatchNo:
  15232. v, ok := value.(string)
  15233. if !ok {
  15234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15235. }
  15236. m.SetBatchNo(v)
  15237. return nil
  15238. }
  15239. return fmt.Errorf("unknown Msg field %s", name)
  15240. }
  15241. // AddedFields returns all numeric fields that were incremented/decremented during
  15242. // this mutation.
  15243. func (m *MsgMutation) AddedFields() []string {
  15244. var fields []string
  15245. if m.addstatus != nil {
  15246. fields = append(fields, msg.FieldStatus)
  15247. }
  15248. if m.addmsgtype != nil {
  15249. fields = append(fields, msg.FieldMsgtype)
  15250. }
  15251. return fields
  15252. }
  15253. // AddedField returns the numeric value that was incremented/decremented on a field
  15254. // with the given name. The second boolean return value indicates that this field
  15255. // was not set, or was not defined in the schema.
  15256. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15257. switch name {
  15258. case msg.FieldStatus:
  15259. return m.AddedStatus()
  15260. case msg.FieldMsgtype:
  15261. return m.AddedMsgtype()
  15262. }
  15263. return nil, false
  15264. }
  15265. // AddField adds the value to the field with the given name. It returns an error if
  15266. // the field is not defined in the schema, or if the type mismatched the field
  15267. // type.
  15268. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15269. switch name {
  15270. case msg.FieldStatus:
  15271. v, ok := value.(int8)
  15272. if !ok {
  15273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15274. }
  15275. m.AddStatus(v)
  15276. return nil
  15277. case msg.FieldMsgtype:
  15278. v, ok := value.(int32)
  15279. if !ok {
  15280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15281. }
  15282. m.AddMsgtype(v)
  15283. return nil
  15284. }
  15285. return fmt.Errorf("unknown Msg numeric field %s", name)
  15286. }
  15287. // ClearedFields returns all nullable fields that were cleared during this
  15288. // mutation.
  15289. func (m *MsgMutation) ClearedFields() []string {
  15290. var fields []string
  15291. if m.FieldCleared(msg.FieldDeletedAt) {
  15292. fields = append(fields, msg.FieldDeletedAt)
  15293. }
  15294. if m.FieldCleared(msg.FieldStatus) {
  15295. fields = append(fields, msg.FieldStatus)
  15296. }
  15297. if m.FieldCleared(msg.FieldFromwxid) {
  15298. fields = append(fields, msg.FieldFromwxid)
  15299. }
  15300. if m.FieldCleared(msg.FieldToid) {
  15301. fields = append(fields, msg.FieldToid)
  15302. }
  15303. if m.FieldCleared(msg.FieldMsgtype) {
  15304. fields = append(fields, msg.FieldMsgtype)
  15305. }
  15306. if m.FieldCleared(msg.FieldMsg) {
  15307. fields = append(fields, msg.FieldMsg)
  15308. }
  15309. if m.FieldCleared(msg.FieldBatchNo) {
  15310. fields = append(fields, msg.FieldBatchNo)
  15311. }
  15312. return fields
  15313. }
  15314. // FieldCleared returns a boolean indicating if a field with the given name was
  15315. // cleared in this mutation.
  15316. func (m *MsgMutation) FieldCleared(name string) bool {
  15317. _, ok := m.clearedFields[name]
  15318. return ok
  15319. }
  15320. // ClearField clears the value of the field with the given name. It returns an
  15321. // error if the field is not defined in the schema.
  15322. func (m *MsgMutation) ClearField(name string) error {
  15323. switch name {
  15324. case msg.FieldDeletedAt:
  15325. m.ClearDeletedAt()
  15326. return nil
  15327. case msg.FieldStatus:
  15328. m.ClearStatus()
  15329. return nil
  15330. case msg.FieldFromwxid:
  15331. m.ClearFromwxid()
  15332. return nil
  15333. case msg.FieldToid:
  15334. m.ClearToid()
  15335. return nil
  15336. case msg.FieldMsgtype:
  15337. m.ClearMsgtype()
  15338. return nil
  15339. case msg.FieldMsg:
  15340. m.ClearMsg()
  15341. return nil
  15342. case msg.FieldBatchNo:
  15343. m.ClearBatchNo()
  15344. return nil
  15345. }
  15346. return fmt.Errorf("unknown Msg nullable field %s", name)
  15347. }
  15348. // ResetField resets all changes in the mutation for the field with the given name.
  15349. // It returns an error if the field is not defined in the schema.
  15350. func (m *MsgMutation) ResetField(name string) error {
  15351. switch name {
  15352. case msg.FieldCreatedAt:
  15353. m.ResetCreatedAt()
  15354. return nil
  15355. case msg.FieldUpdatedAt:
  15356. m.ResetUpdatedAt()
  15357. return nil
  15358. case msg.FieldDeletedAt:
  15359. m.ResetDeletedAt()
  15360. return nil
  15361. case msg.FieldStatus:
  15362. m.ResetStatus()
  15363. return nil
  15364. case msg.FieldFromwxid:
  15365. m.ResetFromwxid()
  15366. return nil
  15367. case msg.FieldToid:
  15368. m.ResetToid()
  15369. return nil
  15370. case msg.FieldMsgtype:
  15371. m.ResetMsgtype()
  15372. return nil
  15373. case msg.FieldMsg:
  15374. m.ResetMsg()
  15375. return nil
  15376. case msg.FieldBatchNo:
  15377. m.ResetBatchNo()
  15378. return nil
  15379. }
  15380. return fmt.Errorf("unknown Msg field %s", name)
  15381. }
  15382. // AddedEdges returns all edge names that were set/added in this mutation.
  15383. func (m *MsgMutation) AddedEdges() []string {
  15384. edges := make([]string, 0, 0)
  15385. return edges
  15386. }
  15387. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15388. // name in this mutation.
  15389. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15390. return nil
  15391. }
  15392. // RemovedEdges returns all edge names that were removed in this mutation.
  15393. func (m *MsgMutation) RemovedEdges() []string {
  15394. edges := make([]string, 0, 0)
  15395. return edges
  15396. }
  15397. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15398. // the given name in this mutation.
  15399. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15400. return nil
  15401. }
  15402. // ClearedEdges returns all edge names that were cleared in this mutation.
  15403. func (m *MsgMutation) ClearedEdges() []string {
  15404. edges := make([]string, 0, 0)
  15405. return edges
  15406. }
  15407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15408. // was cleared in this mutation.
  15409. func (m *MsgMutation) EdgeCleared(name string) bool {
  15410. return false
  15411. }
  15412. // ClearEdge clears the value of the edge with the given name. It returns an error
  15413. // if that edge is not defined in the schema.
  15414. func (m *MsgMutation) ClearEdge(name string) error {
  15415. return fmt.Errorf("unknown Msg unique edge %s", name)
  15416. }
  15417. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15418. // It returns an error if the edge is not defined in the schema.
  15419. func (m *MsgMutation) ResetEdge(name string) error {
  15420. return fmt.Errorf("unknown Msg edge %s", name)
  15421. }
  15422. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15423. type ServerMutation struct {
  15424. config
  15425. op Op
  15426. typ string
  15427. id *uint64
  15428. created_at *time.Time
  15429. updated_at *time.Time
  15430. status *uint8
  15431. addstatus *int8
  15432. deleted_at *time.Time
  15433. name *string
  15434. public_ip *string
  15435. private_ip *string
  15436. admin_port *string
  15437. clearedFields map[string]struct{}
  15438. wxs map[uint64]struct{}
  15439. removedwxs map[uint64]struct{}
  15440. clearedwxs bool
  15441. done bool
  15442. oldValue func(context.Context) (*Server, error)
  15443. predicates []predicate.Server
  15444. }
  15445. var _ ent.Mutation = (*ServerMutation)(nil)
  15446. // serverOption allows management of the mutation configuration using functional options.
  15447. type serverOption func(*ServerMutation)
  15448. // newServerMutation creates new mutation for the Server entity.
  15449. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15450. m := &ServerMutation{
  15451. config: c,
  15452. op: op,
  15453. typ: TypeServer,
  15454. clearedFields: make(map[string]struct{}),
  15455. }
  15456. for _, opt := range opts {
  15457. opt(m)
  15458. }
  15459. return m
  15460. }
  15461. // withServerID sets the ID field of the mutation.
  15462. func withServerID(id uint64) serverOption {
  15463. return func(m *ServerMutation) {
  15464. var (
  15465. err error
  15466. once sync.Once
  15467. value *Server
  15468. )
  15469. m.oldValue = func(ctx context.Context) (*Server, error) {
  15470. once.Do(func() {
  15471. if m.done {
  15472. err = errors.New("querying old values post mutation is not allowed")
  15473. } else {
  15474. value, err = m.Client().Server.Get(ctx, id)
  15475. }
  15476. })
  15477. return value, err
  15478. }
  15479. m.id = &id
  15480. }
  15481. }
  15482. // withServer sets the old Server of the mutation.
  15483. func withServer(node *Server) serverOption {
  15484. return func(m *ServerMutation) {
  15485. m.oldValue = func(context.Context) (*Server, error) {
  15486. return node, nil
  15487. }
  15488. m.id = &node.ID
  15489. }
  15490. }
  15491. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15492. // executed in a transaction (ent.Tx), a transactional client is returned.
  15493. func (m ServerMutation) Client() *Client {
  15494. client := &Client{config: m.config}
  15495. client.init()
  15496. return client
  15497. }
  15498. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15499. // it returns an error otherwise.
  15500. func (m ServerMutation) Tx() (*Tx, error) {
  15501. if _, ok := m.driver.(*txDriver); !ok {
  15502. return nil, errors.New("ent: mutation is not running in a transaction")
  15503. }
  15504. tx := &Tx{config: m.config}
  15505. tx.init()
  15506. return tx, nil
  15507. }
  15508. // SetID sets the value of the id field. Note that this
  15509. // operation is only accepted on creation of Server entities.
  15510. func (m *ServerMutation) SetID(id uint64) {
  15511. m.id = &id
  15512. }
  15513. // ID returns the ID value in the mutation. Note that the ID is only available
  15514. // if it was provided to the builder or after it was returned from the database.
  15515. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15516. if m.id == nil {
  15517. return
  15518. }
  15519. return *m.id, true
  15520. }
  15521. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15522. // That means, if the mutation is applied within a transaction with an isolation level such
  15523. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15524. // or updated by the mutation.
  15525. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15526. switch {
  15527. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15528. id, exists := m.ID()
  15529. if exists {
  15530. return []uint64{id}, nil
  15531. }
  15532. fallthrough
  15533. case m.op.Is(OpUpdate | OpDelete):
  15534. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15535. default:
  15536. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15537. }
  15538. }
  15539. // SetCreatedAt sets the "created_at" field.
  15540. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15541. m.created_at = &t
  15542. }
  15543. // CreatedAt returns the value of the "created_at" field in the mutation.
  15544. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15545. v := m.created_at
  15546. if v == nil {
  15547. return
  15548. }
  15549. return *v, true
  15550. }
  15551. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15552. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15554. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15555. if !m.op.Is(OpUpdateOne) {
  15556. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15557. }
  15558. if m.id == nil || m.oldValue == nil {
  15559. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15560. }
  15561. oldValue, err := m.oldValue(ctx)
  15562. if err != nil {
  15563. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15564. }
  15565. return oldValue.CreatedAt, nil
  15566. }
  15567. // ResetCreatedAt resets all changes to the "created_at" field.
  15568. func (m *ServerMutation) ResetCreatedAt() {
  15569. m.created_at = nil
  15570. }
  15571. // SetUpdatedAt sets the "updated_at" field.
  15572. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15573. m.updated_at = &t
  15574. }
  15575. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15576. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15577. v := m.updated_at
  15578. if v == nil {
  15579. return
  15580. }
  15581. return *v, true
  15582. }
  15583. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15584. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15586. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15587. if !m.op.Is(OpUpdateOne) {
  15588. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15589. }
  15590. if m.id == nil || m.oldValue == nil {
  15591. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15592. }
  15593. oldValue, err := m.oldValue(ctx)
  15594. if err != nil {
  15595. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15596. }
  15597. return oldValue.UpdatedAt, nil
  15598. }
  15599. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15600. func (m *ServerMutation) ResetUpdatedAt() {
  15601. m.updated_at = nil
  15602. }
  15603. // SetStatus sets the "status" field.
  15604. func (m *ServerMutation) SetStatus(u uint8) {
  15605. m.status = &u
  15606. m.addstatus = nil
  15607. }
  15608. // Status returns the value of the "status" field in the mutation.
  15609. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15610. v := m.status
  15611. if v == nil {
  15612. return
  15613. }
  15614. return *v, true
  15615. }
  15616. // OldStatus returns the old "status" field's value of the Server entity.
  15617. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15619. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15620. if !m.op.Is(OpUpdateOne) {
  15621. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15622. }
  15623. if m.id == nil || m.oldValue == nil {
  15624. return v, errors.New("OldStatus requires an ID field in the mutation")
  15625. }
  15626. oldValue, err := m.oldValue(ctx)
  15627. if err != nil {
  15628. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15629. }
  15630. return oldValue.Status, nil
  15631. }
  15632. // AddStatus adds u to the "status" field.
  15633. func (m *ServerMutation) AddStatus(u int8) {
  15634. if m.addstatus != nil {
  15635. *m.addstatus += u
  15636. } else {
  15637. m.addstatus = &u
  15638. }
  15639. }
  15640. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15641. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15642. v := m.addstatus
  15643. if v == nil {
  15644. return
  15645. }
  15646. return *v, true
  15647. }
  15648. // ClearStatus clears the value of the "status" field.
  15649. func (m *ServerMutation) ClearStatus() {
  15650. m.status = nil
  15651. m.addstatus = nil
  15652. m.clearedFields[server.FieldStatus] = struct{}{}
  15653. }
  15654. // StatusCleared returns if the "status" field was cleared in this mutation.
  15655. func (m *ServerMutation) StatusCleared() bool {
  15656. _, ok := m.clearedFields[server.FieldStatus]
  15657. return ok
  15658. }
  15659. // ResetStatus resets all changes to the "status" field.
  15660. func (m *ServerMutation) ResetStatus() {
  15661. m.status = nil
  15662. m.addstatus = nil
  15663. delete(m.clearedFields, server.FieldStatus)
  15664. }
  15665. // SetDeletedAt sets the "deleted_at" field.
  15666. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15667. m.deleted_at = &t
  15668. }
  15669. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15670. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15671. v := m.deleted_at
  15672. if v == nil {
  15673. return
  15674. }
  15675. return *v, true
  15676. }
  15677. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15678. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15680. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15681. if !m.op.Is(OpUpdateOne) {
  15682. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15683. }
  15684. if m.id == nil || m.oldValue == nil {
  15685. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15686. }
  15687. oldValue, err := m.oldValue(ctx)
  15688. if err != nil {
  15689. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15690. }
  15691. return oldValue.DeletedAt, nil
  15692. }
  15693. // ClearDeletedAt clears the value of the "deleted_at" field.
  15694. func (m *ServerMutation) ClearDeletedAt() {
  15695. m.deleted_at = nil
  15696. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15697. }
  15698. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15699. func (m *ServerMutation) DeletedAtCleared() bool {
  15700. _, ok := m.clearedFields[server.FieldDeletedAt]
  15701. return ok
  15702. }
  15703. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15704. func (m *ServerMutation) ResetDeletedAt() {
  15705. m.deleted_at = nil
  15706. delete(m.clearedFields, server.FieldDeletedAt)
  15707. }
  15708. // SetName sets the "name" field.
  15709. func (m *ServerMutation) SetName(s string) {
  15710. m.name = &s
  15711. }
  15712. // Name returns the value of the "name" field in the mutation.
  15713. func (m *ServerMutation) Name() (r string, exists bool) {
  15714. v := m.name
  15715. if v == nil {
  15716. return
  15717. }
  15718. return *v, true
  15719. }
  15720. // OldName returns the old "name" field's value of the Server entity.
  15721. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15723. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15724. if !m.op.Is(OpUpdateOne) {
  15725. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15726. }
  15727. if m.id == nil || m.oldValue == nil {
  15728. return v, errors.New("OldName requires an ID field in the mutation")
  15729. }
  15730. oldValue, err := m.oldValue(ctx)
  15731. if err != nil {
  15732. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15733. }
  15734. return oldValue.Name, nil
  15735. }
  15736. // ResetName resets all changes to the "name" field.
  15737. func (m *ServerMutation) ResetName() {
  15738. m.name = nil
  15739. }
  15740. // SetPublicIP sets the "public_ip" field.
  15741. func (m *ServerMutation) SetPublicIP(s string) {
  15742. m.public_ip = &s
  15743. }
  15744. // PublicIP returns the value of the "public_ip" field in the mutation.
  15745. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15746. v := m.public_ip
  15747. if v == nil {
  15748. return
  15749. }
  15750. return *v, true
  15751. }
  15752. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15753. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15755. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15756. if !m.op.Is(OpUpdateOne) {
  15757. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15758. }
  15759. if m.id == nil || m.oldValue == nil {
  15760. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15761. }
  15762. oldValue, err := m.oldValue(ctx)
  15763. if err != nil {
  15764. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15765. }
  15766. return oldValue.PublicIP, nil
  15767. }
  15768. // ResetPublicIP resets all changes to the "public_ip" field.
  15769. func (m *ServerMutation) ResetPublicIP() {
  15770. m.public_ip = nil
  15771. }
  15772. // SetPrivateIP sets the "private_ip" field.
  15773. func (m *ServerMutation) SetPrivateIP(s string) {
  15774. m.private_ip = &s
  15775. }
  15776. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15777. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15778. v := m.private_ip
  15779. if v == nil {
  15780. return
  15781. }
  15782. return *v, true
  15783. }
  15784. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15785. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15787. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15788. if !m.op.Is(OpUpdateOne) {
  15789. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15790. }
  15791. if m.id == nil || m.oldValue == nil {
  15792. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15793. }
  15794. oldValue, err := m.oldValue(ctx)
  15795. if err != nil {
  15796. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15797. }
  15798. return oldValue.PrivateIP, nil
  15799. }
  15800. // ResetPrivateIP resets all changes to the "private_ip" field.
  15801. func (m *ServerMutation) ResetPrivateIP() {
  15802. m.private_ip = nil
  15803. }
  15804. // SetAdminPort sets the "admin_port" field.
  15805. func (m *ServerMutation) SetAdminPort(s string) {
  15806. m.admin_port = &s
  15807. }
  15808. // AdminPort returns the value of the "admin_port" field in the mutation.
  15809. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15810. v := m.admin_port
  15811. if v == nil {
  15812. return
  15813. }
  15814. return *v, true
  15815. }
  15816. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15817. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15819. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15820. if !m.op.Is(OpUpdateOne) {
  15821. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15822. }
  15823. if m.id == nil || m.oldValue == nil {
  15824. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15825. }
  15826. oldValue, err := m.oldValue(ctx)
  15827. if err != nil {
  15828. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15829. }
  15830. return oldValue.AdminPort, nil
  15831. }
  15832. // ResetAdminPort resets all changes to the "admin_port" field.
  15833. func (m *ServerMutation) ResetAdminPort() {
  15834. m.admin_port = nil
  15835. }
  15836. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15837. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15838. if m.wxs == nil {
  15839. m.wxs = make(map[uint64]struct{})
  15840. }
  15841. for i := range ids {
  15842. m.wxs[ids[i]] = struct{}{}
  15843. }
  15844. }
  15845. // ClearWxs clears the "wxs" edge to the Wx entity.
  15846. func (m *ServerMutation) ClearWxs() {
  15847. m.clearedwxs = true
  15848. }
  15849. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15850. func (m *ServerMutation) WxsCleared() bool {
  15851. return m.clearedwxs
  15852. }
  15853. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15854. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15855. if m.removedwxs == nil {
  15856. m.removedwxs = make(map[uint64]struct{})
  15857. }
  15858. for i := range ids {
  15859. delete(m.wxs, ids[i])
  15860. m.removedwxs[ids[i]] = struct{}{}
  15861. }
  15862. }
  15863. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15864. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15865. for id := range m.removedwxs {
  15866. ids = append(ids, id)
  15867. }
  15868. return
  15869. }
  15870. // WxsIDs returns the "wxs" edge IDs in the mutation.
  15871. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  15872. for id := range m.wxs {
  15873. ids = append(ids, id)
  15874. }
  15875. return
  15876. }
  15877. // ResetWxs resets all changes to the "wxs" edge.
  15878. func (m *ServerMutation) ResetWxs() {
  15879. m.wxs = nil
  15880. m.clearedwxs = false
  15881. m.removedwxs = nil
  15882. }
  15883. // Where appends a list predicates to the ServerMutation builder.
  15884. func (m *ServerMutation) Where(ps ...predicate.Server) {
  15885. m.predicates = append(m.predicates, ps...)
  15886. }
  15887. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  15888. // users can use type-assertion to append predicates that do not depend on any generated package.
  15889. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  15890. p := make([]predicate.Server, len(ps))
  15891. for i := range ps {
  15892. p[i] = ps[i]
  15893. }
  15894. m.Where(p...)
  15895. }
  15896. // Op returns the operation name.
  15897. func (m *ServerMutation) Op() Op {
  15898. return m.op
  15899. }
  15900. // SetOp allows setting the mutation operation.
  15901. func (m *ServerMutation) SetOp(op Op) {
  15902. m.op = op
  15903. }
  15904. // Type returns the node type of this mutation (Server).
  15905. func (m *ServerMutation) Type() string {
  15906. return m.typ
  15907. }
  15908. // Fields returns all fields that were changed during this mutation. Note that in
  15909. // order to get all numeric fields that were incremented/decremented, call
  15910. // AddedFields().
  15911. func (m *ServerMutation) Fields() []string {
  15912. fields := make([]string, 0, 8)
  15913. if m.created_at != nil {
  15914. fields = append(fields, server.FieldCreatedAt)
  15915. }
  15916. if m.updated_at != nil {
  15917. fields = append(fields, server.FieldUpdatedAt)
  15918. }
  15919. if m.status != nil {
  15920. fields = append(fields, server.FieldStatus)
  15921. }
  15922. if m.deleted_at != nil {
  15923. fields = append(fields, server.FieldDeletedAt)
  15924. }
  15925. if m.name != nil {
  15926. fields = append(fields, server.FieldName)
  15927. }
  15928. if m.public_ip != nil {
  15929. fields = append(fields, server.FieldPublicIP)
  15930. }
  15931. if m.private_ip != nil {
  15932. fields = append(fields, server.FieldPrivateIP)
  15933. }
  15934. if m.admin_port != nil {
  15935. fields = append(fields, server.FieldAdminPort)
  15936. }
  15937. return fields
  15938. }
  15939. // Field returns the value of a field with the given name. The second boolean
  15940. // return value indicates that this field was not set, or was not defined in the
  15941. // schema.
  15942. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  15943. switch name {
  15944. case server.FieldCreatedAt:
  15945. return m.CreatedAt()
  15946. case server.FieldUpdatedAt:
  15947. return m.UpdatedAt()
  15948. case server.FieldStatus:
  15949. return m.Status()
  15950. case server.FieldDeletedAt:
  15951. return m.DeletedAt()
  15952. case server.FieldName:
  15953. return m.Name()
  15954. case server.FieldPublicIP:
  15955. return m.PublicIP()
  15956. case server.FieldPrivateIP:
  15957. return m.PrivateIP()
  15958. case server.FieldAdminPort:
  15959. return m.AdminPort()
  15960. }
  15961. return nil, false
  15962. }
  15963. // OldField returns the old value of the field from the database. An error is
  15964. // returned if the mutation operation is not UpdateOne, or the query to the
  15965. // database failed.
  15966. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15967. switch name {
  15968. case server.FieldCreatedAt:
  15969. return m.OldCreatedAt(ctx)
  15970. case server.FieldUpdatedAt:
  15971. return m.OldUpdatedAt(ctx)
  15972. case server.FieldStatus:
  15973. return m.OldStatus(ctx)
  15974. case server.FieldDeletedAt:
  15975. return m.OldDeletedAt(ctx)
  15976. case server.FieldName:
  15977. return m.OldName(ctx)
  15978. case server.FieldPublicIP:
  15979. return m.OldPublicIP(ctx)
  15980. case server.FieldPrivateIP:
  15981. return m.OldPrivateIP(ctx)
  15982. case server.FieldAdminPort:
  15983. return m.OldAdminPort(ctx)
  15984. }
  15985. return nil, fmt.Errorf("unknown Server field %s", name)
  15986. }
  15987. // SetField sets the value of a field with the given name. It returns an error if
  15988. // the field is not defined in the schema, or if the type mismatched the field
  15989. // type.
  15990. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  15991. switch name {
  15992. case server.FieldCreatedAt:
  15993. v, ok := value.(time.Time)
  15994. if !ok {
  15995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15996. }
  15997. m.SetCreatedAt(v)
  15998. return nil
  15999. case server.FieldUpdatedAt:
  16000. v, ok := value.(time.Time)
  16001. if !ok {
  16002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16003. }
  16004. m.SetUpdatedAt(v)
  16005. return nil
  16006. case server.FieldStatus:
  16007. v, ok := value.(uint8)
  16008. if !ok {
  16009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16010. }
  16011. m.SetStatus(v)
  16012. return nil
  16013. case server.FieldDeletedAt:
  16014. v, ok := value.(time.Time)
  16015. if !ok {
  16016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16017. }
  16018. m.SetDeletedAt(v)
  16019. return nil
  16020. case server.FieldName:
  16021. v, ok := value.(string)
  16022. if !ok {
  16023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16024. }
  16025. m.SetName(v)
  16026. return nil
  16027. case server.FieldPublicIP:
  16028. v, ok := value.(string)
  16029. if !ok {
  16030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16031. }
  16032. m.SetPublicIP(v)
  16033. return nil
  16034. case server.FieldPrivateIP:
  16035. v, ok := value.(string)
  16036. if !ok {
  16037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16038. }
  16039. m.SetPrivateIP(v)
  16040. return nil
  16041. case server.FieldAdminPort:
  16042. v, ok := value.(string)
  16043. if !ok {
  16044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16045. }
  16046. m.SetAdminPort(v)
  16047. return nil
  16048. }
  16049. return fmt.Errorf("unknown Server field %s", name)
  16050. }
  16051. // AddedFields returns all numeric fields that were incremented/decremented during
  16052. // this mutation.
  16053. func (m *ServerMutation) AddedFields() []string {
  16054. var fields []string
  16055. if m.addstatus != nil {
  16056. fields = append(fields, server.FieldStatus)
  16057. }
  16058. return fields
  16059. }
  16060. // AddedField returns the numeric value that was incremented/decremented on a field
  16061. // with the given name. The second boolean return value indicates that this field
  16062. // was not set, or was not defined in the schema.
  16063. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16064. switch name {
  16065. case server.FieldStatus:
  16066. return m.AddedStatus()
  16067. }
  16068. return nil, false
  16069. }
  16070. // AddField adds the value to the field with the given name. It returns an error if
  16071. // the field is not defined in the schema, or if the type mismatched the field
  16072. // type.
  16073. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16074. switch name {
  16075. case server.FieldStatus:
  16076. v, ok := value.(int8)
  16077. if !ok {
  16078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16079. }
  16080. m.AddStatus(v)
  16081. return nil
  16082. }
  16083. return fmt.Errorf("unknown Server numeric field %s", name)
  16084. }
  16085. // ClearedFields returns all nullable fields that were cleared during this
  16086. // mutation.
  16087. func (m *ServerMutation) ClearedFields() []string {
  16088. var fields []string
  16089. if m.FieldCleared(server.FieldStatus) {
  16090. fields = append(fields, server.FieldStatus)
  16091. }
  16092. if m.FieldCleared(server.FieldDeletedAt) {
  16093. fields = append(fields, server.FieldDeletedAt)
  16094. }
  16095. return fields
  16096. }
  16097. // FieldCleared returns a boolean indicating if a field with the given name was
  16098. // cleared in this mutation.
  16099. func (m *ServerMutation) FieldCleared(name string) bool {
  16100. _, ok := m.clearedFields[name]
  16101. return ok
  16102. }
  16103. // ClearField clears the value of the field with the given name. It returns an
  16104. // error if the field is not defined in the schema.
  16105. func (m *ServerMutation) ClearField(name string) error {
  16106. switch name {
  16107. case server.FieldStatus:
  16108. m.ClearStatus()
  16109. return nil
  16110. case server.FieldDeletedAt:
  16111. m.ClearDeletedAt()
  16112. return nil
  16113. }
  16114. return fmt.Errorf("unknown Server nullable field %s", name)
  16115. }
  16116. // ResetField resets all changes in the mutation for the field with the given name.
  16117. // It returns an error if the field is not defined in the schema.
  16118. func (m *ServerMutation) ResetField(name string) error {
  16119. switch name {
  16120. case server.FieldCreatedAt:
  16121. m.ResetCreatedAt()
  16122. return nil
  16123. case server.FieldUpdatedAt:
  16124. m.ResetUpdatedAt()
  16125. return nil
  16126. case server.FieldStatus:
  16127. m.ResetStatus()
  16128. return nil
  16129. case server.FieldDeletedAt:
  16130. m.ResetDeletedAt()
  16131. return nil
  16132. case server.FieldName:
  16133. m.ResetName()
  16134. return nil
  16135. case server.FieldPublicIP:
  16136. m.ResetPublicIP()
  16137. return nil
  16138. case server.FieldPrivateIP:
  16139. m.ResetPrivateIP()
  16140. return nil
  16141. case server.FieldAdminPort:
  16142. m.ResetAdminPort()
  16143. return nil
  16144. }
  16145. return fmt.Errorf("unknown Server field %s", name)
  16146. }
  16147. // AddedEdges returns all edge names that were set/added in this mutation.
  16148. func (m *ServerMutation) AddedEdges() []string {
  16149. edges := make([]string, 0, 1)
  16150. if m.wxs != nil {
  16151. edges = append(edges, server.EdgeWxs)
  16152. }
  16153. return edges
  16154. }
  16155. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16156. // name in this mutation.
  16157. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16158. switch name {
  16159. case server.EdgeWxs:
  16160. ids := make([]ent.Value, 0, len(m.wxs))
  16161. for id := range m.wxs {
  16162. ids = append(ids, id)
  16163. }
  16164. return ids
  16165. }
  16166. return nil
  16167. }
  16168. // RemovedEdges returns all edge names that were removed in this mutation.
  16169. func (m *ServerMutation) RemovedEdges() []string {
  16170. edges := make([]string, 0, 1)
  16171. if m.removedwxs != nil {
  16172. edges = append(edges, server.EdgeWxs)
  16173. }
  16174. return edges
  16175. }
  16176. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16177. // the given name in this mutation.
  16178. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16179. switch name {
  16180. case server.EdgeWxs:
  16181. ids := make([]ent.Value, 0, len(m.removedwxs))
  16182. for id := range m.removedwxs {
  16183. ids = append(ids, id)
  16184. }
  16185. return ids
  16186. }
  16187. return nil
  16188. }
  16189. // ClearedEdges returns all edge names that were cleared in this mutation.
  16190. func (m *ServerMutation) ClearedEdges() []string {
  16191. edges := make([]string, 0, 1)
  16192. if m.clearedwxs {
  16193. edges = append(edges, server.EdgeWxs)
  16194. }
  16195. return edges
  16196. }
  16197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16198. // was cleared in this mutation.
  16199. func (m *ServerMutation) EdgeCleared(name string) bool {
  16200. switch name {
  16201. case server.EdgeWxs:
  16202. return m.clearedwxs
  16203. }
  16204. return false
  16205. }
  16206. // ClearEdge clears the value of the edge with the given name. It returns an error
  16207. // if that edge is not defined in the schema.
  16208. func (m *ServerMutation) ClearEdge(name string) error {
  16209. switch name {
  16210. }
  16211. return fmt.Errorf("unknown Server unique edge %s", name)
  16212. }
  16213. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16214. // It returns an error if the edge is not defined in the schema.
  16215. func (m *ServerMutation) ResetEdge(name string) error {
  16216. switch name {
  16217. case server.EdgeWxs:
  16218. m.ResetWxs()
  16219. return nil
  16220. }
  16221. return fmt.Errorf("unknown Server edge %s", name)
  16222. }
  16223. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16224. type SopNodeMutation struct {
  16225. config
  16226. op Op
  16227. typ string
  16228. id *uint64
  16229. created_at *time.Time
  16230. updated_at *time.Time
  16231. status *uint8
  16232. addstatus *int8
  16233. deleted_at *time.Time
  16234. parent_id *uint64
  16235. addparent_id *int64
  16236. name *string
  16237. condition_type *int
  16238. addcondition_type *int
  16239. condition_list *[]string
  16240. appendcondition_list []string
  16241. no_reply_condition *uint64
  16242. addno_reply_condition *int64
  16243. no_reply_unit *string
  16244. action_message *[]custom_types.Action
  16245. appendaction_message []custom_types.Action
  16246. action_label_add *[]uint64
  16247. appendaction_label_add []uint64
  16248. action_label_del *[]uint64
  16249. appendaction_label_del []uint64
  16250. action_forward **custom_types.ActionForward
  16251. clearedFields map[string]struct{}
  16252. sop_stage *uint64
  16253. clearedsop_stage bool
  16254. node_messages map[uint64]struct{}
  16255. removednode_messages map[uint64]struct{}
  16256. clearednode_messages bool
  16257. done bool
  16258. oldValue func(context.Context) (*SopNode, error)
  16259. predicates []predicate.SopNode
  16260. }
  16261. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16262. // sopnodeOption allows management of the mutation configuration using functional options.
  16263. type sopnodeOption func(*SopNodeMutation)
  16264. // newSopNodeMutation creates new mutation for the SopNode entity.
  16265. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16266. m := &SopNodeMutation{
  16267. config: c,
  16268. op: op,
  16269. typ: TypeSopNode,
  16270. clearedFields: make(map[string]struct{}),
  16271. }
  16272. for _, opt := range opts {
  16273. opt(m)
  16274. }
  16275. return m
  16276. }
  16277. // withSopNodeID sets the ID field of the mutation.
  16278. func withSopNodeID(id uint64) sopnodeOption {
  16279. return func(m *SopNodeMutation) {
  16280. var (
  16281. err error
  16282. once sync.Once
  16283. value *SopNode
  16284. )
  16285. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16286. once.Do(func() {
  16287. if m.done {
  16288. err = errors.New("querying old values post mutation is not allowed")
  16289. } else {
  16290. value, err = m.Client().SopNode.Get(ctx, id)
  16291. }
  16292. })
  16293. return value, err
  16294. }
  16295. m.id = &id
  16296. }
  16297. }
  16298. // withSopNode sets the old SopNode of the mutation.
  16299. func withSopNode(node *SopNode) sopnodeOption {
  16300. return func(m *SopNodeMutation) {
  16301. m.oldValue = func(context.Context) (*SopNode, error) {
  16302. return node, nil
  16303. }
  16304. m.id = &node.ID
  16305. }
  16306. }
  16307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16308. // executed in a transaction (ent.Tx), a transactional client is returned.
  16309. func (m SopNodeMutation) Client() *Client {
  16310. client := &Client{config: m.config}
  16311. client.init()
  16312. return client
  16313. }
  16314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16315. // it returns an error otherwise.
  16316. func (m SopNodeMutation) Tx() (*Tx, error) {
  16317. if _, ok := m.driver.(*txDriver); !ok {
  16318. return nil, errors.New("ent: mutation is not running in a transaction")
  16319. }
  16320. tx := &Tx{config: m.config}
  16321. tx.init()
  16322. return tx, nil
  16323. }
  16324. // SetID sets the value of the id field. Note that this
  16325. // operation is only accepted on creation of SopNode entities.
  16326. func (m *SopNodeMutation) SetID(id uint64) {
  16327. m.id = &id
  16328. }
  16329. // ID returns the ID value in the mutation. Note that the ID is only available
  16330. // if it was provided to the builder or after it was returned from the database.
  16331. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16332. if m.id == nil {
  16333. return
  16334. }
  16335. return *m.id, true
  16336. }
  16337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16338. // That means, if the mutation is applied within a transaction with an isolation level such
  16339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16340. // or updated by the mutation.
  16341. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16342. switch {
  16343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16344. id, exists := m.ID()
  16345. if exists {
  16346. return []uint64{id}, nil
  16347. }
  16348. fallthrough
  16349. case m.op.Is(OpUpdate | OpDelete):
  16350. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16351. default:
  16352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16353. }
  16354. }
  16355. // SetCreatedAt sets the "created_at" field.
  16356. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16357. m.created_at = &t
  16358. }
  16359. // CreatedAt returns the value of the "created_at" field in the mutation.
  16360. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16361. v := m.created_at
  16362. if v == nil {
  16363. return
  16364. }
  16365. return *v, true
  16366. }
  16367. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16368. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16370. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16371. if !m.op.Is(OpUpdateOne) {
  16372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16373. }
  16374. if m.id == nil || m.oldValue == nil {
  16375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16376. }
  16377. oldValue, err := m.oldValue(ctx)
  16378. if err != nil {
  16379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16380. }
  16381. return oldValue.CreatedAt, nil
  16382. }
  16383. // ResetCreatedAt resets all changes to the "created_at" field.
  16384. func (m *SopNodeMutation) ResetCreatedAt() {
  16385. m.created_at = nil
  16386. }
  16387. // SetUpdatedAt sets the "updated_at" field.
  16388. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16389. m.updated_at = &t
  16390. }
  16391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16392. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16393. v := m.updated_at
  16394. if v == nil {
  16395. return
  16396. }
  16397. return *v, true
  16398. }
  16399. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16400. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16402. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16403. if !m.op.Is(OpUpdateOne) {
  16404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16405. }
  16406. if m.id == nil || m.oldValue == nil {
  16407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16408. }
  16409. oldValue, err := m.oldValue(ctx)
  16410. if err != nil {
  16411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16412. }
  16413. return oldValue.UpdatedAt, nil
  16414. }
  16415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16416. func (m *SopNodeMutation) ResetUpdatedAt() {
  16417. m.updated_at = nil
  16418. }
  16419. // SetStatus sets the "status" field.
  16420. func (m *SopNodeMutation) SetStatus(u uint8) {
  16421. m.status = &u
  16422. m.addstatus = nil
  16423. }
  16424. // Status returns the value of the "status" field in the mutation.
  16425. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16426. v := m.status
  16427. if v == nil {
  16428. return
  16429. }
  16430. return *v, true
  16431. }
  16432. // OldStatus returns the old "status" field's value of the SopNode entity.
  16433. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16435. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16436. if !m.op.Is(OpUpdateOne) {
  16437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16438. }
  16439. if m.id == nil || m.oldValue == nil {
  16440. return v, errors.New("OldStatus requires an ID field in the mutation")
  16441. }
  16442. oldValue, err := m.oldValue(ctx)
  16443. if err != nil {
  16444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16445. }
  16446. return oldValue.Status, nil
  16447. }
  16448. // AddStatus adds u to the "status" field.
  16449. func (m *SopNodeMutation) AddStatus(u int8) {
  16450. if m.addstatus != nil {
  16451. *m.addstatus += u
  16452. } else {
  16453. m.addstatus = &u
  16454. }
  16455. }
  16456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16457. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16458. v := m.addstatus
  16459. if v == nil {
  16460. return
  16461. }
  16462. return *v, true
  16463. }
  16464. // ClearStatus clears the value of the "status" field.
  16465. func (m *SopNodeMutation) ClearStatus() {
  16466. m.status = nil
  16467. m.addstatus = nil
  16468. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16469. }
  16470. // StatusCleared returns if the "status" field was cleared in this mutation.
  16471. func (m *SopNodeMutation) StatusCleared() bool {
  16472. _, ok := m.clearedFields[sopnode.FieldStatus]
  16473. return ok
  16474. }
  16475. // ResetStatus resets all changes to the "status" field.
  16476. func (m *SopNodeMutation) ResetStatus() {
  16477. m.status = nil
  16478. m.addstatus = nil
  16479. delete(m.clearedFields, sopnode.FieldStatus)
  16480. }
  16481. // SetDeletedAt sets the "deleted_at" field.
  16482. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16483. m.deleted_at = &t
  16484. }
  16485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16486. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16487. v := m.deleted_at
  16488. if v == nil {
  16489. return
  16490. }
  16491. return *v, true
  16492. }
  16493. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16494. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16496. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16497. if !m.op.Is(OpUpdateOne) {
  16498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16499. }
  16500. if m.id == nil || m.oldValue == nil {
  16501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16502. }
  16503. oldValue, err := m.oldValue(ctx)
  16504. if err != nil {
  16505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16506. }
  16507. return oldValue.DeletedAt, nil
  16508. }
  16509. // ClearDeletedAt clears the value of the "deleted_at" field.
  16510. func (m *SopNodeMutation) ClearDeletedAt() {
  16511. m.deleted_at = nil
  16512. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16513. }
  16514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16515. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16516. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16517. return ok
  16518. }
  16519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16520. func (m *SopNodeMutation) ResetDeletedAt() {
  16521. m.deleted_at = nil
  16522. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16523. }
  16524. // SetStageID sets the "stage_id" field.
  16525. func (m *SopNodeMutation) SetStageID(u uint64) {
  16526. m.sop_stage = &u
  16527. }
  16528. // StageID returns the value of the "stage_id" field in the mutation.
  16529. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16530. v := m.sop_stage
  16531. if v == nil {
  16532. return
  16533. }
  16534. return *v, true
  16535. }
  16536. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16537. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16539. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16540. if !m.op.Is(OpUpdateOne) {
  16541. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16542. }
  16543. if m.id == nil || m.oldValue == nil {
  16544. return v, errors.New("OldStageID requires an ID field in the mutation")
  16545. }
  16546. oldValue, err := m.oldValue(ctx)
  16547. if err != nil {
  16548. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16549. }
  16550. return oldValue.StageID, nil
  16551. }
  16552. // ResetStageID resets all changes to the "stage_id" field.
  16553. func (m *SopNodeMutation) ResetStageID() {
  16554. m.sop_stage = nil
  16555. }
  16556. // SetParentID sets the "parent_id" field.
  16557. func (m *SopNodeMutation) SetParentID(u uint64) {
  16558. m.parent_id = &u
  16559. m.addparent_id = nil
  16560. }
  16561. // ParentID returns the value of the "parent_id" field in the mutation.
  16562. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16563. v := m.parent_id
  16564. if v == nil {
  16565. return
  16566. }
  16567. return *v, true
  16568. }
  16569. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16570. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16572. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16573. if !m.op.Is(OpUpdateOne) {
  16574. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16575. }
  16576. if m.id == nil || m.oldValue == nil {
  16577. return v, errors.New("OldParentID requires an ID field in the mutation")
  16578. }
  16579. oldValue, err := m.oldValue(ctx)
  16580. if err != nil {
  16581. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16582. }
  16583. return oldValue.ParentID, nil
  16584. }
  16585. // AddParentID adds u to the "parent_id" field.
  16586. func (m *SopNodeMutation) AddParentID(u int64) {
  16587. if m.addparent_id != nil {
  16588. *m.addparent_id += u
  16589. } else {
  16590. m.addparent_id = &u
  16591. }
  16592. }
  16593. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16594. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16595. v := m.addparent_id
  16596. if v == nil {
  16597. return
  16598. }
  16599. return *v, true
  16600. }
  16601. // ResetParentID resets all changes to the "parent_id" field.
  16602. func (m *SopNodeMutation) ResetParentID() {
  16603. m.parent_id = nil
  16604. m.addparent_id = nil
  16605. }
  16606. // SetName sets the "name" field.
  16607. func (m *SopNodeMutation) SetName(s string) {
  16608. m.name = &s
  16609. }
  16610. // Name returns the value of the "name" field in the mutation.
  16611. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16612. v := m.name
  16613. if v == nil {
  16614. return
  16615. }
  16616. return *v, true
  16617. }
  16618. // OldName returns the old "name" field's value of the SopNode entity.
  16619. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16621. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16622. if !m.op.Is(OpUpdateOne) {
  16623. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16624. }
  16625. if m.id == nil || m.oldValue == nil {
  16626. return v, errors.New("OldName requires an ID field in the mutation")
  16627. }
  16628. oldValue, err := m.oldValue(ctx)
  16629. if err != nil {
  16630. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16631. }
  16632. return oldValue.Name, nil
  16633. }
  16634. // ResetName resets all changes to the "name" field.
  16635. func (m *SopNodeMutation) ResetName() {
  16636. m.name = nil
  16637. }
  16638. // SetConditionType sets the "condition_type" field.
  16639. func (m *SopNodeMutation) SetConditionType(i int) {
  16640. m.condition_type = &i
  16641. m.addcondition_type = nil
  16642. }
  16643. // ConditionType returns the value of the "condition_type" field in the mutation.
  16644. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16645. v := m.condition_type
  16646. if v == nil {
  16647. return
  16648. }
  16649. return *v, true
  16650. }
  16651. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16652. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16654. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16655. if !m.op.Is(OpUpdateOne) {
  16656. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16657. }
  16658. if m.id == nil || m.oldValue == nil {
  16659. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16660. }
  16661. oldValue, err := m.oldValue(ctx)
  16662. if err != nil {
  16663. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16664. }
  16665. return oldValue.ConditionType, nil
  16666. }
  16667. // AddConditionType adds i to the "condition_type" field.
  16668. func (m *SopNodeMutation) AddConditionType(i int) {
  16669. if m.addcondition_type != nil {
  16670. *m.addcondition_type += i
  16671. } else {
  16672. m.addcondition_type = &i
  16673. }
  16674. }
  16675. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16676. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16677. v := m.addcondition_type
  16678. if v == nil {
  16679. return
  16680. }
  16681. return *v, true
  16682. }
  16683. // ResetConditionType resets all changes to the "condition_type" field.
  16684. func (m *SopNodeMutation) ResetConditionType() {
  16685. m.condition_type = nil
  16686. m.addcondition_type = nil
  16687. }
  16688. // SetConditionList sets the "condition_list" field.
  16689. func (m *SopNodeMutation) SetConditionList(s []string) {
  16690. m.condition_list = &s
  16691. m.appendcondition_list = nil
  16692. }
  16693. // ConditionList returns the value of the "condition_list" field in the mutation.
  16694. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16695. v := m.condition_list
  16696. if v == nil {
  16697. return
  16698. }
  16699. return *v, true
  16700. }
  16701. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16702. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16704. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16705. if !m.op.Is(OpUpdateOne) {
  16706. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16707. }
  16708. if m.id == nil || m.oldValue == nil {
  16709. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16710. }
  16711. oldValue, err := m.oldValue(ctx)
  16712. if err != nil {
  16713. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16714. }
  16715. return oldValue.ConditionList, nil
  16716. }
  16717. // AppendConditionList adds s to the "condition_list" field.
  16718. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16719. m.appendcondition_list = append(m.appendcondition_list, s...)
  16720. }
  16721. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16722. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16723. if len(m.appendcondition_list) == 0 {
  16724. return nil, false
  16725. }
  16726. return m.appendcondition_list, true
  16727. }
  16728. // ClearConditionList clears the value of the "condition_list" field.
  16729. func (m *SopNodeMutation) ClearConditionList() {
  16730. m.condition_list = nil
  16731. m.appendcondition_list = nil
  16732. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16733. }
  16734. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16735. func (m *SopNodeMutation) ConditionListCleared() bool {
  16736. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16737. return ok
  16738. }
  16739. // ResetConditionList resets all changes to the "condition_list" field.
  16740. func (m *SopNodeMutation) ResetConditionList() {
  16741. m.condition_list = nil
  16742. m.appendcondition_list = nil
  16743. delete(m.clearedFields, sopnode.FieldConditionList)
  16744. }
  16745. // SetNoReplyCondition sets the "no_reply_condition" field.
  16746. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16747. m.no_reply_condition = &u
  16748. m.addno_reply_condition = nil
  16749. }
  16750. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16751. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16752. v := m.no_reply_condition
  16753. if v == nil {
  16754. return
  16755. }
  16756. return *v, true
  16757. }
  16758. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16759. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16761. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16762. if !m.op.Is(OpUpdateOne) {
  16763. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16764. }
  16765. if m.id == nil || m.oldValue == nil {
  16766. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16767. }
  16768. oldValue, err := m.oldValue(ctx)
  16769. if err != nil {
  16770. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16771. }
  16772. return oldValue.NoReplyCondition, nil
  16773. }
  16774. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16775. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16776. if m.addno_reply_condition != nil {
  16777. *m.addno_reply_condition += u
  16778. } else {
  16779. m.addno_reply_condition = &u
  16780. }
  16781. }
  16782. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16783. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16784. v := m.addno_reply_condition
  16785. if v == nil {
  16786. return
  16787. }
  16788. return *v, true
  16789. }
  16790. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16791. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16792. m.no_reply_condition = nil
  16793. m.addno_reply_condition = nil
  16794. }
  16795. // SetNoReplyUnit sets the "no_reply_unit" field.
  16796. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16797. m.no_reply_unit = &s
  16798. }
  16799. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16800. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16801. v := m.no_reply_unit
  16802. if v == nil {
  16803. return
  16804. }
  16805. return *v, true
  16806. }
  16807. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16808. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16810. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16811. if !m.op.Is(OpUpdateOne) {
  16812. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16813. }
  16814. if m.id == nil || m.oldValue == nil {
  16815. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16816. }
  16817. oldValue, err := m.oldValue(ctx)
  16818. if err != nil {
  16819. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16820. }
  16821. return oldValue.NoReplyUnit, nil
  16822. }
  16823. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16824. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16825. m.no_reply_unit = nil
  16826. }
  16827. // SetActionMessage sets the "action_message" field.
  16828. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16829. m.action_message = &ct
  16830. m.appendaction_message = nil
  16831. }
  16832. // ActionMessage returns the value of the "action_message" field in the mutation.
  16833. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16834. v := m.action_message
  16835. if v == nil {
  16836. return
  16837. }
  16838. return *v, true
  16839. }
  16840. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16841. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16843. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16844. if !m.op.Is(OpUpdateOne) {
  16845. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16846. }
  16847. if m.id == nil || m.oldValue == nil {
  16848. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16849. }
  16850. oldValue, err := m.oldValue(ctx)
  16851. if err != nil {
  16852. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16853. }
  16854. return oldValue.ActionMessage, nil
  16855. }
  16856. // AppendActionMessage adds ct to the "action_message" field.
  16857. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16858. m.appendaction_message = append(m.appendaction_message, ct...)
  16859. }
  16860. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16861. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16862. if len(m.appendaction_message) == 0 {
  16863. return nil, false
  16864. }
  16865. return m.appendaction_message, true
  16866. }
  16867. // ClearActionMessage clears the value of the "action_message" field.
  16868. func (m *SopNodeMutation) ClearActionMessage() {
  16869. m.action_message = nil
  16870. m.appendaction_message = nil
  16871. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  16872. }
  16873. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  16874. func (m *SopNodeMutation) ActionMessageCleared() bool {
  16875. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  16876. return ok
  16877. }
  16878. // ResetActionMessage resets all changes to the "action_message" field.
  16879. func (m *SopNodeMutation) ResetActionMessage() {
  16880. m.action_message = nil
  16881. m.appendaction_message = nil
  16882. delete(m.clearedFields, sopnode.FieldActionMessage)
  16883. }
  16884. // SetActionLabelAdd sets the "action_label_add" field.
  16885. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  16886. m.action_label_add = &u
  16887. m.appendaction_label_add = nil
  16888. }
  16889. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16890. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16891. v := m.action_label_add
  16892. if v == nil {
  16893. return
  16894. }
  16895. return *v, true
  16896. }
  16897. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  16898. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16900. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16901. if !m.op.Is(OpUpdateOne) {
  16902. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16903. }
  16904. if m.id == nil || m.oldValue == nil {
  16905. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16906. }
  16907. oldValue, err := m.oldValue(ctx)
  16908. if err != nil {
  16909. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16910. }
  16911. return oldValue.ActionLabelAdd, nil
  16912. }
  16913. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16914. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  16915. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16916. }
  16917. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16918. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16919. if len(m.appendaction_label_add) == 0 {
  16920. return nil, false
  16921. }
  16922. return m.appendaction_label_add, true
  16923. }
  16924. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16925. func (m *SopNodeMutation) ClearActionLabelAdd() {
  16926. m.action_label_add = nil
  16927. m.appendaction_label_add = nil
  16928. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  16929. }
  16930. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16931. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  16932. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  16933. return ok
  16934. }
  16935. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16936. func (m *SopNodeMutation) ResetActionLabelAdd() {
  16937. m.action_label_add = nil
  16938. m.appendaction_label_add = nil
  16939. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  16940. }
  16941. // SetActionLabelDel sets the "action_label_del" field.
  16942. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  16943. m.action_label_del = &u
  16944. m.appendaction_label_del = nil
  16945. }
  16946. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16947. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  16948. v := m.action_label_del
  16949. if v == nil {
  16950. return
  16951. }
  16952. return *v, true
  16953. }
  16954. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  16955. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16957. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16958. if !m.op.Is(OpUpdateOne) {
  16959. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16960. }
  16961. if m.id == nil || m.oldValue == nil {
  16962. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16963. }
  16964. oldValue, err := m.oldValue(ctx)
  16965. if err != nil {
  16966. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16967. }
  16968. return oldValue.ActionLabelDel, nil
  16969. }
  16970. // AppendActionLabelDel adds u to the "action_label_del" field.
  16971. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  16972. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16973. }
  16974. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16975. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16976. if len(m.appendaction_label_del) == 0 {
  16977. return nil, false
  16978. }
  16979. return m.appendaction_label_del, true
  16980. }
  16981. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16982. func (m *SopNodeMutation) ClearActionLabelDel() {
  16983. m.action_label_del = nil
  16984. m.appendaction_label_del = nil
  16985. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  16986. }
  16987. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16988. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  16989. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  16990. return ok
  16991. }
  16992. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16993. func (m *SopNodeMutation) ResetActionLabelDel() {
  16994. m.action_label_del = nil
  16995. m.appendaction_label_del = nil
  16996. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  16997. }
  16998. // SetActionForward sets the "action_forward" field.
  16999. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17000. m.action_forward = &ctf
  17001. }
  17002. // ActionForward returns the value of the "action_forward" field in the mutation.
  17003. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17004. v := m.action_forward
  17005. if v == nil {
  17006. return
  17007. }
  17008. return *v, true
  17009. }
  17010. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17011. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17013. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17014. if !m.op.Is(OpUpdateOne) {
  17015. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17016. }
  17017. if m.id == nil || m.oldValue == nil {
  17018. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17019. }
  17020. oldValue, err := m.oldValue(ctx)
  17021. if err != nil {
  17022. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17023. }
  17024. return oldValue.ActionForward, nil
  17025. }
  17026. // ClearActionForward clears the value of the "action_forward" field.
  17027. func (m *SopNodeMutation) ClearActionForward() {
  17028. m.action_forward = nil
  17029. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17030. }
  17031. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17032. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17033. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17034. return ok
  17035. }
  17036. // ResetActionForward resets all changes to the "action_forward" field.
  17037. func (m *SopNodeMutation) ResetActionForward() {
  17038. m.action_forward = nil
  17039. delete(m.clearedFields, sopnode.FieldActionForward)
  17040. }
  17041. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17042. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17043. m.sop_stage = &id
  17044. }
  17045. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17046. func (m *SopNodeMutation) ClearSopStage() {
  17047. m.clearedsop_stage = true
  17048. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17049. }
  17050. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17051. func (m *SopNodeMutation) SopStageCleared() bool {
  17052. return m.clearedsop_stage
  17053. }
  17054. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17055. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17056. if m.sop_stage != nil {
  17057. return *m.sop_stage, true
  17058. }
  17059. return
  17060. }
  17061. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17062. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17063. // SopStageID instead. It exists only for internal usage by the builders.
  17064. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17065. if id := m.sop_stage; id != nil {
  17066. ids = append(ids, *id)
  17067. }
  17068. return
  17069. }
  17070. // ResetSopStage resets all changes to the "sop_stage" edge.
  17071. func (m *SopNodeMutation) ResetSopStage() {
  17072. m.sop_stage = nil
  17073. m.clearedsop_stage = false
  17074. }
  17075. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17076. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17077. if m.node_messages == nil {
  17078. m.node_messages = make(map[uint64]struct{})
  17079. }
  17080. for i := range ids {
  17081. m.node_messages[ids[i]] = struct{}{}
  17082. }
  17083. }
  17084. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17085. func (m *SopNodeMutation) ClearNodeMessages() {
  17086. m.clearednode_messages = true
  17087. }
  17088. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17089. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17090. return m.clearednode_messages
  17091. }
  17092. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17093. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17094. if m.removednode_messages == nil {
  17095. m.removednode_messages = make(map[uint64]struct{})
  17096. }
  17097. for i := range ids {
  17098. delete(m.node_messages, ids[i])
  17099. m.removednode_messages[ids[i]] = struct{}{}
  17100. }
  17101. }
  17102. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17103. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17104. for id := range m.removednode_messages {
  17105. ids = append(ids, id)
  17106. }
  17107. return
  17108. }
  17109. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17110. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17111. for id := range m.node_messages {
  17112. ids = append(ids, id)
  17113. }
  17114. return
  17115. }
  17116. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17117. func (m *SopNodeMutation) ResetNodeMessages() {
  17118. m.node_messages = nil
  17119. m.clearednode_messages = false
  17120. m.removednode_messages = nil
  17121. }
  17122. // Where appends a list predicates to the SopNodeMutation builder.
  17123. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17124. m.predicates = append(m.predicates, ps...)
  17125. }
  17126. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17127. // users can use type-assertion to append predicates that do not depend on any generated package.
  17128. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17129. p := make([]predicate.SopNode, len(ps))
  17130. for i := range ps {
  17131. p[i] = ps[i]
  17132. }
  17133. m.Where(p...)
  17134. }
  17135. // Op returns the operation name.
  17136. func (m *SopNodeMutation) Op() Op {
  17137. return m.op
  17138. }
  17139. // SetOp allows setting the mutation operation.
  17140. func (m *SopNodeMutation) SetOp(op Op) {
  17141. m.op = op
  17142. }
  17143. // Type returns the node type of this mutation (SopNode).
  17144. func (m *SopNodeMutation) Type() string {
  17145. return m.typ
  17146. }
  17147. // Fields returns all fields that were changed during this mutation. Note that in
  17148. // order to get all numeric fields that were incremented/decremented, call
  17149. // AddedFields().
  17150. func (m *SopNodeMutation) Fields() []string {
  17151. fields := make([]string, 0, 15)
  17152. if m.created_at != nil {
  17153. fields = append(fields, sopnode.FieldCreatedAt)
  17154. }
  17155. if m.updated_at != nil {
  17156. fields = append(fields, sopnode.FieldUpdatedAt)
  17157. }
  17158. if m.status != nil {
  17159. fields = append(fields, sopnode.FieldStatus)
  17160. }
  17161. if m.deleted_at != nil {
  17162. fields = append(fields, sopnode.FieldDeletedAt)
  17163. }
  17164. if m.sop_stage != nil {
  17165. fields = append(fields, sopnode.FieldStageID)
  17166. }
  17167. if m.parent_id != nil {
  17168. fields = append(fields, sopnode.FieldParentID)
  17169. }
  17170. if m.name != nil {
  17171. fields = append(fields, sopnode.FieldName)
  17172. }
  17173. if m.condition_type != nil {
  17174. fields = append(fields, sopnode.FieldConditionType)
  17175. }
  17176. if m.condition_list != nil {
  17177. fields = append(fields, sopnode.FieldConditionList)
  17178. }
  17179. if m.no_reply_condition != nil {
  17180. fields = append(fields, sopnode.FieldNoReplyCondition)
  17181. }
  17182. if m.no_reply_unit != nil {
  17183. fields = append(fields, sopnode.FieldNoReplyUnit)
  17184. }
  17185. if m.action_message != nil {
  17186. fields = append(fields, sopnode.FieldActionMessage)
  17187. }
  17188. if m.action_label_add != nil {
  17189. fields = append(fields, sopnode.FieldActionLabelAdd)
  17190. }
  17191. if m.action_label_del != nil {
  17192. fields = append(fields, sopnode.FieldActionLabelDel)
  17193. }
  17194. if m.action_forward != nil {
  17195. fields = append(fields, sopnode.FieldActionForward)
  17196. }
  17197. return fields
  17198. }
  17199. // Field returns the value of a field with the given name. The second boolean
  17200. // return value indicates that this field was not set, or was not defined in the
  17201. // schema.
  17202. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17203. switch name {
  17204. case sopnode.FieldCreatedAt:
  17205. return m.CreatedAt()
  17206. case sopnode.FieldUpdatedAt:
  17207. return m.UpdatedAt()
  17208. case sopnode.FieldStatus:
  17209. return m.Status()
  17210. case sopnode.FieldDeletedAt:
  17211. return m.DeletedAt()
  17212. case sopnode.FieldStageID:
  17213. return m.StageID()
  17214. case sopnode.FieldParentID:
  17215. return m.ParentID()
  17216. case sopnode.FieldName:
  17217. return m.Name()
  17218. case sopnode.FieldConditionType:
  17219. return m.ConditionType()
  17220. case sopnode.FieldConditionList:
  17221. return m.ConditionList()
  17222. case sopnode.FieldNoReplyCondition:
  17223. return m.NoReplyCondition()
  17224. case sopnode.FieldNoReplyUnit:
  17225. return m.NoReplyUnit()
  17226. case sopnode.FieldActionMessage:
  17227. return m.ActionMessage()
  17228. case sopnode.FieldActionLabelAdd:
  17229. return m.ActionLabelAdd()
  17230. case sopnode.FieldActionLabelDel:
  17231. return m.ActionLabelDel()
  17232. case sopnode.FieldActionForward:
  17233. return m.ActionForward()
  17234. }
  17235. return nil, false
  17236. }
  17237. // OldField returns the old value of the field from the database. An error is
  17238. // returned if the mutation operation is not UpdateOne, or the query to the
  17239. // database failed.
  17240. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17241. switch name {
  17242. case sopnode.FieldCreatedAt:
  17243. return m.OldCreatedAt(ctx)
  17244. case sopnode.FieldUpdatedAt:
  17245. return m.OldUpdatedAt(ctx)
  17246. case sopnode.FieldStatus:
  17247. return m.OldStatus(ctx)
  17248. case sopnode.FieldDeletedAt:
  17249. return m.OldDeletedAt(ctx)
  17250. case sopnode.FieldStageID:
  17251. return m.OldStageID(ctx)
  17252. case sopnode.FieldParentID:
  17253. return m.OldParentID(ctx)
  17254. case sopnode.FieldName:
  17255. return m.OldName(ctx)
  17256. case sopnode.FieldConditionType:
  17257. return m.OldConditionType(ctx)
  17258. case sopnode.FieldConditionList:
  17259. return m.OldConditionList(ctx)
  17260. case sopnode.FieldNoReplyCondition:
  17261. return m.OldNoReplyCondition(ctx)
  17262. case sopnode.FieldNoReplyUnit:
  17263. return m.OldNoReplyUnit(ctx)
  17264. case sopnode.FieldActionMessage:
  17265. return m.OldActionMessage(ctx)
  17266. case sopnode.FieldActionLabelAdd:
  17267. return m.OldActionLabelAdd(ctx)
  17268. case sopnode.FieldActionLabelDel:
  17269. return m.OldActionLabelDel(ctx)
  17270. case sopnode.FieldActionForward:
  17271. return m.OldActionForward(ctx)
  17272. }
  17273. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17274. }
  17275. // SetField sets the value of a field with the given name. It returns an error if
  17276. // the field is not defined in the schema, or if the type mismatched the field
  17277. // type.
  17278. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17279. switch name {
  17280. case sopnode.FieldCreatedAt:
  17281. v, ok := value.(time.Time)
  17282. if !ok {
  17283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17284. }
  17285. m.SetCreatedAt(v)
  17286. return nil
  17287. case sopnode.FieldUpdatedAt:
  17288. v, ok := value.(time.Time)
  17289. if !ok {
  17290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17291. }
  17292. m.SetUpdatedAt(v)
  17293. return nil
  17294. case sopnode.FieldStatus:
  17295. v, ok := value.(uint8)
  17296. if !ok {
  17297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17298. }
  17299. m.SetStatus(v)
  17300. return nil
  17301. case sopnode.FieldDeletedAt:
  17302. v, ok := value.(time.Time)
  17303. if !ok {
  17304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17305. }
  17306. m.SetDeletedAt(v)
  17307. return nil
  17308. case sopnode.FieldStageID:
  17309. v, ok := value.(uint64)
  17310. if !ok {
  17311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17312. }
  17313. m.SetStageID(v)
  17314. return nil
  17315. case sopnode.FieldParentID:
  17316. v, ok := value.(uint64)
  17317. if !ok {
  17318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17319. }
  17320. m.SetParentID(v)
  17321. return nil
  17322. case sopnode.FieldName:
  17323. v, ok := value.(string)
  17324. if !ok {
  17325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17326. }
  17327. m.SetName(v)
  17328. return nil
  17329. case sopnode.FieldConditionType:
  17330. v, ok := value.(int)
  17331. if !ok {
  17332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17333. }
  17334. m.SetConditionType(v)
  17335. return nil
  17336. case sopnode.FieldConditionList:
  17337. v, ok := value.([]string)
  17338. if !ok {
  17339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17340. }
  17341. m.SetConditionList(v)
  17342. return nil
  17343. case sopnode.FieldNoReplyCondition:
  17344. v, ok := value.(uint64)
  17345. if !ok {
  17346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17347. }
  17348. m.SetNoReplyCondition(v)
  17349. return nil
  17350. case sopnode.FieldNoReplyUnit:
  17351. v, ok := value.(string)
  17352. if !ok {
  17353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17354. }
  17355. m.SetNoReplyUnit(v)
  17356. return nil
  17357. case sopnode.FieldActionMessage:
  17358. v, ok := value.([]custom_types.Action)
  17359. if !ok {
  17360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17361. }
  17362. m.SetActionMessage(v)
  17363. return nil
  17364. case sopnode.FieldActionLabelAdd:
  17365. v, ok := value.([]uint64)
  17366. if !ok {
  17367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17368. }
  17369. m.SetActionLabelAdd(v)
  17370. return nil
  17371. case sopnode.FieldActionLabelDel:
  17372. v, ok := value.([]uint64)
  17373. if !ok {
  17374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17375. }
  17376. m.SetActionLabelDel(v)
  17377. return nil
  17378. case sopnode.FieldActionForward:
  17379. v, ok := value.(*custom_types.ActionForward)
  17380. if !ok {
  17381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17382. }
  17383. m.SetActionForward(v)
  17384. return nil
  17385. }
  17386. return fmt.Errorf("unknown SopNode field %s", name)
  17387. }
  17388. // AddedFields returns all numeric fields that were incremented/decremented during
  17389. // this mutation.
  17390. func (m *SopNodeMutation) AddedFields() []string {
  17391. var fields []string
  17392. if m.addstatus != nil {
  17393. fields = append(fields, sopnode.FieldStatus)
  17394. }
  17395. if m.addparent_id != nil {
  17396. fields = append(fields, sopnode.FieldParentID)
  17397. }
  17398. if m.addcondition_type != nil {
  17399. fields = append(fields, sopnode.FieldConditionType)
  17400. }
  17401. if m.addno_reply_condition != nil {
  17402. fields = append(fields, sopnode.FieldNoReplyCondition)
  17403. }
  17404. return fields
  17405. }
  17406. // AddedField returns the numeric value that was incremented/decremented on a field
  17407. // with the given name. The second boolean return value indicates that this field
  17408. // was not set, or was not defined in the schema.
  17409. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17410. switch name {
  17411. case sopnode.FieldStatus:
  17412. return m.AddedStatus()
  17413. case sopnode.FieldParentID:
  17414. return m.AddedParentID()
  17415. case sopnode.FieldConditionType:
  17416. return m.AddedConditionType()
  17417. case sopnode.FieldNoReplyCondition:
  17418. return m.AddedNoReplyCondition()
  17419. }
  17420. return nil, false
  17421. }
  17422. // AddField adds the value to the field with the given name. It returns an error if
  17423. // the field is not defined in the schema, or if the type mismatched the field
  17424. // type.
  17425. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17426. switch name {
  17427. case sopnode.FieldStatus:
  17428. v, ok := value.(int8)
  17429. if !ok {
  17430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17431. }
  17432. m.AddStatus(v)
  17433. return nil
  17434. case sopnode.FieldParentID:
  17435. v, ok := value.(int64)
  17436. if !ok {
  17437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17438. }
  17439. m.AddParentID(v)
  17440. return nil
  17441. case sopnode.FieldConditionType:
  17442. v, ok := value.(int)
  17443. if !ok {
  17444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17445. }
  17446. m.AddConditionType(v)
  17447. return nil
  17448. case sopnode.FieldNoReplyCondition:
  17449. v, ok := value.(int64)
  17450. if !ok {
  17451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17452. }
  17453. m.AddNoReplyCondition(v)
  17454. return nil
  17455. }
  17456. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17457. }
  17458. // ClearedFields returns all nullable fields that were cleared during this
  17459. // mutation.
  17460. func (m *SopNodeMutation) ClearedFields() []string {
  17461. var fields []string
  17462. if m.FieldCleared(sopnode.FieldStatus) {
  17463. fields = append(fields, sopnode.FieldStatus)
  17464. }
  17465. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17466. fields = append(fields, sopnode.FieldDeletedAt)
  17467. }
  17468. if m.FieldCleared(sopnode.FieldConditionList) {
  17469. fields = append(fields, sopnode.FieldConditionList)
  17470. }
  17471. if m.FieldCleared(sopnode.FieldActionMessage) {
  17472. fields = append(fields, sopnode.FieldActionMessage)
  17473. }
  17474. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17475. fields = append(fields, sopnode.FieldActionLabelAdd)
  17476. }
  17477. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17478. fields = append(fields, sopnode.FieldActionLabelDel)
  17479. }
  17480. if m.FieldCleared(sopnode.FieldActionForward) {
  17481. fields = append(fields, sopnode.FieldActionForward)
  17482. }
  17483. return fields
  17484. }
  17485. // FieldCleared returns a boolean indicating if a field with the given name was
  17486. // cleared in this mutation.
  17487. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17488. _, ok := m.clearedFields[name]
  17489. return ok
  17490. }
  17491. // ClearField clears the value of the field with the given name. It returns an
  17492. // error if the field is not defined in the schema.
  17493. func (m *SopNodeMutation) ClearField(name string) error {
  17494. switch name {
  17495. case sopnode.FieldStatus:
  17496. m.ClearStatus()
  17497. return nil
  17498. case sopnode.FieldDeletedAt:
  17499. m.ClearDeletedAt()
  17500. return nil
  17501. case sopnode.FieldConditionList:
  17502. m.ClearConditionList()
  17503. return nil
  17504. case sopnode.FieldActionMessage:
  17505. m.ClearActionMessage()
  17506. return nil
  17507. case sopnode.FieldActionLabelAdd:
  17508. m.ClearActionLabelAdd()
  17509. return nil
  17510. case sopnode.FieldActionLabelDel:
  17511. m.ClearActionLabelDel()
  17512. return nil
  17513. case sopnode.FieldActionForward:
  17514. m.ClearActionForward()
  17515. return nil
  17516. }
  17517. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17518. }
  17519. // ResetField resets all changes in the mutation for the field with the given name.
  17520. // It returns an error if the field is not defined in the schema.
  17521. func (m *SopNodeMutation) ResetField(name string) error {
  17522. switch name {
  17523. case sopnode.FieldCreatedAt:
  17524. m.ResetCreatedAt()
  17525. return nil
  17526. case sopnode.FieldUpdatedAt:
  17527. m.ResetUpdatedAt()
  17528. return nil
  17529. case sopnode.FieldStatus:
  17530. m.ResetStatus()
  17531. return nil
  17532. case sopnode.FieldDeletedAt:
  17533. m.ResetDeletedAt()
  17534. return nil
  17535. case sopnode.FieldStageID:
  17536. m.ResetStageID()
  17537. return nil
  17538. case sopnode.FieldParentID:
  17539. m.ResetParentID()
  17540. return nil
  17541. case sopnode.FieldName:
  17542. m.ResetName()
  17543. return nil
  17544. case sopnode.FieldConditionType:
  17545. m.ResetConditionType()
  17546. return nil
  17547. case sopnode.FieldConditionList:
  17548. m.ResetConditionList()
  17549. return nil
  17550. case sopnode.FieldNoReplyCondition:
  17551. m.ResetNoReplyCondition()
  17552. return nil
  17553. case sopnode.FieldNoReplyUnit:
  17554. m.ResetNoReplyUnit()
  17555. return nil
  17556. case sopnode.FieldActionMessage:
  17557. m.ResetActionMessage()
  17558. return nil
  17559. case sopnode.FieldActionLabelAdd:
  17560. m.ResetActionLabelAdd()
  17561. return nil
  17562. case sopnode.FieldActionLabelDel:
  17563. m.ResetActionLabelDel()
  17564. return nil
  17565. case sopnode.FieldActionForward:
  17566. m.ResetActionForward()
  17567. return nil
  17568. }
  17569. return fmt.Errorf("unknown SopNode field %s", name)
  17570. }
  17571. // AddedEdges returns all edge names that were set/added in this mutation.
  17572. func (m *SopNodeMutation) AddedEdges() []string {
  17573. edges := make([]string, 0, 2)
  17574. if m.sop_stage != nil {
  17575. edges = append(edges, sopnode.EdgeSopStage)
  17576. }
  17577. if m.node_messages != nil {
  17578. edges = append(edges, sopnode.EdgeNodeMessages)
  17579. }
  17580. return edges
  17581. }
  17582. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17583. // name in this mutation.
  17584. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17585. switch name {
  17586. case sopnode.EdgeSopStage:
  17587. if id := m.sop_stage; id != nil {
  17588. return []ent.Value{*id}
  17589. }
  17590. case sopnode.EdgeNodeMessages:
  17591. ids := make([]ent.Value, 0, len(m.node_messages))
  17592. for id := range m.node_messages {
  17593. ids = append(ids, id)
  17594. }
  17595. return ids
  17596. }
  17597. return nil
  17598. }
  17599. // RemovedEdges returns all edge names that were removed in this mutation.
  17600. func (m *SopNodeMutation) RemovedEdges() []string {
  17601. edges := make([]string, 0, 2)
  17602. if m.removednode_messages != nil {
  17603. edges = append(edges, sopnode.EdgeNodeMessages)
  17604. }
  17605. return edges
  17606. }
  17607. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17608. // the given name in this mutation.
  17609. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17610. switch name {
  17611. case sopnode.EdgeNodeMessages:
  17612. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17613. for id := range m.removednode_messages {
  17614. ids = append(ids, id)
  17615. }
  17616. return ids
  17617. }
  17618. return nil
  17619. }
  17620. // ClearedEdges returns all edge names that were cleared in this mutation.
  17621. func (m *SopNodeMutation) ClearedEdges() []string {
  17622. edges := make([]string, 0, 2)
  17623. if m.clearedsop_stage {
  17624. edges = append(edges, sopnode.EdgeSopStage)
  17625. }
  17626. if m.clearednode_messages {
  17627. edges = append(edges, sopnode.EdgeNodeMessages)
  17628. }
  17629. return edges
  17630. }
  17631. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17632. // was cleared in this mutation.
  17633. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17634. switch name {
  17635. case sopnode.EdgeSopStage:
  17636. return m.clearedsop_stage
  17637. case sopnode.EdgeNodeMessages:
  17638. return m.clearednode_messages
  17639. }
  17640. return false
  17641. }
  17642. // ClearEdge clears the value of the edge with the given name. It returns an error
  17643. // if that edge is not defined in the schema.
  17644. func (m *SopNodeMutation) ClearEdge(name string) error {
  17645. switch name {
  17646. case sopnode.EdgeSopStage:
  17647. m.ClearSopStage()
  17648. return nil
  17649. }
  17650. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17651. }
  17652. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17653. // It returns an error if the edge is not defined in the schema.
  17654. func (m *SopNodeMutation) ResetEdge(name string) error {
  17655. switch name {
  17656. case sopnode.EdgeSopStage:
  17657. m.ResetSopStage()
  17658. return nil
  17659. case sopnode.EdgeNodeMessages:
  17660. m.ResetNodeMessages()
  17661. return nil
  17662. }
  17663. return fmt.Errorf("unknown SopNode edge %s", name)
  17664. }
  17665. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17666. type SopStageMutation struct {
  17667. config
  17668. op Op
  17669. typ string
  17670. id *uint64
  17671. created_at *time.Time
  17672. updated_at *time.Time
  17673. status *uint8
  17674. addstatus *int8
  17675. deleted_at *time.Time
  17676. name *string
  17677. condition_type *int
  17678. addcondition_type *int
  17679. condition_operator *int
  17680. addcondition_operator *int
  17681. condition_list *[]custom_types.Condition
  17682. appendcondition_list []custom_types.Condition
  17683. action_message *[]custom_types.Action
  17684. appendaction_message []custom_types.Action
  17685. action_label_add *[]uint64
  17686. appendaction_label_add []uint64
  17687. action_label_del *[]uint64
  17688. appendaction_label_del []uint64
  17689. action_forward **custom_types.ActionForward
  17690. index_sort *int
  17691. addindex_sort *int
  17692. clearedFields map[string]struct{}
  17693. sop_task *uint64
  17694. clearedsop_task bool
  17695. stage_nodes map[uint64]struct{}
  17696. removedstage_nodes map[uint64]struct{}
  17697. clearedstage_nodes bool
  17698. stage_messages map[uint64]struct{}
  17699. removedstage_messages map[uint64]struct{}
  17700. clearedstage_messages bool
  17701. done bool
  17702. oldValue func(context.Context) (*SopStage, error)
  17703. predicates []predicate.SopStage
  17704. }
  17705. var _ ent.Mutation = (*SopStageMutation)(nil)
  17706. // sopstageOption allows management of the mutation configuration using functional options.
  17707. type sopstageOption func(*SopStageMutation)
  17708. // newSopStageMutation creates new mutation for the SopStage entity.
  17709. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17710. m := &SopStageMutation{
  17711. config: c,
  17712. op: op,
  17713. typ: TypeSopStage,
  17714. clearedFields: make(map[string]struct{}),
  17715. }
  17716. for _, opt := range opts {
  17717. opt(m)
  17718. }
  17719. return m
  17720. }
  17721. // withSopStageID sets the ID field of the mutation.
  17722. func withSopStageID(id uint64) sopstageOption {
  17723. return func(m *SopStageMutation) {
  17724. var (
  17725. err error
  17726. once sync.Once
  17727. value *SopStage
  17728. )
  17729. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17730. once.Do(func() {
  17731. if m.done {
  17732. err = errors.New("querying old values post mutation is not allowed")
  17733. } else {
  17734. value, err = m.Client().SopStage.Get(ctx, id)
  17735. }
  17736. })
  17737. return value, err
  17738. }
  17739. m.id = &id
  17740. }
  17741. }
  17742. // withSopStage sets the old SopStage of the mutation.
  17743. func withSopStage(node *SopStage) sopstageOption {
  17744. return func(m *SopStageMutation) {
  17745. m.oldValue = func(context.Context) (*SopStage, error) {
  17746. return node, nil
  17747. }
  17748. m.id = &node.ID
  17749. }
  17750. }
  17751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17752. // executed in a transaction (ent.Tx), a transactional client is returned.
  17753. func (m SopStageMutation) Client() *Client {
  17754. client := &Client{config: m.config}
  17755. client.init()
  17756. return client
  17757. }
  17758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17759. // it returns an error otherwise.
  17760. func (m SopStageMutation) Tx() (*Tx, error) {
  17761. if _, ok := m.driver.(*txDriver); !ok {
  17762. return nil, errors.New("ent: mutation is not running in a transaction")
  17763. }
  17764. tx := &Tx{config: m.config}
  17765. tx.init()
  17766. return tx, nil
  17767. }
  17768. // SetID sets the value of the id field. Note that this
  17769. // operation is only accepted on creation of SopStage entities.
  17770. func (m *SopStageMutation) SetID(id uint64) {
  17771. m.id = &id
  17772. }
  17773. // ID returns the ID value in the mutation. Note that the ID is only available
  17774. // if it was provided to the builder or after it was returned from the database.
  17775. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17776. if m.id == nil {
  17777. return
  17778. }
  17779. return *m.id, true
  17780. }
  17781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17782. // That means, if the mutation is applied within a transaction with an isolation level such
  17783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17784. // or updated by the mutation.
  17785. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17786. switch {
  17787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17788. id, exists := m.ID()
  17789. if exists {
  17790. return []uint64{id}, nil
  17791. }
  17792. fallthrough
  17793. case m.op.Is(OpUpdate | OpDelete):
  17794. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17795. default:
  17796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17797. }
  17798. }
  17799. // SetCreatedAt sets the "created_at" field.
  17800. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17801. m.created_at = &t
  17802. }
  17803. // CreatedAt returns the value of the "created_at" field in the mutation.
  17804. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17805. v := m.created_at
  17806. if v == nil {
  17807. return
  17808. }
  17809. return *v, true
  17810. }
  17811. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17812. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17814. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17815. if !m.op.Is(OpUpdateOne) {
  17816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17817. }
  17818. if m.id == nil || m.oldValue == nil {
  17819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17820. }
  17821. oldValue, err := m.oldValue(ctx)
  17822. if err != nil {
  17823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17824. }
  17825. return oldValue.CreatedAt, nil
  17826. }
  17827. // ResetCreatedAt resets all changes to the "created_at" field.
  17828. func (m *SopStageMutation) ResetCreatedAt() {
  17829. m.created_at = nil
  17830. }
  17831. // SetUpdatedAt sets the "updated_at" field.
  17832. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17833. m.updated_at = &t
  17834. }
  17835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17836. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17837. v := m.updated_at
  17838. if v == nil {
  17839. return
  17840. }
  17841. return *v, true
  17842. }
  17843. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17844. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17846. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17847. if !m.op.Is(OpUpdateOne) {
  17848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17849. }
  17850. if m.id == nil || m.oldValue == nil {
  17851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17852. }
  17853. oldValue, err := m.oldValue(ctx)
  17854. if err != nil {
  17855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17856. }
  17857. return oldValue.UpdatedAt, nil
  17858. }
  17859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17860. func (m *SopStageMutation) ResetUpdatedAt() {
  17861. m.updated_at = nil
  17862. }
  17863. // SetStatus sets the "status" field.
  17864. func (m *SopStageMutation) SetStatus(u uint8) {
  17865. m.status = &u
  17866. m.addstatus = nil
  17867. }
  17868. // Status returns the value of the "status" field in the mutation.
  17869. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  17870. v := m.status
  17871. if v == nil {
  17872. return
  17873. }
  17874. return *v, true
  17875. }
  17876. // OldStatus returns the old "status" field's value of the SopStage entity.
  17877. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17879. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17880. if !m.op.Is(OpUpdateOne) {
  17881. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17882. }
  17883. if m.id == nil || m.oldValue == nil {
  17884. return v, errors.New("OldStatus requires an ID field in the mutation")
  17885. }
  17886. oldValue, err := m.oldValue(ctx)
  17887. if err != nil {
  17888. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17889. }
  17890. return oldValue.Status, nil
  17891. }
  17892. // AddStatus adds u to the "status" field.
  17893. func (m *SopStageMutation) AddStatus(u int8) {
  17894. if m.addstatus != nil {
  17895. *m.addstatus += u
  17896. } else {
  17897. m.addstatus = &u
  17898. }
  17899. }
  17900. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17901. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  17902. v := m.addstatus
  17903. if v == nil {
  17904. return
  17905. }
  17906. return *v, true
  17907. }
  17908. // ClearStatus clears the value of the "status" field.
  17909. func (m *SopStageMutation) ClearStatus() {
  17910. m.status = nil
  17911. m.addstatus = nil
  17912. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  17913. }
  17914. // StatusCleared returns if the "status" field was cleared in this mutation.
  17915. func (m *SopStageMutation) StatusCleared() bool {
  17916. _, ok := m.clearedFields[sopstage.FieldStatus]
  17917. return ok
  17918. }
  17919. // ResetStatus resets all changes to the "status" field.
  17920. func (m *SopStageMutation) ResetStatus() {
  17921. m.status = nil
  17922. m.addstatus = nil
  17923. delete(m.clearedFields, sopstage.FieldStatus)
  17924. }
  17925. // SetDeletedAt sets the "deleted_at" field.
  17926. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  17927. m.deleted_at = &t
  17928. }
  17929. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17930. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  17931. v := m.deleted_at
  17932. if v == nil {
  17933. return
  17934. }
  17935. return *v, true
  17936. }
  17937. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  17938. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17940. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17941. if !m.op.Is(OpUpdateOne) {
  17942. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17943. }
  17944. if m.id == nil || m.oldValue == nil {
  17945. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17946. }
  17947. oldValue, err := m.oldValue(ctx)
  17948. if err != nil {
  17949. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17950. }
  17951. return oldValue.DeletedAt, nil
  17952. }
  17953. // ClearDeletedAt clears the value of the "deleted_at" field.
  17954. func (m *SopStageMutation) ClearDeletedAt() {
  17955. m.deleted_at = nil
  17956. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  17957. }
  17958. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17959. func (m *SopStageMutation) DeletedAtCleared() bool {
  17960. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  17961. return ok
  17962. }
  17963. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17964. func (m *SopStageMutation) ResetDeletedAt() {
  17965. m.deleted_at = nil
  17966. delete(m.clearedFields, sopstage.FieldDeletedAt)
  17967. }
  17968. // SetTaskID sets the "task_id" field.
  17969. func (m *SopStageMutation) SetTaskID(u uint64) {
  17970. m.sop_task = &u
  17971. }
  17972. // TaskID returns the value of the "task_id" field in the mutation.
  17973. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  17974. v := m.sop_task
  17975. if v == nil {
  17976. return
  17977. }
  17978. return *v, true
  17979. }
  17980. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  17981. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17983. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  17984. if !m.op.Is(OpUpdateOne) {
  17985. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  17986. }
  17987. if m.id == nil || m.oldValue == nil {
  17988. return v, errors.New("OldTaskID requires an ID field in the mutation")
  17989. }
  17990. oldValue, err := m.oldValue(ctx)
  17991. if err != nil {
  17992. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  17993. }
  17994. return oldValue.TaskID, nil
  17995. }
  17996. // ResetTaskID resets all changes to the "task_id" field.
  17997. func (m *SopStageMutation) ResetTaskID() {
  17998. m.sop_task = nil
  17999. }
  18000. // SetName sets the "name" field.
  18001. func (m *SopStageMutation) SetName(s string) {
  18002. m.name = &s
  18003. }
  18004. // Name returns the value of the "name" field in the mutation.
  18005. func (m *SopStageMutation) Name() (r string, exists bool) {
  18006. v := m.name
  18007. if v == nil {
  18008. return
  18009. }
  18010. return *v, true
  18011. }
  18012. // OldName returns the old "name" field's value of the SopStage entity.
  18013. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18015. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18016. if !m.op.Is(OpUpdateOne) {
  18017. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18018. }
  18019. if m.id == nil || m.oldValue == nil {
  18020. return v, errors.New("OldName requires an ID field in the mutation")
  18021. }
  18022. oldValue, err := m.oldValue(ctx)
  18023. if err != nil {
  18024. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18025. }
  18026. return oldValue.Name, nil
  18027. }
  18028. // ResetName resets all changes to the "name" field.
  18029. func (m *SopStageMutation) ResetName() {
  18030. m.name = nil
  18031. }
  18032. // SetConditionType sets the "condition_type" field.
  18033. func (m *SopStageMutation) SetConditionType(i int) {
  18034. m.condition_type = &i
  18035. m.addcondition_type = nil
  18036. }
  18037. // ConditionType returns the value of the "condition_type" field in the mutation.
  18038. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18039. v := m.condition_type
  18040. if v == nil {
  18041. return
  18042. }
  18043. return *v, true
  18044. }
  18045. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18048. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18049. if !m.op.Is(OpUpdateOne) {
  18050. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18051. }
  18052. if m.id == nil || m.oldValue == nil {
  18053. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18054. }
  18055. oldValue, err := m.oldValue(ctx)
  18056. if err != nil {
  18057. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18058. }
  18059. return oldValue.ConditionType, nil
  18060. }
  18061. // AddConditionType adds i to the "condition_type" field.
  18062. func (m *SopStageMutation) AddConditionType(i int) {
  18063. if m.addcondition_type != nil {
  18064. *m.addcondition_type += i
  18065. } else {
  18066. m.addcondition_type = &i
  18067. }
  18068. }
  18069. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18070. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18071. v := m.addcondition_type
  18072. if v == nil {
  18073. return
  18074. }
  18075. return *v, true
  18076. }
  18077. // ResetConditionType resets all changes to the "condition_type" field.
  18078. func (m *SopStageMutation) ResetConditionType() {
  18079. m.condition_type = nil
  18080. m.addcondition_type = nil
  18081. }
  18082. // SetConditionOperator sets the "condition_operator" field.
  18083. func (m *SopStageMutation) SetConditionOperator(i int) {
  18084. m.condition_operator = &i
  18085. m.addcondition_operator = nil
  18086. }
  18087. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18088. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18089. v := m.condition_operator
  18090. if v == nil {
  18091. return
  18092. }
  18093. return *v, true
  18094. }
  18095. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18096. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18098. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18099. if !m.op.Is(OpUpdateOne) {
  18100. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18101. }
  18102. if m.id == nil || m.oldValue == nil {
  18103. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18104. }
  18105. oldValue, err := m.oldValue(ctx)
  18106. if err != nil {
  18107. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18108. }
  18109. return oldValue.ConditionOperator, nil
  18110. }
  18111. // AddConditionOperator adds i to the "condition_operator" field.
  18112. func (m *SopStageMutation) AddConditionOperator(i int) {
  18113. if m.addcondition_operator != nil {
  18114. *m.addcondition_operator += i
  18115. } else {
  18116. m.addcondition_operator = &i
  18117. }
  18118. }
  18119. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18120. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18121. v := m.addcondition_operator
  18122. if v == nil {
  18123. return
  18124. }
  18125. return *v, true
  18126. }
  18127. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18128. func (m *SopStageMutation) ResetConditionOperator() {
  18129. m.condition_operator = nil
  18130. m.addcondition_operator = nil
  18131. }
  18132. // SetConditionList sets the "condition_list" field.
  18133. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18134. m.condition_list = &ct
  18135. m.appendcondition_list = nil
  18136. }
  18137. // ConditionList returns the value of the "condition_list" field in the mutation.
  18138. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18139. v := m.condition_list
  18140. if v == nil {
  18141. return
  18142. }
  18143. return *v, true
  18144. }
  18145. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18146. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18148. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18149. if !m.op.Is(OpUpdateOne) {
  18150. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18151. }
  18152. if m.id == nil || m.oldValue == nil {
  18153. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18154. }
  18155. oldValue, err := m.oldValue(ctx)
  18156. if err != nil {
  18157. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18158. }
  18159. return oldValue.ConditionList, nil
  18160. }
  18161. // AppendConditionList adds ct to the "condition_list" field.
  18162. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18163. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18164. }
  18165. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18166. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18167. if len(m.appendcondition_list) == 0 {
  18168. return nil, false
  18169. }
  18170. return m.appendcondition_list, true
  18171. }
  18172. // ResetConditionList resets all changes to the "condition_list" field.
  18173. func (m *SopStageMutation) ResetConditionList() {
  18174. m.condition_list = nil
  18175. m.appendcondition_list = nil
  18176. }
  18177. // SetActionMessage sets the "action_message" field.
  18178. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18179. m.action_message = &ct
  18180. m.appendaction_message = nil
  18181. }
  18182. // ActionMessage returns the value of the "action_message" field in the mutation.
  18183. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18184. v := m.action_message
  18185. if v == nil {
  18186. return
  18187. }
  18188. return *v, true
  18189. }
  18190. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18191. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18193. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18194. if !m.op.Is(OpUpdateOne) {
  18195. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18196. }
  18197. if m.id == nil || m.oldValue == nil {
  18198. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18199. }
  18200. oldValue, err := m.oldValue(ctx)
  18201. if err != nil {
  18202. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18203. }
  18204. return oldValue.ActionMessage, nil
  18205. }
  18206. // AppendActionMessage adds ct to the "action_message" field.
  18207. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18208. m.appendaction_message = append(m.appendaction_message, ct...)
  18209. }
  18210. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18211. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18212. if len(m.appendaction_message) == 0 {
  18213. return nil, false
  18214. }
  18215. return m.appendaction_message, true
  18216. }
  18217. // ClearActionMessage clears the value of the "action_message" field.
  18218. func (m *SopStageMutation) ClearActionMessage() {
  18219. m.action_message = nil
  18220. m.appendaction_message = nil
  18221. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18222. }
  18223. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18224. func (m *SopStageMutation) ActionMessageCleared() bool {
  18225. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18226. return ok
  18227. }
  18228. // ResetActionMessage resets all changes to the "action_message" field.
  18229. func (m *SopStageMutation) ResetActionMessage() {
  18230. m.action_message = nil
  18231. m.appendaction_message = nil
  18232. delete(m.clearedFields, sopstage.FieldActionMessage)
  18233. }
  18234. // SetActionLabelAdd sets the "action_label_add" field.
  18235. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18236. m.action_label_add = &u
  18237. m.appendaction_label_add = nil
  18238. }
  18239. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18240. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18241. v := m.action_label_add
  18242. if v == nil {
  18243. return
  18244. }
  18245. return *v, true
  18246. }
  18247. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18248. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18250. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18251. if !m.op.Is(OpUpdateOne) {
  18252. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18253. }
  18254. if m.id == nil || m.oldValue == nil {
  18255. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18256. }
  18257. oldValue, err := m.oldValue(ctx)
  18258. if err != nil {
  18259. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18260. }
  18261. return oldValue.ActionLabelAdd, nil
  18262. }
  18263. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18264. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18265. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18266. }
  18267. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18268. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18269. if len(m.appendaction_label_add) == 0 {
  18270. return nil, false
  18271. }
  18272. return m.appendaction_label_add, true
  18273. }
  18274. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18275. func (m *SopStageMutation) ClearActionLabelAdd() {
  18276. m.action_label_add = nil
  18277. m.appendaction_label_add = nil
  18278. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18279. }
  18280. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18281. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18282. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18283. return ok
  18284. }
  18285. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18286. func (m *SopStageMutation) ResetActionLabelAdd() {
  18287. m.action_label_add = nil
  18288. m.appendaction_label_add = nil
  18289. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18290. }
  18291. // SetActionLabelDel sets the "action_label_del" field.
  18292. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18293. m.action_label_del = &u
  18294. m.appendaction_label_del = nil
  18295. }
  18296. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18297. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18298. v := m.action_label_del
  18299. if v == nil {
  18300. return
  18301. }
  18302. return *v, true
  18303. }
  18304. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18305. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18307. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18308. if !m.op.Is(OpUpdateOne) {
  18309. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18310. }
  18311. if m.id == nil || m.oldValue == nil {
  18312. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18313. }
  18314. oldValue, err := m.oldValue(ctx)
  18315. if err != nil {
  18316. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18317. }
  18318. return oldValue.ActionLabelDel, nil
  18319. }
  18320. // AppendActionLabelDel adds u to the "action_label_del" field.
  18321. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18322. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18323. }
  18324. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18325. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18326. if len(m.appendaction_label_del) == 0 {
  18327. return nil, false
  18328. }
  18329. return m.appendaction_label_del, true
  18330. }
  18331. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18332. func (m *SopStageMutation) ClearActionLabelDel() {
  18333. m.action_label_del = nil
  18334. m.appendaction_label_del = nil
  18335. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18336. }
  18337. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18338. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18339. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18340. return ok
  18341. }
  18342. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18343. func (m *SopStageMutation) ResetActionLabelDel() {
  18344. m.action_label_del = nil
  18345. m.appendaction_label_del = nil
  18346. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18347. }
  18348. // SetActionForward sets the "action_forward" field.
  18349. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18350. m.action_forward = &ctf
  18351. }
  18352. // ActionForward returns the value of the "action_forward" field in the mutation.
  18353. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18354. v := m.action_forward
  18355. if v == nil {
  18356. return
  18357. }
  18358. return *v, true
  18359. }
  18360. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18363. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18364. if !m.op.Is(OpUpdateOne) {
  18365. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18366. }
  18367. if m.id == nil || m.oldValue == nil {
  18368. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18369. }
  18370. oldValue, err := m.oldValue(ctx)
  18371. if err != nil {
  18372. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18373. }
  18374. return oldValue.ActionForward, nil
  18375. }
  18376. // ClearActionForward clears the value of the "action_forward" field.
  18377. func (m *SopStageMutation) ClearActionForward() {
  18378. m.action_forward = nil
  18379. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18380. }
  18381. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18382. func (m *SopStageMutation) ActionForwardCleared() bool {
  18383. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18384. return ok
  18385. }
  18386. // ResetActionForward resets all changes to the "action_forward" field.
  18387. func (m *SopStageMutation) ResetActionForward() {
  18388. m.action_forward = nil
  18389. delete(m.clearedFields, sopstage.FieldActionForward)
  18390. }
  18391. // SetIndexSort sets the "index_sort" field.
  18392. func (m *SopStageMutation) SetIndexSort(i int) {
  18393. m.index_sort = &i
  18394. m.addindex_sort = nil
  18395. }
  18396. // IndexSort returns the value of the "index_sort" field in the mutation.
  18397. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18398. v := m.index_sort
  18399. if v == nil {
  18400. return
  18401. }
  18402. return *v, true
  18403. }
  18404. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18405. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18407. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18408. if !m.op.Is(OpUpdateOne) {
  18409. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18410. }
  18411. if m.id == nil || m.oldValue == nil {
  18412. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18413. }
  18414. oldValue, err := m.oldValue(ctx)
  18415. if err != nil {
  18416. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18417. }
  18418. return oldValue.IndexSort, nil
  18419. }
  18420. // AddIndexSort adds i to the "index_sort" field.
  18421. func (m *SopStageMutation) AddIndexSort(i int) {
  18422. if m.addindex_sort != nil {
  18423. *m.addindex_sort += i
  18424. } else {
  18425. m.addindex_sort = &i
  18426. }
  18427. }
  18428. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18429. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18430. v := m.addindex_sort
  18431. if v == nil {
  18432. return
  18433. }
  18434. return *v, true
  18435. }
  18436. // ClearIndexSort clears the value of the "index_sort" field.
  18437. func (m *SopStageMutation) ClearIndexSort() {
  18438. m.index_sort = nil
  18439. m.addindex_sort = nil
  18440. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18441. }
  18442. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18443. func (m *SopStageMutation) IndexSortCleared() bool {
  18444. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18445. return ok
  18446. }
  18447. // ResetIndexSort resets all changes to the "index_sort" field.
  18448. func (m *SopStageMutation) ResetIndexSort() {
  18449. m.index_sort = nil
  18450. m.addindex_sort = nil
  18451. delete(m.clearedFields, sopstage.FieldIndexSort)
  18452. }
  18453. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18454. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18455. m.sop_task = &id
  18456. }
  18457. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18458. func (m *SopStageMutation) ClearSopTask() {
  18459. m.clearedsop_task = true
  18460. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18461. }
  18462. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18463. func (m *SopStageMutation) SopTaskCleared() bool {
  18464. return m.clearedsop_task
  18465. }
  18466. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18467. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18468. if m.sop_task != nil {
  18469. return *m.sop_task, true
  18470. }
  18471. return
  18472. }
  18473. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18474. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18475. // SopTaskID instead. It exists only for internal usage by the builders.
  18476. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18477. if id := m.sop_task; id != nil {
  18478. ids = append(ids, *id)
  18479. }
  18480. return
  18481. }
  18482. // ResetSopTask resets all changes to the "sop_task" edge.
  18483. func (m *SopStageMutation) ResetSopTask() {
  18484. m.sop_task = nil
  18485. m.clearedsop_task = false
  18486. }
  18487. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18488. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18489. if m.stage_nodes == nil {
  18490. m.stage_nodes = make(map[uint64]struct{})
  18491. }
  18492. for i := range ids {
  18493. m.stage_nodes[ids[i]] = struct{}{}
  18494. }
  18495. }
  18496. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18497. func (m *SopStageMutation) ClearStageNodes() {
  18498. m.clearedstage_nodes = true
  18499. }
  18500. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18501. func (m *SopStageMutation) StageNodesCleared() bool {
  18502. return m.clearedstage_nodes
  18503. }
  18504. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18505. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18506. if m.removedstage_nodes == nil {
  18507. m.removedstage_nodes = make(map[uint64]struct{})
  18508. }
  18509. for i := range ids {
  18510. delete(m.stage_nodes, ids[i])
  18511. m.removedstage_nodes[ids[i]] = struct{}{}
  18512. }
  18513. }
  18514. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18515. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18516. for id := range m.removedstage_nodes {
  18517. ids = append(ids, id)
  18518. }
  18519. return
  18520. }
  18521. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18522. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18523. for id := range m.stage_nodes {
  18524. ids = append(ids, id)
  18525. }
  18526. return
  18527. }
  18528. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18529. func (m *SopStageMutation) ResetStageNodes() {
  18530. m.stage_nodes = nil
  18531. m.clearedstage_nodes = false
  18532. m.removedstage_nodes = nil
  18533. }
  18534. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18535. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18536. if m.stage_messages == nil {
  18537. m.stage_messages = make(map[uint64]struct{})
  18538. }
  18539. for i := range ids {
  18540. m.stage_messages[ids[i]] = struct{}{}
  18541. }
  18542. }
  18543. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18544. func (m *SopStageMutation) ClearStageMessages() {
  18545. m.clearedstage_messages = true
  18546. }
  18547. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18548. func (m *SopStageMutation) StageMessagesCleared() bool {
  18549. return m.clearedstage_messages
  18550. }
  18551. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18552. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18553. if m.removedstage_messages == nil {
  18554. m.removedstage_messages = make(map[uint64]struct{})
  18555. }
  18556. for i := range ids {
  18557. delete(m.stage_messages, ids[i])
  18558. m.removedstage_messages[ids[i]] = struct{}{}
  18559. }
  18560. }
  18561. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18562. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18563. for id := range m.removedstage_messages {
  18564. ids = append(ids, id)
  18565. }
  18566. return
  18567. }
  18568. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18569. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18570. for id := range m.stage_messages {
  18571. ids = append(ids, id)
  18572. }
  18573. return
  18574. }
  18575. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18576. func (m *SopStageMutation) ResetStageMessages() {
  18577. m.stage_messages = nil
  18578. m.clearedstage_messages = false
  18579. m.removedstage_messages = nil
  18580. }
  18581. // Where appends a list predicates to the SopStageMutation builder.
  18582. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18583. m.predicates = append(m.predicates, ps...)
  18584. }
  18585. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18586. // users can use type-assertion to append predicates that do not depend on any generated package.
  18587. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18588. p := make([]predicate.SopStage, len(ps))
  18589. for i := range ps {
  18590. p[i] = ps[i]
  18591. }
  18592. m.Where(p...)
  18593. }
  18594. // Op returns the operation name.
  18595. func (m *SopStageMutation) Op() Op {
  18596. return m.op
  18597. }
  18598. // SetOp allows setting the mutation operation.
  18599. func (m *SopStageMutation) SetOp(op Op) {
  18600. m.op = op
  18601. }
  18602. // Type returns the node type of this mutation (SopStage).
  18603. func (m *SopStageMutation) Type() string {
  18604. return m.typ
  18605. }
  18606. // Fields returns all fields that were changed during this mutation. Note that in
  18607. // order to get all numeric fields that were incremented/decremented, call
  18608. // AddedFields().
  18609. func (m *SopStageMutation) Fields() []string {
  18610. fields := make([]string, 0, 14)
  18611. if m.created_at != nil {
  18612. fields = append(fields, sopstage.FieldCreatedAt)
  18613. }
  18614. if m.updated_at != nil {
  18615. fields = append(fields, sopstage.FieldUpdatedAt)
  18616. }
  18617. if m.status != nil {
  18618. fields = append(fields, sopstage.FieldStatus)
  18619. }
  18620. if m.deleted_at != nil {
  18621. fields = append(fields, sopstage.FieldDeletedAt)
  18622. }
  18623. if m.sop_task != nil {
  18624. fields = append(fields, sopstage.FieldTaskID)
  18625. }
  18626. if m.name != nil {
  18627. fields = append(fields, sopstage.FieldName)
  18628. }
  18629. if m.condition_type != nil {
  18630. fields = append(fields, sopstage.FieldConditionType)
  18631. }
  18632. if m.condition_operator != nil {
  18633. fields = append(fields, sopstage.FieldConditionOperator)
  18634. }
  18635. if m.condition_list != nil {
  18636. fields = append(fields, sopstage.FieldConditionList)
  18637. }
  18638. if m.action_message != nil {
  18639. fields = append(fields, sopstage.FieldActionMessage)
  18640. }
  18641. if m.action_label_add != nil {
  18642. fields = append(fields, sopstage.FieldActionLabelAdd)
  18643. }
  18644. if m.action_label_del != nil {
  18645. fields = append(fields, sopstage.FieldActionLabelDel)
  18646. }
  18647. if m.action_forward != nil {
  18648. fields = append(fields, sopstage.FieldActionForward)
  18649. }
  18650. if m.index_sort != nil {
  18651. fields = append(fields, sopstage.FieldIndexSort)
  18652. }
  18653. return fields
  18654. }
  18655. // Field returns the value of a field with the given name. The second boolean
  18656. // return value indicates that this field was not set, or was not defined in the
  18657. // schema.
  18658. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18659. switch name {
  18660. case sopstage.FieldCreatedAt:
  18661. return m.CreatedAt()
  18662. case sopstage.FieldUpdatedAt:
  18663. return m.UpdatedAt()
  18664. case sopstage.FieldStatus:
  18665. return m.Status()
  18666. case sopstage.FieldDeletedAt:
  18667. return m.DeletedAt()
  18668. case sopstage.FieldTaskID:
  18669. return m.TaskID()
  18670. case sopstage.FieldName:
  18671. return m.Name()
  18672. case sopstage.FieldConditionType:
  18673. return m.ConditionType()
  18674. case sopstage.FieldConditionOperator:
  18675. return m.ConditionOperator()
  18676. case sopstage.FieldConditionList:
  18677. return m.ConditionList()
  18678. case sopstage.FieldActionMessage:
  18679. return m.ActionMessage()
  18680. case sopstage.FieldActionLabelAdd:
  18681. return m.ActionLabelAdd()
  18682. case sopstage.FieldActionLabelDel:
  18683. return m.ActionLabelDel()
  18684. case sopstage.FieldActionForward:
  18685. return m.ActionForward()
  18686. case sopstage.FieldIndexSort:
  18687. return m.IndexSort()
  18688. }
  18689. return nil, false
  18690. }
  18691. // OldField returns the old value of the field from the database. An error is
  18692. // returned if the mutation operation is not UpdateOne, or the query to the
  18693. // database failed.
  18694. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18695. switch name {
  18696. case sopstage.FieldCreatedAt:
  18697. return m.OldCreatedAt(ctx)
  18698. case sopstage.FieldUpdatedAt:
  18699. return m.OldUpdatedAt(ctx)
  18700. case sopstage.FieldStatus:
  18701. return m.OldStatus(ctx)
  18702. case sopstage.FieldDeletedAt:
  18703. return m.OldDeletedAt(ctx)
  18704. case sopstage.FieldTaskID:
  18705. return m.OldTaskID(ctx)
  18706. case sopstage.FieldName:
  18707. return m.OldName(ctx)
  18708. case sopstage.FieldConditionType:
  18709. return m.OldConditionType(ctx)
  18710. case sopstage.FieldConditionOperator:
  18711. return m.OldConditionOperator(ctx)
  18712. case sopstage.FieldConditionList:
  18713. return m.OldConditionList(ctx)
  18714. case sopstage.FieldActionMessage:
  18715. return m.OldActionMessage(ctx)
  18716. case sopstage.FieldActionLabelAdd:
  18717. return m.OldActionLabelAdd(ctx)
  18718. case sopstage.FieldActionLabelDel:
  18719. return m.OldActionLabelDel(ctx)
  18720. case sopstage.FieldActionForward:
  18721. return m.OldActionForward(ctx)
  18722. case sopstage.FieldIndexSort:
  18723. return m.OldIndexSort(ctx)
  18724. }
  18725. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18726. }
  18727. // SetField sets the value of a field with the given name. It returns an error if
  18728. // the field is not defined in the schema, or if the type mismatched the field
  18729. // type.
  18730. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18731. switch name {
  18732. case sopstage.FieldCreatedAt:
  18733. v, ok := value.(time.Time)
  18734. if !ok {
  18735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18736. }
  18737. m.SetCreatedAt(v)
  18738. return nil
  18739. case sopstage.FieldUpdatedAt:
  18740. v, ok := value.(time.Time)
  18741. if !ok {
  18742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18743. }
  18744. m.SetUpdatedAt(v)
  18745. return nil
  18746. case sopstage.FieldStatus:
  18747. v, ok := value.(uint8)
  18748. if !ok {
  18749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18750. }
  18751. m.SetStatus(v)
  18752. return nil
  18753. case sopstage.FieldDeletedAt:
  18754. v, ok := value.(time.Time)
  18755. if !ok {
  18756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18757. }
  18758. m.SetDeletedAt(v)
  18759. return nil
  18760. case sopstage.FieldTaskID:
  18761. v, ok := value.(uint64)
  18762. if !ok {
  18763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18764. }
  18765. m.SetTaskID(v)
  18766. return nil
  18767. case sopstage.FieldName:
  18768. v, ok := value.(string)
  18769. if !ok {
  18770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18771. }
  18772. m.SetName(v)
  18773. return nil
  18774. case sopstage.FieldConditionType:
  18775. v, ok := value.(int)
  18776. if !ok {
  18777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18778. }
  18779. m.SetConditionType(v)
  18780. return nil
  18781. case sopstage.FieldConditionOperator:
  18782. v, ok := value.(int)
  18783. if !ok {
  18784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18785. }
  18786. m.SetConditionOperator(v)
  18787. return nil
  18788. case sopstage.FieldConditionList:
  18789. v, ok := value.([]custom_types.Condition)
  18790. if !ok {
  18791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18792. }
  18793. m.SetConditionList(v)
  18794. return nil
  18795. case sopstage.FieldActionMessage:
  18796. v, ok := value.([]custom_types.Action)
  18797. if !ok {
  18798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18799. }
  18800. m.SetActionMessage(v)
  18801. return nil
  18802. case sopstage.FieldActionLabelAdd:
  18803. v, ok := value.([]uint64)
  18804. if !ok {
  18805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18806. }
  18807. m.SetActionLabelAdd(v)
  18808. return nil
  18809. case sopstage.FieldActionLabelDel:
  18810. v, ok := value.([]uint64)
  18811. if !ok {
  18812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18813. }
  18814. m.SetActionLabelDel(v)
  18815. return nil
  18816. case sopstage.FieldActionForward:
  18817. v, ok := value.(*custom_types.ActionForward)
  18818. if !ok {
  18819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18820. }
  18821. m.SetActionForward(v)
  18822. return nil
  18823. case sopstage.FieldIndexSort:
  18824. v, ok := value.(int)
  18825. if !ok {
  18826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18827. }
  18828. m.SetIndexSort(v)
  18829. return nil
  18830. }
  18831. return fmt.Errorf("unknown SopStage field %s", name)
  18832. }
  18833. // AddedFields returns all numeric fields that were incremented/decremented during
  18834. // this mutation.
  18835. func (m *SopStageMutation) AddedFields() []string {
  18836. var fields []string
  18837. if m.addstatus != nil {
  18838. fields = append(fields, sopstage.FieldStatus)
  18839. }
  18840. if m.addcondition_type != nil {
  18841. fields = append(fields, sopstage.FieldConditionType)
  18842. }
  18843. if m.addcondition_operator != nil {
  18844. fields = append(fields, sopstage.FieldConditionOperator)
  18845. }
  18846. if m.addindex_sort != nil {
  18847. fields = append(fields, sopstage.FieldIndexSort)
  18848. }
  18849. return fields
  18850. }
  18851. // AddedField returns the numeric value that was incremented/decremented on a field
  18852. // with the given name. The second boolean return value indicates that this field
  18853. // was not set, or was not defined in the schema.
  18854. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18855. switch name {
  18856. case sopstage.FieldStatus:
  18857. return m.AddedStatus()
  18858. case sopstage.FieldConditionType:
  18859. return m.AddedConditionType()
  18860. case sopstage.FieldConditionOperator:
  18861. return m.AddedConditionOperator()
  18862. case sopstage.FieldIndexSort:
  18863. return m.AddedIndexSort()
  18864. }
  18865. return nil, false
  18866. }
  18867. // AddField adds the value to the field with the given name. It returns an error if
  18868. // the field is not defined in the schema, or if the type mismatched the field
  18869. // type.
  18870. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  18871. switch name {
  18872. case sopstage.FieldStatus:
  18873. v, ok := value.(int8)
  18874. if !ok {
  18875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18876. }
  18877. m.AddStatus(v)
  18878. return nil
  18879. case sopstage.FieldConditionType:
  18880. v, ok := value.(int)
  18881. if !ok {
  18882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18883. }
  18884. m.AddConditionType(v)
  18885. return nil
  18886. case sopstage.FieldConditionOperator:
  18887. v, ok := value.(int)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.AddConditionOperator(v)
  18892. return nil
  18893. case sopstage.FieldIndexSort:
  18894. v, ok := value.(int)
  18895. if !ok {
  18896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18897. }
  18898. m.AddIndexSort(v)
  18899. return nil
  18900. }
  18901. return fmt.Errorf("unknown SopStage numeric field %s", name)
  18902. }
  18903. // ClearedFields returns all nullable fields that were cleared during this
  18904. // mutation.
  18905. func (m *SopStageMutation) ClearedFields() []string {
  18906. var fields []string
  18907. if m.FieldCleared(sopstage.FieldStatus) {
  18908. fields = append(fields, sopstage.FieldStatus)
  18909. }
  18910. if m.FieldCleared(sopstage.FieldDeletedAt) {
  18911. fields = append(fields, sopstage.FieldDeletedAt)
  18912. }
  18913. if m.FieldCleared(sopstage.FieldActionMessage) {
  18914. fields = append(fields, sopstage.FieldActionMessage)
  18915. }
  18916. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  18917. fields = append(fields, sopstage.FieldActionLabelAdd)
  18918. }
  18919. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  18920. fields = append(fields, sopstage.FieldActionLabelDel)
  18921. }
  18922. if m.FieldCleared(sopstage.FieldActionForward) {
  18923. fields = append(fields, sopstage.FieldActionForward)
  18924. }
  18925. if m.FieldCleared(sopstage.FieldIndexSort) {
  18926. fields = append(fields, sopstage.FieldIndexSort)
  18927. }
  18928. return fields
  18929. }
  18930. // FieldCleared returns a boolean indicating if a field with the given name was
  18931. // cleared in this mutation.
  18932. func (m *SopStageMutation) FieldCleared(name string) bool {
  18933. _, ok := m.clearedFields[name]
  18934. return ok
  18935. }
  18936. // ClearField clears the value of the field with the given name. It returns an
  18937. // error if the field is not defined in the schema.
  18938. func (m *SopStageMutation) ClearField(name string) error {
  18939. switch name {
  18940. case sopstage.FieldStatus:
  18941. m.ClearStatus()
  18942. return nil
  18943. case sopstage.FieldDeletedAt:
  18944. m.ClearDeletedAt()
  18945. return nil
  18946. case sopstage.FieldActionMessage:
  18947. m.ClearActionMessage()
  18948. return nil
  18949. case sopstage.FieldActionLabelAdd:
  18950. m.ClearActionLabelAdd()
  18951. return nil
  18952. case sopstage.FieldActionLabelDel:
  18953. m.ClearActionLabelDel()
  18954. return nil
  18955. case sopstage.FieldActionForward:
  18956. m.ClearActionForward()
  18957. return nil
  18958. case sopstage.FieldIndexSort:
  18959. m.ClearIndexSort()
  18960. return nil
  18961. }
  18962. return fmt.Errorf("unknown SopStage nullable field %s", name)
  18963. }
  18964. // ResetField resets all changes in the mutation for the field with the given name.
  18965. // It returns an error if the field is not defined in the schema.
  18966. func (m *SopStageMutation) ResetField(name string) error {
  18967. switch name {
  18968. case sopstage.FieldCreatedAt:
  18969. m.ResetCreatedAt()
  18970. return nil
  18971. case sopstage.FieldUpdatedAt:
  18972. m.ResetUpdatedAt()
  18973. return nil
  18974. case sopstage.FieldStatus:
  18975. m.ResetStatus()
  18976. return nil
  18977. case sopstage.FieldDeletedAt:
  18978. m.ResetDeletedAt()
  18979. return nil
  18980. case sopstage.FieldTaskID:
  18981. m.ResetTaskID()
  18982. return nil
  18983. case sopstage.FieldName:
  18984. m.ResetName()
  18985. return nil
  18986. case sopstage.FieldConditionType:
  18987. m.ResetConditionType()
  18988. return nil
  18989. case sopstage.FieldConditionOperator:
  18990. m.ResetConditionOperator()
  18991. return nil
  18992. case sopstage.FieldConditionList:
  18993. m.ResetConditionList()
  18994. return nil
  18995. case sopstage.FieldActionMessage:
  18996. m.ResetActionMessage()
  18997. return nil
  18998. case sopstage.FieldActionLabelAdd:
  18999. m.ResetActionLabelAdd()
  19000. return nil
  19001. case sopstage.FieldActionLabelDel:
  19002. m.ResetActionLabelDel()
  19003. return nil
  19004. case sopstage.FieldActionForward:
  19005. m.ResetActionForward()
  19006. return nil
  19007. case sopstage.FieldIndexSort:
  19008. m.ResetIndexSort()
  19009. return nil
  19010. }
  19011. return fmt.Errorf("unknown SopStage field %s", name)
  19012. }
  19013. // AddedEdges returns all edge names that were set/added in this mutation.
  19014. func (m *SopStageMutation) AddedEdges() []string {
  19015. edges := make([]string, 0, 3)
  19016. if m.sop_task != nil {
  19017. edges = append(edges, sopstage.EdgeSopTask)
  19018. }
  19019. if m.stage_nodes != nil {
  19020. edges = append(edges, sopstage.EdgeStageNodes)
  19021. }
  19022. if m.stage_messages != nil {
  19023. edges = append(edges, sopstage.EdgeStageMessages)
  19024. }
  19025. return edges
  19026. }
  19027. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19028. // name in this mutation.
  19029. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19030. switch name {
  19031. case sopstage.EdgeSopTask:
  19032. if id := m.sop_task; id != nil {
  19033. return []ent.Value{*id}
  19034. }
  19035. case sopstage.EdgeStageNodes:
  19036. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19037. for id := range m.stage_nodes {
  19038. ids = append(ids, id)
  19039. }
  19040. return ids
  19041. case sopstage.EdgeStageMessages:
  19042. ids := make([]ent.Value, 0, len(m.stage_messages))
  19043. for id := range m.stage_messages {
  19044. ids = append(ids, id)
  19045. }
  19046. return ids
  19047. }
  19048. return nil
  19049. }
  19050. // RemovedEdges returns all edge names that were removed in this mutation.
  19051. func (m *SopStageMutation) RemovedEdges() []string {
  19052. edges := make([]string, 0, 3)
  19053. if m.removedstage_nodes != nil {
  19054. edges = append(edges, sopstage.EdgeStageNodes)
  19055. }
  19056. if m.removedstage_messages != nil {
  19057. edges = append(edges, sopstage.EdgeStageMessages)
  19058. }
  19059. return edges
  19060. }
  19061. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19062. // the given name in this mutation.
  19063. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19064. switch name {
  19065. case sopstage.EdgeStageNodes:
  19066. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19067. for id := range m.removedstage_nodes {
  19068. ids = append(ids, id)
  19069. }
  19070. return ids
  19071. case sopstage.EdgeStageMessages:
  19072. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19073. for id := range m.removedstage_messages {
  19074. ids = append(ids, id)
  19075. }
  19076. return ids
  19077. }
  19078. return nil
  19079. }
  19080. // ClearedEdges returns all edge names that were cleared in this mutation.
  19081. func (m *SopStageMutation) ClearedEdges() []string {
  19082. edges := make([]string, 0, 3)
  19083. if m.clearedsop_task {
  19084. edges = append(edges, sopstage.EdgeSopTask)
  19085. }
  19086. if m.clearedstage_nodes {
  19087. edges = append(edges, sopstage.EdgeStageNodes)
  19088. }
  19089. if m.clearedstage_messages {
  19090. edges = append(edges, sopstage.EdgeStageMessages)
  19091. }
  19092. return edges
  19093. }
  19094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19095. // was cleared in this mutation.
  19096. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19097. switch name {
  19098. case sopstage.EdgeSopTask:
  19099. return m.clearedsop_task
  19100. case sopstage.EdgeStageNodes:
  19101. return m.clearedstage_nodes
  19102. case sopstage.EdgeStageMessages:
  19103. return m.clearedstage_messages
  19104. }
  19105. return false
  19106. }
  19107. // ClearEdge clears the value of the edge with the given name. It returns an error
  19108. // if that edge is not defined in the schema.
  19109. func (m *SopStageMutation) ClearEdge(name string) error {
  19110. switch name {
  19111. case sopstage.EdgeSopTask:
  19112. m.ClearSopTask()
  19113. return nil
  19114. }
  19115. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19116. }
  19117. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19118. // It returns an error if the edge is not defined in the schema.
  19119. func (m *SopStageMutation) ResetEdge(name string) error {
  19120. switch name {
  19121. case sopstage.EdgeSopTask:
  19122. m.ResetSopTask()
  19123. return nil
  19124. case sopstage.EdgeStageNodes:
  19125. m.ResetStageNodes()
  19126. return nil
  19127. case sopstage.EdgeStageMessages:
  19128. m.ResetStageMessages()
  19129. return nil
  19130. }
  19131. return fmt.Errorf("unknown SopStage edge %s", name)
  19132. }
  19133. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19134. type SopTaskMutation struct {
  19135. config
  19136. op Op
  19137. typ string
  19138. id *uint64
  19139. created_at *time.Time
  19140. updated_at *time.Time
  19141. status *uint8
  19142. addstatus *int8
  19143. deleted_at *time.Time
  19144. name *string
  19145. bot_wxid_list *[]string
  19146. appendbot_wxid_list []string
  19147. _type *int
  19148. add_type *int
  19149. plan_start_time *time.Time
  19150. plan_end_time *time.Time
  19151. creator_id *string
  19152. organization_id *uint64
  19153. addorganization_id *int64
  19154. clearedFields map[string]struct{}
  19155. task_stages map[uint64]struct{}
  19156. removedtask_stages map[uint64]struct{}
  19157. clearedtask_stages bool
  19158. done bool
  19159. oldValue func(context.Context) (*SopTask, error)
  19160. predicates []predicate.SopTask
  19161. }
  19162. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19163. // soptaskOption allows management of the mutation configuration using functional options.
  19164. type soptaskOption func(*SopTaskMutation)
  19165. // newSopTaskMutation creates new mutation for the SopTask entity.
  19166. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19167. m := &SopTaskMutation{
  19168. config: c,
  19169. op: op,
  19170. typ: TypeSopTask,
  19171. clearedFields: make(map[string]struct{}),
  19172. }
  19173. for _, opt := range opts {
  19174. opt(m)
  19175. }
  19176. return m
  19177. }
  19178. // withSopTaskID sets the ID field of the mutation.
  19179. func withSopTaskID(id uint64) soptaskOption {
  19180. return func(m *SopTaskMutation) {
  19181. var (
  19182. err error
  19183. once sync.Once
  19184. value *SopTask
  19185. )
  19186. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19187. once.Do(func() {
  19188. if m.done {
  19189. err = errors.New("querying old values post mutation is not allowed")
  19190. } else {
  19191. value, err = m.Client().SopTask.Get(ctx, id)
  19192. }
  19193. })
  19194. return value, err
  19195. }
  19196. m.id = &id
  19197. }
  19198. }
  19199. // withSopTask sets the old SopTask of the mutation.
  19200. func withSopTask(node *SopTask) soptaskOption {
  19201. return func(m *SopTaskMutation) {
  19202. m.oldValue = func(context.Context) (*SopTask, error) {
  19203. return node, nil
  19204. }
  19205. m.id = &node.ID
  19206. }
  19207. }
  19208. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19209. // executed in a transaction (ent.Tx), a transactional client is returned.
  19210. func (m SopTaskMutation) Client() *Client {
  19211. client := &Client{config: m.config}
  19212. client.init()
  19213. return client
  19214. }
  19215. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19216. // it returns an error otherwise.
  19217. func (m SopTaskMutation) Tx() (*Tx, error) {
  19218. if _, ok := m.driver.(*txDriver); !ok {
  19219. return nil, errors.New("ent: mutation is not running in a transaction")
  19220. }
  19221. tx := &Tx{config: m.config}
  19222. tx.init()
  19223. return tx, nil
  19224. }
  19225. // SetID sets the value of the id field. Note that this
  19226. // operation is only accepted on creation of SopTask entities.
  19227. func (m *SopTaskMutation) SetID(id uint64) {
  19228. m.id = &id
  19229. }
  19230. // ID returns the ID value in the mutation. Note that the ID is only available
  19231. // if it was provided to the builder or after it was returned from the database.
  19232. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19233. if m.id == nil {
  19234. return
  19235. }
  19236. return *m.id, true
  19237. }
  19238. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19239. // That means, if the mutation is applied within a transaction with an isolation level such
  19240. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19241. // or updated by the mutation.
  19242. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19243. switch {
  19244. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19245. id, exists := m.ID()
  19246. if exists {
  19247. return []uint64{id}, nil
  19248. }
  19249. fallthrough
  19250. case m.op.Is(OpUpdate | OpDelete):
  19251. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19252. default:
  19253. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19254. }
  19255. }
  19256. // SetCreatedAt sets the "created_at" field.
  19257. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19258. m.created_at = &t
  19259. }
  19260. // CreatedAt returns the value of the "created_at" field in the mutation.
  19261. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19262. v := m.created_at
  19263. if v == nil {
  19264. return
  19265. }
  19266. return *v, true
  19267. }
  19268. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19269. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19271. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19272. if !m.op.Is(OpUpdateOne) {
  19273. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19274. }
  19275. if m.id == nil || m.oldValue == nil {
  19276. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19277. }
  19278. oldValue, err := m.oldValue(ctx)
  19279. if err != nil {
  19280. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19281. }
  19282. return oldValue.CreatedAt, nil
  19283. }
  19284. // ResetCreatedAt resets all changes to the "created_at" field.
  19285. func (m *SopTaskMutation) ResetCreatedAt() {
  19286. m.created_at = nil
  19287. }
  19288. // SetUpdatedAt sets the "updated_at" field.
  19289. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19290. m.updated_at = &t
  19291. }
  19292. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19293. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19294. v := m.updated_at
  19295. if v == nil {
  19296. return
  19297. }
  19298. return *v, true
  19299. }
  19300. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19301. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19303. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19304. if !m.op.Is(OpUpdateOne) {
  19305. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19306. }
  19307. if m.id == nil || m.oldValue == nil {
  19308. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19309. }
  19310. oldValue, err := m.oldValue(ctx)
  19311. if err != nil {
  19312. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19313. }
  19314. return oldValue.UpdatedAt, nil
  19315. }
  19316. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19317. func (m *SopTaskMutation) ResetUpdatedAt() {
  19318. m.updated_at = nil
  19319. }
  19320. // SetStatus sets the "status" field.
  19321. func (m *SopTaskMutation) SetStatus(u uint8) {
  19322. m.status = &u
  19323. m.addstatus = nil
  19324. }
  19325. // Status returns the value of the "status" field in the mutation.
  19326. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19327. v := m.status
  19328. if v == nil {
  19329. return
  19330. }
  19331. return *v, true
  19332. }
  19333. // OldStatus returns the old "status" field's value of the SopTask entity.
  19334. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19336. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19337. if !m.op.Is(OpUpdateOne) {
  19338. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19339. }
  19340. if m.id == nil || m.oldValue == nil {
  19341. return v, errors.New("OldStatus requires an ID field in the mutation")
  19342. }
  19343. oldValue, err := m.oldValue(ctx)
  19344. if err != nil {
  19345. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19346. }
  19347. return oldValue.Status, nil
  19348. }
  19349. // AddStatus adds u to the "status" field.
  19350. func (m *SopTaskMutation) AddStatus(u int8) {
  19351. if m.addstatus != nil {
  19352. *m.addstatus += u
  19353. } else {
  19354. m.addstatus = &u
  19355. }
  19356. }
  19357. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19358. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19359. v := m.addstatus
  19360. if v == nil {
  19361. return
  19362. }
  19363. return *v, true
  19364. }
  19365. // ClearStatus clears the value of the "status" field.
  19366. func (m *SopTaskMutation) ClearStatus() {
  19367. m.status = nil
  19368. m.addstatus = nil
  19369. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19370. }
  19371. // StatusCleared returns if the "status" field was cleared in this mutation.
  19372. func (m *SopTaskMutation) StatusCleared() bool {
  19373. _, ok := m.clearedFields[soptask.FieldStatus]
  19374. return ok
  19375. }
  19376. // ResetStatus resets all changes to the "status" field.
  19377. func (m *SopTaskMutation) ResetStatus() {
  19378. m.status = nil
  19379. m.addstatus = nil
  19380. delete(m.clearedFields, soptask.FieldStatus)
  19381. }
  19382. // SetDeletedAt sets the "deleted_at" field.
  19383. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19384. m.deleted_at = &t
  19385. }
  19386. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19387. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19388. v := m.deleted_at
  19389. if v == nil {
  19390. return
  19391. }
  19392. return *v, true
  19393. }
  19394. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19395. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19397. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19398. if !m.op.Is(OpUpdateOne) {
  19399. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19400. }
  19401. if m.id == nil || m.oldValue == nil {
  19402. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19403. }
  19404. oldValue, err := m.oldValue(ctx)
  19405. if err != nil {
  19406. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19407. }
  19408. return oldValue.DeletedAt, nil
  19409. }
  19410. // ClearDeletedAt clears the value of the "deleted_at" field.
  19411. func (m *SopTaskMutation) ClearDeletedAt() {
  19412. m.deleted_at = nil
  19413. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19414. }
  19415. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19416. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19417. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19418. return ok
  19419. }
  19420. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19421. func (m *SopTaskMutation) ResetDeletedAt() {
  19422. m.deleted_at = nil
  19423. delete(m.clearedFields, soptask.FieldDeletedAt)
  19424. }
  19425. // SetName sets the "name" field.
  19426. func (m *SopTaskMutation) SetName(s string) {
  19427. m.name = &s
  19428. }
  19429. // Name returns the value of the "name" field in the mutation.
  19430. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19431. v := m.name
  19432. if v == nil {
  19433. return
  19434. }
  19435. return *v, true
  19436. }
  19437. // OldName returns the old "name" field's value of the SopTask entity.
  19438. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19440. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19441. if !m.op.Is(OpUpdateOne) {
  19442. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19443. }
  19444. if m.id == nil || m.oldValue == nil {
  19445. return v, errors.New("OldName requires an ID field in the mutation")
  19446. }
  19447. oldValue, err := m.oldValue(ctx)
  19448. if err != nil {
  19449. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19450. }
  19451. return oldValue.Name, nil
  19452. }
  19453. // ResetName resets all changes to the "name" field.
  19454. func (m *SopTaskMutation) ResetName() {
  19455. m.name = nil
  19456. }
  19457. // SetBotWxidList sets the "bot_wxid_list" field.
  19458. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19459. m.bot_wxid_list = &s
  19460. m.appendbot_wxid_list = nil
  19461. }
  19462. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19463. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19464. v := m.bot_wxid_list
  19465. if v == nil {
  19466. return
  19467. }
  19468. return *v, true
  19469. }
  19470. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19471. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19473. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19474. if !m.op.Is(OpUpdateOne) {
  19475. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19476. }
  19477. if m.id == nil || m.oldValue == nil {
  19478. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19479. }
  19480. oldValue, err := m.oldValue(ctx)
  19481. if err != nil {
  19482. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19483. }
  19484. return oldValue.BotWxidList, nil
  19485. }
  19486. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19487. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19488. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19489. }
  19490. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19491. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19492. if len(m.appendbot_wxid_list) == 0 {
  19493. return nil, false
  19494. }
  19495. return m.appendbot_wxid_list, true
  19496. }
  19497. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19498. func (m *SopTaskMutation) ClearBotWxidList() {
  19499. m.bot_wxid_list = nil
  19500. m.appendbot_wxid_list = nil
  19501. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19502. }
  19503. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19504. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19505. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19506. return ok
  19507. }
  19508. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19509. func (m *SopTaskMutation) ResetBotWxidList() {
  19510. m.bot_wxid_list = nil
  19511. m.appendbot_wxid_list = nil
  19512. delete(m.clearedFields, soptask.FieldBotWxidList)
  19513. }
  19514. // SetType sets the "type" field.
  19515. func (m *SopTaskMutation) SetType(i int) {
  19516. m._type = &i
  19517. m.add_type = nil
  19518. }
  19519. // GetType returns the value of the "type" field in the mutation.
  19520. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19521. v := m._type
  19522. if v == nil {
  19523. return
  19524. }
  19525. return *v, true
  19526. }
  19527. // OldType returns the old "type" field's value of the SopTask entity.
  19528. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19530. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19531. if !m.op.Is(OpUpdateOne) {
  19532. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19533. }
  19534. if m.id == nil || m.oldValue == nil {
  19535. return v, errors.New("OldType requires an ID field in the mutation")
  19536. }
  19537. oldValue, err := m.oldValue(ctx)
  19538. if err != nil {
  19539. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19540. }
  19541. return oldValue.Type, nil
  19542. }
  19543. // AddType adds i to the "type" field.
  19544. func (m *SopTaskMutation) AddType(i int) {
  19545. if m.add_type != nil {
  19546. *m.add_type += i
  19547. } else {
  19548. m.add_type = &i
  19549. }
  19550. }
  19551. // AddedType returns the value that was added to the "type" field in this mutation.
  19552. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19553. v := m.add_type
  19554. if v == nil {
  19555. return
  19556. }
  19557. return *v, true
  19558. }
  19559. // ResetType resets all changes to the "type" field.
  19560. func (m *SopTaskMutation) ResetType() {
  19561. m._type = nil
  19562. m.add_type = nil
  19563. }
  19564. // SetPlanStartTime sets the "plan_start_time" field.
  19565. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19566. m.plan_start_time = &t
  19567. }
  19568. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19569. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19570. v := m.plan_start_time
  19571. if v == nil {
  19572. return
  19573. }
  19574. return *v, true
  19575. }
  19576. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19577. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19579. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19580. if !m.op.Is(OpUpdateOne) {
  19581. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19582. }
  19583. if m.id == nil || m.oldValue == nil {
  19584. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19585. }
  19586. oldValue, err := m.oldValue(ctx)
  19587. if err != nil {
  19588. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19589. }
  19590. return oldValue.PlanStartTime, nil
  19591. }
  19592. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19593. func (m *SopTaskMutation) ClearPlanStartTime() {
  19594. m.plan_start_time = nil
  19595. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19596. }
  19597. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19598. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19599. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19600. return ok
  19601. }
  19602. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19603. func (m *SopTaskMutation) ResetPlanStartTime() {
  19604. m.plan_start_time = nil
  19605. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19606. }
  19607. // SetPlanEndTime sets the "plan_end_time" field.
  19608. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19609. m.plan_end_time = &t
  19610. }
  19611. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19612. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19613. v := m.plan_end_time
  19614. if v == nil {
  19615. return
  19616. }
  19617. return *v, true
  19618. }
  19619. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19620. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19622. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19623. if !m.op.Is(OpUpdateOne) {
  19624. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19625. }
  19626. if m.id == nil || m.oldValue == nil {
  19627. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19628. }
  19629. oldValue, err := m.oldValue(ctx)
  19630. if err != nil {
  19631. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19632. }
  19633. return oldValue.PlanEndTime, nil
  19634. }
  19635. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19636. func (m *SopTaskMutation) ClearPlanEndTime() {
  19637. m.plan_end_time = nil
  19638. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19639. }
  19640. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19641. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19642. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19643. return ok
  19644. }
  19645. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19646. func (m *SopTaskMutation) ResetPlanEndTime() {
  19647. m.plan_end_time = nil
  19648. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19649. }
  19650. // SetCreatorID sets the "creator_id" field.
  19651. func (m *SopTaskMutation) SetCreatorID(s string) {
  19652. m.creator_id = &s
  19653. }
  19654. // CreatorID returns the value of the "creator_id" field in the mutation.
  19655. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19656. v := m.creator_id
  19657. if v == nil {
  19658. return
  19659. }
  19660. return *v, true
  19661. }
  19662. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19663. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19665. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19666. if !m.op.Is(OpUpdateOne) {
  19667. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19668. }
  19669. if m.id == nil || m.oldValue == nil {
  19670. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19671. }
  19672. oldValue, err := m.oldValue(ctx)
  19673. if err != nil {
  19674. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19675. }
  19676. return oldValue.CreatorID, nil
  19677. }
  19678. // ClearCreatorID clears the value of the "creator_id" field.
  19679. func (m *SopTaskMutation) ClearCreatorID() {
  19680. m.creator_id = nil
  19681. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19682. }
  19683. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19684. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19685. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19686. return ok
  19687. }
  19688. // ResetCreatorID resets all changes to the "creator_id" field.
  19689. func (m *SopTaskMutation) ResetCreatorID() {
  19690. m.creator_id = nil
  19691. delete(m.clearedFields, soptask.FieldCreatorID)
  19692. }
  19693. // SetOrganizationID sets the "organization_id" field.
  19694. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19695. m.organization_id = &u
  19696. m.addorganization_id = nil
  19697. }
  19698. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19699. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19700. v := m.organization_id
  19701. if v == nil {
  19702. return
  19703. }
  19704. return *v, true
  19705. }
  19706. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19707. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19709. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19710. if !m.op.Is(OpUpdateOne) {
  19711. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19712. }
  19713. if m.id == nil || m.oldValue == nil {
  19714. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19715. }
  19716. oldValue, err := m.oldValue(ctx)
  19717. if err != nil {
  19718. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19719. }
  19720. return oldValue.OrganizationID, nil
  19721. }
  19722. // AddOrganizationID adds u to the "organization_id" field.
  19723. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19724. if m.addorganization_id != nil {
  19725. *m.addorganization_id += u
  19726. } else {
  19727. m.addorganization_id = &u
  19728. }
  19729. }
  19730. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19731. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19732. v := m.addorganization_id
  19733. if v == nil {
  19734. return
  19735. }
  19736. return *v, true
  19737. }
  19738. // ClearOrganizationID clears the value of the "organization_id" field.
  19739. func (m *SopTaskMutation) ClearOrganizationID() {
  19740. m.organization_id = nil
  19741. m.addorganization_id = nil
  19742. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19743. }
  19744. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19745. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19746. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19747. return ok
  19748. }
  19749. // ResetOrganizationID resets all changes to the "organization_id" field.
  19750. func (m *SopTaskMutation) ResetOrganizationID() {
  19751. m.organization_id = nil
  19752. m.addorganization_id = nil
  19753. delete(m.clearedFields, soptask.FieldOrganizationID)
  19754. }
  19755. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19756. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19757. if m.task_stages == nil {
  19758. m.task_stages = make(map[uint64]struct{})
  19759. }
  19760. for i := range ids {
  19761. m.task_stages[ids[i]] = struct{}{}
  19762. }
  19763. }
  19764. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19765. func (m *SopTaskMutation) ClearTaskStages() {
  19766. m.clearedtask_stages = true
  19767. }
  19768. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19769. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19770. return m.clearedtask_stages
  19771. }
  19772. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19773. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19774. if m.removedtask_stages == nil {
  19775. m.removedtask_stages = make(map[uint64]struct{})
  19776. }
  19777. for i := range ids {
  19778. delete(m.task_stages, ids[i])
  19779. m.removedtask_stages[ids[i]] = struct{}{}
  19780. }
  19781. }
  19782. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19783. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19784. for id := range m.removedtask_stages {
  19785. ids = append(ids, id)
  19786. }
  19787. return
  19788. }
  19789. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19790. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19791. for id := range m.task_stages {
  19792. ids = append(ids, id)
  19793. }
  19794. return
  19795. }
  19796. // ResetTaskStages resets all changes to the "task_stages" edge.
  19797. func (m *SopTaskMutation) ResetTaskStages() {
  19798. m.task_stages = nil
  19799. m.clearedtask_stages = false
  19800. m.removedtask_stages = nil
  19801. }
  19802. // Where appends a list predicates to the SopTaskMutation builder.
  19803. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19804. m.predicates = append(m.predicates, ps...)
  19805. }
  19806. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  19807. // users can use type-assertion to append predicates that do not depend on any generated package.
  19808. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  19809. p := make([]predicate.SopTask, len(ps))
  19810. for i := range ps {
  19811. p[i] = ps[i]
  19812. }
  19813. m.Where(p...)
  19814. }
  19815. // Op returns the operation name.
  19816. func (m *SopTaskMutation) Op() Op {
  19817. return m.op
  19818. }
  19819. // SetOp allows setting the mutation operation.
  19820. func (m *SopTaskMutation) SetOp(op Op) {
  19821. m.op = op
  19822. }
  19823. // Type returns the node type of this mutation (SopTask).
  19824. func (m *SopTaskMutation) Type() string {
  19825. return m.typ
  19826. }
  19827. // Fields returns all fields that were changed during this mutation. Note that in
  19828. // order to get all numeric fields that were incremented/decremented, call
  19829. // AddedFields().
  19830. func (m *SopTaskMutation) Fields() []string {
  19831. fields := make([]string, 0, 11)
  19832. if m.created_at != nil {
  19833. fields = append(fields, soptask.FieldCreatedAt)
  19834. }
  19835. if m.updated_at != nil {
  19836. fields = append(fields, soptask.FieldUpdatedAt)
  19837. }
  19838. if m.status != nil {
  19839. fields = append(fields, soptask.FieldStatus)
  19840. }
  19841. if m.deleted_at != nil {
  19842. fields = append(fields, soptask.FieldDeletedAt)
  19843. }
  19844. if m.name != nil {
  19845. fields = append(fields, soptask.FieldName)
  19846. }
  19847. if m.bot_wxid_list != nil {
  19848. fields = append(fields, soptask.FieldBotWxidList)
  19849. }
  19850. if m._type != nil {
  19851. fields = append(fields, soptask.FieldType)
  19852. }
  19853. if m.plan_start_time != nil {
  19854. fields = append(fields, soptask.FieldPlanStartTime)
  19855. }
  19856. if m.plan_end_time != nil {
  19857. fields = append(fields, soptask.FieldPlanEndTime)
  19858. }
  19859. if m.creator_id != nil {
  19860. fields = append(fields, soptask.FieldCreatorID)
  19861. }
  19862. if m.organization_id != nil {
  19863. fields = append(fields, soptask.FieldOrganizationID)
  19864. }
  19865. return fields
  19866. }
  19867. // Field returns the value of a field with the given name. The second boolean
  19868. // return value indicates that this field was not set, or was not defined in the
  19869. // schema.
  19870. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  19871. switch name {
  19872. case soptask.FieldCreatedAt:
  19873. return m.CreatedAt()
  19874. case soptask.FieldUpdatedAt:
  19875. return m.UpdatedAt()
  19876. case soptask.FieldStatus:
  19877. return m.Status()
  19878. case soptask.FieldDeletedAt:
  19879. return m.DeletedAt()
  19880. case soptask.FieldName:
  19881. return m.Name()
  19882. case soptask.FieldBotWxidList:
  19883. return m.BotWxidList()
  19884. case soptask.FieldType:
  19885. return m.GetType()
  19886. case soptask.FieldPlanStartTime:
  19887. return m.PlanStartTime()
  19888. case soptask.FieldPlanEndTime:
  19889. return m.PlanEndTime()
  19890. case soptask.FieldCreatorID:
  19891. return m.CreatorID()
  19892. case soptask.FieldOrganizationID:
  19893. return m.OrganizationID()
  19894. }
  19895. return nil, false
  19896. }
  19897. // OldField returns the old value of the field from the database. An error is
  19898. // returned if the mutation operation is not UpdateOne, or the query to the
  19899. // database failed.
  19900. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19901. switch name {
  19902. case soptask.FieldCreatedAt:
  19903. return m.OldCreatedAt(ctx)
  19904. case soptask.FieldUpdatedAt:
  19905. return m.OldUpdatedAt(ctx)
  19906. case soptask.FieldStatus:
  19907. return m.OldStatus(ctx)
  19908. case soptask.FieldDeletedAt:
  19909. return m.OldDeletedAt(ctx)
  19910. case soptask.FieldName:
  19911. return m.OldName(ctx)
  19912. case soptask.FieldBotWxidList:
  19913. return m.OldBotWxidList(ctx)
  19914. case soptask.FieldType:
  19915. return m.OldType(ctx)
  19916. case soptask.FieldPlanStartTime:
  19917. return m.OldPlanStartTime(ctx)
  19918. case soptask.FieldPlanEndTime:
  19919. return m.OldPlanEndTime(ctx)
  19920. case soptask.FieldCreatorID:
  19921. return m.OldCreatorID(ctx)
  19922. case soptask.FieldOrganizationID:
  19923. return m.OldOrganizationID(ctx)
  19924. }
  19925. return nil, fmt.Errorf("unknown SopTask field %s", name)
  19926. }
  19927. // SetField sets the value of a field with the given name. It returns an error if
  19928. // the field is not defined in the schema, or if the type mismatched the field
  19929. // type.
  19930. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  19931. switch name {
  19932. case soptask.FieldCreatedAt:
  19933. v, ok := value.(time.Time)
  19934. if !ok {
  19935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19936. }
  19937. m.SetCreatedAt(v)
  19938. return nil
  19939. case soptask.FieldUpdatedAt:
  19940. v, ok := value.(time.Time)
  19941. if !ok {
  19942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19943. }
  19944. m.SetUpdatedAt(v)
  19945. return nil
  19946. case soptask.FieldStatus:
  19947. v, ok := value.(uint8)
  19948. if !ok {
  19949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19950. }
  19951. m.SetStatus(v)
  19952. return nil
  19953. case soptask.FieldDeletedAt:
  19954. v, ok := value.(time.Time)
  19955. if !ok {
  19956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19957. }
  19958. m.SetDeletedAt(v)
  19959. return nil
  19960. case soptask.FieldName:
  19961. v, ok := value.(string)
  19962. if !ok {
  19963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19964. }
  19965. m.SetName(v)
  19966. return nil
  19967. case soptask.FieldBotWxidList:
  19968. v, ok := value.([]string)
  19969. if !ok {
  19970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19971. }
  19972. m.SetBotWxidList(v)
  19973. return nil
  19974. case soptask.FieldType:
  19975. v, ok := value.(int)
  19976. if !ok {
  19977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19978. }
  19979. m.SetType(v)
  19980. return nil
  19981. case soptask.FieldPlanStartTime:
  19982. v, ok := value.(time.Time)
  19983. if !ok {
  19984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19985. }
  19986. m.SetPlanStartTime(v)
  19987. return nil
  19988. case soptask.FieldPlanEndTime:
  19989. v, ok := value.(time.Time)
  19990. if !ok {
  19991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19992. }
  19993. m.SetPlanEndTime(v)
  19994. return nil
  19995. case soptask.FieldCreatorID:
  19996. v, ok := value.(string)
  19997. if !ok {
  19998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19999. }
  20000. m.SetCreatorID(v)
  20001. return nil
  20002. case soptask.FieldOrganizationID:
  20003. v, ok := value.(uint64)
  20004. if !ok {
  20005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20006. }
  20007. m.SetOrganizationID(v)
  20008. return nil
  20009. }
  20010. return fmt.Errorf("unknown SopTask field %s", name)
  20011. }
  20012. // AddedFields returns all numeric fields that were incremented/decremented during
  20013. // this mutation.
  20014. func (m *SopTaskMutation) AddedFields() []string {
  20015. var fields []string
  20016. if m.addstatus != nil {
  20017. fields = append(fields, soptask.FieldStatus)
  20018. }
  20019. if m.add_type != nil {
  20020. fields = append(fields, soptask.FieldType)
  20021. }
  20022. if m.addorganization_id != nil {
  20023. fields = append(fields, soptask.FieldOrganizationID)
  20024. }
  20025. return fields
  20026. }
  20027. // AddedField returns the numeric value that was incremented/decremented on a field
  20028. // with the given name. The second boolean return value indicates that this field
  20029. // was not set, or was not defined in the schema.
  20030. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20031. switch name {
  20032. case soptask.FieldStatus:
  20033. return m.AddedStatus()
  20034. case soptask.FieldType:
  20035. return m.AddedType()
  20036. case soptask.FieldOrganizationID:
  20037. return m.AddedOrganizationID()
  20038. }
  20039. return nil, false
  20040. }
  20041. // AddField adds the value to the field with the given name. It returns an error if
  20042. // the field is not defined in the schema, or if the type mismatched the field
  20043. // type.
  20044. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20045. switch name {
  20046. case soptask.FieldStatus:
  20047. v, ok := value.(int8)
  20048. if !ok {
  20049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20050. }
  20051. m.AddStatus(v)
  20052. return nil
  20053. case soptask.FieldType:
  20054. v, ok := value.(int)
  20055. if !ok {
  20056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20057. }
  20058. m.AddType(v)
  20059. return nil
  20060. case soptask.FieldOrganizationID:
  20061. v, ok := value.(int64)
  20062. if !ok {
  20063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20064. }
  20065. m.AddOrganizationID(v)
  20066. return nil
  20067. }
  20068. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20069. }
  20070. // ClearedFields returns all nullable fields that were cleared during this
  20071. // mutation.
  20072. func (m *SopTaskMutation) ClearedFields() []string {
  20073. var fields []string
  20074. if m.FieldCleared(soptask.FieldStatus) {
  20075. fields = append(fields, soptask.FieldStatus)
  20076. }
  20077. if m.FieldCleared(soptask.FieldDeletedAt) {
  20078. fields = append(fields, soptask.FieldDeletedAt)
  20079. }
  20080. if m.FieldCleared(soptask.FieldBotWxidList) {
  20081. fields = append(fields, soptask.FieldBotWxidList)
  20082. }
  20083. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20084. fields = append(fields, soptask.FieldPlanStartTime)
  20085. }
  20086. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20087. fields = append(fields, soptask.FieldPlanEndTime)
  20088. }
  20089. if m.FieldCleared(soptask.FieldCreatorID) {
  20090. fields = append(fields, soptask.FieldCreatorID)
  20091. }
  20092. if m.FieldCleared(soptask.FieldOrganizationID) {
  20093. fields = append(fields, soptask.FieldOrganizationID)
  20094. }
  20095. return fields
  20096. }
  20097. // FieldCleared returns a boolean indicating if a field with the given name was
  20098. // cleared in this mutation.
  20099. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20100. _, ok := m.clearedFields[name]
  20101. return ok
  20102. }
  20103. // ClearField clears the value of the field with the given name. It returns an
  20104. // error if the field is not defined in the schema.
  20105. func (m *SopTaskMutation) ClearField(name string) error {
  20106. switch name {
  20107. case soptask.FieldStatus:
  20108. m.ClearStatus()
  20109. return nil
  20110. case soptask.FieldDeletedAt:
  20111. m.ClearDeletedAt()
  20112. return nil
  20113. case soptask.FieldBotWxidList:
  20114. m.ClearBotWxidList()
  20115. return nil
  20116. case soptask.FieldPlanStartTime:
  20117. m.ClearPlanStartTime()
  20118. return nil
  20119. case soptask.FieldPlanEndTime:
  20120. m.ClearPlanEndTime()
  20121. return nil
  20122. case soptask.FieldCreatorID:
  20123. m.ClearCreatorID()
  20124. return nil
  20125. case soptask.FieldOrganizationID:
  20126. m.ClearOrganizationID()
  20127. return nil
  20128. }
  20129. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20130. }
  20131. // ResetField resets all changes in the mutation for the field with the given name.
  20132. // It returns an error if the field is not defined in the schema.
  20133. func (m *SopTaskMutation) ResetField(name string) error {
  20134. switch name {
  20135. case soptask.FieldCreatedAt:
  20136. m.ResetCreatedAt()
  20137. return nil
  20138. case soptask.FieldUpdatedAt:
  20139. m.ResetUpdatedAt()
  20140. return nil
  20141. case soptask.FieldStatus:
  20142. m.ResetStatus()
  20143. return nil
  20144. case soptask.FieldDeletedAt:
  20145. m.ResetDeletedAt()
  20146. return nil
  20147. case soptask.FieldName:
  20148. m.ResetName()
  20149. return nil
  20150. case soptask.FieldBotWxidList:
  20151. m.ResetBotWxidList()
  20152. return nil
  20153. case soptask.FieldType:
  20154. m.ResetType()
  20155. return nil
  20156. case soptask.FieldPlanStartTime:
  20157. m.ResetPlanStartTime()
  20158. return nil
  20159. case soptask.FieldPlanEndTime:
  20160. m.ResetPlanEndTime()
  20161. return nil
  20162. case soptask.FieldCreatorID:
  20163. m.ResetCreatorID()
  20164. return nil
  20165. case soptask.FieldOrganizationID:
  20166. m.ResetOrganizationID()
  20167. return nil
  20168. }
  20169. return fmt.Errorf("unknown SopTask field %s", name)
  20170. }
  20171. // AddedEdges returns all edge names that were set/added in this mutation.
  20172. func (m *SopTaskMutation) AddedEdges() []string {
  20173. edges := make([]string, 0, 1)
  20174. if m.task_stages != nil {
  20175. edges = append(edges, soptask.EdgeTaskStages)
  20176. }
  20177. return edges
  20178. }
  20179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20180. // name in this mutation.
  20181. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20182. switch name {
  20183. case soptask.EdgeTaskStages:
  20184. ids := make([]ent.Value, 0, len(m.task_stages))
  20185. for id := range m.task_stages {
  20186. ids = append(ids, id)
  20187. }
  20188. return ids
  20189. }
  20190. return nil
  20191. }
  20192. // RemovedEdges returns all edge names that were removed in this mutation.
  20193. func (m *SopTaskMutation) RemovedEdges() []string {
  20194. edges := make([]string, 0, 1)
  20195. if m.removedtask_stages != nil {
  20196. edges = append(edges, soptask.EdgeTaskStages)
  20197. }
  20198. return edges
  20199. }
  20200. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20201. // the given name in this mutation.
  20202. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20203. switch name {
  20204. case soptask.EdgeTaskStages:
  20205. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20206. for id := range m.removedtask_stages {
  20207. ids = append(ids, id)
  20208. }
  20209. return ids
  20210. }
  20211. return nil
  20212. }
  20213. // ClearedEdges returns all edge names that were cleared in this mutation.
  20214. func (m *SopTaskMutation) ClearedEdges() []string {
  20215. edges := make([]string, 0, 1)
  20216. if m.clearedtask_stages {
  20217. edges = append(edges, soptask.EdgeTaskStages)
  20218. }
  20219. return edges
  20220. }
  20221. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20222. // was cleared in this mutation.
  20223. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20224. switch name {
  20225. case soptask.EdgeTaskStages:
  20226. return m.clearedtask_stages
  20227. }
  20228. return false
  20229. }
  20230. // ClearEdge clears the value of the edge with the given name. It returns an error
  20231. // if that edge is not defined in the schema.
  20232. func (m *SopTaskMutation) ClearEdge(name string) error {
  20233. switch name {
  20234. }
  20235. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20236. }
  20237. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20238. // It returns an error if the edge is not defined in the schema.
  20239. func (m *SopTaskMutation) ResetEdge(name string) error {
  20240. switch name {
  20241. case soptask.EdgeTaskStages:
  20242. m.ResetTaskStages()
  20243. return nil
  20244. }
  20245. return fmt.Errorf("unknown SopTask edge %s", name)
  20246. }
  20247. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20248. type TokenMutation struct {
  20249. config
  20250. op Op
  20251. typ string
  20252. id *uint64
  20253. created_at *time.Time
  20254. updated_at *time.Time
  20255. deleted_at *time.Time
  20256. expire_at *time.Time
  20257. token *string
  20258. mac *string
  20259. clearedFields map[string]struct{}
  20260. done bool
  20261. oldValue func(context.Context) (*Token, error)
  20262. predicates []predicate.Token
  20263. }
  20264. var _ ent.Mutation = (*TokenMutation)(nil)
  20265. // tokenOption allows management of the mutation configuration using functional options.
  20266. type tokenOption func(*TokenMutation)
  20267. // newTokenMutation creates new mutation for the Token entity.
  20268. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20269. m := &TokenMutation{
  20270. config: c,
  20271. op: op,
  20272. typ: TypeToken,
  20273. clearedFields: make(map[string]struct{}),
  20274. }
  20275. for _, opt := range opts {
  20276. opt(m)
  20277. }
  20278. return m
  20279. }
  20280. // withTokenID sets the ID field of the mutation.
  20281. func withTokenID(id uint64) tokenOption {
  20282. return func(m *TokenMutation) {
  20283. var (
  20284. err error
  20285. once sync.Once
  20286. value *Token
  20287. )
  20288. m.oldValue = func(ctx context.Context) (*Token, error) {
  20289. once.Do(func() {
  20290. if m.done {
  20291. err = errors.New("querying old values post mutation is not allowed")
  20292. } else {
  20293. value, err = m.Client().Token.Get(ctx, id)
  20294. }
  20295. })
  20296. return value, err
  20297. }
  20298. m.id = &id
  20299. }
  20300. }
  20301. // withToken sets the old Token of the mutation.
  20302. func withToken(node *Token) tokenOption {
  20303. return func(m *TokenMutation) {
  20304. m.oldValue = func(context.Context) (*Token, error) {
  20305. return node, nil
  20306. }
  20307. m.id = &node.ID
  20308. }
  20309. }
  20310. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20311. // executed in a transaction (ent.Tx), a transactional client is returned.
  20312. func (m TokenMutation) Client() *Client {
  20313. client := &Client{config: m.config}
  20314. client.init()
  20315. return client
  20316. }
  20317. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20318. // it returns an error otherwise.
  20319. func (m TokenMutation) Tx() (*Tx, error) {
  20320. if _, ok := m.driver.(*txDriver); !ok {
  20321. return nil, errors.New("ent: mutation is not running in a transaction")
  20322. }
  20323. tx := &Tx{config: m.config}
  20324. tx.init()
  20325. return tx, nil
  20326. }
  20327. // SetID sets the value of the id field. Note that this
  20328. // operation is only accepted on creation of Token entities.
  20329. func (m *TokenMutation) SetID(id uint64) {
  20330. m.id = &id
  20331. }
  20332. // ID returns the ID value in the mutation. Note that the ID is only available
  20333. // if it was provided to the builder or after it was returned from the database.
  20334. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20335. if m.id == nil {
  20336. return
  20337. }
  20338. return *m.id, true
  20339. }
  20340. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20341. // That means, if the mutation is applied within a transaction with an isolation level such
  20342. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20343. // or updated by the mutation.
  20344. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20345. switch {
  20346. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20347. id, exists := m.ID()
  20348. if exists {
  20349. return []uint64{id}, nil
  20350. }
  20351. fallthrough
  20352. case m.op.Is(OpUpdate | OpDelete):
  20353. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20354. default:
  20355. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20356. }
  20357. }
  20358. // SetCreatedAt sets the "created_at" field.
  20359. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20360. m.created_at = &t
  20361. }
  20362. // CreatedAt returns the value of the "created_at" field in the mutation.
  20363. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20364. v := m.created_at
  20365. if v == nil {
  20366. return
  20367. }
  20368. return *v, true
  20369. }
  20370. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20371. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20373. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20374. if !m.op.Is(OpUpdateOne) {
  20375. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20376. }
  20377. if m.id == nil || m.oldValue == nil {
  20378. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20379. }
  20380. oldValue, err := m.oldValue(ctx)
  20381. if err != nil {
  20382. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20383. }
  20384. return oldValue.CreatedAt, nil
  20385. }
  20386. // ResetCreatedAt resets all changes to the "created_at" field.
  20387. func (m *TokenMutation) ResetCreatedAt() {
  20388. m.created_at = nil
  20389. }
  20390. // SetUpdatedAt sets the "updated_at" field.
  20391. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20392. m.updated_at = &t
  20393. }
  20394. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20395. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20396. v := m.updated_at
  20397. if v == nil {
  20398. return
  20399. }
  20400. return *v, true
  20401. }
  20402. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20403. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20405. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20406. if !m.op.Is(OpUpdateOne) {
  20407. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20408. }
  20409. if m.id == nil || m.oldValue == nil {
  20410. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20411. }
  20412. oldValue, err := m.oldValue(ctx)
  20413. if err != nil {
  20414. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20415. }
  20416. return oldValue.UpdatedAt, nil
  20417. }
  20418. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20419. func (m *TokenMutation) ResetUpdatedAt() {
  20420. m.updated_at = nil
  20421. }
  20422. // SetDeletedAt sets the "deleted_at" field.
  20423. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20424. m.deleted_at = &t
  20425. }
  20426. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20427. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20428. v := m.deleted_at
  20429. if v == nil {
  20430. return
  20431. }
  20432. return *v, true
  20433. }
  20434. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20435. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20437. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20438. if !m.op.Is(OpUpdateOne) {
  20439. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20440. }
  20441. if m.id == nil || m.oldValue == nil {
  20442. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20443. }
  20444. oldValue, err := m.oldValue(ctx)
  20445. if err != nil {
  20446. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20447. }
  20448. return oldValue.DeletedAt, nil
  20449. }
  20450. // ClearDeletedAt clears the value of the "deleted_at" field.
  20451. func (m *TokenMutation) ClearDeletedAt() {
  20452. m.deleted_at = nil
  20453. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20454. }
  20455. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20456. func (m *TokenMutation) DeletedAtCleared() bool {
  20457. _, ok := m.clearedFields[token.FieldDeletedAt]
  20458. return ok
  20459. }
  20460. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20461. func (m *TokenMutation) ResetDeletedAt() {
  20462. m.deleted_at = nil
  20463. delete(m.clearedFields, token.FieldDeletedAt)
  20464. }
  20465. // SetExpireAt sets the "expire_at" field.
  20466. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20467. m.expire_at = &t
  20468. }
  20469. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20470. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20471. v := m.expire_at
  20472. if v == nil {
  20473. return
  20474. }
  20475. return *v, true
  20476. }
  20477. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20478. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20480. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20481. if !m.op.Is(OpUpdateOne) {
  20482. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20483. }
  20484. if m.id == nil || m.oldValue == nil {
  20485. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20486. }
  20487. oldValue, err := m.oldValue(ctx)
  20488. if err != nil {
  20489. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20490. }
  20491. return oldValue.ExpireAt, nil
  20492. }
  20493. // ClearExpireAt clears the value of the "expire_at" field.
  20494. func (m *TokenMutation) ClearExpireAt() {
  20495. m.expire_at = nil
  20496. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20497. }
  20498. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20499. func (m *TokenMutation) ExpireAtCleared() bool {
  20500. _, ok := m.clearedFields[token.FieldExpireAt]
  20501. return ok
  20502. }
  20503. // ResetExpireAt resets all changes to the "expire_at" field.
  20504. func (m *TokenMutation) ResetExpireAt() {
  20505. m.expire_at = nil
  20506. delete(m.clearedFields, token.FieldExpireAt)
  20507. }
  20508. // SetToken sets the "token" field.
  20509. func (m *TokenMutation) SetToken(s string) {
  20510. m.token = &s
  20511. }
  20512. // Token returns the value of the "token" field in the mutation.
  20513. func (m *TokenMutation) Token() (r string, exists bool) {
  20514. v := m.token
  20515. if v == nil {
  20516. return
  20517. }
  20518. return *v, true
  20519. }
  20520. // OldToken returns the old "token" field's value of the Token entity.
  20521. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20523. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20524. if !m.op.Is(OpUpdateOne) {
  20525. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20526. }
  20527. if m.id == nil || m.oldValue == nil {
  20528. return v, errors.New("OldToken requires an ID field in the mutation")
  20529. }
  20530. oldValue, err := m.oldValue(ctx)
  20531. if err != nil {
  20532. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20533. }
  20534. return oldValue.Token, nil
  20535. }
  20536. // ClearToken clears the value of the "token" field.
  20537. func (m *TokenMutation) ClearToken() {
  20538. m.token = nil
  20539. m.clearedFields[token.FieldToken] = struct{}{}
  20540. }
  20541. // TokenCleared returns if the "token" field was cleared in this mutation.
  20542. func (m *TokenMutation) TokenCleared() bool {
  20543. _, ok := m.clearedFields[token.FieldToken]
  20544. return ok
  20545. }
  20546. // ResetToken resets all changes to the "token" field.
  20547. func (m *TokenMutation) ResetToken() {
  20548. m.token = nil
  20549. delete(m.clearedFields, token.FieldToken)
  20550. }
  20551. // SetMAC sets the "mac" field.
  20552. func (m *TokenMutation) SetMAC(s string) {
  20553. m.mac = &s
  20554. }
  20555. // MAC returns the value of the "mac" field in the mutation.
  20556. func (m *TokenMutation) MAC() (r string, exists bool) {
  20557. v := m.mac
  20558. if v == nil {
  20559. return
  20560. }
  20561. return *v, true
  20562. }
  20563. // OldMAC returns the old "mac" field's value of the Token entity.
  20564. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20566. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20567. if !m.op.Is(OpUpdateOne) {
  20568. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20569. }
  20570. if m.id == nil || m.oldValue == nil {
  20571. return v, errors.New("OldMAC requires an ID field in the mutation")
  20572. }
  20573. oldValue, err := m.oldValue(ctx)
  20574. if err != nil {
  20575. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20576. }
  20577. return oldValue.MAC, nil
  20578. }
  20579. // ResetMAC resets all changes to the "mac" field.
  20580. func (m *TokenMutation) ResetMAC() {
  20581. m.mac = nil
  20582. }
  20583. // Where appends a list predicates to the TokenMutation builder.
  20584. func (m *TokenMutation) Where(ps ...predicate.Token) {
  20585. m.predicates = append(m.predicates, ps...)
  20586. }
  20587. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  20588. // users can use type-assertion to append predicates that do not depend on any generated package.
  20589. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  20590. p := make([]predicate.Token, len(ps))
  20591. for i := range ps {
  20592. p[i] = ps[i]
  20593. }
  20594. m.Where(p...)
  20595. }
  20596. // Op returns the operation name.
  20597. func (m *TokenMutation) Op() Op {
  20598. return m.op
  20599. }
  20600. // SetOp allows setting the mutation operation.
  20601. func (m *TokenMutation) SetOp(op Op) {
  20602. m.op = op
  20603. }
  20604. // Type returns the node type of this mutation (Token).
  20605. func (m *TokenMutation) Type() string {
  20606. return m.typ
  20607. }
  20608. // Fields returns all fields that were changed during this mutation. Note that in
  20609. // order to get all numeric fields that were incremented/decremented, call
  20610. // AddedFields().
  20611. func (m *TokenMutation) Fields() []string {
  20612. fields := make([]string, 0, 6)
  20613. if m.created_at != nil {
  20614. fields = append(fields, token.FieldCreatedAt)
  20615. }
  20616. if m.updated_at != nil {
  20617. fields = append(fields, token.FieldUpdatedAt)
  20618. }
  20619. if m.deleted_at != nil {
  20620. fields = append(fields, token.FieldDeletedAt)
  20621. }
  20622. if m.expire_at != nil {
  20623. fields = append(fields, token.FieldExpireAt)
  20624. }
  20625. if m.token != nil {
  20626. fields = append(fields, token.FieldToken)
  20627. }
  20628. if m.mac != nil {
  20629. fields = append(fields, token.FieldMAC)
  20630. }
  20631. return fields
  20632. }
  20633. // Field returns the value of a field with the given name. The second boolean
  20634. // return value indicates that this field was not set, or was not defined in the
  20635. // schema.
  20636. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  20637. switch name {
  20638. case token.FieldCreatedAt:
  20639. return m.CreatedAt()
  20640. case token.FieldUpdatedAt:
  20641. return m.UpdatedAt()
  20642. case token.FieldDeletedAt:
  20643. return m.DeletedAt()
  20644. case token.FieldExpireAt:
  20645. return m.ExpireAt()
  20646. case token.FieldToken:
  20647. return m.Token()
  20648. case token.FieldMAC:
  20649. return m.MAC()
  20650. }
  20651. return nil, false
  20652. }
  20653. // OldField returns the old value of the field from the database. An error is
  20654. // returned if the mutation operation is not UpdateOne, or the query to the
  20655. // database failed.
  20656. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20657. switch name {
  20658. case token.FieldCreatedAt:
  20659. return m.OldCreatedAt(ctx)
  20660. case token.FieldUpdatedAt:
  20661. return m.OldUpdatedAt(ctx)
  20662. case token.FieldDeletedAt:
  20663. return m.OldDeletedAt(ctx)
  20664. case token.FieldExpireAt:
  20665. return m.OldExpireAt(ctx)
  20666. case token.FieldToken:
  20667. return m.OldToken(ctx)
  20668. case token.FieldMAC:
  20669. return m.OldMAC(ctx)
  20670. }
  20671. return nil, fmt.Errorf("unknown Token field %s", name)
  20672. }
  20673. // SetField sets the value of a field with the given name. It returns an error if
  20674. // the field is not defined in the schema, or if the type mismatched the field
  20675. // type.
  20676. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  20677. switch name {
  20678. case token.FieldCreatedAt:
  20679. v, ok := value.(time.Time)
  20680. if !ok {
  20681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20682. }
  20683. m.SetCreatedAt(v)
  20684. return nil
  20685. case token.FieldUpdatedAt:
  20686. v, ok := value.(time.Time)
  20687. if !ok {
  20688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20689. }
  20690. m.SetUpdatedAt(v)
  20691. return nil
  20692. case token.FieldDeletedAt:
  20693. v, ok := value.(time.Time)
  20694. if !ok {
  20695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20696. }
  20697. m.SetDeletedAt(v)
  20698. return nil
  20699. case token.FieldExpireAt:
  20700. v, ok := value.(time.Time)
  20701. if !ok {
  20702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20703. }
  20704. m.SetExpireAt(v)
  20705. return nil
  20706. case token.FieldToken:
  20707. v, ok := value.(string)
  20708. if !ok {
  20709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20710. }
  20711. m.SetToken(v)
  20712. return nil
  20713. case token.FieldMAC:
  20714. v, ok := value.(string)
  20715. if !ok {
  20716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20717. }
  20718. m.SetMAC(v)
  20719. return nil
  20720. }
  20721. return fmt.Errorf("unknown Token field %s", name)
  20722. }
  20723. // AddedFields returns all numeric fields that were incremented/decremented during
  20724. // this mutation.
  20725. func (m *TokenMutation) AddedFields() []string {
  20726. return nil
  20727. }
  20728. // AddedField returns the numeric value that was incremented/decremented on a field
  20729. // with the given name. The second boolean return value indicates that this field
  20730. // was not set, or was not defined in the schema.
  20731. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  20732. return nil, false
  20733. }
  20734. // AddField adds the value to the field with the given name. It returns an error if
  20735. // the field is not defined in the schema, or if the type mismatched the field
  20736. // type.
  20737. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  20738. switch name {
  20739. }
  20740. return fmt.Errorf("unknown Token numeric field %s", name)
  20741. }
  20742. // ClearedFields returns all nullable fields that were cleared during this
  20743. // mutation.
  20744. func (m *TokenMutation) ClearedFields() []string {
  20745. var fields []string
  20746. if m.FieldCleared(token.FieldDeletedAt) {
  20747. fields = append(fields, token.FieldDeletedAt)
  20748. }
  20749. if m.FieldCleared(token.FieldExpireAt) {
  20750. fields = append(fields, token.FieldExpireAt)
  20751. }
  20752. if m.FieldCleared(token.FieldToken) {
  20753. fields = append(fields, token.FieldToken)
  20754. }
  20755. return fields
  20756. }
  20757. // FieldCleared returns a boolean indicating if a field with the given name was
  20758. // cleared in this mutation.
  20759. func (m *TokenMutation) FieldCleared(name string) bool {
  20760. _, ok := m.clearedFields[name]
  20761. return ok
  20762. }
  20763. // ClearField clears the value of the field with the given name. It returns an
  20764. // error if the field is not defined in the schema.
  20765. func (m *TokenMutation) ClearField(name string) error {
  20766. switch name {
  20767. case token.FieldDeletedAt:
  20768. m.ClearDeletedAt()
  20769. return nil
  20770. case token.FieldExpireAt:
  20771. m.ClearExpireAt()
  20772. return nil
  20773. case token.FieldToken:
  20774. m.ClearToken()
  20775. return nil
  20776. }
  20777. return fmt.Errorf("unknown Token nullable field %s", name)
  20778. }
  20779. // ResetField resets all changes in the mutation for the field with the given name.
  20780. // It returns an error if the field is not defined in the schema.
  20781. func (m *TokenMutation) ResetField(name string) error {
  20782. switch name {
  20783. case token.FieldCreatedAt:
  20784. m.ResetCreatedAt()
  20785. return nil
  20786. case token.FieldUpdatedAt:
  20787. m.ResetUpdatedAt()
  20788. return nil
  20789. case token.FieldDeletedAt:
  20790. m.ResetDeletedAt()
  20791. return nil
  20792. case token.FieldExpireAt:
  20793. m.ResetExpireAt()
  20794. return nil
  20795. case token.FieldToken:
  20796. m.ResetToken()
  20797. return nil
  20798. case token.FieldMAC:
  20799. m.ResetMAC()
  20800. return nil
  20801. }
  20802. return fmt.Errorf("unknown Token field %s", name)
  20803. }
  20804. // AddedEdges returns all edge names that were set/added in this mutation.
  20805. func (m *TokenMutation) AddedEdges() []string {
  20806. edges := make([]string, 0, 0)
  20807. return edges
  20808. }
  20809. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20810. // name in this mutation.
  20811. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  20812. return nil
  20813. }
  20814. // RemovedEdges returns all edge names that were removed in this mutation.
  20815. func (m *TokenMutation) RemovedEdges() []string {
  20816. edges := make([]string, 0, 0)
  20817. return edges
  20818. }
  20819. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20820. // the given name in this mutation.
  20821. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  20822. return nil
  20823. }
  20824. // ClearedEdges returns all edge names that were cleared in this mutation.
  20825. func (m *TokenMutation) ClearedEdges() []string {
  20826. edges := make([]string, 0, 0)
  20827. return edges
  20828. }
  20829. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20830. // was cleared in this mutation.
  20831. func (m *TokenMutation) EdgeCleared(name string) bool {
  20832. return false
  20833. }
  20834. // ClearEdge clears the value of the edge with the given name. It returns an error
  20835. // if that edge is not defined in the schema.
  20836. func (m *TokenMutation) ClearEdge(name string) error {
  20837. return fmt.Errorf("unknown Token unique edge %s", name)
  20838. }
  20839. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20840. // It returns an error if the edge is not defined in the schema.
  20841. func (m *TokenMutation) ResetEdge(name string) error {
  20842. return fmt.Errorf("unknown Token edge %s", name)
  20843. }
  20844. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  20845. type TutorialMutation struct {
  20846. config
  20847. op Op
  20848. typ string
  20849. id *uint64
  20850. created_at *time.Time
  20851. updated_at *time.Time
  20852. deleted_at *time.Time
  20853. index *int
  20854. addindex *int
  20855. title *string
  20856. content *string
  20857. organization_id *uint64
  20858. addorganization_id *int64
  20859. clearedFields map[string]struct{}
  20860. employee *uint64
  20861. clearedemployee bool
  20862. done bool
  20863. oldValue func(context.Context) (*Tutorial, error)
  20864. predicates []predicate.Tutorial
  20865. }
  20866. var _ ent.Mutation = (*TutorialMutation)(nil)
  20867. // tutorialOption allows management of the mutation configuration using functional options.
  20868. type tutorialOption func(*TutorialMutation)
  20869. // newTutorialMutation creates new mutation for the Tutorial entity.
  20870. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  20871. m := &TutorialMutation{
  20872. config: c,
  20873. op: op,
  20874. typ: TypeTutorial,
  20875. clearedFields: make(map[string]struct{}),
  20876. }
  20877. for _, opt := range opts {
  20878. opt(m)
  20879. }
  20880. return m
  20881. }
  20882. // withTutorialID sets the ID field of the mutation.
  20883. func withTutorialID(id uint64) tutorialOption {
  20884. return func(m *TutorialMutation) {
  20885. var (
  20886. err error
  20887. once sync.Once
  20888. value *Tutorial
  20889. )
  20890. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  20891. once.Do(func() {
  20892. if m.done {
  20893. err = errors.New("querying old values post mutation is not allowed")
  20894. } else {
  20895. value, err = m.Client().Tutorial.Get(ctx, id)
  20896. }
  20897. })
  20898. return value, err
  20899. }
  20900. m.id = &id
  20901. }
  20902. }
  20903. // withTutorial sets the old Tutorial of the mutation.
  20904. func withTutorial(node *Tutorial) tutorialOption {
  20905. return func(m *TutorialMutation) {
  20906. m.oldValue = func(context.Context) (*Tutorial, error) {
  20907. return node, nil
  20908. }
  20909. m.id = &node.ID
  20910. }
  20911. }
  20912. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20913. // executed in a transaction (ent.Tx), a transactional client is returned.
  20914. func (m TutorialMutation) Client() *Client {
  20915. client := &Client{config: m.config}
  20916. client.init()
  20917. return client
  20918. }
  20919. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20920. // it returns an error otherwise.
  20921. func (m TutorialMutation) Tx() (*Tx, error) {
  20922. if _, ok := m.driver.(*txDriver); !ok {
  20923. return nil, errors.New("ent: mutation is not running in a transaction")
  20924. }
  20925. tx := &Tx{config: m.config}
  20926. tx.init()
  20927. return tx, nil
  20928. }
  20929. // SetID sets the value of the id field. Note that this
  20930. // operation is only accepted on creation of Tutorial entities.
  20931. func (m *TutorialMutation) SetID(id uint64) {
  20932. m.id = &id
  20933. }
  20934. // ID returns the ID value in the mutation. Note that the ID is only available
  20935. // if it was provided to the builder or after it was returned from the database.
  20936. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  20937. if m.id == nil {
  20938. return
  20939. }
  20940. return *m.id, true
  20941. }
  20942. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20943. // That means, if the mutation is applied within a transaction with an isolation level such
  20944. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20945. // or updated by the mutation.
  20946. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  20947. switch {
  20948. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20949. id, exists := m.ID()
  20950. if exists {
  20951. return []uint64{id}, nil
  20952. }
  20953. fallthrough
  20954. case m.op.Is(OpUpdate | OpDelete):
  20955. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  20956. default:
  20957. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20958. }
  20959. }
  20960. // SetCreatedAt sets the "created_at" field.
  20961. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  20962. m.created_at = &t
  20963. }
  20964. // CreatedAt returns the value of the "created_at" field in the mutation.
  20965. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  20966. v := m.created_at
  20967. if v == nil {
  20968. return
  20969. }
  20970. return *v, true
  20971. }
  20972. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  20973. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  20974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20975. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20976. if !m.op.Is(OpUpdateOne) {
  20977. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20978. }
  20979. if m.id == nil || m.oldValue == nil {
  20980. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20981. }
  20982. oldValue, err := m.oldValue(ctx)
  20983. if err != nil {
  20984. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20985. }
  20986. return oldValue.CreatedAt, nil
  20987. }
  20988. // ResetCreatedAt resets all changes to the "created_at" field.
  20989. func (m *TutorialMutation) ResetCreatedAt() {
  20990. m.created_at = nil
  20991. }
  20992. // SetUpdatedAt sets the "updated_at" field.
  20993. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  20994. m.updated_at = &t
  20995. }
  20996. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20997. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  20998. v := m.updated_at
  20999. if v == nil {
  21000. return
  21001. }
  21002. return *v, true
  21003. }
  21004. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21005. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21007. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21008. if !m.op.Is(OpUpdateOne) {
  21009. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21010. }
  21011. if m.id == nil || m.oldValue == nil {
  21012. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21013. }
  21014. oldValue, err := m.oldValue(ctx)
  21015. if err != nil {
  21016. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21017. }
  21018. return oldValue.UpdatedAt, nil
  21019. }
  21020. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21021. func (m *TutorialMutation) ResetUpdatedAt() {
  21022. m.updated_at = nil
  21023. }
  21024. // SetDeletedAt sets the "deleted_at" field.
  21025. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21026. m.deleted_at = &t
  21027. }
  21028. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21029. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21030. v := m.deleted_at
  21031. if v == nil {
  21032. return
  21033. }
  21034. return *v, true
  21035. }
  21036. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21037. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21039. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21040. if !m.op.Is(OpUpdateOne) {
  21041. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21042. }
  21043. if m.id == nil || m.oldValue == nil {
  21044. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21045. }
  21046. oldValue, err := m.oldValue(ctx)
  21047. if err != nil {
  21048. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21049. }
  21050. return oldValue.DeletedAt, nil
  21051. }
  21052. // ClearDeletedAt clears the value of the "deleted_at" field.
  21053. func (m *TutorialMutation) ClearDeletedAt() {
  21054. m.deleted_at = nil
  21055. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21056. }
  21057. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21058. func (m *TutorialMutation) DeletedAtCleared() bool {
  21059. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21060. return ok
  21061. }
  21062. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21063. func (m *TutorialMutation) ResetDeletedAt() {
  21064. m.deleted_at = nil
  21065. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21066. }
  21067. // SetEmployeeID sets the "employee_id" field.
  21068. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21069. m.employee = &u
  21070. }
  21071. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21072. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21073. v := m.employee
  21074. if v == nil {
  21075. return
  21076. }
  21077. return *v, true
  21078. }
  21079. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21080. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21082. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21083. if !m.op.Is(OpUpdateOne) {
  21084. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21085. }
  21086. if m.id == nil || m.oldValue == nil {
  21087. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21088. }
  21089. oldValue, err := m.oldValue(ctx)
  21090. if err != nil {
  21091. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21092. }
  21093. return oldValue.EmployeeID, nil
  21094. }
  21095. // ResetEmployeeID resets all changes to the "employee_id" field.
  21096. func (m *TutorialMutation) ResetEmployeeID() {
  21097. m.employee = nil
  21098. }
  21099. // SetIndex sets the "index" field.
  21100. func (m *TutorialMutation) SetIndex(i int) {
  21101. m.index = &i
  21102. m.addindex = nil
  21103. }
  21104. // Index returns the value of the "index" field in the mutation.
  21105. func (m *TutorialMutation) Index() (r int, exists bool) {
  21106. v := m.index
  21107. if v == nil {
  21108. return
  21109. }
  21110. return *v, true
  21111. }
  21112. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21113. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21115. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21116. if !m.op.Is(OpUpdateOne) {
  21117. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21118. }
  21119. if m.id == nil || m.oldValue == nil {
  21120. return v, errors.New("OldIndex requires an ID field in the mutation")
  21121. }
  21122. oldValue, err := m.oldValue(ctx)
  21123. if err != nil {
  21124. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21125. }
  21126. return oldValue.Index, nil
  21127. }
  21128. // AddIndex adds i to the "index" field.
  21129. func (m *TutorialMutation) AddIndex(i int) {
  21130. if m.addindex != nil {
  21131. *m.addindex += i
  21132. } else {
  21133. m.addindex = &i
  21134. }
  21135. }
  21136. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21137. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21138. v := m.addindex
  21139. if v == nil {
  21140. return
  21141. }
  21142. return *v, true
  21143. }
  21144. // ResetIndex resets all changes to the "index" field.
  21145. func (m *TutorialMutation) ResetIndex() {
  21146. m.index = nil
  21147. m.addindex = nil
  21148. }
  21149. // SetTitle sets the "title" field.
  21150. func (m *TutorialMutation) SetTitle(s string) {
  21151. m.title = &s
  21152. }
  21153. // Title returns the value of the "title" field in the mutation.
  21154. func (m *TutorialMutation) Title() (r string, exists bool) {
  21155. v := m.title
  21156. if v == nil {
  21157. return
  21158. }
  21159. return *v, true
  21160. }
  21161. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21162. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21164. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21165. if !m.op.Is(OpUpdateOne) {
  21166. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21167. }
  21168. if m.id == nil || m.oldValue == nil {
  21169. return v, errors.New("OldTitle requires an ID field in the mutation")
  21170. }
  21171. oldValue, err := m.oldValue(ctx)
  21172. if err != nil {
  21173. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21174. }
  21175. return oldValue.Title, nil
  21176. }
  21177. // ResetTitle resets all changes to the "title" field.
  21178. func (m *TutorialMutation) ResetTitle() {
  21179. m.title = nil
  21180. }
  21181. // SetContent sets the "content" field.
  21182. func (m *TutorialMutation) SetContent(s string) {
  21183. m.content = &s
  21184. }
  21185. // Content returns the value of the "content" field in the mutation.
  21186. func (m *TutorialMutation) Content() (r string, exists bool) {
  21187. v := m.content
  21188. if v == nil {
  21189. return
  21190. }
  21191. return *v, true
  21192. }
  21193. // OldContent returns the old "content" field's value of the Tutorial entity.
  21194. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21196. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21197. if !m.op.Is(OpUpdateOne) {
  21198. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21199. }
  21200. if m.id == nil || m.oldValue == nil {
  21201. return v, errors.New("OldContent requires an ID field in the mutation")
  21202. }
  21203. oldValue, err := m.oldValue(ctx)
  21204. if err != nil {
  21205. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21206. }
  21207. return oldValue.Content, nil
  21208. }
  21209. // ResetContent resets all changes to the "content" field.
  21210. func (m *TutorialMutation) ResetContent() {
  21211. m.content = nil
  21212. }
  21213. // SetOrganizationID sets the "organization_id" field.
  21214. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21215. m.organization_id = &u
  21216. m.addorganization_id = nil
  21217. }
  21218. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21219. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21220. v := m.organization_id
  21221. if v == nil {
  21222. return
  21223. }
  21224. return *v, true
  21225. }
  21226. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21227. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21229. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21230. if !m.op.Is(OpUpdateOne) {
  21231. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21232. }
  21233. if m.id == nil || m.oldValue == nil {
  21234. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21235. }
  21236. oldValue, err := m.oldValue(ctx)
  21237. if err != nil {
  21238. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21239. }
  21240. return oldValue.OrganizationID, nil
  21241. }
  21242. // AddOrganizationID adds u to the "organization_id" field.
  21243. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21244. if m.addorganization_id != nil {
  21245. *m.addorganization_id += u
  21246. } else {
  21247. m.addorganization_id = &u
  21248. }
  21249. }
  21250. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21251. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21252. v := m.addorganization_id
  21253. if v == nil {
  21254. return
  21255. }
  21256. return *v, true
  21257. }
  21258. // ResetOrganizationID resets all changes to the "organization_id" field.
  21259. func (m *TutorialMutation) ResetOrganizationID() {
  21260. m.organization_id = nil
  21261. m.addorganization_id = nil
  21262. }
  21263. // ClearEmployee clears the "employee" edge to the Employee entity.
  21264. func (m *TutorialMutation) ClearEmployee() {
  21265. m.clearedemployee = true
  21266. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21267. }
  21268. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21269. func (m *TutorialMutation) EmployeeCleared() bool {
  21270. return m.clearedemployee
  21271. }
  21272. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21273. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21274. // EmployeeID instead. It exists only for internal usage by the builders.
  21275. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21276. if id := m.employee; id != nil {
  21277. ids = append(ids, *id)
  21278. }
  21279. return
  21280. }
  21281. // ResetEmployee resets all changes to the "employee" edge.
  21282. func (m *TutorialMutation) ResetEmployee() {
  21283. m.employee = nil
  21284. m.clearedemployee = false
  21285. }
  21286. // Where appends a list predicates to the TutorialMutation builder.
  21287. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21288. m.predicates = append(m.predicates, ps...)
  21289. }
  21290. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21291. // users can use type-assertion to append predicates that do not depend on any generated package.
  21292. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21293. p := make([]predicate.Tutorial, len(ps))
  21294. for i := range ps {
  21295. p[i] = ps[i]
  21296. }
  21297. m.Where(p...)
  21298. }
  21299. // Op returns the operation name.
  21300. func (m *TutorialMutation) Op() Op {
  21301. return m.op
  21302. }
  21303. // SetOp allows setting the mutation operation.
  21304. func (m *TutorialMutation) SetOp(op Op) {
  21305. m.op = op
  21306. }
  21307. // Type returns the node type of this mutation (Tutorial).
  21308. func (m *TutorialMutation) Type() string {
  21309. return m.typ
  21310. }
  21311. // Fields returns all fields that were changed during this mutation. Note that in
  21312. // order to get all numeric fields that were incremented/decremented, call
  21313. // AddedFields().
  21314. func (m *TutorialMutation) Fields() []string {
  21315. fields := make([]string, 0, 8)
  21316. if m.created_at != nil {
  21317. fields = append(fields, tutorial.FieldCreatedAt)
  21318. }
  21319. if m.updated_at != nil {
  21320. fields = append(fields, tutorial.FieldUpdatedAt)
  21321. }
  21322. if m.deleted_at != nil {
  21323. fields = append(fields, tutorial.FieldDeletedAt)
  21324. }
  21325. if m.employee != nil {
  21326. fields = append(fields, tutorial.FieldEmployeeID)
  21327. }
  21328. if m.index != nil {
  21329. fields = append(fields, tutorial.FieldIndex)
  21330. }
  21331. if m.title != nil {
  21332. fields = append(fields, tutorial.FieldTitle)
  21333. }
  21334. if m.content != nil {
  21335. fields = append(fields, tutorial.FieldContent)
  21336. }
  21337. if m.organization_id != nil {
  21338. fields = append(fields, tutorial.FieldOrganizationID)
  21339. }
  21340. return fields
  21341. }
  21342. // Field returns the value of a field with the given name. The second boolean
  21343. // return value indicates that this field was not set, or was not defined in the
  21344. // schema.
  21345. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  21346. switch name {
  21347. case tutorial.FieldCreatedAt:
  21348. return m.CreatedAt()
  21349. case tutorial.FieldUpdatedAt:
  21350. return m.UpdatedAt()
  21351. case tutorial.FieldDeletedAt:
  21352. return m.DeletedAt()
  21353. case tutorial.FieldEmployeeID:
  21354. return m.EmployeeID()
  21355. case tutorial.FieldIndex:
  21356. return m.Index()
  21357. case tutorial.FieldTitle:
  21358. return m.Title()
  21359. case tutorial.FieldContent:
  21360. return m.Content()
  21361. case tutorial.FieldOrganizationID:
  21362. return m.OrganizationID()
  21363. }
  21364. return nil, false
  21365. }
  21366. // OldField returns the old value of the field from the database. An error is
  21367. // returned if the mutation operation is not UpdateOne, or the query to the
  21368. // database failed.
  21369. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21370. switch name {
  21371. case tutorial.FieldCreatedAt:
  21372. return m.OldCreatedAt(ctx)
  21373. case tutorial.FieldUpdatedAt:
  21374. return m.OldUpdatedAt(ctx)
  21375. case tutorial.FieldDeletedAt:
  21376. return m.OldDeletedAt(ctx)
  21377. case tutorial.FieldEmployeeID:
  21378. return m.OldEmployeeID(ctx)
  21379. case tutorial.FieldIndex:
  21380. return m.OldIndex(ctx)
  21381. case tutorial.FieldTitle:
  21382. return m.OldTitle(ctx)
  21383. case tutorial.FieldContent:
  21384. return m.OldContent(ctx)
  21385. case tutorial.FieldOrganizationID:
  21386. return m.OldOrganizationID(ctx)
  21387. }
  21388. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  21389. }
  21390. // SetField sets the value of a field with the given name. It returns an error if
  21391. // the field is not defined in the schema, or if the type mismatched the field
  21392. // type.
  21393. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  21394. switch name {
  21395. case tutorial.FieldCreatedAt:
  21396. v, ok := value.(time.Time)
  21397. if !ok {
  21398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21399. }
  21400. m.SetCreatedAt(v)
  21401. return nil
  21402. case tutorial.FieldUpdatedAt:
  21403. v, ok := value.(time.Time)
  21404. if !ok {
  21405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21406. }
  21407. m.SetUpdatedAt(v)
  21408. return nil
  21409. case tutorial.FieldDeletedAt:
  21410. v, ok := value.(time.Time)
  21411. if !ok {
  21412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21413. }
  21414. m.SetDeletedAt(v)
  21415. return nil
  21416. case tutorial.FieldEmployeeID:
  21417. v, ok := value.(uint64)
  21418. if !ok {
  21419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21420. }
  21421. m.SetEmployeeID(v)
  21422. return nil
  21423. case tutorial.FieldIndex:
  21424. v, ok := value.(int)
  21425. if !ok {
  21426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21427. }
  21428. m.SetIndex(v)
  21429. return nil
  21430. case tutorial.FieldTitle:
  21431. v, ok := value.(string)
  21432. if !ok {
  21433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21434. }
  21435. m.SetTitle(v)
  21436. return nil
  21437. case tutorial.FieldContent:
  21438. v, ok := value.(string)
  21439. if !ok {
  21440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21441. }
  21442. m.SetContent(v)
  21443. return nil
  21444. case tutorial.FieldOrganizationID:
  21445. v, ok := value.(uint64)
  21446. if !ok {
  21447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21448. }
  21449. m.SetOrganizationID(v)
  21450. return nil
  21451. }
  21452. return fmt.Errorf("unknown Tutorial field %s", name)
  21453. }
  21454. // AddedFields returns all numeric fields that were incremented/decremented during
  21455. // this mutation.
  21456. func (m *TutorialMutation) AddedFields() []string {
  21457. var fields []string
  21458. if m.addindex != nil {
  21459. fields = append(fields, tutorial.FieldIndex)
  21460. }
  21461. if m.addorganization_id != nil {
  21462. fields = append(fields, tutorial.FieldOrganizationID)
  21463. }
  21464. return fields
  21465. }
  21466. // AddedField returns the numeric value that was incremented/decremented on a field
  21467. // with the given name. The second boolean return value indicates that this field
  21468. // was not set, or was not defined in the schema.
  21469. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  21470. switch name {
  21471. case tutorial.FieldIndex:
  21472. return m.AddedIndex()
  21473. case tutorial.FieldOrganizationID:
  21474. return m.AddedOrganizationID()
  21475. }
  21476. return nil, false
  21477. }
  21478. // AddField adds the value to the field with the given name. It returns an error if
  21479. // the field is not defined in the schema, or if the type mismatched the field
  21480. // type.
  21481. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  21482. switch name {
  21483. case tutorial.FieldIndex:
  21484. v, ok := value.(int)
  21485. if !ok {
  21486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21487. }
  21488. m.AddIndex(v)
  21489. return nil
  21490. case tutorial.FieldOrganizationID:
  21491. v, ok := value.(int64)
  21492. if !ok {
  21493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21494. }
  21495. m.AddOrganizationID(v)
  21496. return nil
  21497. }
  21498. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  21499. }
  21500. // ClearedFields returns all nullable fields that were cleared during this
  21501. // mutation.
  21502. func (m *TutorialMutation) ClearedFields() []string {
  21503. var fields []string
  21504. if m.FieldCleared(tutorial.FieldDeletedAt) {
  21505. fields = append(fields, tutorial.FieldDeletedAt)
  21506. }
  21507. return fields
  21508. }
  21509. // FieldCleared returns a boolean indicating if a field with the given name was
  21510. // cleared in this mutation.
  21511. func (m *TutorialMutation) FieldCleared(name string) bool {
  21512. _, ok := m.clearedFields[name]
  21513. return ok
  21514. }
  21515. // ClearField clears the value of the field with the given name. It returns an
  21516. // error if the field is not defined in the schema.
  21517. func (m *TutorialMutation) ClearField(name string) error {
  21518. switch name {
  21519. case tutorial.FieldDeletedAt:
  21520. m.ClearDeletedAt()
  21521. return nil
  21522. }
  21523. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  21524. }
  21525. // ResetField resets all changes in the mutation for the field with the given name.
  21526. // It returns an error if the field is not defined in the schema.
  21527. func (m *TutorialMutation) ResetField(name string) error {
  21528. switch name {
  21529. case tutorial.FieldCreatedAt:
  21530. m.ResetCreatedAt()
  21531. return nil
  21532. case tutorial.FieldUpdatedAt:
  21533. m.ResetUpdatedAt()
  21534. return nil
  21535. case tutorial.FieldDeletedAt:
  21536. m.ResetDeletedAt()
  21537. return nil
  21538. case tutorial.FieldEmployeeID:
  21539. m.ResetEmployeeID()
  21540. return nil
  21541. case tutorial.FieldIndex:
  21542. m.ResetIndex()
  21543. return nil
  21544. case tutorial.FieldTitle:
  21545. m.ResetTitle()
  21546. return nil
  21547. case tutorial.FieldContent:
  21548. m.ResetContent()
  21549. return nil
  21550. case tutorial.FieldOrganizationID:
  21551. m.ResetOrganizationID()
  21552. return nil
  21553. }
  21554. return fmt.Errorf("unknown Tutorial field %s", name)
  21555. }
  21556. // AddedEdges returns all edge names that were set/added in this mutation.
  21557. func (m *TutorialMutation) AddedEdges() []string {
  21558. edges := make([]string, 0, 1)
  21559. if m.employee != nil {
  21560. edges = append(edges, tutorial.EdgeEmployee)
  21561. }
  21562. return edges
  21563. }
  21564. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21565. // name in this mutation.
  21566. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  21567. switch name {
  21568. case tutorial.EdgeEmployee:
  21569. if id := m.employee; id != nil {
  21570. return []ent.Value{*id}
  21571. }
  21572. }
  21573. return nil
  21574. }
  21575. // RemovedEdges returns all edge names that were removed in this mutation.
  21576. func (m *TutorialMutation) RemovedEdges() []string {
  21577. edges := make([]string, 0, 1)
  21578. return edges
  21579. }
  21580. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21581. // the given name in this mutation.
  21582. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  21583. return nil
  21584. }
  21585. // ClearedEdges returns all edge names that were cleared in this mutation.
  21586. func (m *TutorialMutation) ClearedEdges() []string {
  21587. edges := make([]string, 0, 1)
  21588. if m.clearedemployee {
  21589. edges = append(edges, tutorial.EdgeEmployee)
  21590. }
  21591. return edges
  21592. }
  21593. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21594. // was cleared in this mutation.
  21595. func (m *TutorialMutation) EdgeCleared(name string) bool {
  21596. switch name {
  21597. case tutorial.EdgeEmployee:
  21598. return m.clearedemployee
  21599. }
  21600. return false
  21601. }
  21602. // ClearEdge clears the value of the edge with the given name. It returns an error
  21603. // if that edge is not defined in the schema.
  21604. func (m *TutorialMutation) ClearEdge(name string) error {
  21605. switch name {
  21606. case tutorial.EdgeEmployee:
  21607. m.ClearEmployee()
  21608. return nil
  21609. }
  21610. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  21611. }
  21612. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21613. // It returns an error if the edge is not defined in the schema.
  21614. func (m *TutorialMutation) ResetEdge(name string) error {
  21615. switch name {
  21616. case tutorial.EdgeEmployee:
  21617. m.ResetEmployee()
  21618. return nil
  21619. }
  21620. return fmt.Errorf("unknown Tutorial edge %s", name)
  21621. }
  21622. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  21623. type WorkExperienceMutation struct {
  21624. config
  21625. op Op
  21626. typ string
  21627. id *uint64
  21628. created_at *time.Time
  21629. updated_at *time.Time
  21630. deleted_at *time.Time
  21631. start_date *time.Time
  21632. end_date *time.Time
  21633. company *string
  21634. experience *string
  21635. organization_id *uint64
  21636. addorganization_id *int64
  21637. clearedFields map[string]struct{}
  21638. employee *uint64
  21639. clearedemployee bool
  21640. done bool
  21641. oldValue func(context.Context) (*WorkExperience, error)
  21642. predicates []predicate.WorkExperience
  21643. }
  21644. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  21645. // workexperienceOption allows management of the mutation configuration using functional options.
  21646. type workexperienceOption func(*WorkExperienceMutation)
  21647. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  21648. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  21649. m := &WorkExperienceMutation{
  21650. config: c,
  21651. op: op,
  21652. typ: TypeWorkExperience,
  21653. clearedFields: make(map[string]struct{}),
  21654. }
  21655. for _, opt := range opts {
  21656. opt(m)
  21657. }
  21658. return m
  21659. }
  21660. // withWorkExperienceID sets the ID field of the mutation.
  21661. func withWorkExperienceID(id uint64) workexperienceOption {
  21662. return func(m *WorkExperienceMutation) {
  21663. var (
  21664. err error
  21665. once sync.Once
  21666. value *WorkExperience
  21667. )
  21668. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  21669. once.Do(func() {
  21670. if m.done {
  21671. err = errors.New("querying old values post mutation is not allowed")
  21672. } else {
  21673. value, err = m.Client().WorkExperience.Get(ctx, id)
  21674. }
  21675. })
  21676. return value, err
  21677. }
  21678. m.id = &id
  21679. }
  21680. }
  21681. // withWorkExperience sets the old WorkExperience of the mutation.
  21682. func withWorkExperience(node *WorkExperience) workexperienceOption {
  21683. return func(m *WorkExperienceMutation) {
  21684. m.oldValue = func(context.Context) (*WorkExperience, error) {
  21685. return node, nil
  21686. }
  21687. m.id = &node.ID
  21688. }
  21689. }
  21690. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21691. // executed in a transaction (ent.Tx), a transactional client is returned.
  21692. func (m WorkExperienceMutation) Client() *Client {
  21693. client := &Client{config: m.config}
  21694. client.init()
  21695. return client
  21696. }
  21697. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21698. // it returns an error otherwise.
  21699. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  21700. if _, ok := m.driver.(*txDriver); !ok {
  21701. return nil, errors.New("ent: mutation is not running in a transaction")
  21702. }
  21703. tx := &Tx{config: m.config}
  21704. tx.init()
  21705. return tx, nil
  21706. }
  21707. // SetID sets the value of the id field. Note that this
  21708. // operation is only accepted on creation of WorkExperience entities.
  21709. func (m *WorkExperienceMutation) SetID(id uint64) {
  21710. m.id = &id
  21711. }
  21712. // ID returns the ID value in the mutation. Note that the ID is only available
  21713. // if it was provided to the builder or after it was returned from the database.
  21714. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  21715. if m.id == nil {
  21716. return
  21717. }
  21718. return *m.id, true
  21719. }
  21720. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21721. // That means, if the mutation is applied within a transaction with an isolation level such
  21722. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21723. // or updated by the mutation.
  21724. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  21725. switch {
  21726. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21727. id, exists := m.ID()
  21728. if exists {
  21729. return []uint64{id}, nil
  21730. }
  21731. fallthrough
  21732. case m.op.Is(OpUpdate | OpDelete):
  21733. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  21734. default:
  21735. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21736. }
  21737. }
  21738. // SetCreatedAt sets the "created_at" field.
  21739. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  21740. m.created_at = &t
  21741. }
  21742. // CreatedAt returns the value of the "created_at" field in the mutation.
  21743. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  21744. v := m.created_at
  21745. if v == nil {
  21746. return
  21747. }
  21748. return *v, true
  21749. }
  21750. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  21751. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21753. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21754. if !m.op.Is(OpUpdateOne) {
  21755. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21756. }
  21757. if m.id == nil || m.oldValue == nil {
  21758. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21759. }
  21760. oldValue, err := m.oldValue(ctx)
  21761. if err != nil {
  21762. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21763. }
  21764. return oldValue.CreatedAt, nil
  21765. }
  21766. // ResetCreatedAt resets all changes to the "created_at" field.
  21767. func (m *WorkExperienceMutation) ResetCreatedAt() {
  21768. m.created_at = nil
  21769. }
  21770. // SetUpdatedAt sets the "updated_at" field.
  21771. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  21772. m.updated_at = &t
  21773. }
  21774. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21775. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  21776. v := m.updated_at
  21777. if v == nil {
  21778. return
  21779. }
  21780. return *v, true
  21781. }
  21782. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  21783. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21785. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21786. if !m.op.Is(OpUpdateOne) {
  21787. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21788. }
  21789. if m.id == nil || m.oldValue == nil {
  21790. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21791. }
  21792. oldValue, err := m.oldValue(ctx)
  21793. if err != nil {
  21794. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21795. }
  21796. return oldValue.UpdatedAt, nil
  21797. }
  21798. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21799. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  21800. m.updated_at = nil
  21801. }
  21802. // SetDeletedAt sets the "deleted_at" field.
  21803. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  21804. m.deleted_at = &t
  21805. }
  21806. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21807. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  21808. v := m.deleted_at
  21809. if v == nil {
  21810. return
  21811. }
  21812. return *v, true
  21813. }
  21814. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  21815. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21817. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21818. if !m.op.Is(OpUpdateOne) {
  21819. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21820. }
  21821. if m.id == nil || m.oldValue == nil {
  21822. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21823. }
  21824. oldValue, err := m.oldValue(ctx)
  21825. if err != nil {
  21826. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21827. }
  21828. return oldValue.DeletedAt, nil
  21829. }
  21830. // ClearDeletedAt clears the value of the "deleted_at" field.
  21831. func (m *WorkExperienceMutation) ClearDeletedAt() {
  21832. m.deleted_at = nil
  21833. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  21834. }
  21835. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21836. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  21837. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  21838. return ok
  21839. }
  21840. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21841. func (m *WorkExperienceMutation) ResetDeletedAt() {
  21842. m.deleted_at = nil
  21843. delete(m.clearedFields, workexperience.FieldDeletedAt)
  21844. }
  21845. // SetEmployeeID sets the "employee_id" field.
  21846. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  21847. m.employee = &u
  21848. }
  21849. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21850. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  21851. v := m.employee
  21852. if v == nil {
  21853. return
  21854. }
  21855. return *v, true
  21856. }
  21857. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  21858. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21860. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21861. if !m.op.Is(OpUpdateOne) {
  21862. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21863. }
  21864. if m.id == nil || m.oldValue == nil {
  21865. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21866. }
  21867. oldValue, err := m.oldValue(ctx)
  21868. if err != nil {
  21869. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21870. }
  21871. return oldValue.EmployeeID, nil
  21872. }
  21873. // ResetEmployeeID resets all changes to the "employee_id" field.
  21874. func (m *WorkExperienceMutation) ResetEmployeeID() {
  21875. m.employee = nil
  21876. }
  21877. // SetStartDate sets the "start_date" field.
  21878. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  21879. m.start_date = &t
  21880. }
  21881. // StartDate returns the value of the "start_date" field in the mutation.
  21882. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  21883. v := m.start_date
  21884. if v == nil {
  21885. return
  21886. }
  21887. return *v, true
  21888. }
  21889. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  21890. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21892. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  21893. if !m.op.Is(OpUpdateOne) {
  21894. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  21895. }
  21896. if m.id == nil || m.oldValue == nil {
  21897. return v, errors.New("OldStartDate requires an ID field in the mutation")
  21898. }
  21899. oldValue, err := m.oldValue(ctx)
  21900. if err != nil {
  21901. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  21902. }
  21903. return oldValue.StartDate, nil
  21904. }
  21905. // ResetStartDate resets all changes to the "start_date" field.
  21906. func (m *WorkExperienceMutation) ResetStartDate() {
  21907. m.start_date = nil
  21908. }
  21909. // SetEndDate sets the "end_date" field.
  21910. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  21911. m.end_date = &t
  21912. }
  21913. // EndDate returns the value of the "end_date" field in the mutation.
  21914. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  21915. v := m.end_date
  21916. if v == nil {
  21917. return
  21918. }
  21919. return *v, true
  21920. }
  21921. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  21922. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21924. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  21925. if !m.op.Is(OpUpdateOne) {
  21926. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  21927. }
  21928. if m.id == nil || m.oldValue == nil {
  21929. return v, errors.New("OldEndDate requires an ID field in the mutation")
  21930. }
  21931. oldValue, err := m.oldValue(ctx)
  21932. if err != nil {
  21933. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  21934. }
  21935. return oldValue.EndDate, nil
  21936. }
  21937. // ResetEndDate resets all changes to the "end_date" field.
  21938. func (m *WorkExperienceMutation) ResetEndDate() {
  21939. m.end_date = nil
  21940. }
  21941. // SetCompany sets the "company" field.
  21942. func (m *WorkExperienceMutation) SetCompany(s string) {
  21943. m.company = &s
  21944. }
  21945. // Company returns the value of the "company" field in the mutation.
  21946. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  21947. v := m.company
  21948. if v == nil {
  21949. return
  21950. }
  21951. return *v, true
  21952. }
  21953. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  21954. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21956. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  21957. if !m.op.Is(OpUpdateOne) {
  21958. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  21959. }
  21960. if m.id == nil || m.oldValue == nil {
  21961. return v, errors.New("OldCompany requires an ID field in the mutation")
  21962. }
  21963. oldValue, err := m.oldValue(ctx)
  21964. if err != nil {
  21965. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  21966. }
  21967. return oldValue.Company, nil
  21968. }
  21969. // ResetCompany resets all changes to the "company" field.
  21970. func (m *WorkExperienceMutation) ResetCompany() {
  21971. m.company = nil
  21972. }
  21973. // SetExperience sets the "experience" field.
  21974. func (m *WorkExperienceMutation) SetExperience(s string) {
  21975. m.experience = &s
  21976. }
  21977. // Experience returns the value of the "experience" field in the mutation.
  21978. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  21979. v := m.experience
  21980. if v == nil {
  21981. return
  21982. }
  21983. return *v, true
  21984. }
  21985. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  21986. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  21987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21988. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  21989. if !m.op.Is(OpUpdateOne) {
  21990. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  21991. }
  21992. if m.id == nil || m.oldValue == nil {
  21993. return v, errors.New("OldExperience requires an ID field in the mutation")
  21994. }
  21995. oldValue, err := m.oldValue(ctx)
  21996. if err != nil {
  21997. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  21998. }
  21999. return oldValue.Experience, nil
  22000. }
  22001. // ResetExperience resets all changes to the "experience" field.
  22002. func (m *WorkExperienceMutation) ResetExperience() {
  22003. m.experience = nil
  22004. }
  22005. // SetOrganizationID sets the "organization_id" field.
  22006. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  22007. m.organization_id = &u
  22008. m.addorganization_id = nil
  22009. }
  22010. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22011. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  22012. v := m.organization_id
  22013. if v == nil {
  22014. return
  22015. }
  22016. return *v, true
  22017. }
  22018. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  22019. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  22020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22021. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22022. if !m.op.Is(OpUpdateOne) {
  22023. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22024. }
  22025. if m.id == nil || m.oldValue == nil {
  22026. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22027. }
  22028. oldValue, err := m.oldValue(ctx)
  22029. if err != nil {
  22030. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22031. }
  22032. return oldValue.OrganizationID, nil
  22033. }
  22034. // AddOrganizationID adds u to the "organization_id" field.
  22035. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  22036. if m.addorganization_id != nil {
  22037. *m.addorganization_id += u
  22038. } else {
  22039. m.addorganization_id = &u
  22040. }
  22041. }
  22042. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22043. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  22044. v := m.addorganization_id
  22045. if v == nil {
  22046. return
  22047. }
  22048. return *v, true
  22049. }
  22050. // ResetOrganizationID resets all changes to the "organization_id" field.
  22051. func (m *WorkExperienceMutation) ResetOrganizationID() {
  22052. m.organization_id = nil
  22053. m.addorganization_id = nil
  22054. }
  22055. // ClearEmployee clears the "employee" edge to the Employee entity.
  22056. func (m *WorkExperienceMutation) ClearEmployee() {
  22057. m.clearedemployee = true
  22058. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  22059. }
  22060. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22061. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  22062. return m.clearedemployee
  22063. }
  22064. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22065. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22066. // EmployeeID instead. It exists only for internal usage by the builders.
  22067. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  22068. if id := m.employee; id != nil {
  22069. ids = append(ids, *id)
  22070. }
  22071. return
  22072. }
  22073. // ResetEmployee resets all changes to the "employee" edge.
  22074. func (m *WorkExperienceMutation) ResetEmployee() {
  22075. m.employee = nil
  22076. m.clearedemployee = false
  22077. }
  22078. // Where appends a list predicates to the WorkExperienceMutation builder.
  22079. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  22080. m.predicates = append(m.predicates, ps...)
  22081. }
  22082. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  22083. // users can use type-assertion to append predicates that do not depend on any generated package.
  22084. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  22085. p := make([]predicate.WorkExperience, len(ps))
  22086. for i := range ps {
  22087. p[i] = ps[i]
  22088. }
  22089. m.Where(p...)
  22090. }
  22091. // Op returns the operation name.
  22092. func (m *WorkExperienceMutation) Op() Op {
  22093. return m.op
  22094. }
  22095. // SetOp allows setting the mutation operation.
  22096. func (m *WorkExperienceMutation) SetOp(op Op) {
  22097. m.op = op
  22098. }
  22099. // Type returns the node type of this mutation (WorkExperience).
  22100. func (m *WorkExperienceMutation) Type() string {
  22101. return m.typ
  22102. }
  22103. // Fields returns all fields that were changed during this mutation. Note that in
  22104. // order to get all numeric fields that were incremented/decremented, call
  22105. // AddedFields().
  22106. func (m *WorkExperienceMutation) Fields() []string {
  22107. fields := make([]string, 0, 9)
  22108. if m.created_at != nil {
  22109. fields = append(fields, workexperience.FieldCreatedAt)
  22110. }
  22111. if m.updated_at != nil {
  22112. fields = append(fields, workexperience.FieldUpdatedAt)
  22113. }
  22114. if m.deleted_at != nil {
  22115. fields = append(fields, workexperience.FieldDeletedAt)
  22116. }
  22117. if m.employee != nil {
  22118. fields = append(fields, workexperience.FieldEmployeeID)
  22119. }
  22120. if m.start_date != nil {
  22121. fields = append(fields, workexperience.FieldStartDate)
  22122. }
  22123. if m.end_date != nil {
  22124. fields = append(fields, workexperience.FieldEndDate)
  22125. }
  22126. if m.company != nil {
  22127. fields = append(fields, workexperience.FieldCompany)
  22128. }
  22129. if m.experience != nil {
  22130. fields = append(fields, workexperience.FieldExperience)
  22131. }
  22132. if m.organization_id != nil {
  22133. fields = append(fields, workexperience.FieldOrganizationID)
  22134. }
  22135. return fields
  22136. }
  22137. // Field returns the value of a field with the given name. The second boolean
  22138. // return value indicates that this field was not set, or was not defined in the
  22139. // schema.
  22140. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  22141. switch name {
  22142. case workexperience.FieldCreatedAt:
  22143. return m.CreatedAt()
  22144. case workexperience.FieldUpdatedAt:
  22145. return m.UpdatedAt()
  22146. case workexperience.FieldDeletedAt:
  22147. return m.DeletedAt()
  22148. case workexperience.FieldEmployeeID:
  22149. return m.EmployeeID()
  22150. case workexperience.FieldStartDate:
  22151. return m.StartDate()
  22152. case workexperience.FieldEndDate:
  22153. return m.EndDate()
  22154. case workexperience.FieldCompany:
  22155. return m.Company()
  22156. case workexperience.FieldExperience:
  22157. return m.Experience()
  22158. case workexperience.FieldOrganizationID:
  22159. return m.OrganizationID()
  22160. }
  22161. return nil, false
  22162. }
  22163. // OldField returns the old value of the field from the database. An error is
  22164. // returned if the mutation operation is not UpdateOne, or the query to the
  22165. // database failed.
  22166. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22167. switch name {
  22168. case workexperience.FieldCreatedAt:
  22169. return m.OldCreatedAt(ctx)
  22170. case workexperience.FieldUpdatedAt:
  22171. return m.OldUpdatedAt(ctx)
  22172. case workexperience.FieldDeletedAt:
  22173. return m.OldDeletedAt(ctx)
  22174. case workexperience.FieldEmployeeID:
  22175. return m.OldEmployeeID(ctx)
  22176. case workexperience.FieldStartDate:
  22177. return m.OldStartDate(ctx)
  22178. case workexperience.FieldEndDate:
  22179. return m.OldEndDate(ctx)
  22180. case workexperience.FieldCompany:
  22181. return m.OldCompany(ctx)
  22182. case workexperience.FieldExperience:
  22183. return m.OldExperience(ctx)
  22184. case workexperience.FieldOrganizationID:
  22185. return m.OldOrganizationID(ctx)
  22186. }
  22187. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  22188. }
  22189. // SetField sets the value of a field with the given name. It returns an error if
  22190. // the field is not defined in the schema, or if the type mismatched the field
  22191. // type.
  22192. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  22193. switch name {
  22194. case workexperience.FieldCreatedAt:
  22195. v, ok := value.(time.Time)
  22196. if !ok {
  22197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22198. }
  22199. m.SetCreatedAt(v)
  22200. return nil
  22201. case workexperience.FieldUpdatedAt:
  22202. v, ok := value.(time.Time)
  22203. if !ok {
  22204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22205. }
  22206. m.SetUpdatedAt(v)
  22207. return nil
  22208. case workexperience.FieldDeletedAt:
  22209. v, ok := value.(time.Time)
  22210. if !ok {
  22211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22212. }
  22213. m.SetDeletedAt(v)
  22214. return nil
  22215. case workexperience.FieldEmployeeID:
  22216. v, ok := value.(uint64)
  22217. if !ok {
  22218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22219. }
  22220. m.SetEmployeeID(v)
  22221. return nil
  22222. case workexperience.FieldStartDate:
  22223. v, ok := value.(time.Time)
  22224. if !ok {
  22225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22226. }
  22227. m.SetStartDate(v)
  22228. return nil
  22229. case workexperience.FieldEndDate:
  22230. v, ok := value.(time.Time)
  22231. if !ok {
  22232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22233. }
  22234. m.SetEndDate(v)
  22235. return nil
  22236. case workexperience.FieldCompany:
  22237. v, ok := value.(string)
  22238. if !ok {
  22239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22240. }
  22241. m.SetCompany(v)
  22242. return nil
  22243. case workexperience.FieldExperience:
  22244. v, ok := value.(string)
  22245. if !ok {
  22246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22247. }
  22248. m.SetExperience(v)
  22249. return nil
  22250. case workexperience.FieldOrganizationID:
  22251. v, ok := value.(uint64)
  22252. if !ok {
  22253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22254. }
  22255. m.SetOrganizationID(v)
  22256. return nil
  22257. }
  22258. return fmt.Errorf("unknown WorkExperience field %s", name)
  22259. }
  22260. // AddedFields returns all numeric fields that were incremented/decremented during
  22261. // this mutation.
  22262. func (m *WorkExperienceMutation) AddedFields() []string {
  22263. var fields []string
  22264. if m.addorganization_id != nil {
  22265. fields = append(fields, workexperience.FieldOrganizationID)
  22266. }
  22267. return fields
  22268. }
  22269. // AddedField returns the numeric value that was incremented/decremented on a field
  22270. // with the given name. The second boolean return value indicates that this field
  22271. // was not set, or was not defined in the schema.
  22272. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  22273. switch name {
  22274. case workexperience.FieldOrganizationID:
  22275. return m.AddedOrganizationID()
  22276. }
  22277. return nil, false
  22278. }
  22279. // AddField adds the value to the field with the given name. It returns an error if
  22280. // the field is not defined in the schema, or if the type mismatched the field
  22281. // type.
  22282. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  22283. switch name {
  22284. case workexperience.FieldOrganizationID:
  22285. v, ok := value.(int64)
  22286. if !ok {
  22287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22288. }
  22289. m.AddOrganizationID(v)
  22290. return nil
  22291. }
  22292. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  22293. }
  22294. // ClearedFields returns all nullable fields that were cleared during this
  22295. // mutation.
  22296. func (m *WorkExperienceMutation) ClearedFields() []string {
  22297. var fields []string
  22298. if m.FieldCleared(workexperience.FieldDeletedAt) {
  22299. fields = append(fields, workexperience.FieldDeletedAt)
  22300. }
  22301. return fields
  22302. }
  22303. // FieldCleared returns a boolean indicating if a field with the given name was
  22304. // cleared in this mutation.
  22305. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  22306. _, ok := m.clearedFields[name]
  22307. return ok
  22308. }
  22309. // ClearField clears the value of the field with the given name. It returns an
  22310. // error if the field is not defined in the schema.
  22311. func (m *WorkExperienceMutation) ClearField(name string) error {
  22312. switch name {
  22313. case workexperience.FieldDeletedAt:
  22314. m.ClearDeletedAt()
  22315. return nil
  22316. }
  22317. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  22318. }
  22319. // ResetField resets all changes in the mutation for the field with the given name.
  22320. // It returns an error if the field is not defined in the schema.
  22321. func (m *WorkExperienceMutation) ResetField(name string) error {
  22322. switch name {
  22323. case workexperience.FieldCreatedAt:
  22324. m.ResetCreatedAt()
  22325. return nil
  22326. case workexperience.FieldUpdatedAt:
  22327. m.ResetUpdatedAt()
  22328. return nil
  22329. case workexperience.FieldDeletedAt:
  22330. m.ResetDeletedAt()
  22331. return nil
  22332. case workexperience.FieldEmployeeID:
  22333. m.ResetEmployeeID()
  22334. return nil
  22335. case workexperience.FieldStartDate:
  22336. m.ResetStartDate()
  22337. return nil
  22338. case workexperience.FieldEndDate:
  22339. m.ResetEndDate()
  22340. return nil
  22341. case workexperience.FieldCompany:
  22342. m.ResetCompany()
  22343. return nil
  22344. case workexperience.FieldExperience:
  22345. m.ResetExperience()
  22346. return nil
  22347. case workexperience.FieldOrganizationID:
  22348. m.ResetOrganizationID()
  22349. return nil
  22350. }
  22351. return fmt.Errorf("unknown WorkExperience field %s", name)
  22352. }
  22353. // AddedEdges returns all edge names that were set/added in this mutation.
  22354. func (m *WorkExperienceMutation) AddedEdges() []string {
  22355. edges := make([]string, 0, 1)
  22356. if m.employee != nil {
  22357. edges = append(edges, workexperience.EdgeEmployee)
  22358. }
  22359. return edges
  22360. }
  22361. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22362. // name in this mutation.
  22363. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  22364. switch name {
  22365. case workexperience.EdgeEmployee:
  22366. if id := m.employee; id != nil {
  22367. return []ent.Value{*id}
  22368. }
  22369. }
  22370. return nil
  22371. }
  22372. // RemovedEdges returns all edge names that were removed in this mutation.
  22373. func (m *WorkExperienceMutation) RemovedEdges() []string {
  22374. edges := make([]string, 0, 1)
  22375. return edges
  22376. }
  22377. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22378. // the given name in this mutation.
  22379. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  22380. return nil
  22381. }
  22382. // ClearedEdges returns all edge names that were cleared in this mutation.
  22383. func (m *WorkExperienceMutation) ClearedEdges() []string {
  22384. edges := make([]string, 0, 1)
  22385. if m.clearedemployee {
  22386. edges = append(edges, workexperience.EdgeEmployee)
  22387. }
  22388. return edges
  22389. }
  22390. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22391. // was cleared in this mutation.
  22392. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  22393. switch name {
  22394. case workexperience.EdgeEmployee:
  22395. return m.clearedemployee
  22396. }
  22397. return false
  22398. }
  22399. // ClearEdge clears the value of the edge with the given name. It returns an error
  22400. // if that edge is not defined in the schema.
  22401. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  22402. switch name {
  22403. case workexperience.EdgeEmployee:
  22404. m.ClearEmployee()
  22405. return nil
  22406. }
  22407. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  22408. }
  22409. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22410. // It returns an error if the edge is not defined in the schema.
  22411. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  22412. switch name {
  22413. case workexperience.EdgeEmployee:
  22414. m.ResetEmployee()
  22415. return nil
  22416. }
  22417. return fmt.Errorf("unknown WorkExperience edge %s", name)
  22418. }
  22419. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  22420. type WxMutation struct {
  22421. config
  22422. op Op
  22423. typ string
  22424. id *uint64
  22425. created_at *time.Time
  22426. updated_at *time.Time
  22427. status *uint8
  22428. addstatus *int8
  22429. deleted_at *time.Time
  22430. port *string
  22431. process_id *string
  22432. callback *string
  22433. wxid *string
  22434. account *string
  22435. nickname *string
  22436. tel *string
  22437. head_big *string
  22438. organization_id *uint64
  22439. addorganization_id *int64
  22440. api_base *string
  22441. api_key *string
  22442. allow_list *[]string
  22443. appendallow_list []string
  22444. group_allow_list *[]string
  22445. appendgroup_allow_list []string
  22446. block_list *[]string
  22447. appendblock_list []string
  22448. group_block_list *[]string
  22449. appendgroup_block_list []string
  22450. clearedFields map[string]struct{}
  22451. server *uint64
  22452. clearedserver bool
  22453. agent *uint64
  22454. clearedagent bool
  22455. done bool
  22456. oldValue func(context.Context) (*Wx, error)
  22457. predicates []predicate.Wx
  22458. }
  22459. var _ ent.Mutation = (*WxMutation)(nil)
  22460. // wxOption allows management of the mutation configuration using functional options.
  22461. type wxOption func(*WxMutation)
  22462. // newWxMutation creates new mutation for the Wx entity.
  22463. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  22464. m := &WxMutation{
  22465. config: c,
  22466. op: op,
  22467. typ: TypeWx,
  22468. clearedFields: make(map[string]struct{}),
  22469. }
  22470. for _, opt := range opts {
  22471. opt(m)
  22472. }
  22473. return m
  22474. }
  22475. // withWxID sets the ID field of the mutation.
  22476. func withWxID(id uint64) wxOption {
  22477. return func(m *WxMutation) {
  22478. var (
  22479. err error
  22480. once sync.Once
  22481. value *Wx
  22482. )
  22483. m.oldValue = func(ctx context.Context) (*Wx, error) {
  22484. once.Do(func() {
  22485. if m.done {
  22486. err = errors.New("querying old values post mutation is not allowed")
  22487. } else {
  22488. value, err = m.Client().Wx.Get(ctx, id)
  22489. }
  22490. })
  22491. return value, err
  22492. }
  22493. m.id = &id
  22494. }
  22495. }
  22496. // withWx sets the old Wx of the mutation.
  22497. func withWx(node *Wx) wxOption {
  22498. return func(m *WxMutation) {
  22499. m.oldValue = func(context.Context) (*Wx, error) {
  22500. return node, nil
  22501. }
  22502. m.id = &node.ID
  22503. }
  22504. }
  22505. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22506. // executed in a transaction (ent.Tx), a transactional client is returned.
  22507. func (m WxMutation) Client() *Client {
  22508. client := &Client{config: m.config}
  22509. client.init()
  22510. return client
  22511. }
  22512. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22513. // it returns an error otherwise.
  22514. func (m WxMutation) Tx() (*Tx, error) {
  22515. if _, ok := m.driver.(*txDriver); !ok {
  22516. return nil, errors.New("ent: mutation is not running in a transaction")
  22517. }
  22518. tx := &Tx{config: m.config}
  22519. tx.init()
  22520. return tx, nil
  22521. }
  22522. // SetID sets the value of the id field. Note that this
  22523. // operation is only accepted on creation of Wx entities.
  22524. func (m *WxMutation) SetID(id uint64) {
  22525. m.id = &id
  22526. }
  22527. // ID returns the ID value in the mutation. Note that the ID is only available
  22528. // if it was provided to the builder or after it was returned from the database.
  22529. func (m *WxMutation) ID() (id uint64, exists bool) {
  22530. if m.id == nil {
  22531. return
  22532. }
  22533. return *m.id, true
  22534. }
  22535. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22536. // That means, if the mutation is applied within a transaction with an isolation level such
  22537. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22538. // or updated by the mutation.
  22539. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  22540. switch {
  22541. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22542. id, exists := m.ID()
  22543. if exists {
  22544. return []uint64{id}, nil
  22545. }
  22546. fallthrough
  22547. case m.op.Is(OpUpdate | OpDelete):
  22548. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  22549. default:
  22550. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22551. }
  22552. }
  22553. // SetCreatedAt sets the "created_at" field.
  22554. func (m *WxMutation) SetCreatedAt(t time.Time) {
  22555. m.created_at = &t
  22556. }
  22557. // CreatedAt returns the value of the "created_at" field in the mutation.
  22558. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  22559. v := m.created_at
  22560. if v == nil {
  22561. return
  22562. }
  22563. return *v, true
  22564. }
  22565. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  22566. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22568. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22569. if !m.op.Is(OpUpdateOne) {
  22570. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22571. }
  22572. if m.id == nil || m.oldValue == nil {
  22573. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22574. }
  22575. oldValue, err := m.oldValue(ctx)
  22576. if err != nil {
  22577. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22578. }
  22579. return oldValue.CreatedAt, nil
  22580. }
  22581. // ResetCreatedAt resets all changes to the "created_at" field.
  22582. func (m *WxMutation) ResetCreatedAt() {
  22583. m.created_at = nil
  22584. }
  22585. // SetUpdatedAt sets the "updated_at" field.
  22586. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  22587. m.updated_at = &t
  22588. }
  22589. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22590. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  22591. v := m.updated_at
  22592. if v == nil {
  22593. return
  22594. }
  22595. return *v, true
  22596. }
  22597. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  22598. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22600. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22601. if !m.op.Is(OpUpdateOne) {
  22602. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22603. }
  22604. if m.id == nil || m.oldValue == nil {
  22605. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22606. }
  22607. oldValue, err := m.oldValue(ctx)
  22608. if err != nil {
  22609. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22610. }
  22611. return oldValue.UpdatedAt, nil
  22612. }
  22613. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22614. func (m *WxMutation) ResetUpdatedAt() {
  22615. m.updated_at = nil
  22616. }
  22617. // SetStatus sets the "status" field.
  22618. func (m *WxMutation) SetStatus(u uint8) {
  22619. m.status = &u
  22620. m.addstatus = nil
  22621. }
  22622. // Status returns the value of the "status" field in the mutation.
  22623. func (m *WxMutation) Status() (r uint8, exists bool) {
  22624. v := m.status
  22625. if v == nil {
  22626. return
  22627. }
  22628. return *v, true
  22629. }
  22630. // OldStatus returns the old "status" field's value of the Wx entity.
  22631. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22633. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22634. if !m.op.Is(OpUpdateOne) {
  22635. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22636. }
  22637. if m.id == nil || m.oldValue == nil {
  22638. return v, errors.New("OldStatus requires an ID field in the mutation")
  22639. }
  22640. oldValue, err := m.oldValue(ctx)
  22641. if err != nil {
  22642. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22643. }
  22644. return oldValue.Status, nil
  22645. }
  22646. // AddStatus adds u to the "status" field.
  22647. func (m *WxMutation) AddStatus(u int8) {
  22648. if m.addstatus != nil {
  22649. *m.addstatus += u
  22650. } else {
  22651. m.addstatus = &u
  22652. }
  22653. }
  22654. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22655. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  22656. v := m.addstatus
  22657. if v == nil {
  22658. return
  22659. }
  22660. return *v, true
  22661. }
  22662. // ClearStatus clears the value of the "status" field.
  22663. func (m *WxMutation) ClearStatus() {
  22664. m.status = nil
  22665. m.addstatus = nil
  22666. m.clearedFields[wx.FieldStatus] = struct{}{}
  22667. }
  22668. // StatusCleared returns if the "status" field was cleared in this mutation.
  22669. func (m *WxMutation) StatusCleared() bool {
  22670. _, ok := m.clearedFields[wx.FieldStatus]
  22671. return ok
  22672. }
  22673. // ResetStatus resets all changes to the "status" field.
  22674. func (m *WxMutation) ResetStatus() {
  22675. m.status = nil
  22676. m.addstatus = nil
  22677. delete(m.clearedFields, wx.FieldStatus)
  22678. }
  22679. // SetDeletedAt sets the "deleted_at" field.
  22680. func (m *WxMutation) SetDeletedAt(t time.Time) {
  22681. m.deleted_at = &t
  22682. }
  22683. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22684. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  22685. v := m.deleted_at
  22686. if v == nil {
  22687. return
  22688. }
  22689. return *v, true
  22690. }
  22691. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  22692. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22694. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22695. if !m.op.Is(OpUpdateOne) {
  22696. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22697. }
  22698. if m.id == nil || m.oldValue == nil {
  22699. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22700. }
  22701. oldValue, err := m.oldValue(ctx)
  22702. if err != nil {
  22703. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22704. }
  22705. return oldValue.DeletedAt, nil
  22706. }
  22707. // ClearDeletedAt clears the value of the "deleted_at" field.
  22708. func (m *WxMutation) ClearDeletedAt() {
  22709. m.deleted_at = nil
  22710. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  22711. }
  22712. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22713. func (m *WxMutation) DeletedAtCleared() bool {
  22714. _, ok := m.clearedFields[wx.FieldDeletedAt]
  22715. return ok
  22716. }
  22717. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22718. func (m *WxMutation) ResetDeletedAt() {
  22719. m.deleted_at = nil
  22720. delete(m.clearedFields, wx.FieldDeletedAt)
  22721. }
  22722. // SetServerID sets the "server_id" field.
  22723. func (m *WxMutation) SetServerID(u uint64) {
  22724. m.server = &u
  22725. }
  22726. // ServerID returns the value of the "server_id" field in the mutation.
  22727. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  22728. v := m.server
  22729. if v == nil {
  22730. return
  22731. }
  22732. return *v, true
  22733. }
  22734. // OldServerID returns the old "server_id" field's value of the Wx entity.
  22735. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22737. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  22738. if !m.op.Is(OpUpdateOne) {
  22739. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  22740. }
  22741. if m.id == nil || m.oldValue == nil {
  22742. return v, errors.New("OldServerID requires an ID field in the mutation")
  22743. }
  22744. oldValue, err := m.oldValue(ctx)
  22745. if err != nil {
  22746. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  22747. }
  22748. return oldValue.ServerID, nil
  22749. }
  22750. // ClearServerID clears the value of the "server_id" field.
  22751. func (m *WxMutation) ClearServerID() {
  22752. m.server = nil
  22753. m.clearedFields[wx.FieldServerID] = struct{}{}
  22754. }
  22755. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  22756. func (m *WxMutation) ServerIDCleared() bool {
  22757. _, ok := m.clearedFields[wx.FieldServerID]
  22758. return ok
  22759. }
  22760. // ResetServerID resets all changes to the "server_id" field.
  22761. func (m *WxMutation) ResetServerID() {
  22762. m.server = nil
  22763. delete(m.clearedFields, wx.FieldServerID)
  22764. }
  22765. // SetPort sets the "port" field.
  22766. func (m *WxMutation) SetPort(s string) {
  22767. m.port = &s
  22768. }
  22769. // Port returns the value of the "port" field in the mutation.
  22770. func (m *WxMutation) Port() (r string, exists bool) {
  22771. v := m.port
  22772. if v == nil {
  22773. return
  22774. }
  22775. return *v, true
  22776. }
  22777. // OldPort returns the old "port" field's value of the Wx entity.
  22778. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22780. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  22781. if !m.op.Is(OpUpdateOne) {
  22782. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  22783. }
  22784. if m.id == nil || m.oldValue == nil {
  22785. return v, errors.New("OldPort requires an ID field in the mutation")
  22786. }
  22787. oldValue, err := m.oldValue(ctx)
  22788. if err != nil {
  22789. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  22790. }
  22791. return oldValue.Port, nil
  22792. }
  22793. // ResetPort resets all changes to the "port" field.
  22794. func (m *WxMutation) ResetPort() {
  22795. m.port = nil
  22796. }
  22797. // SetProcessID sets the "process_id" field.
  22798. func (m *WxMutation) SetProcessID(s string) {
  22799. m.process_id = &s
  22800. }
  22801. // ProcessID returns the value of the "process_id" field in the mutation.
  22802. func (m *WxMutation) ProcessID() (r string, exists bool) {
  22803. v := m.process_id
  22804. if v == nil {
  22805. return
  22806. }
  22807. return *v, true
  22808. }
  22809. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  22810. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22812. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  22813. if !m.op.Is(OpUpdateOne) {
  22814. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  22815. }
  22816. if m.id == nil || m.oldValue == nil {
  22817. return v, errors.New("OldProcessID requires an ID field in the mutation")
  22818. }
  22819. oldValue, err := m.oldValue(ctx)
  22820. if err != nil {
  22821. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  22822. }
  22823. return oldValue.ProcessID, nil
  22824. }
  22825. // ResetProcessID resets all changes to the "process_id" field.
  22826. func (m *WxMutation) ResetProcessID() {
  22827. m.process_id = nil
  22828. }
  22829. // SetCallback sets the "callback" field.
  22830. func (m *WxMutation) SetCallback(s string) {
  22831. m.callback = &s
  22832. }
  22833. // Callback returns the value of the "callback" field in the mutation.
  22834. func (m *WxMutation) Callback() (r string, exists bool) {
  22835. v := m.callback
  22836. if v == nil {
  22837. return
  22838. }
  22839. return *v, true
  22840. }
  22841. // OldCallback returns the old "callback" field's value of the Wx entity.
  22842. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22844. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  22845. if !m.op.Is(OpUpdateOne) {
  22846. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  22847. }
  22848. if m.id == nil || m.oldValue == nil {
  22849. return v, errors.New("OldCallback requires an ID field in the mutation")
  22850. }
  22851. oldValue, err := m.oldValue(ctx)
  22852. if err != nil {
  22853. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  22854. }
  22855. return oldValue.Callback, nil
  22856. }
  22857. // ResetCallback resets all changes to the "callback" field.
  22858. func (m *WxMutation) ResetCallback() {
  22859. m.callback = nil
  22860. }
  22861. // SetWxid sets the "wxid" field.
  22862. func (m *WxMutation) SetWxid(s string) {
  22863. m.wxid = &s
  22864. }
  22865. // Wxid returns the value of the "wxid" field in the mutation.
  22866. func (m *WxMutation) Wxid() (r string, exists bool) {
  22867. v := m.wxid
  22868. if v == nil {
  22869. return
  22870. }
  22871. return *v, true
  22872. }
  22873. // OldWxid returns the old "wxid" field's value of the Wx entity.
  22874. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22876. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  22877. if !m.op.Is(OpUpdateOne) {
  22878. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  22879. }
  22880. if m.id == nil || m.oldValue == nil {
  22881. return v, errors.New("OldWxid requires an ID field in the mutation")
  22882. }
  22883. oldValue, err := m.oldValue(ctx)
  22884. if err != nil {
  22885. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  22886. }
  22887. return oldValue.Wxid, nil
  22888. }
  22889. // ResetWxid resets all changes to the "wxid" field.
  22890. func (m *WxMutation) ResetWxid() {
  22891. m.wxid = nil
  22892. }
  22893. // SetAccount sets the "account" field.
  22894. func (m *WxMutation) SetAccount(s string) {
  22895. m.account = &s
  22896. }
  22897. // Account returns the value of the "account" field in the mutation.
  22898. func (m *WxMutation) Account() (r string, exists bool) {
  22899. v := m.account
  22900. if v == nil {
  22901. return
  22902. }
  22903. return *v, true
  22904. }
  22905. // OldAccount returns the old "account" field's value of the Wx entity.
  22906. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22908. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  22909. if !m.op.Is(OpUpdateOne) {
  22910. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  22911. }
  22912. if m.id == nil || m.oldValue == nil {
  22913. return v, errors.New("OldAccount requires an ID field in the mutation")
  22914. }
  22915. oldValue, err := m.oldValue(ctx)
  22916. if err != nil {
  22917. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  22918. }
  22919. return oldValue.Account, nil
  22920. }
  22921. // ResetAccount resets all changes to the "account" field.
  22922. func (m *WxMutation) ResetAccount() {
  22923. m.account = nil
  22924. }
  22925. // SetNickname sets the "nickname" field.
  22926. func (m *WxMutation) SetNickname(s string) {
  22927. m.nickname = &s
  22928. }
  22929. // Nickname returns the value of the "nickname" field in the mutation.
  22930. func (m *WxMutation) Nickname() (r string, exists bool) {
  22931. v := m.nickname
  22932. if v == nil {
  22933. return
  22934. }
  22935. return *v, true
  22936. }
  22937. // OldNickname returns the old "nickname" field's value of the Wx entity.
  22938. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22940. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  22941. if !m.op.Is(OpUpdateOne) {
  22942. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  22943. }
  22944. if m.id == nil || m.oldValue == nil {
  22945. return v, errors.New("OldNickname requires an ID field in the mutation")
  22946. }
  22947. oldValue, err := m.oldValue(ctx)
  22948. if err != nil {
  22949. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  22950. }
  22951. return oldValue.Nickname, nil
  22952. }
  22953. // ResetNickname resets all changes to the "nickname" field.
  22954. func (m *WxMutation) ResetNickname() {
  22955. m.nickname = nil
  22956. }
  22957. // SetTel sets the "tel" field.
  22958. func (m *WxMutation) SetTel(s string) {
  22959. m.tel = &s
  22960. }
  22961. // Tel returns the value of the "tel" field in the mutation.
  22962. func (m *WxMutation) Tel() (r string, exists bool) {
  22963. v := m.tel
  22964. if v == nil {
  22965. return
  22966. }
  22967. return *v, true
  22968. }
  22969. // OldTel returns the old "tel" field's value of the Wx entity.
  22970. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  22971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22972. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  22973. if !m.op.Is(OpUpdateOne) {
  22974. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  22975. }
  22976. if m.id == nil || m.oldValue == nil {
  22977. return v, errors.New("OldTel requires an ID field in the mutation")
  22978. }
  22979. oldValue, err := m.oldValue(ctx)
  22980. if err != nil {
  22981. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  22982. }
  22983. return oldValue.Tel, nil
  22984. }
  22985. // ResetTel resets all changes to the "tel" field.
  22986. func (m *WxMutation) ResetTel() {
  22987. m.tel = nil
  22988. }
  22989. // SetHeadBig sets the "head_big" field.
  22990. func (m *WxMutation) SetHeadBig(s string) {
  22991. m.head_big = &s
  22992. }
  22993. // HeadBig returns the value of the "head_big" field in the mutation.
  22994. func (m *WxMutation) HeadBig() (r string, exists bool) {
  22995. v := m.head_big
  22996. if v == nil {
  22997. return
  22998. }
  22999. return *v, true
  23000. }
  23001. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  23002. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23004. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  23005. if !m.op.Is(OpUpdateOne) {
  23006. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  23007. }
  23008. if m.id == nil || m.oldValue == nil {
  23009. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  23010. }
  23011. oldValue, err := m.oldValue(ctx)
  23012. if err != nil {
  23013. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  23014. }
  23015. return oldValue.HeadBig, nil
  23016. }
  23017. // ResetHeadBig resets all changes to the "head_big" field.
  23018. func (m *WxMutation) ResetHeadBig() {
  23019. m.head_big = nil
  23020. }
  23021. // SetOrganizationID sets the "organization_id" field.
  23022. func (m *WxMutation) SetOrganizationID(u uint64) {
  23023. m.organization_id = &u
  23024. m.addorganization_id = nil
  23025. }
  23026. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23027. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  23028. v := m.organization_id
  23029. if v == nil {
  23030. return
  23031. }
  23032. return *v, true
  23033. }
  23034. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  23035. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23037. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23038. if !m.op.Is(OpUpdateOne) {
  23039. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23040. }
  23041. if m.id == nil || m.oldValue == nil {
  23042. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23043. }
  23044. oldValue, err := m.oldValue(ctx)
  23045. if err != nil {
  23046. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23047. }
  23048. return oldValue.OrganizationID, nil
  23049. }
  23050. // AddOrganizationID adds u to the "organization_id" field.
  23051. func (m *WxMutation) AddOrganizationID(u int64) {
  23052. if m.addorganization_id != nil {
  23053. *m.addorganization_id += u
  23054. } else {
  23055. m.addorganization_id = &u
  23056. }
  23057. }
  23058. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23059. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  23060. v := m.addorganization_id
  23061. if v == nil {
  23062. return
  23063. }
  23064. return *v, true
  23065. }
  23066. // ClearOrganizationID clears the value of the "organization_id" field.
  23067. func (m *WxMutation) ClearOrganizationID() {
  23068. m.organization_id = nil
  23069. m.addorganization_id = nil
  23070. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  23071. }
  23072. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23073. func (m *WxMutation) OrganizationIDCleared() bool {
  23074. _, ok := m.clearedFields[wx.FieldOrganizationID]
  23075. return ok
  23076. }
  23077. // ResetOrganizationID resets all changes to the "organization_id" field.
  23078. func (m *WxMutation) ResetOrganizationID() {
  23079. m.organization_id = nil
  23080. m.addorganization_id = nil
  23081. delete(m.clearedFields, wx.FieldOrganizationID)
  23082. }
  23083. // SetAgentID sets the "agent_id" field.
  23084. func (m *WxMutation) SetAgentID(u uint64) {
  23085. m.agent = &u
  23086. }
  23087. // AgentID returns the value of the "agent_id" field in the mutation.
  23088. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  23089. v := m.agent
  23090. if v == nil {
  23091. return
  23092. }
  23093. return *v, true
  23094. }
  23095. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  23096. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23098. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  23099. if !m.op.Is(OpUpdateOne) {
  23100. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  23101. }
  23102. if m.id == nil || m.oldValue == nil {
  23103. return v, errors.New("OldAgentID requires an ID field in the mutation")
  23104. }
  23105. oldValue, err := m.oldValue(ctx)
  23106. if err != nil {
  23107. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  23108. }
  23109. return oldValue.AgentID, nil
  23110. }
  23111. // ResetAgentID resets all changes to the "agent_id" field.
  23112. func (m *WxMutation) ResetAgentID() {
  23113. m.agent = nil
  23114. }
  23115. // SetAPIBase sets the "api_base" field.
  23116. func (m *WxMutation) SetAPIBase(s string) {
  23117. m.api_base = &s
  23118. }
  23119. // APIBase returns the value of the "api_base" field in the mutation.
  23120. func (m *WxMutation) APIBase() (r string, exists bool) {
  23121. v := m.api_base
  23122. if v == nil {
  23123. return
  23124. }
  23125. return *v, true
  23126. }
  23127. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  23128. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23130. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  23131. if !m.op.Is(OpUpdateOne) {
  23132. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  23133. }
  23134. if m.id == nil || m.oldValue == nil {
  23135. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  23136. }
  23137. oldValue, err := m.oldValue(ctx)
  23138. if err != nil {
  23139. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  23140. }
  23141. return oldValue.APIBase, nil
  23142. }
  23143. // ClearAPIBase clears the value of the "api_base" field.
  23144. func (m *WxMutation) ClearAPIBase() {
  23145. m.api_base = nil
  23146. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  23147. }
  23148. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  23149. func (m *WxMutation) APIBaseCleared() bool {
  23150. _, ok := m.clearedFields[wx.FieldAPIBase]
  23151. return ok
  23152. }
  23153. // ResetAPIBase resets all changes to the "api_base" field.
  23154. func (m *WxMutation) ResetAPIBase() {
  23155. m.api_base = nil
  23156. delete(m.clearedFields, wx.FieldAPIBase)
  23157. }
  23158. // SetAPIKey sets the "api_key" field.
  23159. func (m *WxMutation) SetAPIKey(s string) {
  23160. m.api_key = &s
  23161. }
  23162. // APIKey returns the value of the "api_key" field in the mutation.
  23163. func (m *WxMutation) APIKey() (r string, exists bool) {
  23164. v := m.api_key
  23165. if v == nil {
  23166. return
  23167. }
  23168. return *v, true
  23169. }
  23170. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  23171. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23173. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  23174. if !m.op.Is(OpUpdateOne) {
  23175. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  23176. }
  23177. if m.id == nil || m.oldValue == nil {
  23178. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  23179. }
  23180. oldValue, err := m.oldValue(ctx)
  23181. if err != nil {
  23182. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  23183. }
  23184. return oldValue.APIKey, nil
  23185. }
  23186. // ClearAPIKey clears the value of the "api_key" field.
  23187. func (m *WxMutation) ClearAPIKey() {
  23188. m.api_key = nil
  23189. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  23190. }
  23191. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  23192. func (m *WxMutation) APIKeyCleared() bool {
  23193. _, ok := m.clearedFields[wx.FieldAPIKey]
  23194. return ok
  23195. }
  23196. // ResetAPIKey resets all changes to the "api_key" field.
  23197. func (m *WxMutation) ResetAPIKey() {
  23198. m.api_key = nil
  23199. delete(m.clearedFields, wx.FieldAPIKey)
  23200. }
  23201. // SetAllowList sets the "allow_list" field.
  23202. func (m *WxMutation) SetAllowList(s []string) {
  23203. m.allow_list = &s
  23204. m.appendallow_list = nil
  23205. }
  23206. // AllowList returns the value of the "allow_list" field in the mutation.
  23207. func (m *WxMutation) AllowList() (r []string, exists bool) {
  23208. v := m.allow_list
  23209. if v == nil {
  23210. return
  23211. }
  23212. return *v, true
  23213. }
  23214. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  23215. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23217. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  23218. if !m.op.Is(OpUpdateOne) {
  23219. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  23220. }
  23221. if m.id == nil || m.oldValue == nil {
  23222. return v, errors.New("OldAllowList requires an ID field in the mutation")
  23223. }
  23224. oldValue, err := m.oldValue(ctx)
  23225. if err != nil {
  23226. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  23227. }
  23228. return oldValue.AllowList, nil
  23229. }
  23230. // AppendAllowList adds s to the "allow_list" field.
  23231. func (m *WxMutation) AppendAllowList(s []string) {
  23232. m.appendallow_list = append(m.appendallow_list, s...)
  23233. }
  23234. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  23235. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  23236. if len(m.appendallow_list) == 0 {
  23237. return nil, false
  23238. }
  23239. return m.appendallow_list, true
  23240. }
  23241. // ResetAllowList resets all changes to the "allow_list" field.
  23242. func (m *WxMutation) ResetAllowList() {
  23243. m.allow_list = nil
  23244. m.appendallow_list = nil
  23245. }
  23246. // SetGroupAllowList sets the "group_allow_list" field.
  23247. func (m *WxMutation) SetGroupAllowList(s []string) {
  23248. m.group_allow_list = &s
  23249. m.appendgroup_allow_list = nil
  23250. }
  23251. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  23252. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  23253. v := m.group_allow_list
  23254. if v == nil {
  23255. return
  23256. }
  23257. return *v, true
  23258. }
  23259. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  23260. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23262. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  23263. if !m.op.Is(OpUpdateOne) {
  23264. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  23265. }
  23266. if m.id == nil || m.oldValue == nil {
  23267. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  23268. }
  23269. oldValue, err := m.oldValue(ctx)
  23270. if err != nil {
  23271. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  23272. }
  23273. return oldValue.GroupAllowList, nil
  23274. }
  23275. // AppendGroupAllowList adds s to the "group_allow_list" field.
  23276. func (m *WxMutation) AppendGroupAllowList(s []string) {
  23277. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  23278. }
  23279. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  23280. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  23281. if len(m.appendgroup_allow_list) == 0 {
  23282. return nil, false
  23283. }
  23284. return m.appendgroup_allow_list, true
  23285. }
  23286. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  23287. func (m *WxMutation) ResetGroupAllowList() {
  23288. m.group_allow_list = nil
  23289. m.appendgroup_allow_list = nil
  23290. }
  23291. // SetBlockList sets the "block_list" field.
  23292. func (m *WxMutation) SetBlockList(s []string) {
  23293. m.block_list = &s
  23294. m.appendblock_list = nil
  23295. }
  23296. // BlockList returns the value of the "block_list" field in the mutation.
  23297. func (m *WxMutation) BlockList() (r []string, exists bool) {
  23298. v := m.block_list
  23299. if v == nil {
  23300. return
  23301. }
  23302. return *v, true
  23303. }
  23304. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  23305. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23307. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  23308. if !m.op.Is(OpUpdateOne) {
  23309. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  23310. }
  23311. if m.id == nil || m.oldValue == nil {
  23312. return v, errors.New("OldBlockList requires an ID field in the mutation")
  23313. }
  23314. oldValue, err := m.oldValue(ctx)
  23315. if err != nil {
  23316. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  23317. }
  23318. return oldValue.BlockList, nil
  23319. }
  23320. // AppendBlockList adds s to the "block_list" field.
  23321. func (m *WxMutation) AppendBlockList(s []string) {
  23322. m.appendblock_list = append(m.appendblock_list, s...)
  23323. }
  23324. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  23325. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  23326. if len(m.appendblock_list) == 0 {
  23327. return nil, false
  23328. }
  23329. return m.appendblock_list, true
  23330. }
  23331. // ResetBlockList resets all changes to the "block_list" field.
  23332. func (m *WxMutation) ResetBlockList() {
  23333. m.block_list = nil
  23334. m.appendblock_list = nil
  23335. }
  23336. // SetGroupBlockList sets the "group_block_list" field.
  23337. func (m *WxMutation) SetGroupBlockList(s []string) {
  23338. m.group_block_list = &s
  23339. m.appendgroup_block_list = nil
  23340. }
  23341. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  23342. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  23343. v := m.group_block_list
  23344. if v == nil {
  23345. return
  23346. }
  23347. return *v, true
  23348. }
  23349. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  23350. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  23351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23352. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  23353. if !m.op.Is(OpUpdateOne) {
  23354. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  23355. }
  23356. if m.id == nil || m.oldValue == nil {
  23357. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  23358. }
  23359. oldValue, err := m.oldValue(ctx)
  23360. if err != nil {
  23361. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  23362. }
  23363. return oldValue.GroupBlockList, nil
  23364. }
  23365. // AppendGroupBlockList adds s to the "group_block_list" field.
  23366. func (m *WxMutation) AppendGroupBlockList(s []string) {
  23367. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  23368. }
  23369. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  23370. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  23371. if len(m.appendgroup_block_list) == 0 {
  23372. return nil, false
  23373. }
  23374. return m.appendgroup_block_list, true
  23375. }
  23376. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  23377. func (m *WxMutation) ResetGroupBlockList() {
  23378. m.group_block_list = nil
  23379. m.appendgroup_block_list = nil
  23380. }
  23381. // ClearServer clears the "server" edge to the Server entity.
  23382. func (m *WxMutation) ClearServer() {
  23383. m.clearedserver = true
  23384. m.clearedFields[wx.FieldServerID] = struct{}{}
  23385. }
  23386. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  23387. func (m *WxMutation) ServerCleared() bool {
  23388. return m.ServerIDCleared() || m.clearedserver
  23389. }
  23390. // ServerIDs returns the "server" edge IDs in the mutation.
  23391. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23392. // ServerID instead. It exists only for internal usage by the builders.
  23393. func (m *WxMutation) ServerIDs() (ids []uint64) {
  23394. if id := m.server; id != nil {
  23395. ids = append(ids, *id)
  23396. }
  23397. return
  23398. }
  23399. // ResetServer resets all changes to the "server" edge.
  23400. func (m *WxMutation) ResetServer() {
  23401. m.server = nil
  23402. m.clearedserver = false
  23403. }
  23404. // ClearAgent clears the "agent" edge to the Agent entity.
  23405. func (m *WxMutation) ClearAgent() {
  23406. m.clearedagent = true
  23407. m.clearedFields[wx.FieldAgentID] = struct{}{}
  23408. }
  23409. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  23410. func (m *WxMutation) AgentCleared() bool {
  23411. return m.clearedagent
  23412. }
  23413. // AgentIDs returns the "agent" edge IDs in the mutation.
  23414. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23415. // AgentID instead. It exists only for internal usage by the builders.
  23416. func (m *WxMutation) AgentIDs() (ids []uint64) {
  23417. if id := m.agent; id != nil {
  23418. ids = append(ids, *id)
  23419. }
  23420. return
  23421. }
  23422. // ResetAgent resets all changes to the "agent" edge.
  23423. func (m *WxMutation) ResetAgent() {
  23424. m.agent = nil
  23425. m.clearedagent = false
  23426. }
  23427. // Where appends a list predicates to the WxMutation builder.
  23428. func (m *WxMutation) Where(ps ...predicate.Wx) {
  23429. m.predicates = append(m.predicates, ps...)
  23430. }
  23431. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  23432. // users can use type-assertion to append predicates that do not depend on any generated package.
  23433. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  23434. p := make([]predicate.Wx, len(ps))
  23435. for i := range ps {
  23436. p[i] = ps[i]
  23437. }
  23438. m.Where(p...)
  23439. }
  23440. // Op returns the operation name.
  23441. func (m *WxMutation) Op() Op {
  23442. return m.op
  23443. }
  23444. // SetOp allows setting the mutation operation.
  23445. func (m *WxMutation) SetOp(op Op) {
  23446. m.op = op
  23447. }
  23448. // Type returns the node type of this mutation (Wx).
  23449. func (m *WxMutation) Type() string {
  23450. return m.typ
  23451. }
  23452. // Fields returns all fields that were changed during this mutation. Note that in
  23453. // order to get all numeric fields that were incremented/decremented, call
  23454. // AddedFields().
  23455. func (m *WxMutation) Fields() []string {
  23456. fields := make([]string, 0, 21)
  23457. if m.created_at != nil {
  23458. fields = append(fields, wx.FieldCreatedAt)
  23459. }
  23460. if m.updated_at != nil {
  23461. fields = append(fields, wx.FieldUpdatedAt)
  23462. }
  23463. if m.status != nil {
  23464. fields = append(fields, wx.FieldStatus)
  23465. }
  23466. if m.deleted_at != nil {
  23467. fields = append(fields, wx.FieldDeletedAt)
  23468. }
  23469. if m.server != nil {
  23470. fields = append(fields, wx.FieldServerID)
  23471. }
  23472. if m.port != nil {
  23473. fields = append(fields, wx.FieldPort)
  23474. }
  23475. if m.process_id != nil {
  23476. fields = append(fields, wx.FieldProcessID)
  23477. }
  23478. if m.callback != nil {
  23479. fields = append(fields, wx.FieldCallback)
  23480. }
  23481. if m.wxid != nil {
  23482. fields = append(fields, wx.FieldWxid)
  23483. }
  23484. if m.account != nil {
  23485. fields = append(fields, wx.FieldAccount)
  23486. }
  23487. if m.nickname != nil {
  23488. fields = append(fields, wx.FieldNickname)
  23489. }
  23490. if m.tel != nil {
  23491. fields = append(fields, wx.FieldTel)
  23492. }
  23493. if m.head_big != nil {
  23494. fields = append(fields, wx.FieldHeadBig)
  23495. }
  23496. if m.organization_id != nil {
  23497. fields = append(fields, wx.FieldOrganizationID)
  23498. }
  23499. if m.agent != nil {
  23500. fields = append(fields, wx.FieldAgentID)
  23501. }
  23502. if m.api_base != nil {
  23503. fields = append(fields, wx.FieldAPIBase)
  23504. }
  23505. if m.api_key != nil {
  23506. fields = append(fields, wx.FieldAPIKey)
  23507. }
  23508. if m.allow_list != nil {
  23509. fields = append(fields, wx.FieldAllowList)
  23510. }
  23511. if m.group_allow_list != nil {
  23512. fields = append(fields, wx.FieldGroupAllowList)
  23513. }
  23514. if m.block_list != nil {
  23515. fields = append(fields, wx.FieldBlockList)
  23516. }
  23517. if m.group_block_list != nil {
  23518. fields = append(fields, wx.FieldGroupBlockList)
  23519. }
  23520. return fields
  23521. }
  23522. // Field returns the value of a field with the given name. The second boolean
  23523. // return value indicates that this field was not set, or was not defined in the
  23524. // schema.
  23525. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  23526. switch name {
  23527. case wx.FieldCreatedAt:
  23528. return m.CreatedAt()
  23529. case wx.FieldUpdatedAt:
  23530. return m.UpdatedAt()
  23531. case wx.FieldStatus:
  23532. return m.Status()
  23533. case wx.FieldDeletedAt:
  23534. return m.DeletedAt()
  23535. case wx.FieldServerID:
  23536. return m.ServerID()
  23537. case wx.FieldPort:
  23538. return m.Port()
  23539. case wx.FieldProcessID:
  23540. return m.ProcessID()
  23541. case wx.FieldCallback:
  23542. return m.Callback()
  23543. case wx.FieldWxid:
  23544. return m.Wxid()
  23545. case wx.FieldAccount:
  23546. return m.Account()
  23547. case wx.FieldNickname:
  23548. return m.Nickname()
  23549. case wx.FieldTel:
  23550. return m.Tel()
  23551. case wx.FieldHeadBig:
  23552. return m.HeadBig()
  23553. case wx.FieldOrganizationID:
  23554. return m.OrganizationID()
  23555. case wx.FieldAgentID:
  23556. return m.AgentID()
  23557. case wx.FieldAPIBase:
  23558. return m.APIBase()
  23559. case wx.FieldAPIKey:
  23560. return m.APIKey()
  23561. case wx.FieldAllowList:
  23562. return m.AllowList()
  23563. case wx.FieldGroupAllowList:
  23564. return m.GroupAllowList()
  23565. case wx.FieldBlockList:
  23566. return m.BlockList()
  23567. case wx.FieldGroupBlockList:
  23568. return m.GroupBlockList()
  23569. }
  23570. return nil, false
  23571. }
  23572. // OldField returns the old value of the field from the database. An error is
  23573. // returned if the mutation operation is not UpdateOne, or the query to the
  23574. // database failed.
  23575. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23576. switch name {
  23577. case wx.FieldCreatedAt:
  23578. return m.OldCreatedAt(ctx)
  23579. case wx.FieldUpdatedAt:
  23580. return m.OldUpdatedAt(ctx)
  23581. case wx.FieldStatus:
  23582. return m.OldStatus(ctx)
  23583. case wx.FieldDeletedAt:
  23584. return m.OldDeletedAt(ctx)
  23585. case wx.FieldServerID:
  23586. return m.OldServerID(ctx)
  23587. case wx.FieldPort:
  23588. return m.OldPort(ctx)
  23589. case wx.FieldProcessID:
  23590. return m.OldProcessID(ctx)
  23591. case wx.FieldCallback:
  23592. return m.OldCallback(ctx)
  23593. case wx.FieldWxid:
  23594. return m.OldWxid(ctx)
  23595. case wx.FieldAccount:
  23596. return m.OldAccount(ctx)
  23597. case wx.FieldNickname:
  23598. return m.OldNickname(ctx)
  23599. case wx.FieldTel:
  23600. return m.OldTel(ctx)
  23601. case wx.FieldHeadBig:
  23602. return m.OldHeadBig(ctx)
  23603. case wx.FieldOrganizationID:
  23604. return m.OldOrganizationID(ctx)
  23605. case wx.FieldAgentID:
  23606. return m.OldAgentID(ctx)
  23607. case wx.FieldAPIBase:
  23608. return m.OldAPIBase(ctx)
  23609. case wx.FieldAPIKey:
  23610. return m.OldAPIKey(ctx)
  23611. case wx.FieldAllowList:
  23612. return m.OldAllowList(ctx)
  23613. case wx.FieldGroupAllowList:
  23614. return m.OldGroupAllowList(ctx)
  23615. case wx.FieldBlockList:
  23616. return m.OldBlockList(ctx)
  23617. case wx.FieldGroupBlockList:
  23618. return m.OldGroupBlockList(ctx)
  23619. }
  23620. return nil, fmt.Errorf("unknown Wx field %s", name)
  23621. }
  23622. // SetField sets the value of a field with the given name. It returns an error if
  23623. // the field is not defined in the schema, or if the type mismatched the field
  23624. // type.
  23625. func (m *WxMutation) SetField(name string, value ent.Value) error {
  23626. switch name {
  23627. case wx.FieldCreatedAt:
  23628. v, ok := value.(time.Time)
  23629. if !ok {
  23630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23631. }
  23632. m.SetCreatedAt(v)
  23633. return nil
  23634. case wx.FieldUpdatedAt:
  23635. v, ok := value.(time.Time)
  23636. if !ok {
  23637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23638. }
  23639. m.SetUpdatedAt(v)
  23640. return nil
  23641. case wx.FieldStatus:
  23642. v, ok := value.(uint8)
  23643. if !ok {
  23644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23645. }
  23646. m.SetStatus(v)
  23647. return nil
  23648. case wx.FieldDeletedAt:
  23649. v, ok := value.(time.Time)
  23650. if !ok {
  23651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23652. }
  23653. m.SetDeletedAt(v)
  23654. return nil
  23655. case wx.FieldServerID:
  23656. v, ok := value.(uint64)
  23657. if !ok {
  23658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23659. }
  23660. m.SetServerID(v)
  23661. return nil
  23662. case wx.FieldPort:
  23663. v, ok := value.(string)
  23664. if !ok {
  23665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23666. }
  23667. m.SetPort(v)
  23668. return nil
  23669. case wx.FieldProcessID:
  23670. v, ok := value.(string)
  23671. if !ok {
  23672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23673. }
  23674. m.SetProcessID(v)
  23675. return nil
  23676. case wx.FieldCallback:
  23677. v, ok := value.(string)
  23678. if !ok {
  23679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23680. }
  23681. m.SetCallback(v)
  23682. return nil
  23683. case wx.FieldWxid:
  23684. v, ok := value.(string)
  23685. if !ok {
  23686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23687. }
  23688. m.SetWxid(v)
  23689. return nil
  23690. case wx.FieldAccount:
  23691. v, ok := value.(string)
  23692. if !ok {
  23693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23694. }
  23695. m.SetAccount(v)
  23696. return nil
  23697. case wx.FieldNickname:
  23698. v, ok := value.(string)
  23699. if !ok {
  23700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23701. }
  23702. m.SetNickname(v)
  23703. return nil
  23704. case wx.FieldTel:
  23705. v, ok := value.(string)
  23706. if !ok {
  23707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23708. }
  23709. m.SetTel(v)
  23710. return nil
  23711. case wx.FieldHeadBig:
  23712. v, ok := value.(string)
  23713. if !ok {
  23714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23715. }
  23716. m.SetHeadBig(v)
  23717. return nil
  23718. case wx.FieldOrganizationID:
  23719. v, ok := value.(uint64)
  23720. if !ok {
  23721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23722. }
  23723. m.SetOrganizationID(v)
  23724. return nil
  23725. case wx.FieldAgentID:
  23726. v, ok := value.(uint64)
  23727. if !ok {
  23728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23729. }
  23730. m.SetAgentID(v)
  23731. return nil
  23732. case wx.FieldAPIBase:
  23733. v, ok := value.(string)
  23734. if !ok {
  23735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23736. }
  23737. m.SetAPIBase(v)
  23738. return nil
  23739. case wx.FieldAPIKey:
  23740. v, ok := value.(string)
  23741. if !ok {
  23742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23743. }
  23744. m.SetAPIKey(v)
  23745. return nil
  23746. case wx.FieldAllowList:
  23747. v, ok := value.([]string)
  23748. if !ok {
  23749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23750. }
  23751. m.SetAllowList(v)
  23752. return nil
  23753. case wx.FieldGroupAllowList:
  23754. v, ok := value.([]string)
  23755. if !ok {
  23756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23757. }
  23758. m.SetGroupAllowList(v)
  23759. return nil
  23760. case wx.FieldBlockList:
  23761. v, ok := value.([]string)
  23762. if !ok {
  23763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23764. }
  23765. m.SetBlockList(v)
  23766. return nil
  23767. case wx.FieldGroupBlockList:
  23768. v, ok := value.([]string)
  23769. if !ok {
  23770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23771. }
  23772. m.SetGroupBlockList(v)
  23773. return nil
  23774. }
  23775. return fmt.Errorf("unknown Wx field %s", name)
  23776. }
  23777. // AddedFields returns all numeric fields that were incremented/decremented during
  23778. // this mutation.
  23779. func (m *WxMutation) AddedFields() []string {
  23780. var fields []string
  23781. if m.addstatus != nil {
  23782. fields = append(fields, wx.FieldStatus)
  23783. }
  23784. if m.addorganization_id != nil {
  23785. fields = append(fields, wx.FieldOrganizationID)
  23786. }
  23787. return fields
  23788. }
  23789. // AddedField returns the numeric value that was incremented/decremented on a field
  23790. // with the given name. The second boolean return value indicates that this field
  23791. // was not set, or was not defined in the schema.
  23792. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  23793. switch name {
  23794. case wx.FieldStatus:
  23795. return m.AddedStatus()
  23796. case wx.FieldOrganizationID:
  23797. return m.AddedOrganizationID()
  23798. }
  23799. return nil, false
  23800. }
  23801. // AddField adds the value to the field with the given name. It returns an error if
  23802. // the field is not defined in the schema, or if the type mismatched the field
  23803. // type.
  23804. func (m *WxMutation) AddField(name string, value ent.Value) error {
  23805. switch name {
  23806. case wx.FieldStatus:
  23807. v, ok := value.(int8)
  23808. if !ok {
  23809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23810. }
  23811. m.AddStatus(v)
  23812. return nil
  23813. case wx.FieldOrganizationID:
  23814. v, ok := value.(int64)
  23815. if !ok {
  23816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23817. }
  23818. m.AddOrganizationID(v)
  23819. return nil
  23820. }
  23821. return fmt.Errorf("unknown Wx numeric field %s", name)
  23822. }
  23823. // ClearedFields returns all nullable fields that were cleared during this
  23824. // mutation.
  23825. func (m *WxMutation) ClearedFields() []string {
  23826. var fields []string
  23827. if m.FieldCleared(wx.FieldStatus) {
  23828. fields = append(fields, wx.FieldStatus)
  23829. }
  23830. if m.FieldCleared(wx.FieldDeletedAt) {
  23831. fields = append(fields, wx.FieldDeletedAt)
  23832. }
  23833. if m.FieldCleared(wx.FieldServerID) {
  23834. fields = append(fields, wx.FieldServerID)
  23835. }
  23836. if m.FieldCleared(wx.FieldOrganizationID) {
  23837. fields = append(fields, wx.FieldOrganizationID)
  23838. }
  23839. if m.FieldCleared(wx.FieldAPIBase) {
  23840. fields = append(fields, wx.FieldAPIBase)
  23841. }
  23842. if m.FieldCleared(wx.FieldAPIKey) {
  23843. fields = append(fields, wx.FieldAPIKey)
  23844. }
  23845. return fields
  23846. }
  23847. // FieldCleared returns a boolean indicating if a field with the given name was
  23848. // cleared in this mutation.
  23849. func (m *WxMutation) FieldCleared(name string) bool {
  23850. _, ok := m.clearedFields[name]
  23851. return ok
  23852. }
  23853. // ClearField clears the value of the field with the given name. It returns an
  23854. // error if the field is not defined in the schema.
  23855. func (m *WxMutation) ClearField(name string) error {
  23856. switch name {
  23857. case wx.FieldStatus:
  23858. m.ClearStatus()
  23859. return nil
  23860. case wx.FieldDeletedAt:
  23861. m.ClearDeletedAt()
  23862. return nil
  23863. case wx.FieldServerID:
  23864. m.ClearServerID()
  23865. return nil
  23866. case wx.FieldOrganizationID:
  23867. m.ClearOrganizationID()
  23868. return nil
  23869. case wx.FieldAPIBase:
  23870. m.ClearAPIBase()
  23871. return nil
  23872. case wx.FieldAPIKey:
  23873. m.ClearAPIKey()
  23874. return nil
  23875. }
  23876. return fmt.Errorf("unknown Wx nullable field %s", name)
  23877. }
  23878. // ResetField resets all changes in the mutation for the field with the given name.
  23879. // It returns an error if the field is not defined in the schema.
  23880. func (m *WxMutation) ResetField(name string) error {
  23881. switch name {
  23882. case wx.FieldCreatedAt:
  23883. m.ResetCreatedAt()
  23884. return nil
  23885. case wx.FieldUpdatedAt:
  23886. m.ResetUpdatedAt()
  23887. return nil
  23888. case wx.FieldStatus:
  23889. m.ResetStatus()
  23890. return nil
  23891. case wx.FieldDeletedAt:
  23892. m.ResetDeletedAt()
  23893. return nil
  23894. case wx.FieldServerID:
  23895. m.ResetServerID()
  23896. return nil
  23897. case wx.FieldPort:
  23898. m.ResetPort()
  23899. return nil
  23900. case wx.FieldProcessID:
  23901. m.ResetProcessID()
  23902. return nil
  23903. case wx.FieldCallback:
  23904. m.ResetCallback()
  23905. return nil
  23906. case wx.FieldWxid:
  23907. m.ResetWxid()
  23908. return nil
  23909. case wx.FieldAccount:
  23910. m.ResetAccount()
  23911. return nil
  23912. case wx.FieldNickname:
  23913. m.ResetNickname()
  23914. return nil
  23915. case wx.FieldTel:
  23916. m.ResetTel()
  23917. return nil
  23918. case wx.FieldHeadBig:
  23919. m.ResetHeadBig()
  23920. return nil
  23921. case wx.FieldOrganizationID:
  23922. m.ResetOrganizationID()
  23923. return nil
  23924. case wx.FieldAgentID:
  23925. m.ResetAgentID()
  23926. return nil
  23927. case wx.FieldAPIBase:
  23928. m.ResetAPIBase()
  23929. return nil
  23930. case wx.FieldAPIKey:
  23931. m.ResetAPIKey()
  23932. return nil
  23933. case wx.FieldAllowList:
  23934. m.ResetAllowList()
  23935. return nil
  23936. case wx.FieldGroupAllowList:
  23937. m.ResetGroupAllowList()
  23938. return nil
  23939. case wx.FieldBlockList:
  23940. m.ResetBlockList()
  23941. return nil
  23942. case wx.FieldGroupBlockList:
  23943. m.ResetGroupBlockList()
  23944. return nil
  23945. }
  23946. return fmt.Errorf("unknown Wx field %s", name)
  23947. }
  23948. // AddedEdges returns all edge names that were set/added in this mutation.
  23949. func (m *WxMutation) AddedEdges() []string {
  23950. edges := make([]string, 0, 2)
  23951. if m.server != nil {
  23952. edges = append(edges, wx.EdgeServer)
  23953. }
  23954. if m.agent != nil {
  23955. edges = append(edges, wx.EdgeAgent)
  23956. }
  23957. return edges
  23958. }
  23959. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23960. // name in this mutation.
  23961. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  23962. switch name {
  23963. case wx.EdgeServer:
  23964. if id := m.server; id != nil {
  23965. return []ent.Value{*id}
  23966. }
  23967. case wx.EdgeAgent:
  23968. if id := m.agent; id != nil {
  23969. return []ent.Value{*id}
  23970. }
  23971. }
  23972. return nil
  23973. }
  23974. // RemovedEdges returns all edge names that were removed in this mutation.
  23975. func (m *WxMutation) RemovedEdges() []string {
  23976. edges := make([]string, 0, 2)
  23977. return edges
  23978. }
  23979. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23980. // the given name in this mutation.
  23981. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  23982. return nil
  23983. }
  23984. // ClearedEdges returns all edge names that were cleared in this mutation.
  23985. func (m *WxMutation) ClearedEdges() []string {
  23986. edges := make([]string, 0, 2)
  23987. if m.clearedserver {
  23988. edges = append(edges, wx.EdgeServer)
  23989. }
  23990. if m.clearedagent {
  23991. edges = append(edges, wx.EdgeAgent)
  23992. }
  23993. return edges
  23994. }
  23995. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23996. // was cleared in this mutation.
  23997. func (m *WxMutation) EdgeCleared(name string) bool {
  23998. switch name {
  23999. case wx.EdgeServer:
  24000. return m.clearedserver
  24001. case wx.EdgeAgent:
  24002. return m.clearedagent
  24003. }
  24004. return false
  24005. }
  24006. // ClearEdge clears the value of the edge with the given name. It returns an error
  24007. // if that edge is not defined in the schema.
  24008. func (m *WxMutation) ClearEdge(name string) error {
  24009. switch name {
  24010. case wx.EdgeServer:
  24011. m.ClearServer()
  24012. return nil
  24013. case wx.EdgeAgent:
  24014. m.ClearAgent()
  24015. return nil
  24016. }
  24017. return fmt.Errorf("unknown Wx unique edge %s", name)
  24018. }
  24019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24020. // It returns an error if the edge is not defined in the schema.
  24021. func (m *WxMutation) ResetEdge(name string) error {
  24022. switch name {
  24023. case wx.EdgeServer:
  24024. m.ResetServer()
  24025. return nil
  24026. case wx.EdgeAgent:
  24027. m.ResetAgent()
  24028. return nil
  24029. }
  24030. return fmt.Errorf("unknown Wx edge %s", name)
  24031. }
  24032. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  24033. type WxCardMutation struct {
  24034. config
  24035. op Op
  24036. typ string
  24037. id *uint64
  24038. created_at *time.Time
  24039. updated_at *time.Time
  24040. deleted_at *time.Time
  24041. user_id *uint64
  24042. adduser_id *int64
  24043. wx_user_id *uint64
  24044. addwx_user_id *int64
  24045. avatar *string
  24046. logo *string
  24047. name *string
  24048. company *string
  24049. address *string
  24050. phone *string
  24051. official_account *string
  24052. wechat_account *string
  24053. email *string
  24054. api_base *string
  24055. api_key *string
  24056. ai_info *string
  24057. intro *string
  24058. clearedFields map[string]struct{}
  24059. done bool
  24060. oldValue func(context.Context) (*WxCard, error)
  24061. predicates []predicate.WxCard
  24062. }
  24063. var _ ent.Mutation = (*WxCardMutation)(nil)
  24064. // wxcardOption allows management of the mutation configuration using functional options.
  24065. type wxcardOption func(*WxCardMutation)
  24066. // newWxCardMutation creates new mutation for the WxCard entity.
  24067. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  24068. m := &WxCardMutation{
  24069. config: c,
  24070. op: op,
  24071. typ: TypeWxCard,
  24072. clearedFields: make(map[string]struct{}),
  24073. }
  24074. for _, opt := range opts {
  24075. opt(m)
  24076. }
  24077. return m
  24078. }
  24079. // withWxCardID sets the ID field of the mutation.
  24080. func withWxCardID(id uint64) wxcardOption {
  24081. return func(m *WxCardMutation) {
  24082. var (
  24083. err error
  24084. once sync.Once
  24085. value *WxCard
  24086. )
  24087. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  24088. once.Do(func() {
  24089. if m.done {
  24090. err = errors.New("querying old values post mutation is not allowed")
  24091. } else {
  24092. value, err = m.Client().WxCard.Get(ctx, id)
  24093. }
  24094. })
  24095. return value, err
  24096. }
  24097. m.id = &id
  24098. }
  24099. }
  24100. // withWxCard sets the old WxCard of the mutation.
  24101. func withWxCard(node *WxCard) wxcardOption {
  24102. return func(m *WxCardMutation) {
  24103. m.oldValue = func(context.Context) (*WxCard, error) {
  24104. return node, nil
  24105. }
  24106. m.id = &node.ID
  24107. }
  24108. }
  24109. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24110. // executed in a transaction (ent.Tx), a transactional client is returned.
  24111. func (m WxCardMutation) Client() *Client {
  24112. client := &Client{config: m.config}
  24113. client.init()
  24114. return client
  24115. }
  24116. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24117. // it returns an error otherwise.
  24118. func (m WxCardMutation) Tx() (*Tx, error) {
  24119. if _, ok := m.driver.(*txDriver); !ok {
  24120. return nil, errors.New("ent: mutation is not running in a transaction")
  24121. }
  24122. tx := &Tx{config: m.config}
  24123. tx.init()
  24124. return tx, nil
  24125. }
  24126. // SetID sets the value of the id field. Note that this
  24127. // operation is only accepted on creation of WxCard entities.
  24128. func (m *WxCardMutation) SetID(id uint64) {
  24129. m.id = &id
  24130. }
  24131. // ID returns the ID value in the mutation. Note that the ID is only available
  24132. // if it was provided to the builder or after it was returned from the database.
  24133. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  24134. if m.id == nil {
  24135. return
  24136. }
  24137. return *m.id, true
  24138. }
  24139. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24140. // That means, if the mutation is applied within a transaction with an isolation level such
  24141. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24142. // or updated by the mutation.
  24143. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  24144. switch {
  24145. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24146. id, exists := m.ID()
  24147. if exists {
  24148. return []uint64{id}, nil
  24149. }
  24150. fallthrough
  24151. case m.op.Is(OpUpdate | OpDelete):
  24152. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  24153. default:
  24154. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24155. }
  24156. }
  24157. // SetCreatedAt sets the "created_at" field.
  24158. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  24159. m.created_at = &t
  24160. }
  24161. // CreatedAt returns the value of the "created_at" field in the mutation.
  24162. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  24163. v := m.created_at
  24164. if v == nil {
  24165. return
  24166. }
  24167. return *v, true
  24168. }
  24169. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  24170. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24172. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24173. if !m.op.Is(OpUpdateOne) {
  24174. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24175. }
  24176. if m.id == nil || m.oldValue == nil {
  24177. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24178. }
  24179. oldValue, err := m.oldValue(ctx)
  24180. if err != nil {
  24181. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24182. }
  24183. return oldValue.CreatedAt, nil
  24184. }
  24185. // ResetCreatedAt resets all changes to the "created_at" field.
  24186. func (m *WxCardMutation) ResetCreatedAt() {
  24187. m.created_at = nil
  24188. }
  24189. // SetUpdatedAt sets the "updated_at" field.
  24190. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  24191. m.updated_at = &t
  24192. }
  24193. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24194. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  24195. v := m.updated_at
  24196. if v == nil {
  24197. return
  24198. }
  24199. return *v, true
  24200. }
  24201. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  24202. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24204. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24205. if !m.op.Is(OpUpdateOne) {
  24206. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24207. }
  24208. if m.id == nil || m.oldValue == nil {
  24209. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24210. }
  24211. oldValue, err := m.oldValue(ctx)
  24212. if err != nil {
  24213. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24214. }
  24215. return oldValue.UpdatedAt, nil
  24216. }
  24217. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24218. func (m *WxCardMutation) ResetUpdatedAt() {
  24219. m.updated_at = nil
  24220. }
  24221. // SetDeletedAt sets the "deleted_at" field.
  24222. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  24223. m.deleted_at = &t
  24224. }
  24225. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24226. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  24227. v := m.deleted_at
  24228. if v == nil {
  24229. return
  24230. }
  24231. return *v, true
  24232. }
  24233. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  24234. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24236. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24237. if !m.op.Is(OpUpdateOne) {
  24238. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24239. }
  24240. if m.id == nil || m.oldValue == nil {
  24241. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24242. }
  24243. oldValue, err := m.oldValue(ctx)
  24244. if err != nil {
  24245. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24246. }
  24247. return oldValue.DeletedAt, nil
  24248. }
  24249. // ClearDeletedAt clears the value of the "deleted_at" field.
  24250. func (m *WxCardMutation) ClearDeletedAt() {
  24251. m.deleted_at = nil
  24252. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  24253. }
  24254. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24255. func (m *WxCardMutation) DeletedAtCleared() bool {
  24256. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  24257. return ok
  24258. }
  24259. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24260. func (m *WxCardMutation) ResetDeletedAt() {
  24261. m.deleted_at = nil
  24262. delete(m.clearedFields, wxcard.FieldDeletedAt)
  24263. }
  24264. // SetUserID sets the "user_id" field.
  24265. func (m *WxCardMutation) SetUserID(u uint64) {
  24266. m.user_id = &u
  24267. m.adduser_id = nil
  24268. }
  24269. // UserID returns the value of the "user_id" field in the mutation.
  24270. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  24271. v := m.user_id
  24272. if v == nil {
  24273. return
  24274. }
  24275. return *v, true
  24276. }
  24277. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  24278. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24280. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  24281. if !m.op.Is(OpUpdateOne) {
  24282. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  24283. }
  24284. if m.id == nil || m.oldValue == nil {
  24285. return v, errors.New("OldUserID requires an ID field in the mutation")
  24286. }
  24287. oldValue, err := m.oldValue(ctx)
  24288. if err != nil {
  24289. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  24290. }
  24291. return oldValue.UserID, nil
  24292. }
  24293. // AddUserID adds u to the "user_id" field.
  24294. func (m *WxCardMutation) AddUserID(u int64) {
  24295. if m.adduser_id != nil {
  24296. *m.adduser_id += u
  24297. } else {
  24298. m.adduser_id = &u
  24299. }
  24300. }
  24301. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  24302. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  24303. v := m.adduser_id
  24304. if v == nil {
  24305. return
  24306. }
  24307. return *v, true
  24308. }
  24309. // ClearUserID clears the value of the "user_id" field.
  24310. func (m *WxCardMutation) ClearUserID() {
  24311. m.user_id = nil
  24312. m.adduser_id = nil
  24313. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  24314. }
  24315. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  24316. func (m *WxCardMutation) UserIDCleared() bool {
  24317. _, ok := m.clearedFields[wxcard.FieldUserID]
  24318. return ok
  24319. }
  24320. // ResetUserID resets all changes to the "user_id" field.
  24321. func (m *WxCardMutation) ResetUserID() {
  24322. m.user_id = nil
  24323. m.adduser_id = nil
  24324. delete(m.clearedFields, wxcard.FieldUserID)
  24325. }
  24326. // SetWxUserID sets the "wx_user_id" field.
  24327. func (m *WxCardMutation) SetWxUserID(u uint64) {
  24328. m.wx_user_id = &u
  24329. m.addwx_user_id = nil
  24330. }
  24331. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  24332. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  24333. v := m.wx_user_id
  24334. if v == nil {
  24335. return
  24336. }
  24337. return *v, true
  24338. }
  24339. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  24340. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24342. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  24343. if !m.op.Is(OpUpdateOne) {
  24344. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  24345. }
  24346. if m.id == nil || m.oldValue == nil {
  24347. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  24348. }
  24349. oldValue, err := m.oldValue(ctx)
  24350. if err != nil {
  24351. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  24352. }
  24353. return oldValue.WxUserID, nil
  24354. }
  24355. // AddWxUserID adds u to the "wx_user_id" field.
  24356. func (m *WxCardMutation) AddWxUserID(u int64) {
  24357. if m.addwx_user_id != nil {
  24358. *m.addwx_user_id += u
  24359. } else {
  24360. m.addwx_user_id = &u
  24361. }
  24362. }
  24363. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  24364. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  24365. v := m.addwx_user_id
  24366. if v == nil {
  24367. return
  24368. }
  24369. return *v, true
  24370. }
  24371. // ClearWxUserID clears the value of the "wx_user_id" field.
  24372. func (m *WxCardMutation) ClearWxUserID() {
  24373. m.wx_user_id = nil
  24374. m.addwx_user_id = nil
  24375. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  24376. }
  24377. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  24378. func (m *WxCardMutation) WxUserIDCleared() bool {
  24379. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  24380. return ok
  24381. }
  24382. // ResetWxUserID resets all changes to the "wx_user_id" field.
  24383. func (m *WxCardMutation) ResetWxUserID() {
  24384. m.wx_user_id = nil
  24385. m.addwx_user_id = nil
  24386. delete(m.clearedFields, wxcard.FieldWxUserID)
  24387. }
  24388. // SetAvatar sets the "avatar" field.
  24389. func (m *WxCardMutation) SetAvatar(s string) {
  24390. m.avatar = &s
  24391. }
  24392. // Avatar returns the value of the "avatar" field in the mutation.
  24393. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  24394. v := m.avatar
  24395. if v == nil {
  24396. return
  24397. }
  24398. return *v, true
  24399. }
  24400. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  24401. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24403. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  24404. if !m.op.Is(OpUpdateOne) {
  24405. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  24406. }
  24407. if m.id == nil || m.oldValue == nil {
  24408. return v, errors.New("OldAvatar requires an ID field in the mutation")
  24409. }
  24410. oldValue, err := m.oldValue(ctx)
  24411. if err != nil {
  24412. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  24413. }
  24414. return oldValue.Avatar, nil
  24415. }
  24416. // ResetAvatar resets all changes to the "avatar" field.
  24417. func (m *WxCardMutation) ResetAvatar() {
  24418. m.avatar = nil
  24419. }
  24420. // SetLogo sets the "logo" field.
  24421. func (m *WxCardMutation) SetLogo(s string) {
  24422. m.logo = &s
  24423. }
  24424. // Logo returns the value of the "logo" field in the mutation.
  24425. func (m *WxCardMutation) Logo() (r string, exists bool) {
  24426. v := m.logo
  24427. if v == nil {
  24428. return
  24429. }
  24430. return *v, true
  24431. }
  24432. // OldLogo returns the old "logo" field's value of the WxCard entity.
  24433. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24435. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  24436. if !m.op.Is(OpUpdateOne) {
  24437. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  24438. }
  24439. if m.id == nil || m.oldValue == nil {
  24440. return v, errors.New("OldLogo requires an ID field in the mutation")
  24441. }
  24442. oldValue, err := m.oldValue(ctx)
  24443. if err != nil {
  24444. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  24445. }
  24446. return oldValue.Logo, nil
  24447. }
  24448. // ResetLogo resets all changes to the "logo" field.
  24449. func (m *WxCardMutation) ResetLogo() {
  24450. m.logo = nil
  24451. }
  24452. // SetName sets the "name" field.
  24453. func (m *WxCardMutation) SetName(s string) {
  24454. m.name = &s
  24455. }
  24456. // Name returns the value of the "name" field in the mutation.
  24457. func (m *WxCardMutation) Name() (r string, exists bool) {
  24458. v := m.name
  24459. if v == nil {
  24460. return
  24461. }
  24462. return *v, true
  24463. }
  24464. // OldName returns the old "name" field's value of the WxCard entity.
  24465. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24467. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  24468. if !m.op.Is(OpUpdateOne) {
  24469. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24470. }
  24471. if m.id == nil || m.oldValue == nil {
  24472. return v, errors.New("OldName requires an ID field in the mutation")
  24473. }
  24474. oldValue, err := m.oldValue(ctx)
  24475. if err != nil {
  24476. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24477. }
  24478. return oldValue.Name, nil
  24479. }
  24480. // ResetName resets all changes to the "name" field.
  24481. func (m *WxCardMutation) ResetName() {
  24482. m.name = nil
  24483. }
  24484. // SetCompany sets the "company" field.
  24485. func (m *WxCardMutation) SetCompany(s string) {
  24486. m.company = &s
  24487. }
  24488. // Company returns the value of the "company" field in the mutation.
  24489. func (m *WxCardMutation) Company() (r string, exists bool) {
  24490. v := m.company
  24491. if v == nil {
  24492. return
  24493. }
  24494. return *v, true
  24495. }
  24496. // OldCompany returns the old "company" field's value of the WxCard entity.
  24497. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24499. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  24500. if !m.op.Is(OpUpdateOne) {
  24501. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  24502. }
  24503. if m.id == nil || m.oldValue == nil {
  24504. return v, errors.New("OldCompany requires an ID field in the mutation")
  24505. }
  24506. oldValue, err := m.oldValue(ctx)
  24507. if err != nil {
  24508. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  24509. }
  24510. return oldValue.Company, nil
  24511. }
  24512. // ResetCompany resets all changes to the "company" field.
  24513. func (m *WxCardMutation) ResetCompany() {
  24514. m.company = nil
  24515. }
  24516. // SetAddress sets the "address" field.
  24517. func (m *WxCardMutation) SetAddress(s string) {
  24518. m.address = &s
  24519. }
  24520. // Address returns the value of the "address" field in the mutation.
  24521. func (m *WxCardMutation) Address() (r string, exists bool) {
  24522. v := m.address
  24523. if v == nil {
  24524. return
  24525. }
  24526. return *v, true
  24527. }
  24528. // OldAddress returns the old "address" field's value of the WxCard entity.
  24529. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24531. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  24532. if !m.op.Is(OpUpdateOne) {
  24533. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  24534. }
  24535. if m.id == nil || m.oldValue == nil {
  24536. return v, errors.New("OldAddress requires an ID field in the mutation")
  24537. }
  24538. oldValue, err := m.oldValue(ctx)
  24539. if err != nil {
  24540. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  24541. }
  24542. return oldValue.Address, nil
  24543. }
  24544. // ResetAddress resets all changes to the "address" field.
  24545. func (m *WxCardMutation) ResetAddress() {
  24546. m.address = nil
  24547. }
  24548. // SetPhone sets the "phone" field.
  24549. func (m *WxCardMutation) SetPhone(s string) {
  24550. m.phone = &s
  24551. }
  24552. // Phone returns the value of the "phone" field in the mutation.
  24553. func (m *WxCardMutation) Phone() (r string, exists bool) {
  24554. v := m.phone
  24555. if v == nil {
  24556. return
  24557. }
  24558. return *v, true
  24559. }
  24560. // OldPhone returns the old "phone" field's value of the WxCard entity.
  24561. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24563. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  24564. if !m.op.Is(OpUpdateOne) {
  24565. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24566. }
  24567. if m.id == nil || m.oldValue == nil {
  24568. return v, errors.New("OldPhone requires an ID field in the mutation")
  24569. }
  24570. oldValue, err := m.oldValue(ctx)
  24571. if err != nil {
  24572. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24573. }
  24574. return oldValue.Phone, nil
  24575. }
  24576. // ResetPhone resets all changes to the "phone" field.
  24577. func (m *WxCardMutation) ResetPhone() {
  24578. m.phone = nil
  24579. }
  24580. // SetOfficialAccount sets the "official_account" field.
  24581. func (m *WxCardMutation) SetOfficialAccount(s string) {
  24582. m.official_account = &s
  24583. }
  24584. // OfficialAccount returns the value of the "official_account" field in the mutation.
  24585. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  24586. v := m.official_account
  24587. if v == nil {
  24588. return
  24589. }
  24590. return *v, true
  24591. }
  24592. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  24593. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24595. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  24596. if !m.op.Is(OpUpdateOne) {
  24597. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  24598. }
  24599. if m.id == nil || m.oldValue == nil {
  24600. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  24601. }
  24602. oldValue, err := m.oldValue(ctx)
  24603. if err != nil {
  24604. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  24605. }
  24606. return oldValue.OfficialAccount, nil
  24607. }
  24608. // ResetOfficialAccount resets all changes to the "official_account" field.
  24609. func (m *WxCardMutation) ResetOfficialAccount() {
  24610. m.official_account = nil
  24611. }
  24612. // SetWechatAccount sets the "wechat_account" field.
  24613. func (m *WxCardMutation) SetWechatAccount(s string) {
  24614. m.wechat_account = &s
  24615. }
  24616. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  24617. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  24618. v := m.wechat_account
  24619. if v == nil {
  24620. return
  24621. }
  24622. return *v, true
  24623. }
  24624. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  24625. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24627. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  24628. if !m.op.Is(OpUpdateOne) {
  24629. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  24630. }
  24631. if m.id == nil || m.oldValue == nil {
  24632. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  24633. }
  24634. oldValue, err := m.oldValue(ctx)
  24635. if err != nil {
  24636. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  24637. }
  24638. return oldValue.WechatAccount, nil
  24639. }
  24640. // ResetWechatAccount resets all changes to the "wechat_account" field.
  24641. func (m *WxCardMutation) ResetWechatAccount() {
  24642. m.wechat_account = nil
  24643. }
  24644. // SetEmail sets the "email" field.
  24645. func (m *WxCardMutation) SetEmail(s string) {
  24646. m.email = &s
  24647. }
  24648. // Email returns the value of the "email" field in the mutation.
  24649. func (m *WxCardMutation) Email() (r string, exists bool) {
  24650. v := m.email
  24651. if v == nil {
  24652. return
  24653. }
  24654. return *v, true
  24655. }
  24656. // OldEmail returns the old "email" field's value of the WxCard entity.
  24657. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24659. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  24660. if !m.op.Is(OpUpdateOne) {
  24661. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  24662. }
  24663. if m.id == nil || m.oldValue == nil {
  24664. return v, errors.New("OldEmail requires an ID field in the mutation")
  24665. }
  24666. oldValue, err := m.oldValue(ctx)
  24667. if err != nil {
  24668. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  24669. }
  24670. return oldValue.Email, nil
  24671. }
  24672. // ClearEmail clears the value of the "email" field.
  24673. func (m *WxCardMutation) ClearEmail() {
  24674. m.email = nil
  24675. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  24676. }
  24677. // EmailCleared returns if the "email" field was cleared in this mutation.
  24678. func (m *WxCardMutation) EmailCleared() bool {
  24679. _, ok := m.clearedFields[wxcard.FieldEmail]
  24680. return ok
  24681. }
  24682. // ResetEmail resets all changes to the "email" field.
  24683. func (m *WxCardMutation) ResetEmail() {
  24684. m.email = nil
  24685. delete(m.clearedFields, wxcard.FieldEmail)
  24686. }
  24687. // SetAPIBase sets the "api_base" field.
  24688. func (m *WxCardMutation) SetAPIBase(s string) {
  24689. m.api_base = &s
  24690. }
  24691. // APIBase returns the value of the "api_base" field in the mutation.
  24692. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  24693. v := m.api_base
  24694. if v == nil {
  24695. return
  24696. }
  24697. return *v, true
  24698. }
  24699. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  24700. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24702. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  24703. if !m.op.Is(OpUpdateOne) {
  24704. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  24705. }
  24706. if m.id == nil || m.oldValue == nil {
  24707. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  24708. }
  24709. oldValue, err := m.oldValue(ctx)
  24710. if err != nil {
  24711. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  24712. }
  24713. return oldValue.APIBase, nil
  24714. }
  24715. // ClearAPIBase clears the value of the "api_base" field.
  24716. func (m *WxCardMutation) ClearAPIBase() {
  24717. m.api_base = nil
  24718. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  24719. }
  24720. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  24721. func (m *WxCardMutation) APIBaseCleared() bool {
  24722. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  24723. return ok
  24724. }
  24725. // ResetAPIBase resets all changes to the "api_base" field.
  24726. func (m *WxCardMutation) ResetAPIBase() {
  24727. m.api_base = nil
  24728. delete(m.clearedFields, wxcard.FieldAPIBase)
  24729. }
  24730. // SetAPIKey sets the "api_key" field.
  24731. func (m *WxCardMutation) SetAPIKey(s string) {
  24732. m.api_key = &s
  24733. }
  24734. // APIKey returns the value of the "api_key" field in the mutation.
  24735. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  24736. v := m.api_key
  24737. if v == nil {
  24738. return
  24739. }
  24740. return *v, true
  24741. }
  24742. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  24743. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24745. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  24746. if !m.op.Is(OpUpdateOne) {
  24747. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  24748. }
  24749. if m.id == nil || m.oldValue == nil {
  24750. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  24751. }
  24752. oldValue, err := m.oldValue(ctx)
  24753. if err != nil {
  24754. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  24755. }
  24756. return oldValue.APIKey, nil
  24757. }
  24758. // ClearAPIKey clears the value of the "api_key" field.
  24759. func (m *WxCardMutation) ClearAPIKey() {
  24760. m.api_key = nil
  24761. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  24762. }
  24763. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  24764. func (m *WxCardMutation) APIKeyCleared() bool {
  24765. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  24766. return ok
  24767. }
  24768. // ResetAPIKey resets all changes to the "api_key" field.
  24769. func (m *WxCardMutation) ResetAPIKey() {
  24770. m.api_key = nil
  24771. delete(m.clearedFields, wxcard.FieldAPIKey)
  24772. }
  24773. // SetAiInfo sets the "ai_info" field.
  24774. func (m *WxCardMutation) SetAiInfo(s string) {
  24775. m.ai_info = &s
  24776. }
  24777. // AiInfo returns the value of the "ai_info" field in the mutation.
  24778. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  24779. v := m.ai_info
  24780. if v == nil {
  24781. return
  24782. }
  24783. return *v, true
  24784. }
  24785. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  24786. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24788. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  24789. if !m.op.Is(OpUpdateOne) {
  24790. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  24791. }
  24792. if m.id == nil || m.oldValue == nil {
  24793. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  24794. }
  24795. oldValue, err := m.oldValue(ctx)
  24796. if err != nil {
  24797. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  24798. }
  24799. return oldValue.AiInfo, nil
  24800. }
  24801. // ClearAiInfo clears the value of the "ai_info" field.
  24802. func (m *WxCardMutation) ClearAiInfo() {
  24803. m.ai_info = nil
  24804. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  24805. }
  24806. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  24807. func (m *WxCardMutation) AiInfoCleared() bool {
  24808. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  24809. return ok
  24810. }
  24811. // ResetAiInfo resets all changes to the "ai_info" field.
  24812. func (m *WxCardMutation) ResetAiInfo() {
  24813. m.ai_info = nil
  24814. delete(m.clearedFields, wxcard.FieldAiInfo)
  24815. }
  24816. // SetIntro sets the "intro" field.
  24817. func (m *WxCardMutation) SetIntro(s string) {
  24818. m.intro = &s
  24819. }
  24820. // Intro returns the value of the "intro" field in the mutation.
  24821. func (m *WxCardMutation) Intro() (r string, exists bool) {
  24822. v := m.intro
  24823. if v == nil {
  24824. return
  24825. }
  24826. return *v, true
  24827. }
  24828. // OldIntro returns the old "intro" field's value of the WxCard entity.
  24829. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  24830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24831. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  24832. if !m.op.Is(OpUpdateOne) {
  24833. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  24834. }
  24835. if m.id == nil || m.oldValue == nil {
  24836. return v, errors.New("OldIntro requires an ID field in the mutation")
  24837. }
  24838. oldValue, err := m.oldValue(ctx)
  24839. if err != nil {
  24840. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  24841. }
  24842. return oldValue.Intro, nil
  24843. }
  24844. // ClearIntro clears the value of the "intro" field.
  24845. func (m *WxCardMutation) ClearIntro() {
  24846. m.intro = nil
  24847. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  24848. }
  24849. // IntroCleared returns if the "intro" field was cleared in this mutation.
  24850. func (m *WxCardMutation) IntroCleared() bool {
  24851. _, ok := m.clearedFields[wxcard.FieldIntro]
  24852. return ok
  24853. }
  24854. // ResetIntro resets all changes to the "intro" field.
  24855. func (m *WxCardMutation) ResetIntro() {
  24856. m.intro = nil
  24857. delete(m.clearedFields, wxcard.FieldIntro)
  24858. }
  24859. // Where appends a list predicates to the WxCardMutation builder.
  24860. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  24861. m.predicates = append(m.predicates, ps...)
  24862. }
  24863. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  24864. // users can use type-assertion to append predicates that do not depend on any generated package.
  24865. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  24866. p := make([]predicate.WxCard, len(ps))
  24867. for i := range ps {
  24868. p[i] = ps[i]
  24869. }
  24870. m.Where(p...)
  24871. }
  24872. // Op returns the operation name.
  24873. func (m *WxCardMutation) Op() Op {
  24874. return m.op
  24875. }
  24876. // SetOp allows setting the mutation operation.
  24877. func (m *WxCardMutation) SetOp(op Op) {
  24878. m.op = op
  24879. }
  24880. // Type returns the node type of this mutation (WxCard).
  24881. func (m *WxCardMutation) Type() string {
  24882. return m.typ
  24883. }
  24884. // Fields returns all fields that were changed during this mutation. Note that in
  24885. // order to get all numeric fields that were incremented/decremented, call
  24886. // AddedFields().
  24887. func (m *WxCardMutation) Fields() []string {
  24888. fields := make([]string, 0, 18)
  24889. if m.created_at != nil {
  24890. fields = append(fields, wxcard.FieldCreatedAt)
  24891. }
  24892. if m.updated_at != nil {
  24893. fields = append(fields, wxcard.FieldUpdatedAt)
  24894. }
  24895. if m.deleted_at != nil {
  24896. fields = append(fields, wxcard.FieldDeletedAt)
  24897. }
  24898. if m.user_id != nil {
  24899. fields = append(fields, wxcard.FieldUserID)
  24900. }
  24901. if m.wx_user_id != nil {
  24902. fields = append(fields, wxcard.FieldWxUserID)
  24903. }
  24904. if m.avatar != nil {
  24905. fields = append(fields, wxcard.FieldAvatar)
  24906. }
  24907. if m.logo != nil {
  24908. fields = append(fields, wxcard.FieldLogo)
  24909. }
  24910. if m.name != nil {
  24911. fields = append(fields, wxcard.FieldName)
  24912. }
  24913. if m.company != nil {
  24914. fields = append(fields, wxcard.FieldCompany)
  24915. }
  24916. if m.address != nil {
  24917. fields = append(fields, wxcard.FieldAddress)
  24918. }
  24919. if m.phone != nil {
  24920. fields = append(fields, wxcard.FieldPhone)
  24921. }
  24922. if m.official_account != nil {
  24923. fields = append(fields, wxcard.FieldOfficialAccount)
  24924. }
  24925. if m.wechat_account != nil {
  24926. fields = append(fields, wxcard.FieldWechatAccount)
  24927. }
  24928. if m.email != nil {
  24929. fields = append(fields, wxcard.FieldEmail)
  24930. }
  24931. if m.api_base != nil {
  24932. fields = append(fields, wxcard.FieldAPIBase)
  24933. }
  24934. if m.api_key != nil {
  24935. fields = append(fields, wxcard.FieldAPIKey)
  24936. }
  24937. if m.ai_info != nil {
  24938. fields = append(fields, wxcard.FieldAiInfo)
  24939. }
  24940. if m.intro != nil {
  24941. fields = append(fields, wxcard.FieldIntro)
  24942. }
  24943. return fields
  24944. }
  24945. // Field returns the value of a field with the given name. The second boolean
  24946. // return value indicates that this field was not set, or was not defined in the
  24947. // schema.
  24948. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  24949. switch name {
  24950. case wxcard.FieldCreatedAt:
  24951. return m.CreatedAt()
  24952. case wxcard.FieldUpdatedAt:
  24953. return m.UpdatedAt()
  24954. case wxcard.FieldDeletedAt:
  24955. return m.DeletedAt()
  24956. case wxcard.FieldUserID:
  24957. return m.UserID()
  24958. case wxcard.FieldWxUserID:
  24959. return m.WxUserID()
  24960. case wxcard.FieldAvatar:
  24961. return m.Avatar()
  24962. case wxcard.FieldLogo:
  24963. return m.Logo()
  24964. case wxcard.FieldName:
  24965. return m.Name()
  24966. case wxcard.FieldCompany:
  24967. return m.Company()
  24968. case wxcard.FieldAddress:
  24969. return m.Address()
  24970. case wxcard.FieldPhone:
  24971. return m.Phone()
  24972. case wxcard.FieldOfficialAccount:
  24973. return m.OfficialAccount()
  24974. case wxcard.FieldWechatAccount:
  24975. return m.WechatAccount()
  24976. case wxcard.FieldEmail:
  24977. return m.Email()
  24978. case wxcard.FieldAPIBase:
  24979. return m.APIBase()
  24980. case wxcard.FieldAPIKey:
  24981. return m.APIKey()
  24982. case wxcard.FieldAiInfo:
  24983. return m.AiInfo()
  24984. case wxcard.FieldIntro:
  24985. return m.Intro()
  24986. }
  24987. return nil, false
  24988. }
  24989. // OldField returns the old value of the field from the database. An error is
  24990. // returned if the mutation operation is not UpdateOne, or the query to the
  24991. // database failed.
  24992. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24993. switch name {
  24994. case wxcard.FieldCreatedAt:
  24995. return m.OldCreatedAt(ctx)
  24996. case wxcard.FieldUpdatedAt:
  24997. return m.OldUpdatedAt(ctx)
  24998. case wxcard.FieldDeletedAt:
  24999. return m.OldDeletedAt(ctx)
  25000. case wxcard.FieldUserID:
  25001. return m.OldUserID(ctx)
  25002. case wxcard.FieldWxUserID:
  25003. return m.OldWxUserID(ctx)
  25004. case wxcard.FieldAvatar:
  25005. return m.OldAvatar(ctx)
  25006. case wxcard.FieldLogo:
  25007. return m.OldLogo(ctx)
  25008. case wxcard.FieldName:
  25009. return m.OldName(ctx)
  25010. case wxcard.FieldCompany:
  25011. return m.OldCompany(ctx)
  25012. case wxcard.FieldAddress:
  25013. return m.OldAddress(ctx)
  25014. case wxcard.FieldPhone:
  25015. return m.OldPhone(ctx)
  25016. case wxcard.FieldOfficialAccount:
  25017. return m.OldOfficialAccount(ctx)
  25018. case wxcard.FieldWechatAccount:
  25019. return m.OldWechatAccount(ctx)
  25020. case wxcard.FieldEmail:
  25021. return m.OldEmail(ctx)
  25022. case wxcard.FieldAPIBase:
  25023. return m.OldAPIBase(ctx)
  25024. case wxcard.FieldAPIKey:
  25025. return m.OldAPIKey(ctx)
  25026. case wxcard.FieldAiInfo:
  25027. return m.OldAiInfo(ctx)
  25028. case wxcard.FieldIntro:
  25029. return m.OldIntro(ctx)
  25030. }
  25031. return nil, fmt.Errorf("unknown WxCard field %s", name)
  25032. }
  25033. // SetField sets the value of a field with the given name. It returns an error if
  25034. // the field is not defined in the schema, or if the type mismatched the field
  25035. // type.
  25036. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  25037. switch name {
  25038. case wxcard.FieldCreatedAt:
  25039. v, ok := value.(time.Time)
  25040. if !ok {
  25041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25042. }
  25043. m.SetCreatedAt(v)
  25044. return nil
  25045. case wxcard.FieldUpdatedAt:
  25046. v, ok := value.(time.Time)
  25047. if !ok {
  25048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25049. }
  25050. m.SetUpdatedAt(v)
  25051. return nil
  25052. case wxcard.FieldDeletedAt:
  25053. v, ok := value.(time.Time)
  25054. if !ok {
  25055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25056. }
  25057. m.SetDeletedAt(v)
  25058. return nil
  25059. case wxcard.FieldUserID:
  25060. v, ok := value.(uint64)
  25061. if !ok {
  25062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25063. }
  25064. m.SetUserID(v)
  25065. return nil
  25066. case wxcard.FieldWxUserID:
  25067. v, ok := value.(uint64)
  25068. if !ok {
  25069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25070. }
  25071. m.SetWxUserID(v)
  25072. return nil
  25073. case wxcard.FieldAvatar:
  25074. v, ok := value.(string)
  25075. if !ok {
  25076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25077. }
  25078. m.SetAvatar(v)
  25079. return nil
  25080. case wxcard.FieldLogo:
  25081. v, ok := value.(string)
  25082. if !ok {
  25083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25084. }
  25085. m.SetLogo(v)
  25086. return nil
  25087. case wxcard.FieldName:
  25088. v, ok := value.(string)
  25089. if !ok {
  25090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25091. }
  25092. m.SetName(v)
  25093. return nil
  25094. case wxcard.FieldCompany:
  25095. v, ok := value.(string)
  25096. if !ok {
  25097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25098. }
  25099. m.SetCompany(v)
  25100. return nil
  25101. case wxcard.FieldAddress:
  25102. v, ok := value.(string)
  25103. if !ok {
  25104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25105. }
  25106. m.SetAddress(v)
  25107. return nil
  25108. case wxcard.FieldPhone:
  25109. v, ok := value.(string)
  25110. if !ok {
  25111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25112. }
  25113. m.SetPhone(v)
  25114. return nil
  25115. case wxcard.FieldOfficialAccount:
  25116. v, ok := value.(string)
  25117. if !ok {
  25118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25119. }
  25120. m.SetOfficialAccount(v)
  25121. return nil
  25122. case wxcard.FieldWechatAccount:
  25123. v, ok := value.(string)
  25124. if !ok {
  25125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25126. }
  25127. m.SetWechatAccount(v)
  25128. return nil
  25129. case wxcard.FieldEmail:
  25130. v, ok := value.(string)
  25131. if !ok {
  25132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25133. }
  25134. m.SetEmail(v)
  25135. return nil
  25136. case wxcard.FieldAPIBase:
  25137. v, ok := value.(string)
  25138. if !ok {
  25139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25140. }
  25141. m.SetAPIBase(v)
  25142. return nil
  25143. case wxcard.FieldAPIKey:
  25144. v, ok := value.(string)
  25145. if !ok {
  25146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25147. }
  25148. m.SetAPIKey(v)
  25149. return nil
  25150. case wxcard.FieldAiInfo:
  25151. v, ok := value.(string)
  25152. if !ok {
  25153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25154. }
  25155. m.SetAiInfo(v)
  25156. return nil
  25157. case wxcard.FieldIntro:
  25158. v, ok := value.(string)
  25159. if !ok {
  25160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25161. }
  25162. m.SetIntro(v)
  25163. return nil
  25164. }
  25165. return fmt.Errorf("unknown WxCard field %s", name)
  25166. }
  25167. // AddedFields returns all numeric fields that were incremented/decremented during
  25168. // this mutation.
  25169. func (m *WxCardMutation) AddedFields() []string {
  25170. var fields []string
  25171. if m.adduser_id != nil {
  25172. fields = append(fields, wxcard.FieldUserID)
  25173. }
  25174. if m.addwx_user_id != nil {
  25175. fields = append(fields, wxcard.FieldWxUserID)
  25176. }
  25177. return fields
  25178. }
  25179. // AddedField returns the numeric value that was incremented/decremented on a field
  25180. // with the given name. The second boolean return value indicates that this field
  25181. // was not set, or was not defined in the schema.
  25182. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  25183. switch name {
  25184. case wxcard.FieldUserID:
  25185. return m.AddedUserID()
  25186. case wxcard.FieldWxUserID:
  25187. return m.AddedWxUserID()
  25188. }
  25189. return nil, false
  25190. }
  25191. // AddField adds the value to the field with the given name. It returns an error if
  25192. // the field is not defined in the schema, or if the type mismatched the field
  25193. // type.
  25194. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  25195. switch name {
  25196. case wxcard.FieldUserID:
  25197. v, ok := value.(int64)
  25198. if !ok {
  25199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25200. }
  25201. m.AddUserID(v)
  25202. return nil
  25203. case wxcard.FieldWxUserID:
  25204. v, ok := value.(int64)
  25205. if !ok {
  25206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25207. }
  25208. m.AddWxUserID(v)
  25209. return nil
  25210. }
  25211. return fmt.Errorf("unknown WxCard numeric field %s", name)
  25212. }
  25213. // ClearedFields returns all nullable fields that were cleared during this
  25214. // mutation.
  25215. func (m *WxCardMutation) ClearedFields() []string {
  25216. var fields []string
  25217. if m.FieldCleared(wxcard.FieldDeletedAt) {
  25218. fields = append(fields, wxcard.FieldDeletedAt)
  25219. }
  25220. if m.FieldCleared(wxcard.FieldUserID) {
  25221. fields = append(fields, wxcard.FieldUserID)
  25222. }
  25223. if m.FieldCleared(wxcard.FieldWxUserID) {
  25224. fields = append(fields, wxcard.FieldWxUserID)
  25225. }
  25226. if m.FieldCleared(wxcard.FieldEmail) {
  25227. fields = append(fields, wxcard.FieldEmail)
  25228. }
  25229. if m.FieldCleared(wxcard.FieldAPIBase) {
  25230. fields = append(fields, wxcard.FieldAPIBase)
  25231. }
  25232. if m.FieldCleared(wxcard.FieldAPIKey) {
  25233. fields = append(fields, wxcard.FieldAPIKey)
  25234. }
  25235. if m.FieldCleared(wxcard.FieldAiInfo) {
  25236. fields = append(fields, wxcard.FieldAiInfo)
  25237. }
  25238. if m.FieldCleared(wxcard.FieldIntro) {
  25239. fields = append(fields, wxcard.FieldIntro)
  25240. }
  25241. return fields
  25242. }
  25243. // FieldCleared returns a boolean indicating if a field with the given name was
  25244. // cleared in this mutation.
  25245. func (m *WxCardMutation) FieldCleared(name string) bool {
  25246. _, ok := m.clearedFields[name]
  25247. return ok
  25248. }
  25249. // ClearField clears the value of the field with the given name. It returns an
  25250. // error if the field is not defined in the schema.
  25251. func (m *WxCardMutation) ClearField(name string) error {
  25252. switch name {
  25253. case wxcard.FieldDeletedAt:
  25254. m.ClearDeletedAt()
  25255. return nil
  25256. case wxcard.FieldUserID:
  25257. m.ClearUserID()
  25258. return nil
  25259. case wxcard.FieldWxUserID:
  25260. m.ClearWxUserID()
  25261. return nil
  25262. case wxcard.FieldEmail:
  25263. m.ClearEmail()
  25264. return nil
  25265. case wxcard.FieldAPIBase:
  25266. m.ClearAPIBase()
  25267. return nil
  25268. case wxcard.FieldAPIKey:
  25269. m.ClearAPIKey()
  25270. return nil
  25271. case wxcard.FieldAiInfo:
  25272. m.ClearAiInfo()
  25273. return nil
  25274. case wxcard.FieldIntro:
  25275. m.ClearIntro()
  25276. return nil
  25277. }
  25278. return fmt.Errorf("unknown WxCard nullable field %s", name)
  25279. }
  25280. // ResetField resets all changes in the mutation for the field with the given name.
  25281. // It returns an error if the field is not defined in the schema.
  25282. func (m *WxCardMutation) ResetField(name string) error {
  25283. switch name {
  25284. case wxcard.FieldCreatedAt:
  25285. m.ResetCreatedAt()
  25286. return nil
  25287. case wxcard.FieldUpdatedAt:
  25288. m.ResetUpdatedAt()
  25289. return nil
  25290. case wxcard.FieldDeletedAt:
  25291. m.ResetDeletedAt()
  25292. return nil
  25293. case wxcard.FieldUserID:
  25294. m.ResetUserID()
  25295. return nil
  25296. case wxcard.FieldWxUserID:
  25297. m.ResetWxUserID()
  25298. return nil
  25299. case wxcard.FieldAvatar:
  25300. m.ResetAvatar()
  25301. return nil
  25302. case wxcard.FieldLogo:
  25303. m.ResetLogo()
  25304. return nil
  25305. case wxcard.FieldName:
  25306. m.ResetName()
  25307. return nil
  25308. case wxcard.FieldCompany:
  25309. m.ResetCompany()
  25310. return nil
  25311. case wxcard.FieldAddress:
  25312. m.ResetAddress()
  25313. return nil
  25314. case wxcard.FieldPhone:
  25315. m.ResetPhone()
  25316. return nil
  25317. case wxcard.FieldOfficialAccount:
  25318. m.ResetOfficialAccount()
  25319. return nil
  25320. case wxcard.FieldWechatAccount:
  25321. m.ResetWechatAccount()
  25322. return nil
  25323. case wxcard.FieldEmail:
  25324. m.ResetEmail()
  25325. return nil
  25326. case wxcard.FieldAPIBase:
  25327. m.ResetAPIBase()
  25328. return nil
  25329. case wxcard.FieldAPIKey:
  25330. m.ResetAPIKey()
  25331. return nil
  25332. case wxcard.FieldAiInfo:
  25333. m.ResetAiInfo()
  25334. return nil
  25335. case wxcard.FieldIntro:
  25336. m.ResetIntro()
  25337. return nil
  25338. }
  25339. return fmt.Errorf("unknown WxCard field %s", name)
  25340. }
  25341. // AddedEdges returns all edge names that were set/added in this mutation.
  25342. func (m *WxCardMutation) AddedEdges() []string {
  25343. edges := make([]string, 0, 0)
  25344. return edges
  25345. }
  25346. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25347. // name in this mutation.
  25348. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  25349. return nil
  25350. }
  25351. // RemovedEdges returns all edge names that were removed in this mutation.
  25352. func (m *WxCardMutation) RemovedEdges() []string {
  25353. edges := make([]string, 0, 0)
  25354. return edges
  25355. }
  25356. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25357. // the given name in this mutation.
  25358. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  25359. return nil
  25360. }
  25361. // ClearedEdges returns all edge names that were cleared in this mutation.
  25362. func (m *WxCardMutation) ClearedEdges() []string {
  25363. edges := make([]string, 0, 0)
  25364. return edges
  25365. }
  25366. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25367. // was cleared in this mutation.
  25368. func (m *WxCardMutation) EdgeCleared(name string) bool {
  25369. return false
  25370. }
  25371. // ClearEdge clears the value of the edge with the given name. It returns an error
  25372. // if that edge is not defined in the schema.
  25373. func (m *WxCardMutation) ClearEdge(name string) error {
  25374. return fmt.Errorf("unknown WxCard unique edge %s", name)
  25375. }
  25376. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25377. // It returns an error if the edge is not defined in the schema.
  25378. func (m *WxCardMutation) ResetEdge(name string) error {
  25379. return fmt.Errorf("unknown WxCard edge %s", name)
  25380. }
  25381. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  25382. type WxCardUserMutation struct {
  25383. config
  25384. op Op
  25385. typ string
  25386. id *uint64
  25387. created_at *time.Time
  25388. updated_at *time.Time
  25389. deleted_at *time.Time
  25390. wxid *string
  25391. account *string
  25392. avatar *string
  25393. nickname *string
  25394. remark *string
  25395. phone *string
  25396. open_id *string
  25397. union_id *string
  25398. session_key *string
  25399. is_vip *int
  25400. addis_vip *int
  25401. clearedFields map[string]struct{}
  25402. done bool
  25403. oldValue func(context.Context) (*WxCardUser, error)
  25404. predicates []predicate.WxCardUser
  25405. }
  25406. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  25407. // wxcarduserOption allows management of the mutation configuration using functional options.
  25408. type wxcarduserOption func(*WxCardUserMutation)
  25409. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  25410. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  25411. m := &WxCardUserMutation{
  25412. config: c,
  25413. op: op,
  25414. typ: TypeWxCardUser,
  25415. clearedFields: make(map[string]struct{}),
  25416. }
  25417. for _, opt := range opts {
  25418. opt(m)
  25419. }
  25420. return m
  25421. }
  25422. // withWxCardUserID sets the ID field of the mutation.
  25423. func withWxCardUserID(id uint64) wxcarduserOption {
  25424. return func(m *WxCardUserMutation) {
  25425. var (
  25426. err error
  25427. once sync.Once
  25428. value *WxCardUser
  25429. )
  25430. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  25431. once.Do(func() {
  25432. if m.done {
  25433. err = errors.New("querying old values post mutation is not allowed")
  25434. } else {
  25435. value, err = m.Client().WxCardUser.Get(ctx, id)
  25436. }
  25437. })
  25438. return value, err
  25439. }
  25440. m.id = &id
  25441. }
  25442. }
  25443. // withWxCardUser sets the old WxCardUser of the mutation.
  25444. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  25445. return func(m *WxCardUserMutation) {
  25446. m.oldValue = func(context.Context) (*WxCardUser, error) {
  25447. return node, nil
  25448. }
  25449. m.id = &node.ID
  25450. }
  25451. }
  25452. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25453. // executed in a transaction (ent.Tx), a transactional client is returned.
  25454. func (m WxCardUserMutation) Client() *Client {
  25455. client := &Client{config: m.config}
  25456. client.init()
  25457. return client
  25458. }
  25459. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25460. // it returns an error otherwise.
  25461. func (m WxCardUserMutation) Tx() (*Tx, error) {
  25462. if _, ok := m.driver.(*txDriver); !ok {
  25463. return nil, errors.New("ent: mutation is not running in a transaction")
  25464. }
  25465. tx := &Tx{config: m.config}
  25466. tx.init()
  25467. return tx, nil
  25468. }
  25469. // SetID sets the value of the id field. Note that this
  25470. // operation is only accepted on creation of WxCardUser entities.
  25471. func (m *WxCardUserMutation) SetID(id uint64) {
  25472. m.id = &id
  25473. }
  25474. // ID returns the ID value in the mutation. Note that the ID is only available
  25475. // if it was provided to the builder or after it was returned from the database.
  25476. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  25477. if m.id == nil {
  25478. return
  25479. }
  25480. return *m.id, true
  25481. }
  25482. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25483. // That means, if the mutation is applied within a transaction with an isolation level such
  25484. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25485. // or updated by the mutation.
  25486. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  25487. switch {
  25488. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25489. id, exists := m.ID()
  25490. if exists {
  25491. return []uint64{id}, nil
  25492. }
  25493. fallthrough
  25494. case m.op.Is(OpUpdate | OpDelete):
  25495. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  25496. default:
  25497. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25498. }
  25499. }
  25500. // SetCreatedAt sets the "created_at" field.
  25501. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  25502. m.created_at = &t
  25503. }
  25504. // CreatedAt returns the value of the "created_at" field in the mutation.
  25505. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  25506. v := m.created_at
  25507. if v == nil {
  25508. return
  25509. }
  25510. return *v, true
  25511. }
  25512. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  25513. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25515. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25516. if !m.op.Is(OpUpdateOne) {
  25517. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25518. }
  25519. if m.id == nil || m.oldValue == nil {
  25520. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25521. }
  25522. oldValue, err := m.oldValue(ctx)
  25523. if err != nil {
  25524. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25525. }
  25526. return oldValue.CreatedAt, nil
  25527. }
  25528. // ResetCreatedAt resets all changes to the "created_at" field.
  25529. func (m *WxCardUserMutation) ResetCreatedAt() {
  25530. m.created_at = nil
  25531. }
  25532. // SetUpdatedAt sets the "updated_at" field.
  25533. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  25534. m.updated_at = &t
  25535. }
  25536. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25537. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  25538. v := m.updated_at
  25539. if v == nil {
  25540. return
  25541. }
  25542. return *v, true
  25543. }
  25544. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  25545. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25547. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25548. if !m.op.Is(OpUpdateOne) {
  25549. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25550. }
  25551. if m.id == nil || m.oldValue == nil {
  25552. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25553. }
  25554. oldValue, err := m.oldValue(ctx)
  25555. if err != nil {
  25556. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25557. }
  25558. return oldValue.UpdatedAt, nil
  25559. }
  25560. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25561. func (m *WxCardUserMutation) ResetUpdatedAt() {
  25562. m.updated_at = nil
  25563. }
  25564. // SetDeletedAt sets the "deleted_at" field.
  25565. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  25566. m.deleted_at = &t
  25567. }
  25568. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25569. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  25570. v := m.deleted_at
  25571. if v == nil {
  25572. return
  25573. }
  25574. return *v, true
  25575. }
  25576. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  25577. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25579. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25580. if !m.op.Is(OpUpdateOne) {
  25581. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25582. }
  25583. if m.id == nil || m.oldValue == nil {
  25584. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25585. }
  25586. oldValue, err := m.oldValue(ctx)
  25587. if err != nil {
  25588. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25589. }
  25590. return oldValue.DeletedAt, nil
  25591. }
  25592. // ClearDeletedAt clears the value of the "deleted_at" field.
  25593. func (m *WxCardUserMutation) ClearDeletedAt() {
  25594. m.deleted_at = nil
  25595. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  25596. }
  25597. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25598. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  25599. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  25600. return ok
  25601. }
  25602. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25603. func (m *WxCardUserMutation) ResetDeletedAt() {
  25604. m.deleted_at = nil
  25605. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  25606. }
  25607. // SetWxid sets the "wxid" field.
  25608. func (m *WxCardUserMutation) SetWxid(s string) {
  25609. m.wxid = &s
  25610. }
  25611. // Wxid returns the value of the "wxid" field in the mutation.
  25612. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  25613. v := m.wxid
  25614. if v == nil {
  25615. return
  25616. }
  25617. return *v, true
  25618. }
  25619. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  25620. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25622. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  25623. if !m.op.Is(OpUpdateOne) {
  25624. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  25625. }
  25626. if m.id == nil || m.oldValue == nil {
  25627. return v, errors.New("OldWxid requires an ID field in the mutation")
  25628. }
  25629. oldValue, err := m.oldValue(ctx)
  25630. if err != nil {
  25631. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  25632. }
  25633. return oldValue.Wxid, nil
  25634. }
  25635. // ResetWxid resets all changes to the "wxid" field.
  25636. func (m *WxCardUserMutation) ResetWxid() {
  25637. m.wxid = nil
  25638. }
  25639. // SetAccount sets the "account" field.
  25640. func (m *WxCardUserMutation) SetAccount(s string) {
  25641. m.account = &s
  25642. }
  25643. // Account returns the value of the "account" field in the mutation.
  25644. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  25645. v := m.account
  25646. if v == nil {
  25647. return
  25648. }
  25649. return *v, true
  25650. }
  25651. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  25652. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25654. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  25655. if !m.op.Is(OpUpdateOne) {
  25656. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  25657. }
  25658. if m.id == nil || m.oldValue == nil {
  25659. return v, errors.New("OldAccount requires an ID field in the mutation")
  25660. }
  25661. oldValue, err := m.oldValue(ctx)
  25662. if err != nil {
  25663. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  25664. }
  25665. return oldValue.Account, nil
  25666. }
  25667. // ResetAccount resets all changes to the "account" field.
  25668. func (m *WxCardUserMutation) ResetAccount() {
  25669. m.account = nil
  25670. }
  25671. // SetAvatar sets the "avatar" field.
  25672. func (m *WxCardUserMutation) SetAvatar(s string) {
  25673. m.avatar = &s
  25674. }
  25675. // Avatar returns the value of the "avatar" field in the mutation.
  25676. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  25677. v := m.avatar
  25678. if v == nil {
  25679. return
  25680. }
  25681. return *v, true
  25682. }
  25683. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  25684. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25686. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  25687. if !m.op.Is(OpUpdateOne) {
  25688. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  25689. }
  25690. if m.id == nil || m.oldValue == nil {
  25691. return v, errors.New("OldAvatar requires an ID field in the mutation")
  25692. }
  25693. oldValue, err := m.oldValue(ctx)
  25694. if err != nil {
  25695. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  25696. }
  25697. return oldValue.Avatar, nil
  25698. }
  25699. // ResetAvatar resets all changes to the "avatar" field.
  25700. func (m *WxCardUserMutation) ResetAvatar() {
  25701. m.avatar = nil
  25702. }
  25703. // SetNickname sets the "nickname" field.
  25704. func (m *WxCardUserMutation) SetNickname(s string) {
  25705. m.nickname = &s
  25706. }
  25707. // Nickname returns the value of the "nickname" field in the mutation.
  25708. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  25709. v := m.nickname
  25710. if v == nil {
  25711. return
  25712. }
  25713. return *v, true
  25714. }
  25715. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  25716. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25718. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  25719. if !m.op.Is(OpUpdateOne) {
  25720. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  25721. }
  25722. if m.id == nil || m.oldValue == nil {
  25723. return v, errors.New("OldNickname requires an ID field in the mutation")
  25724. }
  25725. oldValue, err := m.oldValue(ctx)
  25726. if err != nil {
  25727. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  25728. }
  25729. return oldValue.Nickname, nil
  25730. }
  25731. // ResetNickname resets all changes to the "nickname" field.
  25732. func (m *WxCardUserMutation) ResetNickname() {
  25733. m.nickname = nil
  25734. }
  25735. // SetRemark sets the "remark" field.
  25736. func (m *WxCardUserMutation) SetRemark(s string) {
  25737. m.remark = &s
  25738. }
  25739. // Remark returns the value of the "remark" field in the mutation.
  25740. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  25741. v := m.remark
  25742. if v == nil {
  25743. return
  25744. }
  25745. return *v, true
  25746. }
  25747. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  25748. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25750. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  25751. if !m.op.Is(OpUpdateOne) {
  25752. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  25753. }
  25754. if m.id == nil || m.oldValue == nil {
  25755. return v, errors.New("OldRemark requires an ID field in the mutation")
  25756. }
  25757. oldValue, err := m.oldValue(ctx)
  25758. if err != nil {
  25759. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  25760. }
  25761. return oldValue.Remark, nil
  25762. }
  25763. // ResetRemark resets all changes to the "remark" field.
  25764. func (m *WxCardUserMutation) ResetRemark() {
  25765. m.remark = nil
  25766. }
  25767. // SetPhone sets the "phone" field.
  25768. func (m *WxCardUserMutation) SetPhone(s string) {
  25769. m.phone = &s
  25770. }
  25771. // Phone returns the value of the "phone" field in the mutation.
  25772. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  25773. v := m.phone
  25774. if v == nil {
  25775. return
  25776. }
  25777. return *v, true
  25778. }
  25779. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  25780. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25782. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  25783. if !m.op.Is(OpUpdateOne) {
  25784. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  25785. }
  25786. if m.id == nil || m.oldValue == nil {
  25787. return v, errors.New("OldPhone requires an ID field in the mutation")
  25788. }
  25789. oldValue, err := m.oldValue(ctx)
  25790. if err != nil {
  25791. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  25792. }
  25793. return oldValue.Phone, nil
  25794. }
  25795. // ResetPhone resets all changes to the "phone" field.
  25796. func (m *WxCardUserMutation) ResetPhone() {
  25797. m.phone = nil
  25798. }
  25799. // SetOpenID sets the "open_id" field.
  25800. func (m *WxCardUserMutation) SetOpenID(s string) {
  25801. m.open_id = &s
  25802. }
  25803. // OpenID returns the value of the "open_id" field in the mutation.
  25804. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  25805. v := m.open_id
  25806. if v == nil {
  25807. return
  25808. }
  25809. return *v, true
  25810. }
  25811. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  25812. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25814. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  25815. if !m.op.Is(OpUpdateOne) {
  25816. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  25817. }
  25818. if m.id == nil || m.oldValue == nil {
  25819. return v, errors.New("OldOpenID requires an ID field in the mutation")
  25820. }
  25821. oldValue, err := m.oldValue(ctx)
  25822. if err != nil {
  25823. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  25824. }
  25825. return oldValue.OpenID, nil
  25826. }
  25827. // ResetOpenID resets all changes to the "open_id" field.
  25828. func (m *WxCardUserMutation) ResetOpenID() {
  25829. m.open_id = nil
  25830. }
  25831. // SetUnionID sets the "union_id" field.
  25832. func (m *WxCardUserMutation) SetUnionID(s string) {
  25833. m.union_id = &s
  25834. }
  25835. // UnionID returns the value of the "union_id" field in the mutation.
  25836. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  25837. v := m.union_id
  25838. if v == nil {
  25839. return
  25840. }
  25841. return *v, true
  25842. }
  25843. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  25844. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25846. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  25847. if !m.op.Is(OpUpdateOne) {
  25848. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  25849. }
  25850. if m.id == nil || m.oldValue == nil {
  25851. return v, errors.New("OldUnionID requires an ID field in the mutation")
  25852. }
  25853. oldValue, err := m.oldValue(ctx)
  25854. if err != nil {
  25855. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  25856. }
  25857. return oldValue.UnionID, nil
  25858. }
  25859. // ResetUnionID resets all changes to the "union_id" field.
  25860. func (m *WxCardUserMutation) ResetUnionID() {
  25861. m.union_id = nil
  25862. }
  25863. // SetSessionKey sets the "session_key" field.
  25864. func (m *WxCardUserMutation) SetSessionKey(s string) {
  25865. m.session_key = &s
  25866. }
  25867. // SessionKey returns the value of the "session_key" field in the mutation.
  25868. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  25869. v := m.session_key
  25870. if v == nil {
  25871. return
  25872. }
  25873. return *v, true
  25874. }
  25875. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  25876. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25878. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  25879. if !m.op.Is(OpUpdateOne) {
  25880. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  25881. }
  25882. if m.id == nil || m.oldValue == nil {
  25883. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  25884. }
  25885. oldValue, err := m.oldValue(ctx)
  25886. if err != nil {
  25887. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  25888. }
  25889. return oldValue.SessionKey, nil
  25890. }
  25891. // ResetSessionKey resets all changes to the "session_key" field.
  25892. func (m *WxCardUserMutation) ResetSessionKey() {
  25893. m.session_key = nil
  25894. }
  25895. // SetIsVip sets the "is_vip" field.
  25896. func (m *WxCardUserMutation) SetIsVip(i int) {
  25897. m.is_vip = &i
  25898. m.addis_vip = nil
  25899. }
  25900. // IsVip returns the value of the "is_vip" field in the mutation.
  25901. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  25902. v := m.is_vip
  25903. if v == nil {
  25904. return
  25905. }
  25906. return *v, true
  25907. }
  25908. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  25909. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  25910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25911. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  25912. if !m.op.Is(OpUpdateOne) {
  25913. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  25914. }
  25915. if m.id == nil || m.oldValue == nil {
  25916. return v, errors.New("OldIsVip requires an ID field in the mutation")
  25917. }
  25918. oldValue, err := m.oldValue(ctx)
  25919. if err != nil {
  25920. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  25921. }
  25922. return oldValue.IsVip, nil
  25923. }
  25924. // AddIsVip adds i to the "is_vip" field.
  25925. func (m *WxCardUserMutation) AddIsVip(i int) {
  25926. if m.addis_vip != nil {
  25927. *m.addis_vip += i
  25928. } else {
  25929. m.addis_vip = &i
  25930. }
  25931. }
  25932. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  25933. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  25934. v := m.addis_vip
  25935. if v == nil {
  25936. return
  25937. }
  25938. return *v, true
  25939. }
  25940. // ResetIsVip resets all changes to the "is_vip" field.
  25941. func (m *WxCardUserMutation) ResetIsVip() {
  25942. m.is_vip = nil
  25943. m.addis_vip = nil
  25944. }
  25945. // Where appends a list predicates to the WxCardUserMutation builder.
  25946. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  25947. m.predicates = append(m.predicates, ps...)
  25948. }
  25949. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  25950. // users can use type-assertion to append predicates that do not depend on any generated package.
  25951. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  25952. p := make([]predicate.WxCardUser, len(ps))
  25953. for i := range ps {
  25954. p[i] = ps[i]
  25955. }
  25956. m.Where(p...)
  25957. }
  25958. // Op returns the operation name.
  25959. func (m *WxCardUserMutation) Op() Op {
  25960. return m.op
  25961. }
  25962. // SetOp allows setting the mutation operation.
  25963. func (m *WxCardUserMutation) SetOp(op Op) {
  25964. m.op = op
  25965. }
  25966. // Type returns the node type of this mutation (WxCardUser).
  25967. func (m *WxCardUserMutation) Type() string {
  25968. return m.typ
  25969. }
  25970. // Fields returns all fields that were changed during this mutation. Note that in
  25971. // order to get all numeric fields that were incremented/decremented, call
  25972. // AddedFields().
  25973. func (m *WxCardUserMutation) Fields() []string {
  25974. fields := make([]string, 0, 13)
  25975. if m.created_at != nil {
  25976. fields = append(fields, wxcarduser.FieldCreatedAt)
  25977. }
  25978. if m.updated_at != nil {
  25979. fields = append(fields, wxcarduser.FieldUpdatedAt)
  25980. }
  25981. if m.deleted_at != nil {
  25982. fields = append(fields, wxcarduser.FieldDeletedAt)
  25983. }
  25984. if m.wxid != nil {
  25985. fields = append(fields, wxcarduser.FieldWxid)
  25986. }
  25987. if m.account != nil {
  25988. fields = append(fields, wxcarduser.FieldAccount)
  25989. }
  25990. if m.avatar != nil {
  25991. fields = append(fields, wxcarduser.FieldAvatar)
  25992. }
  25993. if m.nickname != nil {
  25994. fields = append(fields, wxcarduser.FieldNickname)
  25995. }
  25996. if m.remark != nil {
  25997. fields = append(fields, wxcarduser.FieldRemark)
  25998. }
  25999. if m.phone != nil {
  26000. fields = append(fields, wxcarduser.FieldPhone)
  26001. }
  26002. if m.open_id != nil {
  26003. fields = append(fields, wxcarduser.FieldOpenID)
  26004. }
  26005. if m.union_id != nil {
  26006. fields = append(fields, wxcarduser.FieldUnionID)
  26007. }
  26008. if m.session_key != nil {
  26009. fields = append(fields, wxcarduser.FieldSessionKey)
  26010. }
  26011. if m.is_vip != nil {
  26012. fields = append(fields, wxcarduser.FieldIsVip)
  26013. }
  26014. return fields
  26015. }
  26016. // Field returns the value of a field with the given name. The second boolean
  26017. // return value indicates that this field was not set, or was not defined in the
  26018. // schema.
  26019. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  26020. switch name {
  26021. case wxcarduser.FieldCreatedAt:
  26022. return m.CreatedAt()
  26023. case wxcarduser.FieldUpdatedAt:
  26024. return m.UpdatedAt()
  26025. case wxcarduser.FieldDeletedAt:
  26026. return m.DeletedAt()
  26027. case wxcarduser.FieldWxid:
  26028. return m.Wxid()
  26029. case wxcarduser.FieldAccount:
  26030. return m.Account()
  26031. case wxcarduser.FieldAvatar:
  26032. return m.Avatar()
  26033. case wxcarduser.FieldNickname:
  26034. return m.Nickname()
  26035. case wxcarduser.FieldRemark:
  26036. return m.Remark()
  26037. case wxcarduser.FieldPhone:
  26038. return m.Phone()
  26039. case wxcarduser.FieldOpenID:
  26040. return m.OpenID()
  26041. case wxcarduser.FieldUnionID:
  26042. return m.UnionID()
  26043. case wxcarduser.FieldSessionKey:
  26044. return m.SessionKey()
  26045. case wxcarduser.FieldIsVip:
  26046. return m.IsVip()
  26047. }
  26048. return nil, false
  26049. }
  26050. // OldField returns the old value of the field from the database. An error is
  26051. // returned if the mutation operation is not UpdateOne, or the query to the
  26052. // database failed.
  26053. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26054. switch name {
  26055. case wxcarduser.FieldCreatedAt:
  26056. return m.OldCreatedAt(ctx)
  26057. case wxcarduser.FieldUpdatedAt:
  26058. return m.OldUpdatedAt(ctx)
  26059. case wxcarduser.FieldDeletedAt:
  26060. return m.OldDeletedAt(ctx)
  26061. case wxcarduser.FieldWxid:
  26062. return m.OldWxid(ctx)
  26063. case wxcarduser.FieldAccount:
  26064. return m.OldAccount(ctx)
  26065. case wxcarduser.FieldAvatar:
  26066. return m.OldAvatar(ctx)
  26067. case wxcarduser.FieldNickname:
  26068. return m.OldNickname(ctx)
  26069. case wxcarduser.FieldRemark:
  26070. return m.OldRemark(ctx)
  26071. case wxcarduser.FieldPhone:
  26072. return m.OldPhone(ctx)
  26073. case wxcarduser.FieldOpenID:
  26074. return m.OldOpenID(ctx)
  26075. case wxcarduser.FieldUnionID:
  26076. return m.OldUnionID(ctx)
  26077. case wxcarduser.FieldSessionKey:
  26078. return m.OldSessionKey(ctx)
  26079. case wxcarduser.FieldIsVip:
  26080. return m.OldIsVip(ctx)
  26081. }
  26082. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  26083. }
  26084. // SetField sets the value of a field with the given name. It returns an error if
  26085. // the field is not defined in the schema, or if the type mismatched the field
  26086. // type.
  26087. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  26088. switch name {
  26089. case wxcarduser.FieldCreatedAt:
  26090. v, ok := value.(time.Time)
  26091. if !ok {
  26092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26093. }
  26094. m.SetCreatedAt(v)
  26095. return nil
  26096. case wxcarduser.FieldUpdatedAt:
  26097. v, ok := value.(time.Time)
  26098. if !ok {
  26099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26100. }
  26101. m.SetUpdatedAt(v)
  26102. return nil
  26103. case wxcarduser.FieldDeletedAt:
  26104. v, ok := value.(time.Time)
  26105. if !ok {
  26106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26107. }
  26108. m.SetDeletedAt(v)
  26109. return nil
  26110. case wxcarduser.FieldWxid:
  26111. v, ok := value.(string)
  26112. if !ok {
  26113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26114. }
  26115. m.SetWxid(v)
  26116. return nil
  26117. case wxcarduser.FieldAccount:
  26118. v, ok := value.(string)
  26119. if !ok {
  26120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26121. }
  26122. m.SetAccount(v)
  26123. return nil
  26124. case wxcarduser.FieldAvatar:
  26125. v, ok := value.(string)
  26126. if !ok {
  26127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26128. }
  26129. m.SetAvatar(v)
  26130. return nil
  26131. case wxcarduser.FieldNickname:
  26132. v, ok := value.(string)
  26133. if !ok {
  26134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26135. }
  26136. m.SetNickname(v)
  26137. return nil
  26138. case wxcarduser.FieldRemark:
  26139. v, ok := value.(string)
  26140. if !ok {
  26141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26142. }
  26143. m.SetRemark(v)
  26144. return nil
  26145. case wxcarduser.FieldPhone:
  26146. v, ok := value.(string)
  26147. if !ok {
  26148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26149. }
  26150. m.SetPhone(v)
  26151. return nil
  26152. case wxcarduser.FieldOpenID:
  26153. v, ok := value.(string)
  26154. if !ok {
  26155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26156. }
  26157. m.SetOpenID(v)
  26158. return nil
  26159. case wxcarduser.FieldUnionID:
  26160. v, ok := value.(string)
  26161. if !ok {
  26162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26163. }
  26164. m.SetUnionID(v)
  26165. return nil
  26166. case wxcarduser.FieldSessionKey:
  26167. v, ok := value.(string)
  26168. if !ok {
  26169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26170. }
  26171. m.SetSessionKey(v)
  26172. return nil
  26173. case wxcarduser.FieldIsVip:
  26174. v, ok := value.(int)
  26175. if !ok {
  26176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26177. }
  26178. m.SetIsVip(v)
  26179. return nil
  26180. }
  26181. return fmt.Errorf("unknown WxCardUser field %s", name)
  26182. }
  26183. // AddedFields returns all numeric fields that were incremented/decremented during
  26184. // this mutation.
  26185. func (m *WxCardUserMutation) AddedFields() []string {
  26186. var fields []string
  26187. if m.addis_vip != nil {
  26188. fields = append(fields, wxcarduser.FieldIsVip)
  26189. }
  26190. return fields
  26191. }
  26192. // AddedField returns the numeric value that was incremented/decremented on a field
  26193. // with the given name. The second boolean return value indicates that this field
  26194. // was not set, or was not defined in the schema.
  26195. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  26196. switch name {
  26197. case wxcarduser.FieldIsVip:
  26198. return m.AddedIsVip()
  26199. }
  26200. return nil, false
  26201. }
  26202. // AddField adds the value to the field with the given name. It returns an error if
  26203. // the field is not defined in the schema, or if the type mismatched the field
  26204. // type.
  26205. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  26206. switch name {
  26207. case wxcarduser.FieldIsVip:
  26208. v, ok := value.(int)
  26209. if !ok {
  26210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26211. }
  26212. m.AddIsVip(v)
  26213. return nil
  26214. }
  26215. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  26216. }
  26217. // ClearedFields returns all nullable fields that were cleared during this
  26218. // mutation.
  26219. func (m *WxCardUserMutation) ClearedFields() []string {
  26220. var fields []string
  26221. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  26222. fields = append(fields, wxcarduser.FieldDeletedAt)
  26223. }
  26224. return fields
  26225. }
  26226. // FieldCleared returns a boolean indicating if a field with the given name was
  26227. // cleared in this mutation.
  26228. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  26229. _, ok := m.clearedFields[name]
  26230. return ok
  26231. }
  26232. // ClearField clears the value of the field with the given name. It returns an
  26233. // error if the field is not defined in the schema.
  26234. func (m *WxCardUserMutation) ClearField(name string) error {
  26235. switch name {
  26236. case wxcarduser.FieldDeletedAt:
  26237. m.ClearDeletedAt()
  26238. return nil
  26239. }
  26240. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  26241. }
  26242. // ResetField resets all changes in the mutation for the field with the given name.
  26243. // It returns an error if the field is not defined in the schema.
  26244. func (m *WxCardUserMutation) ResetField(name string) error {
  26245. switch name {
  26246. case wxcarduser.FieldCreatedAt:
  26247. m.ResetCreatedAt()
  26248. return nil
  26249. case wxcarduser.FieldUpdatedAt:
  26250. m.ResetUpdatedAt()
  26251. return nil
  26252. case wxcarduser.FieldDeletedAt:
  26253. m.ResetDeletedAt()
  26254. return nil
  26255. case wxcarduser.FieldWxid:
  26256. m.ResetWxid()
  26257. return nil
  26258. case wxcarduser.FieldAccount:
  26259. m.ResetAccount()
  26260. return nil
  26261. case wxcarduser.FieldAvatar:
  26262. m.ResetAvatar()
  26263. return nil
  26264. case wxcarduser.FieldNickname:
  26265. m.ResetNickname()
  26266. return nil
  26267. case wxcarduser.FieldRemark:
  26268. m.ResetRemark()
  26269. return nil
  26270. case wxcarduser.FieldPhone:
  26271. m.ResetPhone()
  26272. return nil
  26273. case wxcarduser.FieldOpenID:
  26274. m.ResetOpenID()
  26275. return nil
  26276. case wxcarduser.FieldUnionID:
  26277. m.ResetUnionID()
  26278. return nil
  26279. case wxcarduser.FieldSessionKey:
  26280. m.ResetSessionKey()
  26281. return nil
  26282. case wxcarduser.FieldIsVip:
  26283. m.ResetIsVip()
  26284. return nil
  26285. }
  26286. return fmt.Errorf("unknown WxCardUser field %s", name)
  26287. }
  26288. // AddedEdges returns all edge names that were set/added in this mutation.
  26289. func (m *WxCardUserMutation) AddedEdges() []string {
  26290. edges := make([]string, 0, 0)
  26291. return edges
  26292. }
  26293. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26294. // name in this mutation.
  26295. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  26296. return nil
  26297. }
  26298. // RemovedEdges returns all edge names that were removed in this mutation.
  26299. func (m *WxCardUserMutation) RemovedEdges() []string {
  26300. edges := make([]string, 0, 0)
  26301. return edges
  26302. }
  26303. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26304. // the given name in this mutation.
  26305. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  26306. return nil
  26307. }
  26308. // ClearedEdges returns all edge names that were cleared in this mutation.
  26309. func (m *WxCardUserMutation) ClearedEdges() []string {
  26310. edges := make([]string, 0, 0)
  26311. return edges
  26312. }
  26313. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26314. // was cleared in this mutation.
  26315. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  26316. return false
  26317. }
  26318. // ClearEdge clears the value of the edge with the given name. It returns an error
  26319. // if that edge is not defined in the schema.
  26320. func (m *WxCardUserMutation) ClearEdge(name string) error {
  26321. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  26322. }
  26323. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26324. // It returns an error if the edge is not defined in the schema.
  26325. func (m *WxCardUserMutation) ResetEdge(name string) error {
  26326. return fmt.Errorf("unknown WxCardUser edge %s", name)
  26327. }
  26328. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  26329. type WxCardVisitMutation struct {
  26330. config
  26331. op Op
  26332. typ string
  26333. id *uint64
  26334. created_at *time.Time
  26335. updated_at *time.Time
  26336. deleted_at *time.Time
  26337. user_id *uint64
  26338. adduser_id *int64
  26339. bot_id *uint64
  26340. addbot_id *int64
  26341. bot_type *uint8
  26342. addbot_type *int8
  26343. clearedFields map[string]struct{}
  26344. done bool
  26345. oldValue func(context.Context) (*WxCardVisit, error)
  26346. predicates []predicate.WxCardVisit
  26347. }
  26348. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  26349. // wxcardvisitOption allows management of the mutation configuration using functional options.
  26350. type wxcardvisitOption func(*WxCardVisitMutation)
  26351. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  26352. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  26353. m := &WxCardVisitMutation{
  26354. config: c,
  26355. op: op,
  26356. typ: TypeWxCardVisit,
  26357. clearedFields: make(map[string]struct{}),
  26358. }
  26359. for _, opt := range opts {
  26360. opt(m)
  26361. }
  26362. return m
  26363. }
  26364. // withWxCardVisitID sets the ID field of the mutation.
  26365. func withWxCardVisitID(id uint64) wxcardvisitOption {
  26366. return func(m *WxCardVisitMutation) {
  26367. var (
  26368. err error
  26369. once sync.Once
  26370. value *WxCardVisit
  26371. )
  26372. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  26373. once.Do(func() {
  26374. if m.done {
  26375. err = errors.New("querying old values post mutation is not allowed")
  26376. } else {
  26377. value, err = m.Client().WxCardVisit.Get(ctx, id)
  26378. }
  26379. })
  26380. return value, err
  26381. }
  26382. m.id = &id
  26383. }
  26384. }
  26385. // withWxCardVisit sets the old WxCardVisit of the mutation.
  26386. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  26387. return func(m *WxCardVisitMutation) {
  26388. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  26389. return node, nil
  26390. }
  26391. m.id = &node.ID
  26392. }
  26393. }
  26394. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26395. // executed in a transaction (ent.Tx), a transactional client is returned.
  26396. func (m WxCardVisitMutation) Client() *Client {
  26397. client := &Client{config: m.config}
  26398. client.init()
  26399. return client
  26400. }
  26401. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26402. // it returns an error otherwise.
  26403. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  26404. if _, ok := m.driver.(*txDriver); !ok {
  26405. return nil, errors.New("ent: mutation is not running in a transaction")
  26406. }
  26407. tx := &Tx{config: m.config}
  26408. tx.init()
  26409. return tx, nil
  26410. }
  26411. // SetID sets the value of the id field. Note that this
  26412. // operation is only accepted on creation of WxCardVisit entities.
  26413. func (m *WxCardVisitMutation) SetID(id uint64) {
  26414. m.id = &id
  26415. }
  26416. // ID returns the ID value in the mutation. Note that the ID is only available
  26417. // if it was provided to the builder or after it was returned from the database.
  26418. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  26419. if m.id == nil {
  26420. return
  26421. }
  26422. return *m.id, true
  26423. }
  26424. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26425. // That means, if the mutation is applied within a transaction with an isolation level such
  26426. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26427. // or updated by the mutation.
  26428. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  26429. switch {
  26430. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26431. id, exists := m.ID()
  26432. if exists {
  26433. return []uint64{id}, nil
  26434. }
  26435. fallthrough
  26436. case m.op.Is(OpUpdate | OpDelete):
  26437. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  26438. default:
  26439. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26440. }
  26441. }
  26442. // SetCreatedAt sets the "created_at" field.
  26443. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  26444. m.created_at = &t
  26445. }
  26446. // CreatedAt returns the value of the "created_at" field in the mutation.
  26447. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  26448. v := m.created_at
  26449. if v == nil {
  26450. return
  26451. }
  26452. return *v, true
  26453. }
  26454. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  26455. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26457. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26458. if !m.op.Is(OpUpdateOne) {
  26459. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26460. }
  26461. if m.id == nil || m.oldValue == nil {
  26462. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26463. }
  26464. oldValue, err := m.oldValue(ctx)
  26465. if err != nil {
  26466. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26467. }
  26468. return oldValue.CreatedAt, nil
  26469. }
  26470. // ResetCreatedAt resets all changes to the "created_at" field.
  26471. func (m *WxCardVisitMutation) ResetCreatedAt() {
  26472. m.created_at = nil
  26473. }
  26474. // SetUpdatedAt sets the "updated_at" field.
  26475. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  26476. m.updated_at = &t
  26477. }
  26478. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26479. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  26480. v := m.updated_at
  26481. if v == nil {
  26482. return
  26483. }
  26484. return *v, true
  26485. }
  26486. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  26487. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26489. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26490. if !m.op.Is(OpUpdateOne) {
  26491. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26492. }
  26493. if m.id == nil || m.oldValue == nil {
  26494. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26495. }
  26496. oldValue, err := m.oldValue(ctx)
  26497. if err != nil {
  26498. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26499. }
  26500. return oldValue.UpdatedAt, nil
  26501. }
  26502. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26503. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  26504. m.updated_at = nil
  26505. }
  26506. // SetDeletedAt sets the "deleted_at" field.
  26507. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  26508. m.deleted_at = &t
  26509. }
  26510. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26511. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  26512. v := m.deleted_at
  26513. if v == nil {
  26514. return
  26515. }
  26516. return *v, true
  26517. }
  26518. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  26519. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26521. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26522. if !m.op.Is(OpUpdateOne) {
  26523. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26524. }
  26525. if m.id == nil || m.oldValue == nil {
  26526. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26527. }
  26528. oldValue, err := m.oldValue(ctx)
  26529. if err != nil {
  26530. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26531. }
  26532. return oldValue.DeletedAt, nil
  26533. }
  26534. // ClearDeletedAt clears the value of the "deleted_at" field.
  26535. func (m *WxCardVisitMutation) ClearDeletedAt() {
  26536. m.deleted_at = nil
  26537. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  26538. }
  26539. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26540. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  26541. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  26542. return ok
  26543. }
  26544. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26545. func (m *WxCardVisitMutation) ResetDeletedAt() {
  26546. m.deleted_at = nil
  26547. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  26548. }
  26549. // SetUserID sets the "user_id" field.
  26550. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  26551. m.user_id = &u
  26552. m.adduser_id = nil
  26553. }
  26554. // UserID returns the value of the "user_id" field in the mutation.
  26555. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  26556. v := m.user_id
  26557. if v == nil {
  26558. return
  26559. }
  26560. return *v, true
  26561. }
  26562. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  26563. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26565. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  26566. if !m.op.Is(OpUpdateOne) {
  26567. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  26568. }
  26569. if m.id == nil || m.oldValue == nil {
  26570. return v, errors.New("OldUserID requires an ID field in the mutation")
  26571. }
  26572. oldValue, err := m.oldValue(ctx)
  26573. if err != nil {
  26574. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  26575. }
  26576. return oldValue.UserID, nil
  26577. }
  26578. // AddUserID adds u to the "user_id" field.
  26579. func (m *WxCardVisitMutation) AddUserID(u int64) {
  26580. if m.adduser_id != nil {
  26581. *m.adduser_id += u
  26582. } else {
  26583. m.adduser_id = &u
  26584. }
  26585. }
  26586. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  26587. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  26588. v := m.adduser_id
  26589. if v == nil {
  26590. return
  26591. }
  26592. return *v, true
  26593. }
  26594. // ClearUserID clears the value of the "user_id" field.
  26595. func (m *WxCardVisitMutation) ClearUserID() {
  26596. m.user_id = nil
  26597. m.adduser_id = nil
  26598. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  26599. }
  26600. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  26601. func (m *WxCardVisitMutation) UserIDCleared() bool {
  26602. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  26603. return ok
  26604. }
  26605. // ResetUserID resets all changes to the "user_id" field.
  26606. func (m *WxCardVisitMutation) ResetUserID() {
  26607. m.user_id = nil
  26608. m.adduser_id = nil
  26609. delete(m.clearedFields, wxcardvisit.FieldUserID)
  26610. }
  26611. // SetBotID sets the "bot_id" field.
  26612. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  26613. m.bot_id = &u
  26614. m.addbot_id = nil
  26615. }
  26616. // BotID returns the value of the "bot_id" field in the mutation.
  26617. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  26618. v := m.bot_id
  26619. if v == nil {
  26620. return
  26621. }
  26622. return *v, true
  26623. }
  26624. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  26625. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26627. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  26628. if !m.op.Is(OpUpdateOne) {
  26629. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26630. }
  26631. if m.id == nil || m.oldValue == nil {
  26632. return v, errors.New("OldBotID requires an ID field in the mutation")
  26633. }
  26634. oldValue, err := m.oldValue(ctx)
  26635. if err != nil {
  26636. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26637. }
  26638. return oldValue.BotID, nil
  26639. }
  26640. // AddBotID adds u to the "bot_id" field.
  26641. func (m *WxCardVisitMutation) AddBotID(u int64) {
  26642. if m.addbot_id != nil {
  26643. *m.addbot_id += u
  26644. } else {
  26645. m.addbot_id = &u
  26646. }
  26647. }
  26648. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  26649. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  26650. v := m.addbot_id
  26651. if v == nil {
  26652. return
  26653. }
  26654. return *v, true
  26655. }
  26656. // ResetBotID resets all changes to the "bot_id" field.
  26657. func (m *WxCardVisitMutation) ResetBotID() {
  26658. m.bot_id = nil
  26659. m.addbot_id = nil
  26660. }
  26661. // SetBotType sets the "bot_type" field.
  26662. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  26663. m.bot_type = &u
  26664. m.addbot_type = nil
  26665. }
  26666. // BotType returns the value of the "bot_type" field in the mutation.
  26667. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  26668. v := m.bot_type
  26669. if v == nil {
  26670. return
  26671. }
  26672. return *v, true
  26673. }
  26674. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  26675. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  26676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26677. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  26678. if !m.op.Is(OpUpdateOne) {
  26679. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  26680. }
  26681. if m.id == nil || m.oldValue == nil {
  26682. return v, errors.New("OldBotType requires an ID field in the mutation")
  26683. }
  26684. oldValue, err := m.oldValue(ctx)
  26685. if err != nil {
  26686. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  26687. }
  26688. return oldValue.BotType, nil
  26689. }
  26690. // AddBotType adds u to the "bot_type" field.
  26691. func (m *WxCardVisitMutation) AddBotType(u int8) {
  26692. if m.addbot_type != nil {
  26693. *m.addbot_type += u
  26694. } else {
  26695. m.addbot_type = &u
  26696. }
  26697. }
  26698. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  26699. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  26700. v := m.addbot_type
  26701. if v == nil {
  26702. return
  26703. }
  26704. return *v, true
  26705. }
  26706. // ResetBotType resets all changes to the "bot_type" field.
  26707. func (m *WxCardVisitMutation) ResetBotType() {
  26708. m.bot_type = nil
  26709. m.addbot_type = nil
  26710. }
  26711. // Where appends a list predicates to the WxCardVisitMutation builder.
  26712. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  26713. m.predicates = append(m.predicates, ps...)
  26714. }
  26715. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  26716. // users can use type-assertion to append predicates that do not depend on any generated package.
  26717. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  26718. p := make([]predicate.WxCardVisit, len(ps))
  26719. for i := range ps {
  26720. p[i] = ps[i]
  26721. }
  26722. m.Where(p...)
  26723. }
  26724. // Op returns the operation name.
  26725. func (m *WxCardVisitMutation) Op() Op {
  26726. return m.op
  26727. }
  26728. // SetOp allows setting the mutation operation.
  26729. func (m *WxCardVisitMutation) SetOp(op Op) {
  26730. m.op = op
  26731. }
  26732. // Type returns the node type of this mutation (WxCardVisit).
  26733. func (m *WxCardVisitMutation) Type() string {
  26734. return m.typ
  26735. }
  26736. // Fields returns all fields that were changed during this mutation. Note that in
  26737. // order to get all numeric fields that were incremented/decremented, call
  26738. // AddedFields().
  26739. func (m *WxCardVisitMutation) Fields() []string {
  26740. fields := make([]string, 0, 6)
  26741. if m.created_at != nil {
  26742. fields = append(fields, wxcardvisit.FieldCreatedAt)
  26743. }
  26744. if m.updated_at != nil {
  26745. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  26746. }
  26747. if m.deleted_at != nil {
  26748. fields = append(fields, wxcardvisit.FieldDeletedAt)
  26749. }
  26750. if m.user_id != nil {
  26751. fields = append(fields, wxcardvisit.FieldUserID)
  26752. }
  26753. if m.bot_id != nil {
  26754. fields = append(fields, wxcardvisit.FieldBotID)
  26755. }
  26756. if m.bot_type != nil {
  26757. fields = append(fields, wxcardvisit.FieldBotType)
  26758. }
  26759. return fields
  26760. }
  26761. // Field returns the value of a field with the given name. The second boolean
  26762. // return value indicates that this field was not set, or was not defined in the
  26763. // schema.
  26764. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  26765. switch name {
  26766. case wxcardvisit.FieldCreatedAt:
  26767. return m.CreatedAt()
  26768. case wxcardvisit.FieldUpdatedAt:
  26769. return m.UpdatedAt()
  26770. case wxcardvisit.FieldDeletedAt:
  26771. return m.DeletedAt()
  26772. case wxcardvisit.FieldUserID:
  26773. return m.UserID()
  26774. case wxcardvisit.FieldBotID:
  26775. return m.BotID()
  26776. case wxcardvisit.FieldBotType:
  26777. return m.BotType()
  26778. }
  26779. return nil, false
  26780. }
  26781. // OldField returns the old value of the field from the database. An error is
  26782. // returned if the mutation operation is not UpdateOne, or the query to the
  26783. // database failed.
  26784. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26785. switch name {
  26786. case wxcardvisit.FieldCreatedAt:
  26787. return m.OldCreatedAt(ctx)
  26788. case wxcardvisit.FieldUpdatedAt:
  26789. return m.OldUpdatedAt(ctx)
  26790. case wxcardvisit.FieldDeletedAt:
  26791. return m.OldDeletedAt(ctx)
  26792. case wxcardvisit.FieldUserID:
  26793. return m.OldUserID(ctx)
  26794. case wxcardvisit.FieldBotID:
  26795. return m.OldBotID(ctx)
  26796. case wxcardvisit.FieldBotType:
  26797. return m.OldBotType(ctx)
  26798. }
  26799. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  26800. }
  26801. // SetField sets the value of a field with the given name. It returns an error if
  26802. // the field is not defined in the schema, or if the type mismatched the field
  26803. // type.
  26804. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  26805. switch name {
  26806. case wxcardvisit.FieldCreatedAt:
  26807. v, ok := value.(time.Time)
  26808. if !ok {
  26809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26810. }
  26811. m.SetCreatedAt(v)
  26812. return nil
  26813. case wxcardvisit.FieldUpdatedAt:
  26814. v, ok := value.(time.Time)
  26815. if !ok {
  26816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26817. }
  26818. m.SetUpdatedAt(v)
  26819. return nil
  26820. case wxcardvisit.FieldDeletedAt:
  26821. v, ok := value.(time.Time)
  26822. if !ok {
  26823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26824. }
  26825. m.SetDeletedAt(v)
  26826. return nil
  26827. case wxcardvisit.FieldUserID:
  26828. v, ok := value.(uint64)
  26829. if !ok {
  26830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26831. }
  26832. m.SetUserID(v)
  26833. return nil
  26834. case wxcardvisit.FieldBotID:
  26835. v, ok := value.(uint64)
  26836. if !ok {
  26837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26838. }
  26839. m.SetBotID(v)
  26840. return nil
  26841. case wxcardvisit.FieldBotType:
  26842. v, ok := value.(uint8)
  26843. if !ok {
  26844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26845. }
  26846. m.SetBotType(v)
  26847. return nil
  26848. }
  26849. return fmt.Errorf("unknown WxCardVisit field %s", name)
  26850. }
  26851. // AddedFields returns all numeric fields that were incremented/decremented during
  26852. // this mutation.
  26853. func (m *WxCardVisitMutation) AddedFields() []string {
  26854. var fields []string
  26855. if m.adduser_id != nil {
  26856. fields = append(fields, wxcardvisit.FieldUserID)
  26857. }
  26858. if m.addbot_id != nil {
  26859. fields = append(fields, wxcardvisit.FieldBotID)
  26860. }
  26861. if m.addbot_type != nil {
  26862. fields = append(fields, wxcardvisit.FieldBotType)
  26863. }
  26864. return fields
  26865. }
  26866. // AddedField returns the numeric value that was incremented/decremented on a field
  26867. // with the given name. The second boolean return value indicates that this field
  26868. // was not set, or was not defined in the schema.
  26869. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  26870. switch name {
  26871. case wxcardvisit.FieldUserID:
  26872. return m.AddedUserID()
  26873. case wxcardvisit.FieldBotID:
  26874. return m.AddedBotID()
  26875. case wxcardvisit.FieldBotType:
  26876. return m.AddedBotType()
  26877. }
  26878. return nil, false
  26879. }
  26880. // AddField adds the value to the field with the given name. It returns an error if
  26881. // the field is not defined in the schema, or if the type mismatched the field
  26882. // type.
  26883. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  26884. switch name {
  26885. case wxcardvisit.FieldUserID:
  26886. v, ok := value.(int64)
  26887. if !ok {
  26888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26889. }
  26890. m.AddUserID(v)
  26891. return nil
  26892. case wxcardvisit.FieldBotID:
  26893. v, ok := value.(int64)
  26894. if !ok {
  26895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26896. }
  26897. m.AddBotID(v)
  26898. return nil
  26899. case wxcardvisit.FieldBotType:
  26900. v, ok := value.(int8)
  26901. if !ok {
  26902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26903. }
  26904. m.AddBotType(v)
  26905. return nil
  26906. }
  26907. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  26908. }
  26909. // ClearedFields returns all nullable fields that were cleared during this
  26910. // mutation.
  26911. func (m *WxCardVisitMutation) ClearedFields() []string {
  26912. var fields []string
  26913. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  26914. fields = append(fields, wxcardvisit.FieldDeletedAt)
  26915. }
  26916. if m.FieldCleared(wxcardvisit.FieldUserID) {
  26917. fields = append(fields, wxcardvisit.FieldUserID)
  26918. }
  26919. return fields
  26920. }
  26921. // FieldCleared returns a boolean indicating if a field with the given name was
  26922. // cleared in this mutation.
  26923. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  26924. _, ok := m.clearedFields[name]
  26925. return ok
  26926. }
  26927. // ClearField clears the value of the field with the given name. It returns an
  26928. // error if the field is not defined in the schema.
  26929. func (m *WxCardVisitMutation) ClearField(name string) error {
  26930. switch name {
  26931. case wxcardvisit.FieldDeletedAt:
  26932. m.ClearDeletedAt()
  26933. return nil
  26934. case wxcardvisit.FieldUserID:
  26935. m.ClearUserID()
  26936. return nil
  26937. }
  26938. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  26939. }
  26940. // ResetField resets all changes in the mutation for the field with the given name.
  26941. // It returns an error if the field is not defined in the schema.
  26942. func (m *WxCardVisitMutation) ResetField(name string) error {
  26943. switch name {
  26944. case wxcardvisit.FieldCreatedAt:
  26945. m.ResetCreatedAt()
  26946. return nil
  26947. case wxcardvisit.FieldUpdatedAt:
  26948. m.ResetUpdatedAt()
  26949. return nil
  26950. case wxcardvisit.FieldDeletedAt:
  26951. m.ResetDeletedAt()
  26952. return nil
  26953. case wxcardvisit.FieldUserID:
  26954. m.ResetUserID()
  26955. return nil
  26956. case wxcardvisit.FieldBotID:
  26957. m.ResetBotID()
  26958. return nil
  26959. case wxcardvisit.FieldBotType:
  26960. m.ResetBotType()
  26961. return nil
  26962. }
  26963. return fmt.Errorf("unknown WxCardVisit field %s", name)
  26964. }
  26965. // AddedEdges returns all edge names that were set/added in this mutation.
  26966. func (m *WxCardVisitMutation) AddedEdges() []string {
  26967. edges := make([]string, 0, 0)
  26968. return edges
  26969. }
  26970. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26971. // name in this mutation.
  26972. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  26973. return nil
  26974. }
  26975. // RemovedEdges returns all edge names that were removed in this mutation.
  26976. func (m *WxCardVisitMutation) RemovedEdges() []string {
  26977. edges := make([]string, 0, 0)
  26978. return edges
  26979. }
  26980. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26981. // the given name in this mutation.
  26982. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  26983. return nil
  26984. }
  26985. // ClearedEdges returns all edge names that were cleared in this mutation.
  26986. func (m *WxCardVisitMutation) ClearedEdges() []string {
  26987. edges := make([]string, 0, 0)
  26988. return edges
  26989. }
  26990. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26991. // was cleared in this mutation.
  26992. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  26993. return false
  26994. }
  26995. // ClearEdge clears the value of the edge with the given name. It returns an error
  26996. // if that edge is not defined in the schema.
  26997. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  26998. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  26999. }
  27000. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27001. // It returns an error if the edge is not defined in the schema.
  27002. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  27003. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  27004. }