mutation.go 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530
  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/labeltagging"
  23. "wechat-api/ent/message"
  24. "wechat-api/ent/messagerecords"
  25. "wechat-api/ent/msg"
  26. "wechat-api/ent/predicate"
  27. "wechat-api/ent/server"
  28. "wechat-api/ent/sopnode"
  29. "wechat-api/ent/sopstage"
  30. "wechat-api/ent/soptask"
  31. "wechat-api/ent/token"
  32. "wechat-api/ent/tutorial"
  33. "wechat-api/ent/usagedetail"
  34. "wechat-api/ent/usagestatisticday"
  35. "wechat-api/ent/usagestatistichour"
  36. "wechat-api/ent/usagestatisticmonth"
  37. "wechat-api/ent/usagetotal"
  38. "wechat-api/ent/workexperience"
  39. "wechat-api/ent/wpchatroom"
  40. "wechat-api/ent/wpchatroommember"
  41. "wechat-api/ent/wx"
  42. "wechat-api/ent/wxcard"
  43. "wechat-api/ent/wxcarduser"
  44. "wechat-api/ent/wxcardvisit"
  45. "entgo.io/ent"
  46. "entgo.io/ent/dialect/sql"
  47. )
  48. const (
  49. // Operation types.
  50. OpCreate = ent.OpCreate
  51. OpDelete = ent.OpDelete
  52. OpDeleteOne = ent.OpDeleteOne
  53. OpUpdate = ent.OpUpdate
  54. OpUpdateOne = ent.OpUpdateOne
  55. // Node types.
  56. TypeAgent = "Agent"
  57. TypeAgentBase = "AgentBase"
  58. TypeAliyunAvatar = "AliyunAvatar"
  59. TypeBatchMsg = "BatchMsg"
  60. TypeCategory = "Category"
  61. TypeChatRecords = "ChatRecords"
  62. TypeChatSession = "ChatSession"
  63. TypeContact = "Contact"
  64. TypeEmployee = "Employee"
  65. TypeEmployeeConfig = "EmployeeConfig"
  66. TypeLabel = "Label"
  67. TypeLabelRelationship = "LabelRelationship"
  68. TypeLabelTagging = "LabelTagging"
  69. TypeMessage = "Message"
  70. TypeMessageRecords = "MessageRecords"
  71. TypeMsg = "Msg"
  72. TypeServer = "Server"
  73. TypeSopNode = "SopNode"
  74. TypeSopStage = "SopStage"
  75. TypeSopTask = "SopTask"
  76. TypeToken = "Token"
  77. TypeTutorial = "Tutorial"
  78. TypeUsageDetail = "UsageDetail"
  79. TypeUsageStatisticDay = "UsageStatisticDay"
  80. TypeUsageStatisticHour = "UsageStatisticHour"
  81. TypeUsageStatisticMonth = "UsageStatisticMonth"
  82. TypeUsageTotal = "UsageTotal"
  83. TypeWorkExperience = "WorkExperience"
  84. TypeWpChatroom = "WpChatroom"
  85. TypeWpChatroomMember = "WpChatroomMember"
  86. TypeWx = "Wx"
  87. TypeWxCard = "WxCard"
  88. TypeWxCardUser = "WxCardUser"
  89. TypeWxCardVisit = "WxCardVisit"
  90. )
  91. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  92. type AgentMutation struct {
  93. config
  94. op Op
  95. typ string
  96. id *uint64
  97. created_at *time.Time
  98. updated_at *time.Time
  99. deleted_at *time.Time
  100. name *string
  101. role *string
  102. status *int
  103. addstatus *int
  104. background *string
  105. examples *string
  106. organization_id *uint64
  107. addorganization_id *int64
  108. dataset_id *string
  109. collection_id *string
  110. clearedFields map[string]struct{}
  111. wx_agent map[uint64]struct{}
  112. removedwx_agent map[uint64]struct{}
  113. clearedwx_agent bool
  114. token_agent map[uint64]struct{}
  115. removedtoken_agent map[uint64]struct{}
  116. clearedtoken_agent bool
  117. done bool
  118. oldValue func(context.Context) (*Agent, error)
  119. predicates []predicate.Agent
  120. }
  121. var _ ent.Mutation = (*AgentMutation)(nil)
  122. // agentOption allows management of the mutation configuration using functional options.
  123. type agentOption func(*AgentMutation)
  124. // newAgentMutation creates new mutation for the Agent entity.
  125. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  126. m := &AgentMutation{
  127. config: c,
  128. op: op,
  129. typ: TypeAgent,
  130. clearedFields: make(map[string]struct{}),
  131. }
  132. for _, opt := range opts {
  133. opt(m)
  134. }
  135. return m
  136. }
  137. // withAgentID sets the ID field of the mutation.
  138. func withAgentID(id uint64) agentOption {
  139. return func(m *AgentMutation) {
  140. var (
  141. err error
  142. once sync.Once
  143. value *Agent
  144. )
  145. m.oldValue = func(ctx context.Context) (*Agent, error) {
  146. once.Do(func() {
  147. if m.done {
  148. err = errors.New("querying old values post mutation is not allowed")
  149. } else {
  150. value, err = m.Client().Agent.Get(ctx, id)
  151. }
  152. })
  153. return value, err
  154. }
  155. m.id = &id
  156. }
  157. }
  158. // withAgent sets the old Agent of the mutation.
  159. func withAgent(node *Agent) agentOption {
  160. return func(m *AgentMutation) {
  161. m.oldValue = func(context.Context) (*Agent, error) {
  162. return node, nil
  163. }
  164. m.id = &node.ID
  165. }
  166. }
  167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  168. // executed in a transaction (ent.Tx), a transactional client is returned.
  169. func (m AgentMutation) Client() *Client {
  170. client := &Client{config: m.config}
  171. client.init()
  172. return client
  173. }
  174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  175. // it returns an error otherwise.
  176. func (m AgentMutation) Tx() (*Tx, error) {
  177. if _, ok := m.driver.(*txDriver); !ok {
  178. return nil, errors.New("ent: mutation is not running in a transaction")
  179. }
  180. tx := &Tx{config: m.config}
  181. tx.init()
  182. return tx, nil
  183. }
  184. // SetID sets the value of the id field. Note that this
  185. // operation is only accepted on creation of Agent entities.
  186. func (m *AgentMutation) SetID(id uint64) {
  187. m.id = &id
  188. }
  189. // ID returns the ID value in the mutation. Note that the ID is only available
  190. // if it was provided to the builder or after it was returned from the database.
  191. func (m *AgentMutation) ID() (id uint64, exists bool) {
  192. if m.id == nil {
  193. return
  194. }
  195. return *m.id, true
  196. }
  197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  198. // That means, if the mutation is applied within a transaction with an isolation level such
  199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  200. // or updated by the mutation.
  201. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  202. switch {
  203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  204. id, exists := m.ID()
  205. if exists {
  206. return []uint64{id}, nil
  207. }
  208. fallthrough
  209. case m.op.Is(OpUpdate | OpDelete):
  210. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  211. default:
  212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  213. }
  214. }
  215. // SetCreatedAt sets the "created_at" field.
  216. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  217. m.created_at = &t
  218. }
  219. // CreatedAt returns the value of the "created_at" field in the mutation.
  220. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  221. v := m.created_at
  222. if v == nil {
  223. return
  224. }
  225. return *v, true
  226. }
  227. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  228. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  230. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  231. if !m.op.Is(OpUpdateOne) {
  232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  233. }
  234. if m.id == nil || m.oldValue == nil {
  235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  236. }
  237. oldValue, err := m.oldValue(ctx)
  238. if err != nil {
  239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  240. }
  241. return oldValue.CreatedAt, nil
  242. }
  243. // ResetCreatedAt resets all changes to the "created_at" field.
  244. func (m *AgentMutation) ResetCreatedAt() {
  245. m.created_at = nil
  246. }
  247. // SetUpdatedAt sets the "updated_at" field.
  248. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  249. m.updated_at = &t
  250. }
  251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  252. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  253. v := m.updated_at
  254. if v == nil {
  255. return
  256. }
  257. return *v, true
  258. }
  259. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  260. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  262. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  263. if !m.op.Is(OpUpdateOne) {
  264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  265. }
  266. if m.id == nil || m.oldValue == nil {
  267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  268. }
  269. oldValue, err := m.oldValue(ctx)
  270. if err != nil {
  271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  272. }
  273. return oldValue.UpdatedAt, nil
  274. }
  275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  276. func (m *AgentMutation) ResetUpdatedAt() {
  277. m.updated_at = nil
  278. }
  279. // SetDeletedAt sets the "deleted_at" field.
  280. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  281. m.deleted_at = &t
  282. }
  283. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  284. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  285. v := m.deleted_at
  286. if v == nil {
  287. return
  288. }
  289. return *v, true
  290. }
  291. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  292. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  294. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  295. if !m.op.Is(OpUpdateOne) {
  296. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  297. }
  298. if m.id == nil || m.oldValue == nil {
  299. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  300. }
  301. oldValue, err := m.oldValue(ctx)
  302. if err != nil {
  303. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  304. }
  305. return oldValue.DeletedAt, nil
  306. }
  307. // ClearDeletedAt clears the value of the "deleted_at" field.
  308. func (m *AgentMutation) ClearDeletedAt() {
  309. m.deleted_at = nil
  310. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  311. }
  312. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  313. func (m *AgentMutation) DeletedAtCleared() bool {
  314. _, ok := m.clearedFields[agent.FieldDeletedAt]
  315. return ok
  316. }
  317. // ResetDeletedAt resets all changes to the "deleted_at" field.
  318. func (m *AgentMutation) ResetDeletedAt() {
  319. m.deleted_at = nil
  320. delete(m.clearedFields, agent.FieldDeletedAt)
  321. }
  322. // SetName sets the "name" field.
  323. func (m *AgentMutation) SetName(s string) {
  324. m.name = &s
  325. }
  326. // Name returns the value of the "name" field in the mutation.
  327. func (m *AgentMutation) Name() (r string, exists bool) {
  328. v := m.name
  329. if v == nil {
  330. return
  331. }
  332. return *v, true
  333. }
  334. // OldName returns the old "name" field's value of the Agent entity.
  335. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  337. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  338. if !m.op.Is(OpUpdateOne) {
  339. return v, errors.New("OldName is only allowed on UpdateOne operations")
  340. }
  341. if m.id == nil || m.oldValue == nil {
  342. return v, errors.New("OldName requires an ID field in the mutation")
  343. }
  344. oldValue, err := m.oldValue(ctx)
  345. if err != nil {
  346. return v, fmt.Errorf("querying old value for OldName: %w", err)
  347. }
  348. return oldValue.Name, nil
  349. }
  350. // ResetName resets all changes to the "name" field.
  351. func (m *AgentMutation) ResetName() {
  352. m.name = nil
  353. }
  354. // SetRole sets the "role" field.
  355. func (m *AgentMutation) SetRole(s string) {
  356. m.role = &s
  357. }
  358. // Role returns the value of the "role" field in the mutation.
  359. func (m *AgentMutation) Role() (r string, exists bool) {
  360. v := m.role
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldRole returns the old "role" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldRole requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  379. }
  380. return oldValue.Role, nil
  381. }
  382. // ResetRole resets all changes to the "role" field.
  383. func (m *AgentMutation) ResetRole() {
  384. m.role = nil
  385. }
  386. // SetStatus sets the "status" field.
  387. func (m *AgentMutation) SetStatus(i int) {
  388. m.status = &i
  389. m.addstatus = nil
  390. }
  391. // Status returns the value of the "status" field in the mutation.
  392. func (m *AgentMutation) Status() (r int, exists bool) {
  393. v := m.status
  394. if v == nil {
  395. return
  396. }
  397. return *v, true
  398. }
  399. // OldStatus returns the old "status" field's value of the Agent entity.
  400. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  402. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  403. if !m.op.Is(OpUpdateOne) {
  404. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  405. }
  406. if m.id == nil || m.oldValue == nil {
  407. return v, errors.New("OldStatus requires an ID field in the mutation")
  408. }
  409. oldValue, err := m.oldValue(ctx)
  410. if err != nil {
  411. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  412. }
  413. return oldValue.Status, nil
  414. }
  415. // AddStatus adds i to the "status" field.
  416. func (m *AgentMutation) AddStatus(i int) {
  417. if m.addstatus != nil {
  418. *m.addstatus += i
  419. } else {
  420. m.addstatus = &i
  421. }
  422. }
  423. // AddedStatus returns the value that was added to the "status" field in this mutation.
  424. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  425. v := m.addstatus
  426. if v == nil {
  427. return
  428. }
  429. return *v, true
  430. }
  431. // ClearStatus clears the value of the "status" field.
  432. func (m *AgentMutation) ClearStatus() {
  433. m.status = nil
  434. m.addstatus = nil
  435. m.clearedFields[agent.FieldStatus] = struct{}{}
  436. }
  437. // StatusCleared returns if the "status" field was cleared in this mutation.
  438. func (m *AgentMutation) StatusCleared() bool {
  439. _, ok := m.clearedFields[agent.FieldStatus]
  440. return ok
  441. }
  442. // ResetStatus resets all changes to the "status" field.
  443. func (m *AgentMutation) ResetStatus() {
  444. m.status = nil
  445. m.addstatus = nil
  446. delete(m.clearedFields, agent.FieldStatus)
  447. }
  448. // SetBackground sets the "background" field.
  449. func (m *AgentMutation) SetBackground(s string) {
  450. m.background = &s
  451. }
  452. // Background returns the value of the "background" field in the mutation.
  453. func (m *AgentMutation) Background() (r string, exists bool) {
  454. v := m.background
  455. if v == nil {
  456. return
  457. }
  458. return *v, true
  459. }
  460. // OldBackground returns the old "background" field's value of the Agent entity.
  461. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  463. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  464. if !m.op.Is(OpUpdateOne) {
  465. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  466. }
  467. if m.id == nil || m.oldValue == nil {
  468. return v, errors.New("OldBackground requires an ID field in the mutation")
  469. }
  470. oldValue, err := m.oldValue(ctx)
  471. if err != nil {
  472. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  473. }
  474. return oldValue.Background, nil
  475. }
  476. // ClearBackground clears the value of the "background" field.
  477. func (m *AgentMutation) ClearBackground() {
  478. m.background = nil
  479. m.clearedFields[agent.FieldBackground] = struct{}{}
  480. }
  481. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  482. func (m *AgentMutation) BackgroundCleared() bool {
  483. _, ok := m.clearedFields[agent.FieldBackground]
  484. return ok
  485. }
  486. // ResetBackground resets all changes to the "background" field.
  487. func (m *AgentMutation) ResetBackground() {
  488. m.background = nil
  489. delete(m.clearedFields, agent.FieldBackground)
  490. }
  491. // SetExamples sets the "examples" field.
  492. func (m *AgentMutation) SetExamples(s string) {
  493. m.examples = &s
  494. }
  495. // Examples returns the value of the "examples" field in the mutation.
  496. func (m *AgentMutation) Examples() (r string, exists bool) {
  497. v := m.examples
  498. if v == nil {
  499. return
  500. }
  501. return *v, true
  502. }
  503. // OldExamples returns the old "examples" field's value of the Agent entity.
  504. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  506. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  507. if !m.op.Is(OpUpdateOne) {
  508. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  509. }
  510. if m.id == nil || m.oldValue == nil {
  511. return v, errors.New("OldExamples requires an ID field in the mutation")
  512. }
  513. oldValue, err := m.oldValue(ctx)
  514. if err != nil {
  515. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  516. }
  517. return oldValue.Examples, nil
  518. }
  519. // ClearExamples clears the value of the "examples" field.
  520. func (m *AgentMutation) ClearExamples() {
  521. m.examples = nil
  522. m.clearedFields[agent.FieldExamples] = struct{}{}
  523. }
  524. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  525. func (m *AgentMutation) ExamplesCleared() bool {
  526. _, ok := m.clearedFields[agent.FieldExamples]
  527. return ok
  528. }
  529. // ResetExamples resets all changes to the "examples" field.
  530. func (m *AgentMutation) ResetExamples() {
  531. m.examples = nil
  532. delete(m.clearedFields, agent.FieldExamples)
  533. }
  534. // SetOrganizationID sets the "organization_id" field.
  535. func (m *AgentMutation) SetOrganizationID(u uint64) {
  536. m.organization_id = &u
  537. m.addorganization_id = nil
  538. }
  539. // OrganizationID returns the value of the "organization_id" field in the mutation.
  540. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  541. v := m.organization_id
  542. if v == nil {
  543. return
  544. }
  545. return *v, true
  546. }
  547. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  548. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  550. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  551. if !m.op.Is(OpUpdateOne) {
  552. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  553. }
  554. if m.id == nil || m.oldValue == nil {
  555. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  556. }
  557. oldValue, err := m.oldValue(ctx)
  558. if err != nil {
  559. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  560. }
  561. return oldValue.OrganizationID, nil
  562. }
  563. // AddOrganizationID adds u to the "organization_id" field.
  564. func (m *AgentMutation) AddOrganizationID(u int64) {
  565. if m.addorganization_id != nil {
  566. *m.addorganization_id += u
  567. } else {
  568. m.addorganization_id = &u
  569. }
  570. }
  571. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  572. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  573. v := m.addorganization_id
  574. if v == nil {
  575. return
  576. }
  577. return *v, true
  578. }
  579. // ResetOrganizationID resets all changes to the "organization_id" field.
  580. func (m *AgentMutation) ResetOrganizationID() {
  581. m.organization_id = nil
  582. m.addorganization_id = nil
  583. }
  584. // SetDatasetID sets the "dataset_id" field.
  585. func (m *AgentMutation) SetDatasetID(s string) {
  586. m.dataset_id = &s
  587. }
  588. // DatasetID returns the value of the "dataset_id" field in the mutation.
  589. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  590. v := m.dataset_id
  591. if v == nil {
  592. return
  593. }
  594. return *v, true
  595. }
  596. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  597. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  599. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  600. if !m.op.Is(OpUpdateOne) {
  601. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  602. }
  603. if m.id == nil || m.oldValue == nil {
  604. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  605. }
  606. oldValue, err := m.oldValue(ctx)
  607. if err != nil {
  608. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  609. }
  610. return oldValue.DatasetID, nil
  611. }
  612. // ResetDatasetID resets all changes to the "dataset_id" field.
  613. func (m *AgentMutation) ResetDatasetID() {
  614. m.dataset_id = nil
  615. }
  616. // SetCollectionID sets the "collection_id" field.
  617. func (m *AgentMutation) SetCollectionID(s string) {
  618. m.collection_id = &s
  619. }
  620. // CollectionID returns the value of the "collection_id" field in the mutation.
  621. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  622. v := m.collection_id
  623. if v == nil {
  624. return
  625. }
  626. return *v, true
  627. }
  628. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  629. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  631. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  632. if !m.op.Is(OpUpdateOne) {
  633. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  634. }
  635. if m.id == nil || m.oldValue == nil {
  636. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  637. }
  638. oldValue, err := m.oldValue(ctx)
  639. if err != nil {
  640. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  641. }
  642. return oldValue.CollectionID, nil
  643. }
  644. // ResetCollectionID resets all changes to the "collection_id" field.
  645. func (m *AgentMutation) ResetCollectionID() {
  646. m.collection_id = nil
  647. }
  648. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  649. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  650. if m.wx_agent == nil {
  651. m.wx_agent = make(map[uint64]struct{})
  652. }
  653. for i := range ids {
  654. m.wx_agent[ids[i]] = struct{}{}
  655. }
  656. }
  657. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  658. func (m *AgentMutation) ClearWxAgent() {
  659. m.clearedwx_agent = true
  660. }
  661. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  662. func (m *AgentMutation) WxAgentCleared() bool {
  663. return m.clearedwx_agent
  664. }
  665. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  666. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  667. if m.removedwx_agent == nil {
  668. m.removedwx_agent = make(map[uint64]struct{})
  669. }
  670. for i := range ids {
  671. delete(m.wx_agent, ids[i])
  672. m.removedwx_agent[ids[i]] = struct{}{}
  673. }
  674. }
  675. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  676. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  677. for id := range m.removedwx_agent {
  678. ids = append(ids, id)
  679. }
  680. return
  681. }
  682. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  683. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  684. for id := range m.wx_agent {
  685. ids = append(ids, id)
  686. }
  687. return
  688. }
  689. // ResetWxAgent resets all changes to the "wx_agent" edge.
  690. func (m *AgentMutation) ResetWxAgent() {
  691. m.wx_agent = nil
  692. m.clearedwx_agent = false
  693. m.removedwx_agent = nil
  694. }
  695. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  696. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  697. if m.token_agent == nil {
  698. m.token_agent = make(map[uint64]struct{})
  699. }
  700. for i := range ids {
  701. m.token_agent[ids[i]] = struct{}{}
  702. }
  703. }
  704. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  705. func (m *AgentMutation) ClearTokenAgent() {
  706. m.clearedtoken_agent = true
  707. }
  708. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  709. func (m *AgentMutation) TokenAgentCleared() bool {
  710. return m.clearedtoken_agent
  711. }
  712. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  713. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  714. if m.removedtoken_agent == nil {
  715. m.removedtoken_agent = make(map[uint64]struct{})
  716. }
  717. for i := range ids {
  718. delete(m.token_agent, ids[i])
  719. m.removedtoken_agent[ids[i]] = struct{}{}
  720. }
  721. }
  722. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  723. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  724. for id := range m.removedtoken_agent {
  725. ids = append(ids, id)
  726. }
  727. return
  728. }
  729. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  730. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  731. for id := range m.token_agent {
  732. ids = append(ids, id)
  733. }
  734. return
  735. }
  736. // ResetTokenAgent resets all changes to the "token_agent" edge.
  737. func (m *AgentMutation) ResetTokenAgent() {
  738. m.token_agent = nil
  739. m.clearedtoken_agent = false
  740. m.removedtoken_agent = nil
  741. }
  742. // Where appends a list predicates to the AgentMutation builder.
  743. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  744. m.predicates = append(m.predicates, ps...)
  745. }
  746. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  747. // users can use type-assertion to append predicates that do not depend on any generated package.
  748. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  749. p := make([]predicate.Agent, len(ps))
  750. for i := range ps {
  751. p[i] = ps[i]
  752. }
  753. m.Where(p...)
  754. }
  755. // Op returns the operation name.
  756. func (m *AgentMutation) Op() Op {
  757. return m.op
  758. }
  759. // SetOp allows setting the mutation operation.
  760. func (m *AgentMutation) SetOp(op Op) {
  761. m.op = op
  762. }
  763. // Type returns the node type of this mutation (Agent).
  764. func (m *AgentMutation) Type() string {
  765. return m.typ
  766. }
  767. // Fields returns all fields that were changed during this mutation. Note that in
  768. // order to get all numeric fields that were incremented/decremented, call
  769. // AddedFields().
  770. func (m *AgentMutation) Fields() []string {
  771. fields := make([]string, 0, 11)
  772. if m.created_at != nil {
  773. fields = append(fields, agent.FieldCreatedAt)
  774. }
  775. if m.updated_at != nil {
  776. fields = append(fields, agent.FieldUpdatedAt)
  777. }
  778. if m.deleted_at != nil {
  779. fields = append(fields, agent.FieldDeletedAt)
  780. }
  781. if m.name != nil {
  782. fields = append(fields, agent.FieldName)
  783. }
  784. if m.role != nil {
  785. fields = append(fields, agent.FieldRole)
  786. }
  787. if m.status != nil {
  788. fields = append(fields, agent.FieldStatus)
  789. }
  790. if m.background != nil {
  791. fields = append(fields, agent.FieldBackground)
  792. }
  793. if m.examples != nil {
  794. fields = append(fields, agent.FieldExamples)
  795. }
  796. if m.organization_id != nil {
  797. fields = append(fields, agent.FieldOrganizationID)
  798. }
  799. if m.dataset_id != nil {
  800. fields = append(fields, agent.FieldDatasetID)
  801. }
  802. if m.collection_id != nil {
  803. fields = append(fields, agent.FieldCollectionID)
  804. }
  805. return fields
  806. }
  807. // Field returns the value of a field with the given name. The second boolean
  808. // return value indicates that this field was not set, or was not defined in the
  809. // schema.
  810. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  811. switch name {
  812. case agent.FieldCreatedAt:
  813. return m.CreatedAt()
  814. case agent.FieldUpdatedAt:
  815. return m.UpdatedAt()
  816. case agent.FieldDeletedAt:
  817. return m.DeletedAt()
  818. case agent.FieldName:
  819. return m.Name()
  820. case agent.FieldRole:
  821. return m.Role()
  822. case agent.FieldStatus:
  823. return m.Status()
  824. case agent.FieldBackground:
  825. return m.Background()
  826. case agent.FieldExamples:
  827. return m.Examples()
  828. case agent.FieldOrganizationID:
  829. return m.OrganizationID()
  830. case agent.FieldDatasetID:
  831. return m.DatasetID()
  832. case agent.FieldCollectionID:
  833. return m.CollectionID()
  834. }
  835. return nil, false
  836. }
  837. // OldField returns the old value of the field from the database. An error is
  838. // returned if the mutation operation is not UpdateOne, or the query to the
  839. // database failed.
  840. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  841. switch name {
  842. case agent.FieldCreatedAt:
  843. return m.OldCreatedAt(ctx)
  844. case agent.FieldUpdatedAt:
  845. return m.OldUpdatedAt(ctx)
  846. case agent.FieldDeletedAt:
  847. return m.OldDeletedAt(ctx)
  848. case agent.FieldName:
  849. return m.OldName(ctx)
  850. case agent.FieldRole:
  851. return m.OldRole(ctx)
  852. case agent.FieldStatus:
  853. return m.OldStatus(ctx)
  854. case agent.FieldBackground:
  855. return m.OldBackground(ctx)
  856. case agent.FieldExamples:
  857. return m.OldExamples(ctx)
  858. case agent.FieldOrganizationID:
  859. return m.OldOrganizationID(ctx)
  860. case agent.FieldDatasetID:
  861. return m.OldDatasetID(ctx)
  862. case agent.FieldCollectionID:
  863. return m.OldCollectionID(ctx)
  864. }
  865. return nil, fmt.Errorf("unknown Agent field %s", name)
  866. }
  867. // SetField sets the value of a field with the given name. It returns an error if
  868. // the field is not defined in the schema, or if the type mismatched the field
  869. // type.
  870. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  871. switch name {
  872. case agent.FieldCreatedAt:
  873. v, ok := value.(time.Time)
  874. if !ok {
  875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  876. }
  877. m.SetCreatedAt(v)
  878. return nil
  879. case agent.FieldUpdatedAt:
  880. v, ok := value.(time.Time)
  881. if !ok {
  882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  883. }
  884. m.SetUpdatedAt(v)
  885. return nil
  886. case agent.FieldDeletedAt:
  887. v, ok := value.(time.Time)
  888. if !ok {
  889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  890. }
  891. m.SetDeletedAt(v)
  892. return nil
  893. case agent.FieldName:
  894. v, ok := value.(string)
  895. if !ok {
  896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  897. }
  898. m.SetName(v)
  899. return nil
  900. case agent.FieldRole:
  901. v, ok := value.(string)
  902. if !ok {
  903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  904. }
  905. m.SetRole(v)
  906. return nil
  907. case agent.FieldStatus:
  908. v, ok := value.(int)
  909. if !ok {
  910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  911. }
  912. m.SetStatus(v)
  913. return nil
  914. case agent.FieldBackground:
  915. v, ok := value.(string)
  916. if !ok {
  917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  918. }
  919. m.SetBackground(v)
  920. return nil
  921. case agent.FieldExamples:
  922. v, ok := value.(string)
  923. if !ok {
  924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  925. }
  926. m.SetExamples(v)
  927. return nil
  928. case agent.FieldOrganizationID:
  929. v, ok := value.(uint64)
  930. if !ok {
  931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  932. }
  933. m.SetOrganizationID(v)
  934. return nil
  935. case agent.FieldDatasetID:
  936. v, ok := value.(string)
  937. if !ok {
  938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  939. }
  940. m.SetDatasetID(v)
  941. return nil
  942. case agent.FieldCollectionID:
  943. v, ok := value.(string)
  944. if !ok {
  945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  946. }
  947. m.SetCollectionID(v)
  948. return nil
  949. }
  950. return fmt.Errorf("unknown Agent field %s", name)
  951. }
  952. // AddedFields returns all numeric fields that were incremented/decremented during
  953. // this mutation.
  954. func (m *AgentMutation) AddedFields() []string {
  955. var fields []string
  956. if m.addstatus != nil {
  957. fields = append(fields, agent.FieldStatus)
  958. }
  959. if m.addorganization_id != nil {
  960. fields = append(fields, agent.FieldOrganizationID)
  961. }
  962. return fields
  963. }
  964. // AddedField returns the numeric value that was incremented/decremented on a field
  965. // with the given name. The second boolean return value indicates that this field
  966. // was not set, or was not defined in the schema.
  967. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  968. switch name {
  969. case agent.FieldStatus:
  970. return m.AddedStatus()
  971. case agent.FieldOrganizationID:
  972. return m.AddedOrganizationID()
  973. }
  974. return nil, false
  975. }
  976. // AddField adds the value to the field with the given name. It returns an error if
  977. // the field is not defined in the schema, or if the type mismatched the field
  978. // type.
  979. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  980. switch name {
  981. case agent.FieldStatus:
  982. v, ok := value.(int)
  983. if !ok {
  984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  985. }
  986. m.AddStatus(v)
  987. return nil
  988. case agent.FieldOrganizationID:
  989. v, ok := value.(int64)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.AddOrganizationID(v)
  994. return nil
  995. }
  996. return fmt.Errorf("unknown Agent numeric field %s", name)
  997. }
  998. // ClearedFields returns all nullable fields that were cleared during this
  999. // mutation.
  1000. func (m *AgentMutation) ClearedFields() []string {
  1001. var fields []string
  1002. if m.FieldCleared(agent.FieldDeletedAt) {
  1003. fields = append(fields, agent.FieldDeletedAt)
  1004. }
  1005. if m.FieldCleared(agent.FieldStatus) {
  1006. fields = append(fields, agent.FieldStatus)
  1007. }
  1008. if m.FieldCleared(agent.FieldBackground) {
  1009. fields = append(fields, agent.FieldBackground)
  1010. }
  1011. if m.FieldCleared(agent.FieldExamples) {
  1012. fields = append(fields, agent.FieldExamples)
  1013. }
  1014. return fields
  1015. }
  1016. // FieldCleared returns a boolean indicating if a field with the given name was
  1017. // cleared in this mutation.
  1018. func (m *AgentMutation) FieldCleared(name string) bool {
  1019. _, ok := m.clearedFields[name]
  1020. return ok
  1021. }
  1022. // ClearField clears the value of the field with the given name. It returns an
  1023. // error if the field is not defined in the schema.
  1024. func (m *AgentMutation) ClearField(name string) error {
  1025. switch name {
  1026. case agent.FieldDeletedAt:
  1027. m.ClearDeletedAt()
  1028. return nil
  1029. case agent.FieldStatus:
  1030. m.ClearStatus()
  1031. return nil
  1032. case agent.FieldBackground:
  1033. m.ClearBackground()
  1034. return nil
  1035. case agent.FieldExamples:
  1036. m.ClearExamples()
  1037. return nil
  1038. }
  1039. return fmt.Errorf("unknown Agent nullable field %s", name)
  1040. }
  1041. // ResetField resets all changes in the mutation for the field with the given name.
  1042. // It returns an error if the field is not defined in the schema.
  1043. func (m *AgentMutation) ResetField(name string) error {
  1044. switch name {
  1045. case agent.FieldCreatedAt:
  1046. m.ResetCreatedAt()
  1047. return nil
  1048. case agent.FieldUpdatedAt:
  1049. m.ResetUpdatedAt()
  1050. return nil
  1051. case agent.FieldDeletedAt:
  1052. m.ResetDeletedAt()
  1053. return nil
  1054. case agent.FieldName:
  1055. m.ResetName()
  1056. return nil
  1057. case agent.FieldRole:
  1058. m.ResetRole()
  1059. return nil
  1060. case agent.FieldStatus:
  1061. m.ResetStatus()
  1062. return nil
  1063. case agent.FieldBackground:
  1064. m.ResetBackground()
  1065. return nil
  1066. case agent.FieldExamples:
  1067. m.ResetExamples()
  1068. return nil
  1069. case agent.FieldOrganizationID:
  1070. m.ResetOrganizationID()
  1071. return nil
  1072. case agent.FieldDatasetID:
  1073. m.ResetDatasetID()
  1074. return nil
  1075. case agent.FieldCollectionID:
  1076. m.ResetCollectionID()
  1077. return nil
  1078. }
  1079. return fmt.Errorf("unknown Agent field %s", name)
  1080. }
  1081. // AddedEdges returns all edge names that were set/added in this mutation.
  1082. func (m *AgentMutation) AddedEdges() []string {
  1083. edges := make([]string, 0, 2)
  1084. if m.wx_agent != nil {
  1085. edges = append(edges, agent.EdgeWxAgent)
  1086. }
  1087. if m.token_agent != nil {
  1088. edges = append(edges, agent.EdgeTokenAgent)
  1089. }
  1090. return edges
  1091. }
  1092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1093. // name in this mutation.
  1094. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1095. switch name {
  1096. case agent.EdgeWxAgent:
  1097. ids := make([]ent.Value, 0, len(m.wx_agent))
  1098. for id := range m.wx_agent {
  1099. ids = append(ids, id)
  1100. }
  1101. return ids
  1102. case agent.EdgeTokenAgent:
  1103. ids := make([]ent.Value, 0, len(m.token_agent))
  1104. for id := range m.token_agent {
  1105. ids = append(ids, id)
  1106. }
  1107. return ids
  1108. }
  1109. return nil
  1110. }
  1111. // RemovedEdges returns all edge names that were removed in this mutation.
  1112. func (m *AgentMutation) RemovedEdges() []string {
  1113. edges := make([]string, 0, 2)
  1114. if m.removedwx_agent != nil {
  1115. edges = append(edges, agent.EdgeWxAgent)
  1116. }
  1117. if m.removedtoken_agent != nil {
  1118. edges = append(edges, agent.EdgeTokenAgent)
  1119. }
  1120. return edges
  1121. }
  1122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1123. // the given name in this mutation.
  1124. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1125. switch name {
  1126. case agent.EdgeWxAgent:
  1127. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1128. for id := range m.removedwx_agent {
  1129. ids = append(ids, id)
  1130. }
  1131. return ids
  1132. case agent.EdgeTokenAgent:
  1133. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1134. for id := range m.removedtoken_agent {
  1135. ids = append(ids, id)
  1136. }
  1137. return ids
  1138. }
  1139. return nil
  1140. }
  1141. // ClearedEdges returns all edge names that were cleared in this mutation.
  1142. func (m *AgentMutation) ClearedEdges() []string {
  1143. edges := make([]string, 0, 2)
  1144. if m.clearedwx_agent {
  1145. edges = append(edges, agent.EdgeWxAgent)
  1146. }
  1147. if m.clearedtoken_agent {
  1148. edges = append(edges, agent.EdgeTokenAgent)
  1149. }
  1150. return edges
  1151. }
  1152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1153. // was cleared in this mutation.
  1154. func (m *AgentMutation) EdgeCleared(name string) bool {
  1155. switch name {
  1156. case agent.EdgeWxAgent:
  1157. return m.clearedwx_agent
  1158. case agent.EdgeTokenAgent:
  1159. return m.clearedtoken_agent
  1160. }
  1161. return false
  1162. }
  1163. // ClearEdge clears the value of the edge with the given name. It returns an error
  1164. // if that edge is not defined in the schema.
  1165. func (m *AgentMutation) ClearEdge(name string) error {
  1166. switch name {
  1167. }
  1168. return fmt.Errorf("unknown Agent unique edge %s", name)
  1169. }
  1170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1171. // It returns an error if the edge is not defined in the schema.
  1172. func (m *AgentMutation) ResetEdge(name string) error {
  1173. switch name {
  1174. case agent.EdgeWxAgent:
  1175. m.ResetWxAgent()
  1176. return nil
  1177. case agent.EdgeTokenAgent:
  1178. m.ResetTokenAgent()
  1179. return nil
  1180. }
  1181. return fmt.Errorf("unknown Agent edge %s", name)
  1182. }
  1183. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1184. type AgentBaseMutation struct {
  1185. config
  1186. op Op
  1187. typ string
  1188. id *string
  1189. q *string
  1190. a *string
  1191. chunk_index *uint64
  1192. addchunk_index *int64
  1193. indexes *[]string
  1194. appendindexes []string
  1195. dataset_id *string
  1196. collection_id *string
  1197. source_name *string
  1198. can_write *[]bool
  1199. appendcan_write []bool
  1200. is_owner *[]bool
  1201. appendis_owner []bool
  1202. clearedFields map[string]struct{}
  1203. wx_agent map[uint64]struct{}
  1204. removedwx_agent map[uint64]struct{}
  1205. clearedwx_agent bool
  1206. done bool
  1207. oldValue func(context.Context) (*AgentBase, error)
  1208. predicates []predicate.AgentBase
  1209. }
  1210. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1211. // agentbaseOption allows management of the mutation configuration using functional options.
  1212. type agentbaseOption func(*AgentBaseMutation)
  1213. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1214. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1215. m := &AgentBaseMutation{
  1216. config: c,
  1217. op: op,
  1218. typ: TypeAgentBase,
  1219. clearedFields: make(map[string]struct{}),
  1220. }
  1221. for _, opt := range opts {
  1222. opt(m)
  1223. }
  1224. return m
  1225. }
  1226. // withAgentBaseID sets the ID field of the mutation.
  1227. func withAgentBaseID(id string) agentbaseOption {
  1228. return func(m *AgentBaseMutation) {
  1229. var (
  1230. err error
  1231. once sync.Once
  1232. value *AgentBase
  1233. )
  1234. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1235. once.Do(func() {
  1236. if m.done {
  1237. err = errors.New("querying old values post mutation is not allowed")
  1238. } else {
  1239. value, err = m.Client().AgentBase.Get(ctx, id)
  1240. }
  1241. })
  1242. return value, err
  1243. }
  1244. m.id = &id
  1245. }
  1246. }
  1247. // withAgentBase sets the old AgentBase of the mutation.
  1248. func withAgentBase(node *AgentBase) agentbaseOption {
  1249. return func(m *AgentBaseMutation) {
  1250. m.oldValue = func(context.Context) (*AgentBase, error) {
  1251. return node, nil
  1252. }
  1253. m.id = &node.ID
  1254. }
  1255. }
  1256. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1257. // executed in a transaction (ent.Tx), a transactional client is returned.
  1258. func (m AgentBaseMutation) Client() *Client {
  1259. client := &Client{config: m.config}
  1260. client.init()
  1261. return client
  1262. }
  1263. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1264. // it returns an error otherwise.
  1265. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1266. if _, ok := m.driver.(*txDriver); !ok {
  1267. return nil, errors.New("ent: mutation is not running in a transaction")
  1268. }
  1269. tx := &Tx{config: m.config}
  1270. tx.init()
  1271. return tx, nil
  1272. }
  1273. // SetID sets the value of the id field. Note that this
  1274. // operation is only accepted on creation of AgentBase entities.
  1275. func (m *AgentBaseMutation) SetID(id string) {
  1276. m.id = &id
  1277. }
  1278. // ID returns the ID value in the mutation. Note that the ID is only available
  1279. // if it was provided to the builder or after it was returned from the database.
  1280. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1281. if m.id == nil {
  1282. return
  1283. }
  1284. return *m.id, true
  1285. }
  1286. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1287. // That means, if the mutation is applied within a transaction with an isolation level such
  1288. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1289. // or updated by the mutation.
  1290. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1291. switch {
  1292. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1293. id, exists := m.ID()
  1294. if exists {
  1295. return []string{id}, nil
  1296. }
  1297. fallthrough
  1298. case m.op.Is(OpUpdate | OpDelete):
  1299. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1300. default:
  1301. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1302. }
  1303. }
  1304. // SetQ sets the "q" field.
  1305. func (m *AgentBaseMutation) SetQ(s string) {
  1306. m.q = &s
  1307. }
  1308. // Q returns the value of the "q" field in the mutation.
  1309. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1310. v := m.q
  1311. if v == nil {
  1312. return
  1313. }
  1314. return *v, true
  1315. }
  1316. // OldQ returns the old "q" field's value of the AgentBase entity.
  1317. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1319. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1320. if !m.op.Is(OpUpdateOne) {
  1321. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1322. }
  1323. if m.id == nil || m.oldValue == nil {
  1324. return v, errors.New("OldQ requires an ID field in the mutation")
  1325. }
  1326. oldValue, err := m.oldValue(ctx)
  1327. if err != nil {
  1328. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1329. }
  1330. return oldValue.Q, nil
  1331. }
  1332. // ClearQ clears the value of the "q" field.
  1333. func (m *AgentBaseMutation) ClearQ() {
  1334. m.q = nil
  1335. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1336. }
  1337. // QCleared returns if the "q" field was cleared in this mutation.
  1338. func (m *AgentBaseMutation) QCleared() bool {
  1339. _, ok := m.clearedFields[agentbase.FieldQ]
  1340. return ok
  1341. }
  1342. // ResetQ resets all changes to the "q" field.
  1343. func (m *AgentBaseMutation) ResetQ() {
  1344. m.q = nil
  1345. delete(m.clearedFields, agentbase.FieldQ)
  1346. }
  1347. // SetA sets the "a" field.
  1348. func (m *AgentBaseMutation) SetA(s string) {
  1349. m.a = &s
  1350. }
  1351. // A returns the value of the "a" field in the mutation.
  1352. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1353. v := m.a
  1354. if v == nil {
  1355. return
  1356. }
  1357. return *v, true
  1358. }
  1359. // OldA returns the old "a" field's value of the AgentBase entity.
  1360. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1362. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1363. if !m.op.Is(OpUpdateOne) {
  1364. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1365. }
  1366. if m.id == nil || m.oldValue == nil {
  1367. return v, errors.New("OldA requires an ID field in the mutation")
  1368. }
  1369. oldValue, err := m.oldValue(ctx)
  1370. if err != nil {
  1371. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1372. }
  1373. return oldValue.A, nil
  1374. }
  1375. // ClearA clears the value of the "a" field.
  1376. func (m *AgentBaseMutation) ClearA() {
  1377. m.a = nil
  1378. m.clearedFields[agentbase.FieldA] = struct{}{}
  1379. }
  1380. // ACleared returns if the "a" field was cleared in this mutation.
  1381. func (m *AgentBaseMutation) ACleared() bool {
  1382. _, ok := m.clearedFields[agentbase.FieldA]
  1383. return ok
  1384. }
  1385. // ResetA resets all changes to the "a" field.
  1386. func (m *AgentBaseMutation) ResetA() {
  1387. m.a = nil
  1388. delete(m.clearedFields, agentbase.FieldA)
  1389. }
  1390. // SetChunkIndex sets the "chunk_index" field.
  1391. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1392. m.chunk_index = &u
  1393. m.addchunk_index = nil
  1394. }
  1395. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1396. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1397. v := m.chunk_index
  1398. if v == nil {
  1399. return
  1400. }
  1401. return *v, true
  1402. }
  1403. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1404. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1406. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1407. if !m.op.Is(OpUpdateOne) {
  1408. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1409. }
  1410. if m.id == nil || m.oldValue == nil {
  1411. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1412. }
  1413. oldValue, err := m.oldValue(ctx)
  1414. if err != nil {
  1415. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1416. }
  1417. return oldValue.ChunkIndex, nil
  1418. }
  1419. // AddChunkIndex adds u to the "chunk_index" field.
  1420. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1421. if m.addchunk_index != nil {
  1422. *m.addchunk_index += u
  1423. } else {
  1424. m.addchunk_index = &u
  1425. }
  1426. }
  1427. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1428. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1429. v := m.addchunk_index
  1430. if v == nil {
  1431. return
  1432. }
  1433. return *v, true
  1434. }
  1435. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1436. func (m *AgentBaseMutation) ResetChunkIndex() {
  1437. m.chunk_index = nil
  1438. m.addchunk_index = nil
  1439. }
  1440. // SetIndexes sets the "indexes" field.
  1441. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1442. m.indexes = &s
  1443. m.appendindexes = nil
  1444. }
  1445. // Indexes returns the value of the "indexes" field in the mutation.
  1446. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1447. v := m.indexes
  1448. if v == nil {
  1449. return
  1450. }
  1451. return *v, true
  1452. }
  1453. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1454. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1456. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1457. if !m.op.Is(OpUpdateOne) {
  1458. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1459. }
  1460. if m.id == nil || m.oldValue == nil {
  1461. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1462. }
  1463. oldValue, err := m.oldValue(ctx)
  1464. if err != nil {
  1465. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1466. }
  1467. return oldValue.Indexes, nil
  1468. }
  1469. // AppendIndexes adds s to the "indexes" field.
  1470. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1471. m.appendindexes = append(m.appendindexes, s...)
  1472. }
  1473. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1474. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1475. if len(m.appendindexes) == 0 {
  1476. return nil, false
  1477. }
  1478. return m.appendindexes, true
  1479. }
  1480. // ClearIndexes clears the value of the "indexes" field.
  1481. func (m *AgentBaseMutation) ClearIndexes() {
  1482. m.indexes = nil
  1483. m.appendindexes = nil
  1484. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1485. }
  1486. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1487. func (m *AgentBaseMutation) IndexesCleared() bool {
  1488. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1489. return ok
  1490. }
  1491. // ResetIndexes resets all changes to the "indexes" field.
  1492. func (m *AgentBaseMutation) ResetIndexes() {
  1493. m.indexes = nil
  1494. m.appendindexes = nil
  1495. delete(m.clearedFields, agentbase.FieldIndexes)
  1496. }
  1497. // SetDatasetID sets the "dataset_id" field.
  1498. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1499. m.dataset_id = &s
  1500. }
  1501. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1502. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1503. v := m.dataset_id
  1504. if v == nil {
  1505. return
  1506. }
  1507. return *v, true
  1508. }
  1509. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1510. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1512. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1513. if !m.op.Is(OpUpdateOne) {
  1514. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1515. }
  1516. if m.id == nil || m.oldValue == nil {
  1517. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1518. }
  1519. oldValue, err := m.oldValue(ctx)
  1520. if err != nil {
  1521. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1522. }
  1523. return oldValue.DatasetID, nil
  1524. }
  1525. // ClearDatasetID clears the value of the "dataset_id" field.
  1526. func (m *AgentBaseMutation) ClearDatasetID() {
  1527. m.dataset_id = nil
  1528. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1529. }
  1530. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1531. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1532. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1533. return ok
  1534. }
  1535. // ResetDatasetID resets all changes to the "dataset_id" field.
  1536. func (m *AgentBaseMutation) ResetDatasetID() {
  1537. m.dataset_id = nil
  1538. delete(m.clearedFields, agentbase.FieldDatasetID)
  1539. }
  1540. // SetCollectionID sets the "collection_id" field.
  1541. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1542. m.collection_id = &s
  1543. }
  1544. // CollectionID returns the value of the "collection_id" field in the mutation.
  1545. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1546. v := m.collection_id
  1547. if v == nil {
  1548. return
  1549. }
  1550. return *v, true
  1551. }
  1552. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1553. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1555. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1556. if !m.op.Is(OpUpdateOne) {
  1557. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1558. }
  1559. if m.id == nil || m.oldValue == nil {
  1560. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1561. }
  1562. oldValue, err := m.oldValue(ctx)
  1563. if err != nil {
  1564. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1565. }
  1566. return oldValue.CollectionID, nil
  1567. }
  1568. // ClearCollectionID clears the value of the "collection_id" field.
  1569. func (m *AgentBaseMutation) ClearCollectionID() {
  1570. m.collection_id = nil
  1571. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1572. }
  1573. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1574. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1575. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1576. return ok
  1577. }
  1578. // ResetCollectionID resets all changes to the "collection_id" field.
  1579. func (m *AgentBaseMutation) ResetCollectionID() {
  1580. m.collection_id = nil
  1581. delete(m.clearedFields, agentbase.FieldCollectionID)
  1582. }
  1583. // SetSourceName sets the "source_name" field.
  1584. func (m *AgentBaseMutation) SetSourceName(s string) {
  1585. m.source_name = &s
  1586. }
  1587. // SourceName returns the value of the "source_name" field in the mutation.
  1588. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1589. v := m.source_name
  1590. if v == nil {
  1591. return
  1592. }
  1593. return *v, true
  1594. }
  1595. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1596. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1598. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1599. if !m.op.Is(OpUpdateOne) {
  1600. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1601. }
  1602. if m.id == nil || m.oldValue == nil {
  1603. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1604. }
  1605. oldValue, err := m.oldValue(ctx)
  1606. if err != nil {
  1607. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1608. }
  1609. return oldValue.SourceName, nil
  1610. }
  1611. // ClearSourceName clears the value of the "source_name" field.
  1612. func (m *AgentBaseMutation) ClearSourceName() {
  1613. m.source_name = nil
  1614. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1615. }
  1616. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1617. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1618. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1619. return ok
  1620. }
  1621. // ResetSourceName resets all changes to the "source_name" field.
  1622. func (m *AgentBaseMutation) ResetSourceName() {
  1623. m.source_name = nil
  1624. delete(m.clearedFields, agentbase.FieldSourceName)
  1625. }
  1626. // SetCanWrite sets the "can_write" field.
  1627. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1628. m.can_write = &b
  1629. m.appendcan_write = nil
  1630. }
  1631. // CanWrite returns the value of the "can_write" field in the mutation.
  1632. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1633. v := m.can_write
  1634. if v == nil {
  1635. return
  1636. }
  1637. return *v, true
  1638. }
  1639. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1640. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1642. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1643. if !m.op.Is(OpUpdateOne) {
  1644. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1645. }
  1646. if m.id == nil || m.oldValue == nil {
  1647. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1648. }
  1649. oldValue, err := m.oldValue(ctx)
  1650. if err != nil {
  1651. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1652. }
  1653. return oldValue.CanWrite, nil
  1654. }
  1655. // AppendCanWrite adds b to the "can_write" field.
  1656. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1657. m.appendcan_write = append(m.appendcan_write, b...)
  1658. }
  1659. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1660. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1661. if len(m.appendcan_write) == 0 {
  1662. return nil, false
  1663. }
  1664. return m.appendcan_write, true
  1665. }
  1666. // ClearCanWrite clears the value of the "can_write" field.
  1667. func (m *AgentBaseMutation) ClearCanWrite() {
  1668. m.can_write = nil
  1669. m.appendcan_write = nil
  1670. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1671. }
  1672. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1673. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1674. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1675. return ok
  1676. }
  1677. // ResetCanWrite resets all changes to the "can_write" field.
  1678. func (m *AgentBaseMutation) ResetCanWrite() {
  1679. m.can_write = nil
  1680. m.appendcan_write = nil
  1681. delete(m.clearedFields, agentbase.FieldCanWrite)
  1682. }
  1683. // SetIsOwner sets the "is_owner" field.
  1684. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1685. m.is_owner = &b
  1686. m.appendis_owner = nil
  1687. }
  1688. // IsOwner returns the value of the "is_owner" field in the mutation.
  1689. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1690. v := m.is_owner
  1691. if v == nil {
  1692. return
  1693. }
  1694. return *v, true
  1695. }
  1696. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1697. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1699. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1700. if !m.op.Is(OpUpdateOne) {
  1701. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1702. }
  1703. if m.id == nil || m.oldValue == nil {
  1704. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1705. }
  1706. oldValue, err := m.oldValue(ctx)
  1707. if err != nil {
  1708. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1709. }
  1710. return oldValue.IsOwner, nil
  1711. }
  1712. // AppendIsOwner adds b to the "is_owner" field.
  1713. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1714. m.appendis_owner = append(m.appendis_owner, b...)
  1715. }
  1716. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1717. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1718. if len(m.appendis_owner) == 0 {
  1719. return nil, false
  1720. }
  1721. return m.appendis_owner, true
  1722. }
  1723. // ClearIsOwner clears the value of the "is_owner" field.
  1724. func (m *AgentBaseMutation) ClearIsOwner() {
  1725. m.is_owner = nil
  1726. m.appendis_owner = nil
  1727. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1728. }
  1729. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1730. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1731. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1732. return ok
  1733. }
  1734. // ResetIsOwner resets all changes to the "is_owner" field.
  1735. func (m *AgentBaseMutation) ResetIsOwner() {
  1736. m.is_owner = nil
  1737. m.appendis_owner = nil
  1738. delete(m.clearedFields, agentbase.FieldIsOwner)
  1739. }
  1740. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1741. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1742. if m.wx_agent == nil {
  1743. m.wx_agent = make(map[uint64]struct{})
  1744. }
  1745. for i := range ids {
  1746. m.wx_agent[ids[i]] = struct{}{}
  1747. }
  1748. }
  1749. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1750. func (m *AgentBaseMutation) ClearWxAgent() {
  1751. m.clearedwx_agent = true
  1752. }
  1753. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1754. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1755. return m.clearedwx_agent
  1756. }
  1757. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1758. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1759. if m.removedwx_agent == nil {
  1760. m.removedwx_agent = make(map[uint64]struct{})
  1761. }
  1762. for i := range ids {
  1763. delete(m.wx_agent, ids[i])
  1764. m.removedwx_agent[ids[i]] = struct{}{}
  1765. }
  1766. }
  1767. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1768. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1769. for id := range m.removedwx_agent {
  1770. ids = append(ids, id)
  1771. }
  1772. return
  1773. }
  1774. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1775. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1776. for id := range m.wx_agent {
  1777. ids = append(ids, id)
  1778. }
  1779. return
  1780. }
  1781. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1782. func (m *AgentBaseMutation) ResetWxAgent() {
  1783. m.wx_agent = nil
  1784. m.clearedwx_agent = false
  1785. m.removedwx_agent = nil
  1786. }
  1787. // Where appends a list predicates to the AgentBaseMutation builder.
  1788. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1789. m.predicates = append(m.predicates, ps...)
  1790. }
  1791. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1792. // users can use type-assertion to append predicates that do not depend on any generated package.
  1793. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1794. p := make([]predicate.AgentBase, len(ps))
  1795. for i := range ps {
  1796. p[i] = ps[i]
  1797. }
  1798. m.Where(p...)
  1799. }
  1800. // Op returns the operation name.
  1801. func (m *AgentBaseMutation) Op() Op {
  1802. return m.op
  1803. }
  1804. // SetOp allows setting the mutation operation.
  1805. func (m *AgentBaseMutation) SetOp(op Op) {
  1806. m.op = op
  1807. }
  1808. // Type returns the node type of this mutation (AgentBase).
  1809. func (m *AgentBaseMutation) Type() string {
  1810. return m.typ
  1811. }
  1812. // Fields returns all fields that were changed during this mutation. Note that in
  1813. // order to get all numeric fields that were incremented/decremented, call
  1814. // AddedFields().
  1815. func (m *AgentBaseMutation) Fields() []string {
  1816. fields := make([]string, 0, 9)
  1817. if m.q != nil {
  1818. fields = append(fields, agentbase.FieldQ)
  1819. }
  1820. if m.a != nil {
  1821. fields = append(fields, agentbase.FieldA)
  1822. }
  1823. if m.chunk_index != nil {
  1824. fields = append(fields, agentbase.FieldChunkIndex)
  1825. }
  1826. if m.indexes != nil {
  1827. fields = append(fields, agentbase.FieldIndexes)
  1828. }
  1829. if m.dataset_id != nil {
  1830. fields = append(fields, agentbase.FieldDatasetID)
  1831. }
  1832. if m.collection_id != nil {
  1833. fields = append(fields, agentbase.FieldCollectionID)
  1834. }
  1835. if m.source_name != nil {
  1836. fields = append(fields, agentbase.FieldSourceName)
  1837. }
  1838. if m.can_write != nil {
  1839. fields = append(fields, agentbase.FieldCanWrite)
  1840. }
  1841. if m.is_owner != nil {
  1842. fields = append(fields, agentbase.FieldIsOwner)
  1843. }
  1844. return fields
  1845. }
  1846. // Field returns the value of a field with the given name. The second boolean
  1847. // return value indicates that this field was not set, or was not defined in the
  1848. // schema.
  1849. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1850. switch name {
  1851. case agentbase.FieldQ:
  1852. return m.Q()
  1853. case agentbase.FieldA:
  1854. return m.A()
  1855. case agentbase.FieldChunkIndex:
  1856. return m.ChunkIndex()
  1857. case agentbase.FieldIndexes:
  1858. return m.Indexes()
  1859. case agentbase.FieldDatasetID:
  1860. return m.DatasetID()
  1861. case agentbase.FieldCollectionID:
  1862. return m.CollectionID()
  1863. case agentbase.FieldSourceName:
  1864. return m.SourceName()
  1865. case agentbase.FieldCanWrite:
  1866. return m.CanWrite()
  1867. case agentbase.FieldIsOwner:
  1868. return m.IsOwner()
  1869. }
  1870. return nil, false
  1871. }
  1872. // OldField returns the old value of the field from the database. An error is
  1873. // returned if the mutation operation is not UpdateOne, or the query to the
  1874. // database failed.
  1875. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1876. switch name {
  1877. case agentbase.FieldQ:
  1878. return m.OldQ(ctx)
  1879. case agentbase.FieldA:
  1880. return m.OldA(ctx)
  1881. case agentbase.FieldChunkIndex:
  1882. return m.OldChunkIndex(ctx)
  1883. case agentbase.FieldIndexes:
  1884. return m.OldIndexes(ctx)
  1885. case agentbase.FieldDatasetID:
  1886. return m.OldDatasetID(ctx)
  1887. case agentbase.FieldCollectionID:
  1888. return m.OldCollectionID(ctx)
  1889. case agentbase.FieldSourceName:
  1890. return m.OldSourceName(ctx)
  1891. case agentbase.FieldCanWrite:
  1892. return m.OldCanWrite(ctx)
  1893. case agentbase.FieldIsOwner:
  1894. return m.OldIsOwner(ctx)
  1895. }
  1896. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1897. }
  1898. // SetField sets the value of a field with the given name. It returns an error if
  1899. // the field is not defined in the schema, or if the type mismatched the field
  1900. // type.
  1901. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1902. switch name {
  1903. case agentbase.FieldQ:
  1904. v, ok := value.(string)
  1905. if !ok {
  1906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1907. }
  1908. m.SetQ(v)
  1909. return nil
  1910. case agentbase.FieldA:
  1911. v, ok := value.(string)
  1912. if !ok {
  1913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1914. }
  1915. m.SetA(v)
  1916. return nil
  1917. case agentbase.FieldChunkIndex:
  1918. v, ok := value.(uint64)
  1919. if !ok {
  1920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1921. }
  1922. m.SetChunkIndex(v)
  1923. return nil
  1924. case agentbase.FieldIndexes:
  1925. v, ok := value.([]string)
  1926. if !ok {
  1927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1928. }
  1929. m.SetIndexes(v)
  1930. return nil
  1931. case agentbase.FieldDatasetID:
  1932. v, ok := value.(string)
  1933. if !ok {
  1934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1935. }
  1936. m.SetDatasetID(v)
  1937. return nil
  1938. case agentbase.FieldCollectionID:
  1939. v, ok := value.(string)
  1940. if !ok {
  1941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1942. }
  1943. m.SetCollectionID(v)
  1944. return nil
  1945. case agentbase.FieldSourceName:
  1946. v, ok := value.(string)
  1947. if !ok {
  1948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1949. }
  1950. m.SetSourceName(v)
  1951. return nil
  1952. case agentbase.FieldCanWrite:
  1953. v, ok := value.([]bool)
  1954. if !ok {
  1955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1956. }
  1957. m.SetCanWrite(v)
  1958. return nil
  1959. case agentbase.FieldIsOwner:
  1960. v, ok := value.([]bool)
  1961. if !ok {
  1962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1963. }
  1964. m.SetIsOwner(v)
  1965. return nil
  1966. }
  1967. return fmt.Errorf("unknown AgentBase field %s", name)
  1968. }
  1969. // AddedFields returns all numeric fields that were incremented/decremented during
  1970. // this mutation.
  1971. func (m *AgentBaseMutation) AddedFields() []string {
  1972. var fields []string
  1973. if m.addchunk_index != nil {
  1974. fields = append(fields, agentbase.FieldChunkIndex)
  1975. }
  1976. return fields
  1977. }
  1978. // AddedField returns the numeric value that was incremented/decremented on a field
  1979. // with the given name. The second boolean return value indicates that this field
  1980. // was not set, or was not defined in the schema.
  1981. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1982. switch name {
  1983. case agentbase.FieldChunkIndex:
  1984. return m.AddedChunkIndex()
  1985. }
  1986. return nil, false
  1987. }
  1988. // AddField adds the value to the field with the given name. It returns an error if
  1989. // the field is not defined in the schema, or if the type mismatched the field
  1990. // type.
  1991. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1992. switch name {
  1993. case agentbase.FieldChunkIndex:
  1994. v, ok := value.(int64)
  1995. if !ok {
  1996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1997. }
  1998. m.AddChunkIndex(v)
  1999. return nil
  2000. }
  2001. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2002. }
  2003. // ClearedFields returns all nullable fields that were cleared during this
  2004. // mutation.
  2005. func (m *AgentBaseMutation) ClearedFields() []string {
  2006. var fields []string
  2007. if m.FieldCleared(agentbase.FieldQ) {
  2008. fields = append(fields, agentbase.FieldQ)
  2009. }
  2010. if m.FieldCleared(agentbase.FieldA) {
  2011. fields = append(fields, agentbase.FieldA)
  2012. }
  2013. if m.FieldCleared(agentbase.FieldIndexes) {
  2014. fields = append(fields, agentbase.FieldIndexes)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldDatasetID) {
  2017. fields = append(fields, agentbase.FieldDatasetID)
  2018. }
  2019. if m.FieldCleared(agentbase.FieldCollectionID) {
  2020. fields = append(fields, agentbase.FieldCollectionID)
  2021. }
  2022. if m.FieldCleared(agentbase.FieldSourceName) {
  2023. fields = append(fields, agentbase.FieldSourceName)
  2024. }
  2025. if m.FieldCleared(agentbase.FieldCanWrite) {
  2026. fields = append(fields, agentbase.FieldCanWrite)
  2027. }
  2028. if m.FieldCleared(agentbase.FieldIsOwner) {
  2029. fields = append(fields, agentbase.FieldIsOwner)
  2030. }
  2031. return fields
  2032. }
  2033. // FieldCleared returns a boolean indicating if a field with the given name was
  2034. // cleared in this mutation.
  2035. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2036. _, ok := m.clearedFields[name]
  2037. return ok
  2038. }
  2039. // ClearField clears the value of the field with the given name. It returns an
  2040. // error if the field is not defined in the schema.
  2041. func (m *AgentBaseMutation) ClearField(name string) error {
  2042. switch name {
  2043. case agentbase.FieldQ:
  2044. m.ClearQ()
  2045. return nil
  2046. case agentbase.FieldA:
  2047. m.ClearA()
  2048. return nil
  2049. case agentbase.FieldIndexes:
  2050. m.ClearIndexes()
  2051. return nil
  2052. case agentbase.FieldDatasetID:
  2053. m.ClearDatasetID()
  2054. return nil
  2055. case agentbase.FieldCollectionID:
  2056. m.ClearCollectionID()
  2057. return nil
  2058. case agentbase.FieldSourceName:
  2059. m.ClearSourceName()
  2060. return nil
  2061. case agentbase.FieldCanWrite:
  2062. m.ClearCanWrite()
  2063. return nil
  2064. case agentbase.FieldIsOwner:
  2065. m.ClearIsOwner()
  2066. return nil
  2067. }
  2068. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2069. }
  2070. // ResetField resets all changes in the mutation for the field with the given name.
  2071. // It returns an error if the field is not defined in the schema.
  2072. func (m *AgentBaseMutation) ResetField(name string) error {
  2073. switch name {
  2074. case agentbase.FieldQ:
  2075. m.ResetQ()
  2076. return nil
  2077. case agentbase.FieldA:
  2078. m.ResetA()
  2079. return nil
  2080. case agentbase.FieldChunkIndex:
  2081. m.ResetChunkIndex()
  2082. return nil
  2083. case agentbase.FieldIndexes:
  2084. m.ResetIndexes()
  2085. return nil
  2086. case agentbase.FieldDatasetID:
  2087. m.ResetDatasetID()
  2088. return nil
  2089. case agentbase.FieldCollectionID:
  2090. m.ResetCollectionID()
  2091. return nil
  2092. case agentbase.FieldSourceName:
  2093. m.ResetSourceName()
  2094. return nil
  2095. case agentbase.FieldCanWrite:
  2096. m.ResetCanWrite()
  2097. return nil
  2098. case agentbase.FieldIsOwner:
  2099. m.ResetIsOwner()
  2100. return nil
  2101. }
  2102. return fmt.Errorf("unknown AgentBase field %s", name)
  2103. }
  2104. // AddedEdges returns all edge names that were set/added in this mutation.
  2105. func (m *AgentBaseMutation) AddedEdges() []string {
  2106. edges := make([]string, 0, 1)
  2107. if m.wx_agent != nil {
  2108. edges = append(edges, agentbase.EdgeWxAgent)
  2109. }
  2110. return edges
  2111. }
  2112. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2113. // name in this mutation.
  2114. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2115. switch name {
  2116. case agentbase.EdgeWxAgent:
  2117. ids := make([]ent.Value, 0, len(m.wx_agent))
  2118. for id := range m.wx_agent {
  2119. ids = append(ids, id)
  2120. }
  2121. return ids
  2122. }
  2123. return nil
  2124. }
  2125. // RemovedEdges returns all edge names that were removed in this mutation.
  2126. func (m *AgentBaseMutation) RemovedEdges() []string {
  2127. edges := make([]string, 0, 1)
  2128. if m.removedwx_agent != nil {
  2129. edges = append(edges, agentbase.EdgeWxAgent)
  2130. }
  2131. return edges
  2132. }
  2133. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2134. // the given name in this mutation.
  2135. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2136. switch name {
  2137. case agentbase.EdgeWxAgent:
  2138. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2139. for id := range m.removedwx_agent {
  2140. ids = append(ids, id)
  2141. }
  2142. return ids
  2143. }
  2144. return nil
  2145. }
  2146. // ClearedEdges returns all edge names that were cleared in this mutation.
  2147. func (m *AgentBaseMutation) ClearedEdges() []string {
  2148. edges := make([]string, 0, 1)
  2149. if m.clearedwx_agent {
  2150. edges = append(edges, agentbase.EdgeWxAgent)
  2151. }
  2152. return edges
  2153. }
  2154. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2155. // was cleared in this mutation.
  2156. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2157. switch name {
  2158. case agentbase.EdgeWxAgent:
  2159. return m.clearedwx_agent
  2160. }
  2161. return false
  2162. }
  2163. // ClearEdge clears the value of the edge with the given name. It returns an error
  2164. // if that edge is not defined in the schema.
  2165. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2166. switch name {
  2167. }
  2168. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2169. }
  2170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2171. // It returns an error if the edge is not defined in the schema.
  2172. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2173. switch name {
  2174. case agentbase.EdgeWxAgent:
  2175. m.ResetWxAgent()
  2176. return nil
  2177. }
  2178. return fmt.Errorf("unknown AgentBase edge %s", name)
  2179. }
  2180. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2181. type AliyunAvatarMutation struct {
  2182. config
  2183. op Op
  2184. typ string
  2185. id *uint64
  2186. created_at *time.Time
  2187. updated_at *time.Time
  2188. deleted_at *time.Time
  2189. user_id *uint64
  2190. adduser_id *int64
  2191. biz_id *string
  2192. access_key_id *string
  2193. access_key_secret *string
  2194. app_id *string
  2195. tenant_id *uint64
  2196. addtenant_id *int64
  2197. response *string
  2198. token *string
  2199. session_id *string
  2200. clearedFields map[string]struct{}
  2201. done bool
  2202. oldValue func(context.Context) (*AliyunAvatar, error)
  2203. predicates []predicate.AliyunAvatar
  2204. }
  2205. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2206. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2207. type aliyunavatarOption func(*AliyunAvatarMutation)
  2208. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2209. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2210. m := &AliyunAvatarMutation{
  2211. config: c,
  2212. op: op,
  2213. typ: TypeAliyunAvatar,
  2214. clearedFields: make(map[string]struct{}),
  2215. }
  2216. for _, opt := range opts {
  2217. opt(m)
  2218. }
  2219. return m
  2220. }
  2221. // withAliyunAvatarID sets the ID field of the mutation.
  2222. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2223. return func(m *AliyunAvatarMutation) {
  2224. var (
  2225. err error
  2226. once sync.Once
  2227. value *AliyunAvatar
  2228. )
  2229. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2230. once.Do(func() {
  2231. if m.done {
  2232. err = errors.New("querying old values post mutation is not allowed")
  2233. } else {
  2234. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2235. }
  2236. })
  2237. return value, err
  2238. }
  2239. m.id = &id
  2240. }
  2241. }
  2242. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2243. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2244. return func(m *AliyunAvatarMutation) {
  2245. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2246. return node, nil
  2247. }
  2248. m.id = &node.ID
  2249. }
  2250. }
  2251. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2252. // executed in a transaction (ent.Tx), a transactional client is returned.
  2253. func (m AliyunAvatarMutation) Client() *Client {
  2254. client := &Client{config: m.config}
  2255. client.init()
  2256. return client
  2257. }
  2258. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2259. // it returns an error otherwise.
  2260. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2261. if _, ok := m.driver.(*txDriver); !ok {
  2262. return nil, errors.New("ent: mutation is not running in a transaction")
  2263. }
  2264. tx := &Tx{config: m.config}
  2265. tx.init()
  2266. return tx, nil
  2267. }
  2268. // SetID sets the value of the id field. Note that this
  2269. // operation is only accepted on creation of AliyunAvatar entities.
  2270. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2271. m.id = &id
  2272. }
  2273. // ID returns the ID value in the mutation. Note that the ID is only available
  2274. // if it was provided to the builder or after it was returned from the database.
  2275. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2276. if m.id == nil {
  2277. return
  2278. }
  2279. return *m.id, true
  2280. }
  2281. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2282. // That means, if the mutation is applied within a transaction with an isolation level such
  2283. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2284. // or updated by the mutation.
  2285. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2286. switch {
  2287. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2288. id, exists := m.ID()
  2289. if exists {
  2290. return []uint64{id}, nil
  2291. }
  2292. fallthrough
  2293. case m.op.Is(OpUpdate | OpDelete):
  2294. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2295. default:
  2296. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2297. }
  2298. }
  2299. // SetCreatedAt sets the "created_at" field.
  2300. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2301. m.created_at = &t
  2302. }
  2303. // CreatedAt returns the value of the "created_at" field in the mutation.
  2304. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2305. v := m.created_at
  2306. if v == nil {
  2307. return
  2308. }
  2309. return *v, true
  2310. }
  2311. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2312. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2314. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2315. if !m.op.Is(OpUpdateOne) {
  2316. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2317. }
  2318. if m.id == nil || m.oldValue == nil {
  2319. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2320. }
  2321. oldValue, err := m.oldValue(ctx)
  2322. if err != nil {
  2323. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2324. }
  2325. return oldValue.CreatedAt, nil
  2326. }
  2327. // ResetCreatedAt resets all changes to the "created_at" field.
  2328. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2329. m.created_at = nil
  2330. }
  2331. // SetUpdatedAt sets the "updated_at" field.
  2332. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2333. m.updated_at = &t
  2334. }
  2335. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2336. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2337. v := m.updated_at
  2338. if v == nil {
  2339. return
  2340. }
  2341. return *v, true
  2342. }
  2343. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2344. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2346. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2347. if !m.op.Is(OpUpdateOne) {
  2348. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2349. }
  2350. if m.id == nil || m.oldValue == nil {
  2351. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2352. }
  2353. oldValue, err := m.oldValue(ctx)
  2354. if err != nil {
  2355. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2356. }
  2357. return oldValue.UpdatedAt, nil
  2358. }
  2359. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2360. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2361. m.updated_at = nil
  2362. }
  2363. // SetDeletedAt sets the "deleted_at" field.
  2364. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2365. m.deleted_at = &t
  2366. }
  2367. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2368. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2369. v := m.deleted_at
  2370. if v == nil {
  2371. return
  2372. }
  2373. return *v, true
  2374. }
  2375. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2376. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2378. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2379. if !m.op.Is(OpUpdateOne) {
  2380. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2381. }
  2382. if m.id == nil || m.oldValue == nil {
  2383. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2384. }
  2385. oldValue, err := m.oldValue(ctx)
  2386. if err != nil {
  2387. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2388. }
  2389. return oldValue.DeletedAt, nil
  2390. }
  2391. // ClearDeletedAt clears the value of the "deleted_at" field.
  2392. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2393. m.deleted_at = nil
  2394. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2395. }
  2396. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2397. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2398. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2399. return ok
  2400. }
  2401. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2402. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2403. m.deleted_at = nil
  2404. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2405. }
  2406. // SetUserID sets the "user_id" field.
  2407. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2408. m.user_id = &u
  2409. m.adduser_id = nil
  2410. }
  2411. // UserID returns the value of the "user_id" field in the mutation.
  2412. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2413. v := m.user_id
  2414. if v == nil {
  2415. return
  2416. }
  2417. return *v, true
  2418. }
  2419. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2420. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2422. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2423. if !m.op.Is(OpUpdateOne) {
  2424. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2425. }
  2426. if m.id == nil || m.oldValue == nil {
  2427. return v, errors.New("OldUserID requires an ID field in the mutation")
  2428. }
  2429. oldValue, err := m.oldValue(ctx)
  2430. if err != nil {
  2431. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2432. }
  2433. return oldValue.UserID, nil
  2434. }
  2435. // AddUserID adds u to the "user_id" field.
  2436. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2437. if m.adduser_id != nil {
  2438. *m.adduser_id += u
  2439. } else {
  2440. m.adduser_id = &u
  2441. }
  2442. }
  2443. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2444. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2445. v := m.adduser_id
  2446. if v == nil {
  2447. return
  2448. }
  2449. return *v, true
  2450. }
  2451. // ResetUserID resets all changes to the "user_id" field.
  2452. func (m *AliyunAvatarMutation) ResetUserID() {
  2453. m.user_id = nil
  2454. m.adduser_id = nil
  2455. }
  2456. // SetBizID sets the "biz_id" field.
  2457. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2458. m.biz_id = &s
  2459. }
  2460. // BizID returns the value of the "biz_id" field in the mutation.
  2461. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2462. v := m.biz_id
  2463. if v == nil {
  2464. return
  2465. }
  2466. return *v, true
  2467. }
  2468. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2469. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2471. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2472. if !m.op.Is(OpUpdateOne) {
  2473. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2474. }
  2475. if m.id == nil || m.oldValue == nil {
  2476. return v, errors.New("OldBizID requires an ID field in the mutation")
  2477. }
  2478. oldValue, err := m.oldValue(ctx)
  2479. if err != nil {
  2480. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2481. }
  2482. return oldValue.BizID, nil
  2483. }
  2484. // ResetBizID resets all changes to the "biz_id" field.
  2485. func (m *AliyunAvatarMutation) ResetBizID() {
  2486. m.biz_id = nil
  2487. }
  2488. // SetAccessKeyID sets the "access_key_id" field.
  2489. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2490. m.access_key_id = &s
  2491. }
  2492. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2493. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2494. v := m.access_key_id
  2495. if v == nil {
  2496. return
  2497. }
  2498. return *v, true
  2499. }
  2500. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2501. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2503. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2504. if !m.op.Is(OpUpdateOne) {
  2505. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2506. }
  2507. if m.id == nil || m.oldValue == nil {
  2508. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2509. }
  2510. oldValue, err := m.oldValue(ctx)
  2511. if err != nil {
  2512. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2513. }
  2514. return oldValue.AccessKeyID, nil
  2515. }
  2516. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2517. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2518. m.access_key_id = nil
  2519. }
  2520. // SetAccessKeySecret sets the "access_key_secret" field.
  2521. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2522. m.access_key_secret = &s
  2523. }
  2524. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2525. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2526. v := m.access_key_secret
  2527. if v == nil {
  2528. return
  2529. }
  2530. return *v, true
  2531. }
  2532. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2533. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2535. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2536. if !m.op.Is(OpUpdateOne) {
  2537. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2538. }
  2539. if m.id == nil || m.oldValue == nil {
  2540. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2541. }
  2542. oldValue, err := m.oldValue(ctx)
  2543. if err != nil {
  2544. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2545. }
  2546. return oldValue.AccessKeySecret, nil
  2547. }
  2548. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2549. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2550. m.access_key_secret = nil
  2551. }
  2552. // SetAppID sets the "app_id" field.
  2553. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2554. m.app_id = &s
  2555. }
  2556. // AppID returns the value of the "app_id" field in the mutation.
  2557. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2558. v := m.app_id
  2559. if v == nil {
  2560. return
  2561. }
  2562. return *v, true
  2563. }
  2564. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2565. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2567. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2568. if !m.op.Is(OpUpdateOne) {
  2569. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2570. }
  2571. if m.id == nil || m.oldValue == nil {
  2572. return v, errors.New("OldAppID requires an ID field in the mutation")
  2573. }
  2574. oldValue, err := m.oldValue(ctx)
  2575. if err != nil {
  2576. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2577. }
  2578. return oldValue.AppID, nil
  2579. }
  2580. // ClearAppID clears the value of the "app_id" field.
  2581. func (m *AliyunAvatarMutation) ClearAppID() {
  2582. m.app_id = nil
  2583. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2584. }
  2585. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2586. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2587. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2588. return ok
  2589. }
  2590. // ResetAppID resets all changes to the "app_id" field.
  2591. func (m *AliyunAvatarMutation) ResetAppID() {
  2592. m.app_id = nil
  2593. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2594. }
  2595. // SetTenantID sets the "tenant_id" field.
  2596. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2597. m.tenant_id = &u
  2598. m.addtenant_id = nil
  2599. }
  2600. // TenantID returns the value of the "tenant_id" field in the mutation.
  2601. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2602. v := m.tenant_id
  2603. if v == nil {
  2604. return
  2605. }
  2606. return *v, true
  2607. }
  2608. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2609. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2611. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2612. if !m.op.Is(OpUpdateOne) {
  2613. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2614. }
  2615. if m.id == nil || m.oldValue == nil {
  2616. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2617. }
  2618. oldValue, err := m.oldValue(ctx)
  2619. if err != nil {
  2620. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2621. }
  2622. return oldValue.TenantID, nil
  2623. }
  2624. // AddTenantID adds u to the "tenant_id" field.
  2625. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2626. if m.addtenant_id != nil {
  2627. *m.addtenant_id += u
  2628. } else {
  2629. m.addtenant_id = &u
  2630. }
  2631. }
  2632. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2633. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2634. v := m.addtenant_id
  2635. if v == nil {
  2636. return
  2637. }
  2638. return *v, true
  2639. }
  2640. // ResetTenantID resets all changes to the "tenant_id" field.
  2641. func (m *AliyunAvatarMutation) ResetTenantID() {
  2642. m.tenant_id = nil
  2643. m.addtenant_id = nil
  2644. }
  2645. // SetResponse sets the "response" field.
  2646. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2647. m.response = &s
  2648. }
  2649. // Response returns the value of the "response" field in the mutation.
  2650. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2651. v := m.response
  2652. if v == nil {
  2653. return
  2654. }
  2655. return *v, true
  2656. }
  2657. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2658. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2660. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2661. if !m.op.Is(OpUpdateOne) {
  2662. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2663. }
  2664. if m.id == nil || m.oldValue == nil {
  2665. return v, errors.New("OldResponse requires an ID field in the mutation")
  2666. }
  2667. oldValue, err := m.oldValue(ctx)
  2668. if err != nil {
  2669. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2670. }
  2671. return oldValue.Response, nil
  2672. }
  2673. // ResetResponse resets all changes to the "response" field.
  2674. func (m *AliyunAvatarMutation) ResetResponse() {
  2675. m.response = nil
  2676. }
  2677. // SetToken sets the "token" field.
  2678. func (m *AliyunAvatarMutation) SetToken(s string) {
  2679. m.token = &s
  2680. }
  2681. // Token returns the value of the "token" field in the mutation.
  2682. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2683. v := m.token
  2684. if v == nil {
  2685. return
  2686. }
  2687. return *v, true
  2688. }
  2689. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2690. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2692. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2693. if !m.op.Is(OpUpdateOne) {
  2694. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2695. }
  2696. if m.id == nil || m.oldValue == nil {
  2697. return v, errors.New("OldToken requires an ID field in the mutation")
  2698. }
  2699. oldValue, err := m.oldValue(ctx)
  2700. if err != nil {
  2701. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2702. }
  2703. return oldValue.Token, nil
  2704. }
  2705. // ResetToken resets all changes to the "token" field.
  2706. func (m *AliyunAvatarMutation) ResetToken() {
  2707. m.token = nil
  2708. }
  2709. // SetSessionID sets the "session_id" field.
  2710. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2711. m.session_id = &s
  2712. }
  2713. // SessionID returns the value of the "session_id" field in the mutation.
  2714. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2715. v := m.session_id
  2716. if v == nil {
  2717. return
  2718. }
  2719. return *v, true
  2720. }
  2721. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2722. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2724. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2725. if !m.op.Is(OpUpdateOne) {
  2726. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2727. }
  2728. if m.id == nil || m.oldValue == nil {
  2729. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2730. }
  2731. oldValue, err := m.oldValue(ctx)
  2732. if err != nil {
  2733. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2734. }
  2735. return oldValue.SessionID, nil
  2736. }
  2737. // ResetSessionID resets all changes to the "session_id" field.
  2738. func (m *AliyunAvatarMutation) ResetSessionID() {
  2739. m.session_id = nil
  2740. }
  2741. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2742. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2743. m.predicates = append(m.predicates, ps...)
  2744. }
  2745. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2746. // users can use type-assertion to append predicates that do not depend on any generated package.
  2747. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2748. p := make([]predicate.AliyunAvatar, len(ps))
  2749. for i := range ps {
  2750. p[i] = ps[i]
  2751. }
  2752. m.Where(p...)
  2753. }
  2754. // Op returns the operation name.
  2755. func (m *AliyunAvatarMutation) Op() Op {
  2756. return m.op
  2757. }
  2758. // SetOp allows setting the mutation operation.
  2759. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2760. m.op = op
  2761. }
  2762. // Type returns the node type of this mutation (AliyunAvatar).
  2763. func (m *AliyunAvatarMutation) Type() string {
  2764. return m.typ
  2765. }
  2766. // Fields returns all fields that were changed during this mutation. Note that in
  2767. // order to get all numeric fields that were incremented/decremented, call
  2768. // AddedFields().
  2769. func (m *AliyunAvatarMutation) Fields() []string {
  2770. fields := make([]string, 0, 12)
  2771. if m.created_at != nil {
  2772. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2773. }
  2774. if m.updated_at != nil {
  2775. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2776. }
  2777. if m.deleted_at != nil {
  2778. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2779. }
  2780. if m.user_id != nil {
  2781. fields = append(fields, aliyunavatar.FieldUserID)
  2782. }
  2783. if m.biz_id != nil {
  2784. fields = append(fields, aliyunavatar.FieldBizID)
  2785. }
  2786. if m.access_key_id != nil {
  2787. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2788. }
  2789. if m.access_key_secret != nil {
  2790. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2791. }
  2792. if m.app_id != nil {
  2793. fields = append(fields, aliyunavatar.FieldAppID)
  2794. }
  2795. if m.tenant_id != nil {
  2796. fields = append(fields, aliyunavatar.FieldTenantID)
  2797. }
  2798. if m.response != nil {
  2799. fields = append(fields, aliyunavatar.FieldResponse)
  2800. }
  2801. if m.token != nil {
  2802. fields = append(fields, aliyunavatar.FieldToken)
  2803. }
  2804. if m.session_id != nil {
  2805. fields = append(fields, aliyunavatar.FieldSessionID)
  2806. }
  2807. return fields
  2808. }
  2809. // Field returns the value of a field with the given name. The second boolean
  2810. // return value indicates that this field was not set, or was not defined in the
  2811. // schema.
  2812. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2813. switch name {
  2814. case aliyunavatar.FieldCreatedAt:
  2815. return m.CreatedAt()
  2816. case aliyunavatar.FieldUpdatedAt:
  2817. return m.UpdatedAt()
  2818. case aliyunavatar.FieldDeletedAt:
  2819. return m.DeletedAt()
  2820. case aliyunavatar.FieldUserID:
  2821. return m.UserID()
  2822. case aliyunavatar.FieldBizID:
  2823. return m.BizID()
  2824. case aliyunavatar.FieldAccessKeyID:
  2825. return m.AccessKeyID()
  2826. case aliyunavatar.FieldAccessKeySecret:
  2827. return m.AccessKeySecret()
  2828. case aliyunavatar.FieldAppID:
  2829. return m.AppID()
  2830. case aliyunavatar.FieldTenantID:
  2831. return m.TenantID()
  2832. case aliyunavatar.FieldResponse:
  2833. return m.Response()
  2834. case aliyunavatar.FieldToken:
  2835. return m.Token()
  2836. case aliyunavatar.FieldSessionID:
  2837. return m.SessionID()
  2838. }
  2839. return nil, false
  2840. }
  2841. // OldField returns the old value of the field from the database. An error is
  2842. // returned if the mutation operation is not UpdateOne, or the query to the
  2843. // database failed.
  2844. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2845. switch name {
  2846. case aliyunavatar.FieldCreatedAt:
  2847. return m.OldCreatedAt(ctx)
  2848. case aliyunavatar.FieldUpdatedAt:
  2849. return m.OldUpdatedAt(ctx)
  2850. case aliyunavatar.FieldDeletedAt:
  2851. return m.OldDeletedAt(ctx)
  2852. case aliyunavatar.FieldUserID:
  2853. return m.OldUserID(ctx)
  2854. case aliyunavatar.FieldBizID:
  2855. return m.OldBizID(ctx)
  2856. case aliyunavatar.FieldAccessKeyID:
  2857. return m.OldAccessKeyID(ctx)
  2858. case aliyunavatar.FieldAccessKeySecret:
  2859. return m.OldAccessKeySecret(ctx)
  2860. case aliyunavatar.FieldAppID:
  2861. return m.OldAppID(ctx)
  2862. case aliyunavatar.FieldTenantID:
  2863. return m.OldTenantID(ctx)
  2864. case aliyunavatar.FieldResponse:
  2865. return m.OldResponse(ctx)
  2866. case aliyunavatar.FieldToken:
  2867. return m.OldToken(ctx)
  2868. case aliyunavatar.FieldSessionID:
  2869. return m.OldSessionID(ctx)
  2870. }
  2871. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2872. }
  2873. // SetField sets the value of a field with the given name. It returns an error if
  2874. // the field is not defined in the schema, or if the type mismatched the field
  2875. // type.
  2876. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2877. switch name {
  2878. case aliyunavatar.FieldCreatedAt:
  2879. v, ok := value.(time.Time)
  2880. if !ok {
  2881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2882. }
  2883. m.SetCreatedAt(v)
  2884. return nil
  2885. case aliyunavatar.FieldUpdatedAt:
  2886. v, ok := value.(time.Time)
  2887. if !ok {
  2888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2889. }
  2890. m.SetUpdatedAt(v)
  2891. return nil
  2892. case aliyunavatar.FieldDeletedAt:
  2893. v, ok := value.(time.Time)
  2894. if !ok {
  2895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2896. }
  2897. m.SetDeletedAt(v)
  2898. return nil
  2899. case aliyunavatar.FieldUserID:
  2900. v, ok := value.(uint64)
  2901. if !ok {
  2902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2903. }
  2904. m.SetUserID(v)
  2905. return nil
  2906. case aliyunavatar.FieldBizID:
  2907. v, ok := value.(string)
  2908. if !ok {
  2909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2910. }
  2911. m.SetBizID(v)
  2912. return nil
  2913. case aliyunavatar.FieldAccessKeyID:
  2914. v, ok := value.(string)
  2915. if !ok {
  2916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2917. }
  2918. m.SetAccessKeyID(v)
  2919. return nil
  2920. case aliyunavatar.FieldAccessKeySecret:
  2921. v, ok := value.(string)
  2922. if !ok {
  2923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2924. }
  2925. m.SetAccessKeySecret(v)
  2926. return nil
  2927. case aliyunavatar.FieldAppID:
  2928. v, ok := value.(string)
  2929. if !ok {
  2930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2931. }
  2932. m.SetAppID(v)
  2933. return nil
  2934. case aliyunavatar.FieldTenantID:
  2935. v, ok := value.(uint64)
  2936. if !ok {
  2937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2938. }
  2939. m.SetTenantID(v)
  2940. return nil
  2941. case aliyunavatar.FieldResponse:
  2942. v, ok := value.(string)
  2943. if !ok {
  2944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2945. }
  2946. m.SetResponse(v)
  2947. return nil
  2948. case aliyunavatar.FieldToken:
  2949. v, ok := value.(string)
  2950. if !ok {
  2951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2952. }
  2953. m.SetToken(v)
  2954. return nil
  2955. case aliyunavatar.FieldSessionID:
  2956. v, ok := value.(string)
  2957. if !ok {
  2958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2959. }
  2960. m.SetSessionID(v)
  2961. return nil
  2962. }
  2963. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2964. }
  2965. // AddedFields returns all numeric fields that were incremented/decremented during
  2966. // this mutation.
  2967. func (m *AliyunAvatarMutation) AddedFields() []string {
  2968. var fields []string
  2969. if m.adduser_id != nil {
  2970. fields = append(fields, aliyunavatar.FieldUserID)
  2971. }
  2972. if m.addtenant_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldTenantID)
  2974. }
  2975. return fields
  2976. }
  2977. // AddedField returns the numeric value that was incremented/decremented on a field
  2978. // with the given name. The second boolean return value indicates that this field
  2979. // was not set, or was not defined in the schema.
  2980. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldUserID:
  2983. return m.AddedUserID()
  2984. case aliyunavatar.FieldTenantID:
  2985. return m.AddedTenantID()
  2986. }
  2987. return nil, false
  2988. }
  2989. // AddField adds the value to the field with the given name. It returns an error if
  2990. // the field is not defined in the schema, or if the type mismatched the field
  2991. // type.
  2992. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2993. switch name {
  2994. case aliyunavatar.FieldUserID:
  2995. v, ok := value.(int64)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.AddUserID(v)
  3000. return nil
  3001. case aliyunavatar.FieldTenantID:
  3002. v, ok := value.(int64)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.AddTenantID(v)
  3007. return nil
  3008. }
  3009. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3010. }
  3011. // ClearedFields returns all nullable fields that were cleared during this
  3012. // mutation.
  3013. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3014. var fields []string
  3015. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3016. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3017. }
  3018. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3019. fields = append(fields, aliyunavatar.FieldAppID)
  3020. }
  3021. return fields
  3022. }
  3023. // FieldCleared returns a boolean indicating if a field with the given name was
  3024. // cleared in this mutation.
  3025. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3026. _, ok := m.clearedFields[name]
  3027. return ok
  3028. }
  3029. // ClearField clears the value of the field with the given name. It returns an
  3030. // error if the field is not defined in the schema.
  3031. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3032. switch name {
  3033. case aliyunavatar.FieldDeletedAt:
  3034. m.ClearDeletedAt()
  3035. return nil
  3036. case aliyunavatar.FieldAppID:
  3037. m.ClearAppID()
  3038. return nil
  3039. }
  3040. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3041. }
  3042. // ResetField resets all changes in the mutation for the field with the given name.
  3043. // It returns an error if the field is not defined in the schema.
  3044. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. m.ResetCreatedAt()
  3048. return nil
  3049. case aliyunavatar.FieldUpdatedAt:
  3050. m.ResetUpdatedAt()
  3051. return nil
  3052. case aliyunavatar.FieldDeletedAt:
  3053. m.ResetDeletedAt()
  3054. return nil
  3055. case aliyunavatar.FieldUserID:
  3056. m.ResetUserID()
  3057. return nil
  3058. case aliyunavatar.FieldBizID:
  3059. m.ResetBizID()
  3060. return nil
  3061. case aliyunavatar.FieldAccessKeyID:
  3062. m.ResetAccessKeyID()
  3063. return nil
  3064. case aliyunavatar.FieldAccessKeySecret:
  3065. m.ResetAccessKeySecret()
  3066. return nil
  3067. case aliyunavatar.FieldAppID:
  3068. m.ResetAppID()
  3069. return nil
  3070. case aliyunavatar.FieldTenantID:
  3071. m.ResetTenantID()
  3072. return nil
  3073. case aliyunavatar.FieldResponse:
  3074. m.ResetResponse()
  3075. return nil
  3076. case aliyunavatar.FieldToken:
  3077. m.ResetToken()
  3078. return nil
  3079. case aliyunavatar.FieldSessionID:
  3080. m.ResetSessionID()
  3081. return nil
  3082. }
  3083. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3084. }
  3085. // AddedEdges returns all edge names that were set/added in this mutation.
  3086. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3087. edges := make([]string, 0, 0)
  3088. return edges
  3089. }
  3090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3091. // name in this mutation.
  3092. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3093. return nil
  3094. }
  3095. // RemovedEdges returns all edge names that were removed in this mutation.
  3096. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3097. edges := make([]string, 0, 0)
  3098. return edges
  3099. }
  3100. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3101. // the given name in this mutation.
  3102. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3103. return nil
  3104. }
  3105. // ClearedEdges returns all edge names that were cleared in this mutation.
  3106. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3107. edges := make([]string, 0, 0)
  3108. return edges
  3109. }
  3110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3111. // was cleared in this mutation.
  3112. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3113. return false
  3114. }
  3115. // ClearEdge clears the value of the edge with the given name. It returns an error
  3116. // if that edge is not defined in the schema.
  3117. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3118. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3119. }
  3120. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3121. // It returns an error if the edge is not defined in the schema.
  3122. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3123. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3124. }
  3125. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3126. type BatchMsgMutation struct {
  3127. config
  3128. op Op
  3129. typ string
  3130. id *uint64
  3131. created_at *time.Time
  3132. updated_at *time.Time
  3133. deleted_at *time.Time
  3134. status *uint8
  3135. addstatus *int8
  3136. batch_no *string
  3137. task_name *string
  3138. fromwxid *string
  3139. msg *string
  3140. tag *string
  3141. tagids *string
  3142. total *int32
  3143. addtotal *int32
  3144. success *int32
  3145. addsuccess *int32
  3146. fail *int32
  3147. addfail *int32
  3148. start_time *time.Time
  3149. stop_time *time.Time
  3150. send_time *time.Time
  3151. _type *int32
  3152. add_type *int32
  3153. organization_id *uint64
  3154. addorganization_id *int64
  3155. clearedFields map[string]struct{}
  3156. done bool
  3157. oldValue func(context.Context) (*BatchMsg, error)
  3158. predicates []predicate.BatchMsg
  3159. }
  3160. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3161. // batchmsgOption allows management of the mutation configuration using functional options.
  3162. type batchmsgOption func(*BatchMsgMutation)
  3163. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3164. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3165. m := &BatchMsgMutation{
  3166. config: c,
  3167. op: op,
  3168. typ: TypeBatchMsg,
  3169. clearedFields: make(map[string]struct{}),
  3170. }
  3171. for _, opt := range opts {
  3172. opt(m)
  3173. }
  3174. return m
  3175. }
  3176. // withBatchMsgID sets the ID field of the mutation.
  3177. func withBatchMsgID(id uint64) batchmsgOption {
  3178. return func(m *BatchMsgMutation) {
  3179. var (
  3180. err error
  3181. once sync.Once
  3182. value *BatchMsg
  3183. )
  3184. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3185. once.Do(func() {
  3186. if m.done {
  3187. err = errors.New("querying old values post mutation is not allowed")
  3188. } else {
  3189. value, err = m.Client().BatchMsg.Get(ctx, id)
  3190. }
  3191. })
  3192. return value, err
  3193. }
  3194. m.id = &id
  3195. }
  3196. }
  3197. // withBatchMsg sets the old BatchMsg of the mutation.
  3198. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3199. return func(m *BatchMsgMutation) {
  3200. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3201. return node, nil
  3202. }
  3203. m.id = &node.ID
  3204. }
  3205. }
  3206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3207. // executed in a transaction (ent.Tx), a transactional client is returned.
  3208. func (m BatchMsgMutation) Client() *Client {
  3209. client := &Client{config: m.config}
  3210. client.init()
  3211. return client
  3212. }
  3213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3214. // it returns an error otherwise.
  3215. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3216. if _, ok := m.driver.(*txDriver); !ok {
  3217. return nil, errors.New("ent: mutation is not running in a transaction")
  3218. }
  3219. tx := &Tx{config: m.config}
  3220. tx.init()
  3221. return tx, nil
  3222. }
  3223. // SetID sets the value of the id field. Note that this
  3224. // operation is only accepted on creation of BatchMsg entities.
  3225. func (m *BatchMsgMutation) SetID(id uint64) {
  3226. m.id = &id
  3227. }
  3228. // ID returns the ID value in the mutation. Note that the ID is only available
  3229. // if it was provided to the builder or after it was returned from the database.
  3230. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3231. if m.id == nil {
  3232. return
  3233. }
  3234. return *m.id, true
  3235. }
  3236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3237. // That means, if the mutation is applied within a transaction with an isolation level such
  3238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3239. // or updated by the mutation.
  3240. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3241. switch {
  3242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3243. id, exists := m.ID()
  3244. if exists {
  3245. return []uint64{id}, nil
  3246. }
  3247. fallthrough
  3248. case m.op.Is(OpUpdate | OpDelete):
  3249. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3250. default:
  3251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3252. }
  3253. }
  3254. // SetCreatedAt sets the "created_at" field.
  3255. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3256. m.created_at = &t
  3257. }
  3258. // CreatedAt returns the value of the "created_at" field in the mutation.
  3259. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3260. v := m.created_at
  3261. if v == nil {
  3262. return
  3263. }
  3264. return *v, true
  3265. }
  3266. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3267. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3269. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3270. if !m.op.Is(OpUpdateOne) {
  3271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3272. }
  3273. if m.id == nil || m.oldValue == nil {
  3274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3275. }
  3276. oldValue, err := m.oldValue(ctx)
  3277. if err != nil {
  3278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3279. }
  3280. return oldValue.CreatedAt, nil
  3281. }
  3282. // ResetCreatedAt resets all changes to the "created_at" field.
  3283. func (m *BatchMsgMutation) ResetCreatedAt() {
  3284. m.created_at = nil
  3285. }
  3286. // SetUpdatedAt sets the "updated_at" field.
  3287. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3288. m.updated_at = &t
  3289. }
  3290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3291. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3292. v := m.updated_at
  3293. if v == nil {
  3294. return
  3295. }
  3296. return *v, true
  3297. }
  3298. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3299. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3301. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3302. if !m.op.Is(OpUpdateOne) {
  3303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3304. }
  3305. if m.id == nil || m.oldValue == nil {
  3306. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3307. }
  3308. oldValue, err := m.oldValue(ctx)
  3309. if err != nil {
  3310. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3311. }
  3312. return oldValue.UpdatedAt, nil
  3313. }
  3314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3315. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3316. m.updated_at = nil
  3317. }
  3318. // SetDeletedAt sets the "deleted_at" field.
  3319. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3320. m.deleted_at = &t
  3321. }
  3322. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3323. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3324. v := m.deleted_at
  3325. if v == nil {
  3326. return
  3327. }
  3328. return *v, true
  3329. }
  3330. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3331. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3333. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3334. if !m.op.Is(OpUpdateOne) {
  3335. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3336. }
  3337. if m.id == nil || m.oldValue == nil {
  3338. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3339. }
  3340. oldValue, err := m.oldValue(ctx)
  3341. if err != nil {
  3342. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3343. }
  3344. return oldValue.DeletedAt, nil
  3345. }
  3346. // ClearDeletedAt clears the value of the "deleted_at" field.
  3347. func (m *BatchMsgMutation) ClearDeletedAt() {
  3348. m.deleted_at = nil
  3349. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3350. }
  3351. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3352. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3353. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3354. return ok
  3355. }
  3356. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3357. func (m *BatchMsgMutation) ResetDeletedAt() {
  3358. m.deleted_at = nil
  3359. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3360. }
  3361. // SetStatus sets the "status" field.
  3362. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3363. m.status = &u
  3364. m.addstatus = nil
  3365. }
  3366. // Status returns the value of the "status" field in the mutation.
  3367. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3368. v := m.status
  3369. if v == nil {
  3370. return
  3371. }
  3372. return *v, true
  3373. }
  3374. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3375. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3377. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3378. if !m.op.Is(OpUpdateOne) {
  3379. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3380. }
  3381. if m.id == nil || m.oldValue == nil {
  3382. return v, errors.New("OldStatus requires an ID field in the mutation")
  3383. }
  3384. oldValue, err := m.oldValue(ctx)
  3385. if err != nil {
  3386. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3387. }
  3388. return oldValue.Status, nil
  3389. }
  3390. // AddStatus adds u to the "status" field.
  3391. func (m *BatchMsgMutation) AddStatus(u int8) {
  3392. if m.addstatus != nil {
  3393. *m.addstatus += u
  3394. } else {
  3395. m.addstatus = &u
  3396. }
  3397. }
  3398. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3399. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3400. v := m.addstatus
  3401. if v == nil {
  3402. return
  3403. }
  3404. return *v, true
  3405. }
  3406. // ClearStatus clears the value of the "status" field.
  3407. func (m *BatchMsgMutation) ClearStatus() {
  3408. m.status = nil
  3409. m.addstatus = nil
  3410. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3411. }
  3412. // StatusCleared returns if the "status" field was cleared in this mutation.
  3413. func (m *BatchMsgMutation) StatusCleared() bool {
  3414. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3415. return ok
  3416. }
  3417. // ResetStatus resets all changes to the "status" field.
  3418. func (m *BatchMsgMutation) ResetStatus() {
  3419. m.status = nil
  3420. m.addstatus = nil
  3421. delete(m.clearedFields, batchmsg.FieldStatus)
  3422. }
  3423. // SetBatchNo sets the "batch_no" field.
  3424. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3425. m.batch_no = &s
  3426. }
  3427. // BatchNo returns the value of the "batch_no" field in the mutation.
  3428. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3429. v := m.batch_no
  3430. if v == nil {
  3431. return
  3432. }
  3433. return *v, true
  3434. }
  3435. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3436. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3438. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3439. if !m.op.Is(OpUpdateOne) {
  3440. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3441. }
  3442. if m.id == nil || m.oldValue == nil {
  3443. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3444. }
  3445. oldValue, err := m.oldValue(ctx)
  3446. if err != nil {
  3447. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3448. }
  3449. return oldValue.BatchNo, nil
  3450. }
  3451. // ClearBatchNo clears the value of the "batch_no" field.
  3452. func (m *BatchMsgMutation) ClearBatchNo() {
  3453. m.batch_no = nil
  3454. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3455. }
  3456. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3457. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3458. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3459. return ok
  3460. }
  3461. // ResetBatchNo resets all changes to the "batch_no" field.
  3462. func (m *BatchMsgMutation) ResetBatchNo() {
  3463. m.batch_no = nil
  3464. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3465. }
  3466. // SetTaskName sets the "task_name" field.
  3467. func (m *BatchMsgMutation) SetTaskName(s string) {
  3468. m.task_name = &s
  3469. }
  3470. // TaskName returns the value of the "task_name" field in the mutation.
  3471. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3472. v := m.task_name
  3473. if v == nil {
  3474. return
  3475. }
  3476. return *v, true
  3477. }
  3478. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3479. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3481. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3482. if !m.op.Is(OpUpdateOne) {
  3483. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3484. }
  3485. if m.id == nil || m.oldValue == nil {
  3486. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3487. }
  3488. oldValue, err := m.oldValue(ctx)
  3489. if err != nil {
  3490. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3491. }
  3492. return oldValue.TaskName, nil
  3493. }
  3494. // ClearTaskName clears the value of the "task_name" field.
  3495. func (m *BatchMsgMutation) ClearTaskName() {
  3496. m.task_name = nil
  3497. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3498. }
  3499. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3500. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3501. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3502. return ok
  3503. }
  3504. // ResetTaskName resets all changes to the "task_name" field.
  3505. func (m *BatchMsgMutation) ResetTaskName() {
  3506. m.task_name = nil
  3507. delete(m.clearedFields, batchmsg.FieldTaskName)
  3508. }
  3509. // SetFromwxid sets the "fromwxid" field.
  3510. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3511. m.fromwxid = &s
  3512. }
  3513. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3514. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3515. v := m.fromwxid
  3516. if v == nil {
  3517. return
  3518. }
  3519. return *v, true
  3520. }
  3521. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3522. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3524. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3525. if !m.op.Is(OpUpdateOne) {
  3526. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3527. }
  3528. if m.id == nil || m.oldValue == nil {
  3529. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3530. }
  3531. oldValue, err := m.oldValue(ctx)
  3532. if err != nil {
  3533. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3534. }
  3535. return oldValue.Fromwxid, nil
  3536. }
  3537. // ClearFromwxid clears the value of the "fromwxid" field.
  3538. func (m *BatchMsgMutation) ClearFromwxid() {
  3539. m.fromwxid = nil
  3540. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3541. }
  3542. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3543. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3544. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3545. return ok
  3546. }
  3547. // ResetFromwxid resets all changes to the "fromwxid" field.
  3548. func (m *BatchMsgMutation) ResetFromwxid() {
  3549. m.fromwxid = nil
  3550. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3551. }
  3552. // SetMsg sets the "msg" field.
  3553. func (m *BatchMsgMutation) SetMsg(s string) {
  3554. m.msg = &s
  3555. }
  3556. // Msg returns the value of the "msg" field in the mutation.
  3557. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3558. v := m.msg
  3559. if v == nil {
  3560. return
  3561. }
  3562. return *v, true
  3563. }
  3564. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3565. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3567. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3568. if !m.op.Is(OpUpdateOne) {
  3569. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3570. }
  3571. if m.id == nil || m.oldValue == nil {
  3572. return v, errors.New("OldMsg requires an ID field in the mutation")
  3573. }
  3574. oldValue, err := m.oldValue(ctx)
  3575. if err != nil {
  3576. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3577. }
  3578. return oldValue.Msg, nil
  3579. }
  3580. // ClearMsg clears the value of the "msg" field.
  3581. func (m *BatchMsgMutation) ClearMsg() {
  3582. m.msg = nil
  3583. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3584. }
  3585. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3586. func (m *BatchMsgMutation) MsgCleared() bool {
  3587. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3588. return ok
  3589. }
  3590. // ResetMsg resets all changes to the "msg" field.
  3591. func (m *BatchMsgMutation) ResetMsg() {
  3592. m.msg = nil
  3593. delete(m.clearedFields, batchmsg.FieldMsg)
  3594. }
  3595. // SetTag sets the "tag" field.
  3596. func (m *BatchMsgMutation) SetTag(s string) {
  3597. m.tag = &s
  3598. }
  3599. // Tag returns the value of the "tag" field in the mutation.
  3600. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3601. v := m.tag
  3602. if v == nil {
  3603. return
  3604. }
  3605. return *v, true
  3606. }
  3607. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3608. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3610. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3611. if !m.op.Is(OpUpdateOne) {
  3612. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3613. }
  3614. if m.id == nil || m.oldValue == nil {
  3615. return v, errors.New("OldTag requires an ID field in the mutation")
  3616. }
  3617. oldValue, err := m.oldValue(ctx)
  3618. if err != nil {
  3619. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3620. }
  3621. return oldValue.Tag, nil
  3622. }
  3623. // ClearTag clears the value of the "tag" field.
  3624. func (m *BatchMsgMutation) ClearTag() {
  3625. m.tag = nil
  3626. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3627. }
  3628. // TagCleared returns if the "tag" field was cleared in this mutation.
  3629. func (m *BatchMsgMutation) TagCleared() bool {
  3630. _, ok := m.clearedFields[batchmsg.FieldTag]
  3631. return ok
  3632. }
  3633. // ResetTag resets all changes to the "tag" field.
  3634. func (m *BatchMsgMutation) ResetTag() {
  3635. m.tag = nil
  3636. delete(m.clearedFields, batchmsg.FieldTag)
  3637. }
  3638. // SetTagids sets the "tagids" field.
  3639. func (m *BatchMsgMutation) SetTagids(s string) {
  3640. m.tagids = &s
  3641. }
  3642. // Tagids returns the value of the "tagids" field in the mutation.
  3643. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3644. v := m.tagids
  3645. if v == nil {
  3646. return
  3647. }
  3648. return *v, true
  3649. }
  3650. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3651. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3653. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3654. if !m.op.Is(OpUpdateOne) {
  3655. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3656. }
  3657. if m.id == nil || m.oldValue == nil {
  3658. return v, errors.New("OldTagids requires an ID field in the mutation")
  3659. }
  3660. oldValue, err := m.oldValue(ctx)
  3661. if err != nil {
  3662. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3663. }
  3664. return oldValue.Tagids, nil
  3665. }
  3666. // ClearTagids clears the value of the "tagids" field.
  3667. func (m *BatchMsgMutation) ClearTagids() {
  3668. m.tagids = nil
  3669. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3670. }
  3671. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3672. func (m *BatchMsgMutation) TagidsCleared() bool {
  3673. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3674. return ok
  3675. }
  3676. // ResetTagids resets all changes to the "tagids" field.
  3677. func (m *BatchMsgMutation) ResetTagids() {
  3678. m.tagids = nil
  3679. delete(m.clearedFields, batchmsg.FieldTagids)
  3680. }
  3681. // SetTotal sets the "total" field.
  3682. func (m *BatchMsgMutation) SetTotal(i int32) {
  3683. m.total = &i
  3684. m.addtotal = nil
  3685. }
  3686. // Total returns the value of the "total" field in the mutation.
  3687. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3688. v := m.total
  3689. if v == nil {
  3690. return
  3691. }
  3692. return *v, true
  3693. }
  3694. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3695. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3697. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3698. if !m.op.Is(OpUpdateOne) {
  3699. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3700. }
  3701. if m.id == nil || m.oldValue == nil {
  3702. return v, errors.New("OldTotal requires an ID field in the mutation")
  3703. }
  3704. oldValue, err := m.oldValue(ctx)
  3705. if err != nil {
  3706. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3707. }
  3708. return oldValue.Total, nil
  3709. }
  3710. // AddTotal adds i to the "total" field.
  3711. func (m *BatchMsgMutation) AddTotal(i int32) {
  3712. if m.addtotal != nil {
  3713. *m.addtotal += i
  3714. } else {
  3715. m.addtotal = &i
  3716. }
  3717. }
  3718. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3719. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3720. v := m.addtotal
  3721. if v == nil {
  3722. return
  3723. }
  3724. return *v, true
  3725. }
  3726. // ClearTotal clears the value of the "total" field.
  3727. func (m *BatchMsgMutation) ClearTotal() {
  3728. m.total = nil
  3729. m.addtotal = nil
  3730. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3731. }
  3732. // TotalCleared returns if the "total" field was cleared in this mutation.
  3733. func (m *BatchMsgMutation) TotalCleared() bool {
  3734. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3735. return ok
  3736. }
  3737. // ResetTotal resets all changes to the "total" field.
  3738. func (m *BatchMsgMutation) ResetTotal() {
  3739. m.total = nil
  3740. m.addtotal = nil
  3741. delete(m.clearedFields, batchmsg.FieldTotal)
  3742. }
  3743. // SetSuccess sets the "success" field.
  3744. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3745. m.success = &i
  3746. m.addsuccess = nil
  3747. }
  3748. // Success returns the value of the "success" field in the mutation.
  3749. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3750. v := m.success
  3751. if v == nil {
  3752. return
  3753. }
  3754. return *v, true
  3755. }
  3756. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3757. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3759. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3760. if !m.op.Is(OpUpdateOne) {
  3761. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3762. }
  3763. if m.id == nil || m.oldValue == nil {
  3764. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3765. }
  3766. oldValue, err := m.oldValue(ctx)
  3767. if err != nil {
  3768. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3769. }
  3770. return oldValue.Success, nil
  3771. }
  3772. // AddSuccess adds i to the "success" field.
  3773. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3774. if m.addsuccess != nil {
  3775. *m.addsuccess += i
  3776. } else {
  3777. m.addsuccess = &i
  3778. }
  3779. }
  3780. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3781. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3782. v := m.addsuccess
  3783. if v == nil {
  3784. return
  3785. }
  3786. return *v, true
  3787. }
  3788. // ClearSuccess clears the value of the "success" field.
  3789. func (m *BatchMsgMutation) ClearSuccess() {
  3790. m.success = nil
  3791. m.addsuccess = nil
  3792. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3793. }
  3794. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3795. func (m *BatchMsgMutation) SuccessCleared() bool {
  3796. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3797. return ok
  3798. }
  3799. // ResetSuccess resets all changes to the "success" field.
  3800. func (m *BatchMsgMutation) ResetSuccess() {
  3801. m.success = nil
  3802. m.addsuccess = nil
  3803. delete(m.clearedFields, batchmsg.FieldSuccess)
  3804. }
  3805. // SetFail sets the "fail" field.
  3806. func (m *BatchMsgMutation) SetFail(i int32) {
  3807. m.fail = &i
  3808. m.addfail = nil
  3809. }
  3810. // Fail returns the value of the "fail" field in the mutation.
  3811. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3812. v := m.fail
  3813. if v == nil {
  3814. return
  3815. }
  3816. return *v, true
  3817. }
  3818. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3819. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3821. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3822. if !m.op.Is(OpUpdateOne) {
  3823. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3824. }
  3825. if m.id == nil || m.oldValue == nil {
  3826. return v, errors.New("OldFail requires an ID field in the mutation")
  3827. }
  3828. oldValue, err := m.oldValue(ctx)
  3829. if err != nil {
  3830. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3831. }
  3832. return oldValue.Fail, nil
  3833. }
  3834. // AddFail adds i to the "fail" field.
  3835. func (m *BatchMsgMutation) AddFail(i int32) {
  3836. if m.addfail != nil {
  3837. *m.addfail += i
  3838. } else {
  3839. m.addfail = &i
  3840. }
  3841. }
  3842. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3843. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3844. v := m.addfail
  3845. if v == nil {
  3846. return
  3847. }
  3848. return *v, true
  3849. }
  3850. // ClearFail clears the value of the "fail" field.
  3851. func (m *BatchMsgMutation) ClearFail() {
  3852. m.fail = nil
  3853. m.addfail = nil
  3854. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3855. }
  3856. // FailCleared returns if the "fail" field was cleared in this mutation.
  3857. func (m *BatchMsgMutation) FailCleared() bool {
  3858. _, ok := m.clearedFields[batchmsg.FieldFail]
  3859. return ok
  3860. }
  3861. // ResetFail resets all changes to the "fail" field.
  3862. func (m *BatchMsgMutation) ResetFail() {
  3863. m.fail = nil
  3864. m.addfail = nil
  3865. delete(m.clearedFields, batchmsg.FieldFail)
  3866. }
  3867. // SetStartTime sets the "start_time" field.
  3868. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3869. m.start_time = &t
  3870. }
  3871. // StartTime returns the value of the "start_time" field in the mutation.
  3872. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3873. v := m.start_time
  3874. if v == nil {
  3875. return
  3876. }
  3877. return *v, true
  3878. }
  3879. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3880. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3882. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3883. if !m.op.Is(OpUpdateOne) {
  3884. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3885. }
  3886. if m.id == nil || m.oldValue == nil {
  3887. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3888. }
  3889. oldValue, err := m.oldValue(ctx)
  3890. if err != nil {
  3891. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3892. }
  3893. return oldValue.StartTime, nil
  3894. }
  3895. // ClearStartTime clears the value of the "start_time" field.
  3896. func (m *BatchMsgMutation) ClearStartTime() {
  3897. m.start_time = nil
  3898. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3899. }
  3900. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3901. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3902. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3903. return ok
  3904. }
  3905. // ResetStartTime resets all changes to the "start_time" field.
  3906. func (m *BatchMsgMutation) ResetStartTime() {
  3907. m.start_time = nil
  3908. delete(m.clearedFields, batchmsg.FieldStartTime)
  3909. }
  3910. // SetStopTime sets the "stop_time" field.
  3911. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3912. m.stop_time = &t
  3913. }
  3914. // StopTime returns the value of the "stop_time" field in the mutation.
  3915. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3916. v := m.stop_time
  3917. if v == nil {
  3918. return
  3919. }
  3920. return *v, true
  3921. }
  3922. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3923. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3925. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3926. if !m.op.Is(OpUpdateOne) {
  3927. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3928. }
  3929. if m.id == nil || m.oldValue == nil {
  3930. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3931. }
  3932. oldValue, err := m.oldValue(ctx)
  3933. if err != nil {
  3934. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3935. }
  3936. return oldValue.StopTime, nil
  3937. }
  3938. // ClearStopTime clears the value of the "stop_time" field.
  3939. func (m *BatchMsgMutation) ClearStopTime() {
  3940. m.stop_time = nil
  3941. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3942. }
  3943. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3944. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3945. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3946. return ok
  3947. }
  3948. // ResetStopTime resets all changes to the "stop_time" field.
  3949. func (m *BatchMsgMutation) ResetStopTime() {
  3950. m.stop_time = nil
  3951. delete(m.clearedFields, batchmsg.FieldStopTime)
  3952. }
  3953. // SetSendTime sets the "send_time" field.
  3954. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3955. m.send_time = &t
  3956. }
  3957. // SendTime returns the value of the "send_time" field in the mutation.
  3958. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3959. v := m.send_time
  3960. if v == nil {
  3961. return
  3962. }
  3963. return *v, true
  3964. }
  3965. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3966. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3968. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3969. if !m.op.Is(OpUpdateOne) {
  3970. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3971. }
  3972. if m.id == nil || m.oldValue == nil {
  3973. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3974. }
  3975. oldValue, err := m.oldValue(ctx)
  3976. if err != nil {
  3977. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3978. }
  3979. return oldValue.SendTime, nil
  3980. }
  3981. // ClearSendTime clears the value of the "send_time" field.
  3982. func (m *BatchMsgMutation) ClearSendTime() {
  3983. m.send_time = nil
  3984. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3985. }
  3986. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3987. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3988. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3989. return ok
  3990. }
  3991. // ResetSendTime resets all changes to the "send_time" field.
  3992. func (m *BatchMsgMutation) ResetSendTime() {
  3993. m.send_time = nil
  3994. delete(m.clearedFields, batchmsg.FieldSendTime)
  3995. }
  3996. // SetType sets the "type" field.
  3997. func (m *BatchMsgMutation) SetType(i int32) {
  3998. m._type = &i
  3999. m.add_type = nil
  4000. }
  4001. // GetType returns the value of the "type" field in the mutation.
  4002. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4003. v := m._type
  4004. if v == nil {
  4005. return
  4006. }
  4007. return *v, true
  4008. }
  4009. // OldType returns the old "type" field's value of the BatchMsg entity.
  4010. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4012. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4013. if !m.op.Is(OpUpdateOne) {
  4014. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4015. }
  4016. if m.id == nil || m.oldValue == nil {
  4017. return v, errors.New("OldType requires an ID field in the mutation")
  4018. }
  4019. oldValue, err := m.oldValue(ctx)
  4020. if err != nil {
  4021. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4022. }
  4023. return oldValue.Type, nil
  4024. }
  4025. // AddType adds i to the "type" field.
  4026. func (m *BatchMsgMutation) AddType(i int32) {
  4027. if m.add_type != nil {
  4028. *m.add_type += i
  4029. } else {
  4030. m.add_type = &i
  4031. }
  4032. }
  4033. // AddedType returns the value that was added to the "type" field in this mutation.
  4034. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4035. v := m.add_type
  4036. if v == nil {
  4037. return
  4038. }
  4039. return *v, true
  4040. }
  4041. // ClearType clears the value of the "type" field.
  4042. func (m *BatchMsgMutation) ClearType() {
  4043. m._type = nil
  4044. m.add_type = nil
  4045. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4046. }
  4047. // TypeCleared returns if the "type" field was cleared in this mutation.
  4048. func (m *BatchMsgMutation) TypeCleared() bool {
  4049. _, ok := m.clearedFields[batchmsg.FieldType]
  4050. return ok
  4051. }
  4052. // ResetType resets all changes to the "type" field.
  4053. func (m *BatchMsgMutation) ResetType() {
  4054. m._type = nil
  4055. m.add_type = nil
  4056. delete(m.clearedFields, batchmsg.FieldType)
  4057. }
  4058. // SetOrganizationID sets the "organization_id" field.
  4059. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4060. m.organization_id = &u
  4061. m.addorganization_id = nil
  4062. }
  4063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4064. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4065. v := m.organization_id
  4066. if v == nil {
  4067. return
  4068. }
  4069. return *v, true
  4070. }
  4071. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4072. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4074. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4075. if !m.op.Is(OpUpdateOne) {
  4076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4077. }
  4078. if m.id == nil || m.oldValue == nil {
  4079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4080. }
  4081. oldValue, err := m.oldValue(ctx)
  4082. if err != nil {
  4083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4084. }
  4085. return oldValue.OrganizationID, nil
  4086. }
  4087. // AddOrganizationID adds u to the "organization_id" field.
  4088. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4089. if m.addorganization_id != nil {
  4090. *m.addorganization_id += u
  4091. } else {
  4092. m.addorganization_id = &u
  4093. }
  4094. }
  4095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4096. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4097. v := m.addorganization_id
  4098. if v == nil {
  4099. return
  4100. }
  4101. return *v, true
  4102. }
  4103. // ResetOrganizationID resets all changes to the "organization_id" field.
  4104. func (m *BatchMsgMutation) ResetOrganizationID() {
  4105. m.organization_id = nil
  4106. m.addorganization_id = nil
  4107. }
  4108. // Where appends a list predicates to the BatchMsgMutation builder.
  4109. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4110. m.predicates = append(m.predicates, ps...)
  4111. }
  4112. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4113. // users can use type-assertion to append predicates that do not depend on any generated package.
  4114. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4115. p := make([]predicate.BatchMsg, len(ps))
  4116. for i := range ps {
  4117. p[i] = ps[i]
  4118. }
  4119. m.Where(p...)
  4120. }
  4121. // Op returns the operation name.
  4122. func (m *BatchMsgMutation) Op() Op {
  4123. return m.op
  4124. }
  4125. // SetOp allows setting the mutation operation.
  4126. func (m *BatchMsgMutation) SetOp(op Op) {
  4127. m.op = op
  4128. }
  4129. // Type returns the node type of this mutation (BatchMsg).
  4130. func (m *BatchMsgMutation) Type() string {
  4131. return m.typ
  4132. }
  4133. // Fields returns all fields that were changed during this mutation. Note that in
  4134. // order to get all numeric fields that were incremented/decremented, call
  4135. // AddedFields().
  4136. func (m *BatchMsgMutation) Fields() []string {
  4137. fields := make([]string, 0, 18)
  4138. if m.created_at != nil {
  4139. fields = append(fields, batchmsg.FieldCreatedAt)
  4140. }
  4141. if m.updated_at != nil {
  4142. fields = append(fields, batchmsg.FieldUpdatedAt)
  4143. }
  4144. if m.deleted_at != nil {
  4145. fields = append(fields, batchmsg.FieldDeletedAt)
  4146. }
  4147. if m.status != nil {
  4148. fields = append(fields, batchmsg.FieldStatus)
  4149. }
  4150. if m.batch_no != nil {
  4151. fields = append(fields, batchmsg.FieldBatchNo)
  4152. }
  4153. if m.task_name != nil {
  4154. fields = append(fields, batchmsg.FieldTaskName)
  4155. }
  4156. if m.fromwxid != nil {
  4157. fields = append(fields, batchmsg.FieldFromwxid)
  4158. }
  4159. if m.msg != nil {
  4160. fields = append(fields, batchmsg.FieldMsg)
  4161. }
  4162. if m.tag != nil {
  4163. fields = append(fields, batchmsg.FieldTag)
  4164. }
  4165. if m.tagids != nil {
  4166. fields = append(fields, batchmsg.FieldTagids)
  4167. }
  4168. if m.total != nil {
  4169. fields = append(fields, batchmsg.FieldTotal)
  4170. }
  4171. if m.success != nil {
  4172. fields = append(fields, batchmsg.FieldSuccess)
  4173. }
  4174. if m.fail != nil {
  4175. fields = append(fields, batchmsg.FieldFail)
  4176. }
  4177. if m.start_time != nil {
  4178. fields = append(fields, batchmsg.FieldStartTime)
  4179. }
  4180. if m.stop_time != nil {
  4181. fields = append(fields, batchmsg.FieldStopTime)
  4182. }
  4183. if m.send_time != nil {
  4184. fields = append(fields, batchmsg.FieldSendTime)
  4185. }
  4186. if m._type != nil {
  4187. fields = append(fields, batchmsg.FieldType)
  4188. }
  4189. if m.organization_id != nil {
  4190. fields = append(fields, batchmsg.FieldOrganizationID)
  4191. }
  4192. return fields
  4193. }
  4194. // Field returns the value of a field with the given name. The second boolean
  4195. // return value indicates that this field was not set, or was not defined in the
  4196. // schema.
  4197. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4198. switch name {
  4199. case batchmsg.FieldCreatedAt:
  4200. return m.CreatedAt()
  4201. case batchmsg.FieldUpdatedAt:
  4202. return m.UpdatedAt()
  4203. case batchmsg.FieldDeletedAt:
  4204. return m.DeletedAt()
  4205. case batchmsg.FieldStatus:
  4206. return m.Status()
  4207. case batchmsg.FieldBatchNo:
  4208. return m.BatchNo()
  4209. case batchmsg.FieldTaskName:
  4210. return m.TaskName()
  4211. case batchmsg.FieldFromwxid:
  4212. return m.Fromwxid()
  4213. case batchmsg.FieldMsg:
  4214. return m.Msg()
  4215. case batchmsg.FieldTag:
  4216. return m.Tag()
  4217. case batchmsg.FieldTagids:
  4218. return m.Tagids()
  4219. case batchmsg.FieldTotal:
  4220. return m.Total()
  4221. case batchmsg.FieldSuccess:
  4222. return m.Success()
  4223. case batchmsg.FieldFail:
  4224. return m.Fail()
  4225. case batchmsg.FieldStartTime:
  4226. return m.StartTime()
  4227. case batchmsg.FieldStopTime:
  4228. return m.StopTime()
  4229. case batchmsg.FieldSendTime:
  4230. return m.SendTime()
  4231. case batchmsg.FieldType:
  4232. return m.GetType()
  4233. case batchmsg.FieldOrganizationID:
  4234. return m.OrganizationID()
  4235. }
  4236. return nil, false
  4237. }
  4238. // OldField returns the old value of the field from the database. An error is
  4239. // returned if the mutation operation is not UpdateOne, or the query to the
  4240. // database failed.
  4241. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4242. switch name {
  4243. case batchmsg.FieldCreatedAt:
  4244. return m.OldCreatedAt(ctx)
  4245. case batchmsg.FieldUpdatedAt:
  4246. return m.OldUpdatedAt(ctx)
  4247. case batchmsg.FieldDeletedAt:
  4248. return m.OldDeletedAt(ctx)
  4249. case batchmsg.FieldStatus:
  4250. return m.OldStatus(ctx)
  4251. case batchmsg.FieldBatchNo:
  4252. return m.OldBatchNo(ctx)
  4253. case batchmsg.FieldTaskName:
  4254. return m.OldTaskName(ctx)
  4255. case batchmsg.FieldFromwxid:
  4256. return m.OldFromwxid(ctx)
  4257. case batchmsg.FieldMsg:
  4258. return m.OldMsg(ctx)
  4259. case batchmsg.FieldTag:
  4260. return m.OldTag(ctx)
  4261. case batchmsg.FieldTagids:
  4262. return m.OldTagids(ctx)
  4263. case batchmsg.FieldTotal:
  4264. return m.OldTotal(ctx)
  4265. case batchmsg.FieldSuccess:
  4266. return m.OldSuccess(ctx)
  4267. case batchmsg.FieldFail:
  4268. return m.OldFail(ctx)
  4269. case batchmsg.FieldStartTime:
  4270. return m.OldStartTime(ctx)
  4271. case batchmsg.FieldStopTime:
  4272. return m.OldStopTime(ctx)
  4273. case batchmsg.FieldSendTime:
  4274. return m.OldSendTime(ctx)
  4275. case batchmsg.FieldType:
  4276. return m.OldType(ctx)
  4277. case batchmsg.FieldOrganizationID:
  4278. return m.OldOrganizationID(ctx)
  4279. }
  4280. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4281. }
  4282. // SetField sets the value of a field with the given name. It returns an error if
  4283. // the field is not defined in the schema, or if the type mismatched the field
  4284. // type.
  4285. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4286. switch name {
  4287. case batchmsg.FieldCreatedAt:
  4288. v, ok := value.(time.Time)
  4289. if !ok {
  4290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4291. }
  4292. m.SetCreatedAt(v)
  4293. return nil
  4294. case batchmsg.FieldUpdatedAt:
  4295. v, ok := value.(time.Time)
  4296. if !ok {
  4297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4298. }
  4299. m.SetUpdatedAt(v)
  4300. return nil
  4301. case batchmsg.FieldDeletedAt:
  4302. v, ok := value.(time.Time)
  4303. if !ok {
  4304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4305. }
  4306. m.SetDeletedAt(v)
  4307. return nil
  4308. case batchmsg.FieldStatus:
  4309. v, ok := value.(uint8)
  4310. if !ok {
  4311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4312. }
  4313. m.SetStatus(v)
  4314. return nil
  4315. case batchmsg.FieldBatchNo:
  4316. v, ok := value.(string)
  4317. if !ok {
  4318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4319. }
  4320. m.SetBatchNo(v)
  4321. return nil
  4322. case batchmsg.FieldTaskName:
  4323. v, ok := value.(string)
  4324. if !ok {
  4325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4326. }
  4327. m.SetTaskName(v)
  4328. return nil
  4329. case batchmsg.FieldFromwxid:
  4330. v, ok := value.(string)
  4331. if !ok {
  4332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4333. }
  4334. m.SetFromwxid(v)
  4335. return nil
  4336. case batchmsg.FieldMsg:
  4337. v, ok := value.(string)
  4338. if !ok {
  4339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4340. }
  4341. m.SetMsg(v)
  4342. return nil
  4343. case batchmsg.FieldTag:
  4344. v, ok := value.(string)
  4345. if !ok {
  4346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4347. }
  4348. m.SetTag(v)
  4349. return nil
  4350. case batchmsg.FieldTagids:
  4351. v, ok := value.(string)
  4352. if !ok {
  4353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4354. }
  4355. m.SetTagids(v)
  4356. return nil
  4357. case batchmsg.FieldTotal:
  4358. v, ok := value.(int32)
  4359. if !ok {
  4360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4361. }
  4362. m.SetTotal(v)
  4363. return nil
  4364. case batchmsg.FieldSuccess:
  4365. v, ok := value.(int32)
  4366. if !ok {
  4367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4368. }
  4369. m.SetSuccess(v)
  4370. return nil
  4371. case batchmsg.FieldFail:
  4372. v, ok := value.(int32)
  4373. if !ok {
  4374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4375. }
  4376. m.SetFail(v)
  4377. return nil
  4378. case batchmsg.FieldStartTime:
  4379. v, ok := value.(time.Time)
  4380. if !ok {
  4381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4382. }
  4383. m.SetStartTime(v)
  4384. return nil
  4385. case batchmsg.FieldStopTime:
  4386. v, ok := value.(time.Time)
  4387. if !ok {
  4388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4389. }
  4390. m.SetStopTime(v)
  4391. return nil
  4392. case batchmsg.FieldSendTime:
  4393. v, ok := value.(time.Time)
  4394. if !ok {
  4395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4396. }
  4397. m.SetSendTime(v)
  4398. return nil
  4399. case batchmsg.FieldType:
  4400. v, ok := value.(int32)
  4401. if !ok {
  4402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4403. }
  4404. m.SetType(v)
  4405. return nil
  4406. case batchmsg.FieldOrganizationID:
  4407. v, ok := value.(uint64)
  4408. if !ok {
  4409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4410. }
  4411. m.SetOrganizationID(v)
  4412. return nil
  4413. }
  4414. return fmt.Errorf("unknown BatchMsg field %s", name)
  4415. }
  4416. // AddedFields returns all numeric fields that were incremented/decremented during
  4417. // this mutation.
  4418. func (m *BatchMsgMutation) AddedFields() []string {
  4419. var fields []string
  4420. if m.addstatus != nil {
  4421. fields = append(fields, batchmsg.FieldStatus)
  4422. }
  4423. if m.addtotal != nil {
  4424. fields = append(fields, batchmsg.FieldTotal)
  4425. }
  4426. if m.addsuccess != nil {
  4427. fields = append(fields, batchmsg.FieldSuccess)
  4428. }
  4429. if m.addfail != nil {
  4430. fields = append(fields, batchmsg.FieldFail)
  4431. }
  4432. if m.add_type != nil {
  4433. fields = append(fields, batchmsg.FieldType)
  4434. }
  4435. if m.addorganization_id != nil {
  4436. fields = append(fields, batchmsg.FieldOrganizationID)
  4437. }
  4438. return fields
  4439. }
  4440. // AddedField returns the numeric value that was incremented/decremented on a field
  4441. // with the given name. The second boolean return value indicates that this field
  4442. // was not set, or was not defined in the schema.
  4443. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4444. switch name {
  4445. case batchmsg.FieldStatus:
  4446. return m.AddedStatus()
  4447. case batchmsg.FieldTotal:
  4448. return m.AddedTotal()
  4449. case batchmsg.FieldSuccess:
  4450. return m.AddedSuccess()
  4451. case batchmsg.FieldFail:
  4452. return m.AddedFail()
  4453. case batchmsg.FieldType:
  4454. return m.AddedType()
  4455. case batchmsg.FieldOrganizationID:
  4456. return m.AddedOrganizationID()
  4457. }
  4458. return nil, false
  4459. }
  4460. // AddField adds the value to the field with the given name. It returns an error if
  4461. // the field is not defined in the schema, or if the type mismatched the field
  4462. // type.
  4463. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4464. switch name {
  4465. case batchmsg.FieldStatus:
  4466. v, ok := value.(int8)
  4467. if !ok {
  4468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4469. }
  4470. m.AddStatus(v)
  4471. return nil
  4472. case batchmsg.FieldTotal:
  4473. v, ok := value.(int32)
  4474. if !ok {
  4475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4476. }
  4477. m.AddTotal(v)
  4478. return nil
  4479. case batchmsg.FieldSuccess:
  4480. v, ok := value.(int32)
  4481. if !ok {
  4482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4483. }
  4484. m.AddSuccess(v)
  4485. return nil
  4486. case batchmsg.FieldFail:
  4487. v, ok := value.(int32)
  4488. if !ok {
  4489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4490. }
  4491. m.AddFail(v)
  4492. return nil
  4493. case batchmsg.FieldType:
  4494. v, ok := value.(int32)
  4495. if !ok {
  4496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4497. }
  4498. m.AddType(v)
  4499. return nil
  4500. case batchmsg.FieldOrganizationID:
  4501. v, ok := value.(int64)
  4502. if !ok {
  4503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4504. }
  4505. m.AddOrganizationID(v)
  4506. return nil
  4507. }
  4508. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4509. }
  4510. // ClearedFields returns all nullable fields that were cleared during this
  4511. // mutation.
  4512. func (m *BatchMsgMutation) ClearedFields() []string {
  4513. var fields []string
  4514. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4515. fields = append(fields, batchmsg.FieldDeletedAt)
  4516. }
  4517. if m.FieldCleared(batchmsg.FieldStatus) {
  4518. fields = append(fields, batchmsg.FieldStatus)
  4519. }
  4520. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4521. fields = append(fields, batchmsg.FieldBatchNo)
  4522. }
  4523. if m.FieldCleared(batchmsg.FieldTaskName) {
  4524. fields = append(fields, batchmsg.FieldTaskName)
  4525. }
  4526. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4527. fields = append(fields, batchmsg.FieldFromwxid)
  4528. }
  4529. if m.FieldCleared(batchmsg.FieldMsg) {
  4530. fields = append(fields, batchmsg.FieldMsg)
  4531. }
  4532. if m.FieldCleared(batchmsg.FieldTag) {
  4533. fields = append(fields, batchmsg.FieldTag)
  4534. }
  4535. if m.FieldCleared(batchmsg.FieldTagids) {
  4536. fields = append(fields, batchmsg.FieldTagids)
  4537. }
  4538. if m.FieldCleared(batchmsg.FieldTotal) {
  4539. fields = append(fields, batchmsg.FieldTotal)
  4540. }
  4541. if m.FieldCleared(batchmsg.FieldSuccess) {
  4542. fields = append(fields, batchmsg.FieldSuccess)
  4543. }
  4544. if m.FieldCleared(batchmsg.FieldFail) {
  4545. fields = append(fields, batchmsg.FieldFail)
  4546. }
  4547. if m.FieldCleared(batchmsg.FieldStartTime) {
  4548. fields = append(fields, batchmsg.FieldStartTime)
  4549. }
  4550. if m.FieldCleared(batchmsg.FieldStopTime) {
  4551. fields = append(fields, batchmsg.FieldStopTime)
  4552. }
  4553. if m.FieldCleared(batchmsg.FieldSendTime) {
  4554. fields = append(fields, batchmsg.FieldSendTime)
  4555. }
  4556. if m.FieldCleared(batchmsg.FieldType) {
  4557. fields = append(fields, batchmsg.FieldType)
  4558. }
  4559. return fields
  4560. }
  4561. // FieldCleared returns a boolean indicating if a field with the given name was
  4562. // cleared in this mutation.
  4563. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4564. _, ok := m.clearedFields[name]
  4565. return ok
  4566. }
  4567. // ClearField clears the value of the field with the given name. It returns an
  4568. // error if the field is not defined in the schema.
  4569. func (m *BatchMsgMutation) ClearField(name string) error {
  4570. switch name {
  4571. case batchmsg.FieldDeletedAt:
  4572. m.ClearDeletedAt()
  4573. return nil
  4574. case batchmsg.FieldStatus:
  4575. m.ClearStatus()
  4576. return nil
  4577. case batchmsg.FieldBatchNo:
  4578. m.ClearBatchNo()
  4579. return nil
  4580. case batchmsg.FieldTaskName:
  4581. m.ClearTaskName()
  4582. return nil
  4583. case batchmsg.FieldFromwxid:
  4584. m.ClearFromwxid()
  4585. return nil
  4586. case batchmsg.FieldMsg:
  4587. m.ClearMsg()
  4588. return nil
  4589. case batchmsg.FieldTag:
  4590. m.ClearTag()
  4591. return nil
  4592. case batchmsg.FieldTagids:
  4593. m.ClearTagids()
  4594. return nil
  4595. case batchmsg.FieldTotal:
  4596. m.ClearTotal()
  4597. return nil
  4598. case batchmsg.FieldSuccess:
  4599. m.ClearSuccess()
  4600. return nil
  4601. case batchmsg.FieldFail:
  4602. m.ClearFail()
  4603. return nil
  4604. case batchmsg.FieldStartTime:
  4605. m.ClearStartTime()
  4606. return nil
  4607. case batchmsg.FieldStopTime:
  4608. m.ClearStopTime()
  4609. return nil
  4610. case batchmsg.FieldSendTime:
  4611. m.ClearSendTime()
  4612. return nil
  4613. case batchmsg.FieldType:
  4614. m.ClearType()
  4615. return nil
  4616. }
  4617. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4618. }
  4619. // ResetField resets all changes in the mutation for the field with the given name.
  4620. // It returns an error if the field is not defined in the schema.
  4621. func (m *BatchMsgMutation) ResetField(name string) error {
  4622. switch name {
  4623. case batchmsg.FieldCreatedAt:
  4624. m.ResetCreatedAt()
  4625. return nil
  4626. case batchmsg.FieldUpdatedAt:
  4627. m.ResetUpdatedAt()
  4628. return nil
  4629. case batchmsg.FieldDeletedAt:
  4630. m.ResetDeletedAt()
  4631. return nil
  4632. case batchmsg.FieldStatus:
  4633. m.ResetStatus()
  4634. return nil
  4635. case batchmsg.FieldBatchNo:
  4636. m.ResetBatchNo()
  4637. return nil
  4638. case batchmsg.FieldTaskName:
  4639. m.ResetTaskName()
  4640. return nil
  4641. case batchmsg.FieldFromwxid:
  4642. m.ResetFromwxid()
  4643. return nil
  4644. case batchmsg.FieldMsg:
  4645. m.ResetMsg()
  4646. return nil
  4647. case batchmsg.FieldTag:
  4648. m.ResetTag()
  4649. return nil
  4650. case batchmsg.FieldTagids:
  4651. m.ResetTagids()
  4652. return nil
  4653. case batchmsg.FieldTotal:
  4654. m.ResetTotal()
  4655. return nil
  4656. case batchmsg.FieldSuccess:
  4657. m.ResetSuccess()
  4658. return nil
  4659. case batchmsg.FieldFail:
  4660. m.ResetFail()
  4661. return nil
  4662. case batchmsg.FieldStartTime:
  4663. m.ResetStartTime()
  4664. return nil
  4665. case batchmsg.FieldStopTime:
  4666. m.ResetStopTime()
  4667. return nil
  4668. case batchmsg.FieldSendTime:
  4669. m.ResetSendTime()
  4670. return nil
  4671. case batchmsg.FieldType:
  4672. m.ResetType()
  4673. return nil
  4674. case batchmsg.FieldOrganizationID:
  4675. m.ResetOrganizationID()
  4676. return nil
  4677. }
  4678. return fmt.Errorf("unknown BatchMsg field %s", name)
  4679. }
  4680. // AddedEdges returns all edge names that were set/added in this mutation.
  4681. func (m *BatchMsgMutation) AddedEdges() []string {
  4682. edges := make([]string, 0, 0)
  4683. return edges
  4684. }
  4685. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4686. // name in this mutation.
  4687. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4688. return nil
  4689. }
  4690. // RemovedEdges returns all edge names that were removed in this mutation.
  4691. func (m *BatchMsgMutation) RemovedEdges() []string {
  4692. edges := make([]string, 0, 0)
  4693. return edges
  4694. }
  4695. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4696. // the given name in this mutation.
  4697. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4698. return nil
  4699. }
  4700. // ClearedEdges returns all edge names that were cleared in this mutation.
  4701. func (m *BatchMsgMutation) ClearedEdges() []string {
  4702. edges := make([]string, 0, 0)
  4703. return edges
  4704. }
  4705. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4706. // was cleared in this mutation.
  4707. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4708. return false
  4709. }
  4710. // ClearEdge clears the value of the edge with the given name. It returns an error
  4711. // if that edge is not defined in the schema.
  4712. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4713. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4714. }
  4715. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4716. // It returns an error if the edge is not defined in the schema.
  4717. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4718. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4719. }
  4720. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4721. type CategoryMutation struct {
  4722. config
  4723. op Op
  4724. typ string
  4725. id *uint64
  4726. created_at *time.Time
  4727. updated_at *time.Time
  4728. deleted_at *time.Time
  4729. name *string
  4730. organization_id *uint64
  4731. addorganization_id *int64
  4732. clearedFields map[string]struct{}
  4733. done bool
  4734. oldValue func(context.Context) (*Category, error)
  4735. predicates []predicate.Category
  4736. }
  4737. var _ ent.Mutation = (*CategoryMutation)(nil)
  4738. // categoryOption allows management of the mutation configuration using functional options.
  4739. type categoryOption func(*CategoryMutation)
  4740. // newCategoryMutation creates new mutation for the Category entity.
  4741. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4742. m := &CategoryMutation{
  4743. config: c,
  4744. op: op,
  4745. typ: TypeCategory,
  4746. clearedFields: make(map[string]struct{}),
  4747. }
  4748. for _, opt := range opts {
  4749. opt(m)
  4750. }
  4751. return m
  4752. }
  4753. // withCategoryID sets the ID field of the mutation.
  4754. func withCategoryID(id uint64) categoryOption {
  4755. return func(m *CategoryMutation) {
  4756. var (
  4757. err error
  4758. once sync.Once
  4759. value *Category
  4760. )
  4761. m.oldValue = func(ctx context.Context) (*Category, error) {
  4762. once.Do(func() {
  4763. if m.done {
  4764. err = errors.New("querying old values post mutation is not allowed")
  4765. } else {
  4766. value, err = m.Client().Category.Get(ctx, id)
  4767. }
  4768. })
  4769. return value, err
  4770. }
  4771. m.id = &id
  4772. }
  4773. }
  4774. // withCategory sets the old Category of the mutation.
  4775. func withCategory(node *Category) categoryOption {
  4776. return func(m *CategoryMutation) {
  4777. m.oldValue = func(context.Context) (*Category, error) {
  4778. return node, nil
  4779. }
  4780. m.id = &node.ID
  4781. }
  4782. }
  4783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4784. // executed in a transaction (ent.Tx), a transactional client is returned.
  4785. func (m CategoryMutation) Client() *Client {
  4786. client := &Client{config: m.config}
  4787. client.init()
  4788. return client
  4789. }
  4790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4791. // it returns an error otherwise.
  4792. func (m CategoryMutation) Tx() (*Tx, error) {
  4793. if _, ok := m.driver.(*txDriver); !ok {
  4794. return nil, errors.New("ent: mutation is not running in a transaction")
  4795. }
  4796. tx := &Tx{config: m.config}
  4797. tx.init()
  4798. return tx, nil
  4799. }
  4800. // SetID sets the value of the id field. Note that this
  4801. // operation is only accepted on creation of Category entities.
  4802. func (m *CategoryMutation) SetID(id uint64) {
  4803. m.id = &id
  4804. }
  4805. // ID returns the ID value in the mutation. Note that the ID is only available
  4806. // if it was provided to the builder or after it was returned from the database.
  4807. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4808. if m.id == nil {
  4809. return
  4810. }
  4811. return *m.id, true
  4812. }
  4813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4814. // That means, if the mutation is applied within a transaction with an isolation level such
  4815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4816. // or updated by the mutation.
  4817. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4818. switch {
  4819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4820. id, exists := m.ID()
  4821. if exists {
  4822. return []uint64{id}, nil
  4823. }
  4824. fallthrough
  4825. case m.op.Is(OpUpdate | OpDelete):
  4826. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4827. default:
  4828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4829. }
  4830. }
  4831. // SetCreatedAt sets the "created_at" field.
  4832. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4833. m.created_at = &t
  4834. }
  4835. // CreatedAt returns the value of the "created_at" field in the mutation.
  4836. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4837. v := m.created_at
  4838. if v == nil {
  4839. return
  4840. }
  4841. return *v, true
  4842. }
  4843. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4844. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4846. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4847. if !m.op.Is(OpUpdateOne) {
  4848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4849. }
  4850. if m.id == nil || m.oldValue == nil {
  4851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4852. }
  4853. oldValue, err := m.oldValue(ctx)
  4854. if err != nil {
  4855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4856. }
  4857. return oldValue.CreatedAt, nil
  4858. }
  4859. // ResetCreatedAt resets all changes to the "created_at" field.
  4860. func (m *CategoryMutation) ResetCreatedAt() {
  4861. m.created_at = nil
  4862. }
  4863. // SetUpdatedAt sets the "updated_at" field.
  4864. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4865. m.updated_at = &t
  4866. }
  4867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4868. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4869. v := m.updated_at
  4870. if v == nil {
  4871. return
  4872. }
  4873. return *v, true
  4874. }
  4875. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4876. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4878. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4879. if !m.op.Is(OpUpdateOne) {
  4880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4881. }
  4882. if m.id == nil || m.oldValue == nil {
  4883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4884. }
  4885. oldValue, err := m.oldValue(ctx)
  4886. if err != nil {
  4887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4888. }
  4889. return oldValue.UpdatedAt, nil
  4890. }
  4891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4892. func (m *CategoryMutation) ResetUpdatedAt() {
  4893. m.updated_at = nil
  4894. }
  4895. // SetDeletedAt sets the "deleted_at" field.
  4896. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4897. m.deleted_at = &t
  4898. }
  4899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4900. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4901. v := m.deleted_at
  4902. if v == nil {
  4903. return
  4904. }
  4905. return *v, true
  4906. }
  4907. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4908. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4910. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4911. if !m.op.Is(OpUpdateOne) {
  4912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4913. }
  4914. if m.id == nil || m.oldValue == nil {
  4915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4916. }
  4917. oldValue, err := m.oldValue(ctx)
  4918. if err != nil {
  4919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4920. }
  4921. return oldValue.DeletedAt, nil
  4922. }
  4923. // ClearDeletedAt clears the value of the "deleted_at" field.
  4924. func (m *CategoryMutation) ClearDeletedAt() {
  4925. m.deleted_at = nil
  4926. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4927. }
  4928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4929. func (m *CategoryMutation) DeletedAtCleared() bool {
  4930. _, ok := m.clearedFields[category.FieldDeletedAt]
  4931. return ok
  4932. }
  4933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4934. func (m *CategoryMutation) ResetDeletedAt() {
  4935. m.deleted_at = nil
  4936. delete(m.clearedFields, category.FieldDeletedAt)
  4937. }
  4938. // SetName sets the "name" field.
  4939. func (m *CategoryMutation) SetName(s string) {
  4940. m.name = &s
  4941. }
  4942. // Name returns the value of the "name" field in the mutation.
  4943. func (m *CategoryMutation) Name() (r string, exists bool) {
  4944. v := m.name
  4945. if v == nil {
  4946. return
  4947. }
  4948. return *v, true
  4949. }
  4950. // OldName returns the old "name" field's value of the Category entity.
  4951. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4953. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4954. if !m.op.Is(OpUpdateOne) {
  4955. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4956. }
  4957. if m.id == nil || m.oldValue == nil {
  4958. return v, errors.New("OldName requires an ID field in the mutation")
  4959. }
  4960. oldValue, err := m.oldValue(ctx)
  4961. if err != nil {
  4962. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4963. }
  4964. return oldValue.Name, nil
  4965. }
  4966. // ResetName resets all changes to the "name" field.
  4967. func (m *CategoryMutation) ResetName() {
  4968. m.name = nil
  4969. }
  4970. // SetOrganizationID sets the "organization_id" field.
  4971. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4972. m.organization_id = &u
  4973. m.addorganization_id = nil
  4974. }
  4975. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4976. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4977. v := m.organization_id
  4978. if v == nil {
  4979. return
  4980. }
  4981. return *v, true
  4982. }
  4983. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4984. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4986. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4987. if !m.op.Is(OpUpdateOne) {
  4988. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4989. }
  4990. if m.id == nil || m.oldValue == nil {
  4991. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4992. }
  4993. oldValue, err := m.oldValue(ctx)
  4994. if err != nil {
  4995. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4996. }
  4997. return oldValue.OrganizationID, nil
  4998. }
  4999. // AddOrganizationID adds u to the "organization_id" field.
  5000. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5001. if m.addorganization_id != nil {
  5002. *m.addorganization_id += u
  5003. } else {
  5004. m.addorganization_id = &u
  5005. }
  5006. }
  5007. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5008. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5009. v := m.addorganization_id
  5010. if v == nil {
  5011. return
  5012. }
  5013. return *v, true
  5014. }
  5015. // ResetOrganizationID resets all changes to the "organization_id" field.
  5016. func (m *CategoryMutation) ResetOrganizationID() {
  5017. m.organization_id = nil
  5018. m.addorganization_id = nil
  5019. }
  5020. // Where appends a list predicates to the CategoryMutation builder.
  5021. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5022. m.predicates = append(m.predicates, ps...)
  5023. }
  5024. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5025. // users can use type-assertion to append predicates that do not depend on any generated package.
  5026. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5027. p := make([]predicate.Category, len(ps))
  5028. for i := range ps {
  5029. p[i] = ps[i]
  5030. }
  5031. m.Where(p...)
  5032. }
  5033. // Op returns the operation name.
  5034. func (m *CategoryMutation) Op() Op {
  5035. return m.op
  5036. }
  5037. // SetOp allows setting the mutation operation.
  5038. func (m *CategoryMutation) SetOp(op Op) {
  5039. m.op = op
  5040. }
  5041. // Type returns the node type of this mutation (Category).
  5042. func (m *CategoryMutation) Type() string {
  5043. return m.typ
  5044. }
  5045. // Fields returns all fields that were changed during this mutation. Note that in
  5046. // order to get all numeric fields that were incremented/decremented, call
  5047. // AddedFields().
  5048. func (m *CategoryMutation) Fields() []string {
  5049. fields := make([]string, 0, 5)
  5050. if m.created_at != nil {
  5051. fields = append(fields, category.FieldCreatedAt)
  5052. }
  5053. if m.updated_at != nil {
  5054. fields = append(fields, category.FieldUpdatedAt)
  5055. }
  5056. if m.deleted_at != nil {
  5057. fields = append(fields, category.FieldDeletedAt)
  5058. }
  5059. if m.name != nil {
  5060. fields = append(fields, category.FieldName)
  5061. }
  5062. if m.organization_id != nil {
  5063. fields = append(fields, category.FieldOrganizationID)
  5064. }
  5065. return fields
  5066. }
  5067. // Field returns the value of a field with the given name. The second boolean
  5068. // return value indicates that this field was not set, or was not defined in the
  5069. // schema.
  5070. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5071. switch name {
  5072. case category.FieldCreatedAt:
  5073. return m.CreatedAt()
  5074. case category.FieldUpdatedAt:
  5075. return m.UpdatedAt()
  5076. case category.FieldDeletedAt:
  5077. return m.DeletedAt()
  5078. case category.FieldName:
  5079. return m.Name()
  5080. case category.FieldOrganizationID:
  5081. return m.OrganizationID()
  5082. }
  5083. return nil, false
  5084. }
  5085. // OldField returns the old value of the field from the database. An error is
  5086. // returned if the mutation operation is not UpdateOne, or the query to the
  5087. // database failed.
  5088. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5089. switch name {
  5090. case category.FieldCreatedAt:
  5091. return m.OldCreatedAt(ctx)
  5092. case category.FieldUpdatedAt:
  5093. return m.OldUpdatedAt(ctx)
  5094. case category.FieldDeletedAt:
  5095. return m.OldDeletedAt(ctx)
  5096. case category.FieldName:
  5097. return m.OldName(ctx)
  5098. case category.FieldOrganizationID:
  5099. return m.OldOrganizationID(ctx)
  5100. }
  5101. return nil, fmt.Errorf("unknown Category field %s", name)
  5102. }
  5103. // SetField sets the value of a field with the given name. It returns an error if
  5104. // the field is not defined in the schema, or if the type mismatched the field
  5105. // type.
  5106. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5107. switch name {
  5108. case category.FieldCreatedAt:
  5109. v, ok := value.(time.Time)
  5110. if !ok {
  5111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5112. }
  5113. m.SetCreatedAt(v)
  5114. return nil
  5115. case category.FieldUpdatedAt:
  5116. v, ok := value.(time.Time)
  5117. if !ok {
  5118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5119. }
  5120. m.SetUpdatedAt(v)
  5121. return nil
  5122. case category.FieldDeletedAt:
  5123. v, ok := value.(time.Time)
  5124. if !ok {
  5125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5126. }
  5127. m.SetDeletedAt(v)
  5128. return nil
  5129. case category.FieldName:
  5130. v, ok := value.(string)
  5131. if !ok {
  5132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5133. }
  5134. m.SetName(v)
  5135. return nil
  5136. case category.FieldOrganizationID:
  5137. v, ok := value.(uint64)
  5138. if !ok {
  5139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5140. }
  5141. m.SetOrganizationID(v)
  5142. return nil
  5143. }
  5144. return fmt.Errorf("unknown Category field %s", name)
  5145. }
  5146. // AddedFields returns all numeric fields that were incremented/decremented during
  5147. // this mutation.
  5148. func (m *CategoryMutation) AddedFields() []string {
  5149. var fields []string
  5150. if m.addorganization_id != nil {
  5151. fields = append(fields, category.FieldOrganizationID)
  5152. }
  5153. return fields
  5154. }
  5155. // AddedField returns the numeric value that was incremented/decremented on a field
  5156. // with the given name. The second boolean return value indicates that this field
  5157. // was not set, or was not defined in the schema.
  5158. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5159. switch name {
  5160. case category.FieldOrganizationID:
  5161. return m.AddedOrganizationID()
  5162. }
  5163. return nil, false
  5164. }
  5165. // AddField adds the value to the field with the given name. It returns an error if
  5166. // the field is not defined in the schema, or if the type mismatched the field
  5167. // type.
  5168. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5169. switch name {
  5170. case category.FieldOrganizationID:
  5171. v, ok := value.(int64)
  5172. if !ok {
  5173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5174. }
  5175. m.AddOrganizationID(v)
  5176. return nil
  5177. }
  5178. return fmt.Errorf("unknown Category numeric field %s", name)
  5179. }
  5180. // ClearedFields returns all nullable fields that were cleared during this
  5181. // mutation.
  5182. func (m *CategoryMutation) ClearedFields() []string {
  5183. var fields []string
  5184. if m.FieldCleared(category.FieldDeletedAt) {
  5185. fields = append(fields, category.FieldDeletedAt)
  5186. }
  5187. return fields
  5188. }
  5189. // FieldCleared returns a boolean indicating if a field with the given name was
  5190. // cleared in this mutation.
  5191. func (m *CategoryMutation) FieldCleared(name string) bool {
  5192. _, ok := m.clearedFields[name]
  5193. return ok
  5194. }
  5195. // ClearField clears the value of the field with the given name. It returns an
  5196. // error if the field is not defined in the schema.
  5197. func (m *CategoryMutation) ClearField(name string) error {
  5198. switch name {
  5199. case category.FieldDeletedAt:
  5200. m.ClearDeletedAt()
  5201. return nil
  5202. }
  5203. return fmt.Errorf("unknown Category nullable field %s", name)
  5204. }
  5205. // ResetField resets all changes in the mutation for the field with the given name.
  5206. // It returns an error if the field is not defined in the schema.
  5207. func (m *CategoryMutation) ResetField(name string) error {
  5208. switch name {
  5209. case category.FieldCreatedAt:
  5210. m.ResetCreatedAt()
  5211. return nil
  5212. case category.FieldUpdatedAt:
  5213. m.ResetUpdatedAt()
  5214. return nil
  5215. case category.FieldDeletedAt:
  5216. m.ResetDeletedAt()
  5217. return nil
  5218. case category.FieldName:
  5219. m.ResetName()
  5220. return nil
  5221. case category.FieldOrganizationID:
  5222. m.ResetOrganizationID()
  5223. return nil
  5224. }
  5225. return fmt.Errorf("unknown Category field %s", name)
  5226. }
  5227. // AddedEdges returns all edge names that were set/added in this mutation.
  5228. func (m *CategoryMutation) AddedEdges() []string {
  5229. edges := make([]string, 0, 0)
  5230. return edges
  5231. }
  5232. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5233. // name in this mutation.
  5234. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5235. return nil
  5236. }
  5237. // RemovedEdges returns all edge names that were removed in this mutation.
  5238. func (m *CategoryMutation) RemovedEdges() []string {
  5239. edges := make([]string, 0, 0)
  5240. return edges
  5241. }
  5242. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5243. // the given name in this mutation.
  5244. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5245. return nil
  5246. }
  5247. // ClearedEdges returns all edge names that were cleared in this mutation.
  5248. func (m *CategoryMutation) ClearedEdges() []string {
  5249. edges := make([]string, 0, 0)
  5250. return edges
  5251. }
  5252. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5253. // was cleared in this mutation.
  5254. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5255. return false
  5256. }
  5257. // ClearEdge clears the value of the edge with the given name. It returns an error
  5258. // if that edge is not defined in the schema.
  5259. func (m *CategoryMutation) ClearEdge(name string) error {
  5260. return fmt.Errorf("unknown Category unique edge %s", name)
  5261. }
  5262. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5263. // It returns an error if the edge is not defined in the schema.
  5264. func (m *CategoryMutation) ResetEdge(name string) error {
  5265. return fmt.Errorf("unknown Category edge %s", name)
  5266. }
  5267. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5268. type ChatRecordsMutation struct {
  5269. config
  5270. op Op
  5271. typ string
  5272. id *uint64
  5273. created_at *time.Time
  5274. updated_at *time.Time
  5275. deleted_at *time.Time
  5276. content *string
  5277. content_type *uint8
  5278. addcontent_type *int8
  5279. session_id *uint64
  5280. addsession_id *int64
  5281. user_id *uint64
  5282. adduser_id *int64
  5283. bot_id *uint64
  5284. addbot_id *int64
  5285. bot_type *uint8
  5286. addbot_type *int8
  5287. clearedFields map[string]struct{}
  5288. done bool
  5289. oldValue func(context.Context) (*ChatRecords, error)
  5290. predicates []predicate.ChatRecords
  5291. }
  5292. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5293. // chatrecordsOption allows management of the mutation configuration using functional options.
  5294. type chatrecordsOption func(*ChatRecordsMutation)
  5295. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5296. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5297. m := &ChatRecordsMutation{
  5298. config: c,
  5299. op: op,
  5300. typ: TypeChatRecords,
  5301. clearedFields: make(map[string]struct{}),
  5302. }
  5303. for _, opt := range opts {
  5304. opt(m)
  5305. }
  5306. return m
  5307. }
  5308. // withChatRecordsID sets the ID field of the mutation.
  5309. func withChatRecordsID(id uint64) chatrecordsOption {
  5310. return func(m *ChatRecordsMutation) {
  5311. var (
  5312. err error
  5313. once sync.Once
  5314. value *ChatRecords
  5315. )
  5316. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5317. once.Do(func() {
  5318. if m.done {
  5319. err = errors.New("querying old values post mutation is not allowed")
  5320. } else {
  5321. value, err = m.Client().ChatRecords.Get(ctx, id)
  5322. }
  5323. })
  5324. return value, err
  5325. }
  5326. m.id = &id
  5327. }
  5328. }
  5329. // withChatRecords sets the old ChatRecords of the mutation.
  5330. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5331. return func(m *ChatRecordsMutation) {
  5332. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5333. return node, nil
  5334. }
  5335. m.id = &node.ID
  5336. }
  5337. }
  5338. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5339. // executed in a transaction (ent.Tx), a transactional client is returned.
  5340. func (m ChatRecordsMutation) Client() *Client {
  5341. client := &Client{config: m.config}
  5342. client.init()
  5343. return client
  5344. }
  5345. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5346. // it returns an error otherwise.
  5347. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5348. if _, ok := m.driver.(*txDriver); !ok {
  5349. return nil, errors.New("ent: mutation is not running in a transaction")
  5350. }
  5351. tx := &Tx{config: m.config}
  5352. tx.init()
  5353. return tx, nil
  5354. }
  5355. // SetID sets the value of the id field. Note that this
  5356. // operation is only accepted on creation of ChatRecords entities.
  5357. func (m *ChatRecordsMutation) SetID(id uint64) {
  5358. m.id = &id
  5359. }
  5360. // ID returns the ID value in the mutation. Note that the ID is only available
  5361. // if it was provided to the builder or after it was returned from the database.
  5362. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5363. if m.id == nil {
  5364. return
  5365. }
  5366. return *m.id, true
  5367. }
  5368. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5369. // That means, if the mutation is applied within a transaction with an isolation level such
  5370. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5371. // or updated by the mutation.
  5372. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5373. switch {
  5374. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5375. id, exists := m.ID()
  5376. if exists {
  5377. return []uint64{id}, nil
  5378. }
  5379. fallthrough
  5380. case m.op.Is(OpUpdate | OpDelete):
  5381. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5382. default:
  5383. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5384. }
  5385. }
  5386. // SetCreatedAt sets the "created_at" field.
  5387. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5388. m.created_at = &t
  5389. }
  5390. // CreatedAt returns the value of the "created_at" field in the mutation.
  5391. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5392. v := m.created_at
  5393. if v == nil {
  5394. return
  5395. }
  5396. return *v, true
  5397. }
  5398. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5399. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5401. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5402. if !m.op.Is(OpUpdateOne) {
  5403. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5404. }
  5405. if m.id == nil || m.oldValue == nil {
  5406. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5407. }
  5408. oldValue, err := m.oldValue(ctx)
  5409. if err != nil {
  5410. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5411. }
  5412. return oldValue.CreatedAt, nil
  5413. }
  5414. // ResetCreatedAt resets all changes to the "created_at" field.
  5415. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5416. m.created_at = nil
  5417. }
  5418. // SetUpdatedAt sets the "updated_at" field.
  5419. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5420. m.updated_at = &t
  5421. }
  5422. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5423. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5424. v := m.updated_at
  5425. if v == nil {
  5426. return
  5427. }
  5428. return *v, true
  5429. }
  5430. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5431. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5433. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5434. if !m.op.Is(OpUpdateOne) {
  5435. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5436. }
  5437. if m.id == nil || m.oldValue == nil {
  5438. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5439. }
  5440. oldValue, err := m.oldValue(ctx)
  5441. if err != nil {
  5442. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5443. }
  5444. return oldValue.UpdatedAt, nil
  5445. }
  5446. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5447. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5448. m.updated_at = nil
  5449. }
  5450. // SetDeletedAt sets the "deleted_at" field.
  5451. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5452. m.deleted_at = &t
  5453. }
  5454. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5455. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5456. v := m.deleted_at
  5457. if v == nil {
  5458. return
  5459. }
  5460. return *v, true
  5461. }
  5462. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5463. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5465. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5466. if !m.op.Is(OpUpdateOne) {
  5467. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5468. }
  5469. if m.id == nil || m.oldValue == nil {
  5470. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5471. }
  5472. oldValue, err := m.oldValue(ctx)
  5473. if err != nil {
  5474. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5475. }
  5476. return oldValue.DeletedAt, nil
  5477. }
  5478. // ClearDeletedAt clears the value of the "deleted_at" field.
  5479. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5480. m.deleted_at = nil
  5481. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5482. }
  5483. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5484. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5485. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5486. return ok
  5487. }
  5488. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5489. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5490. m.deleted_at = nil
  5491. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5492. }
  5493. // SetContent sets the "content" field.
  5494. func (m *ChatRecordsMutation) SetContent(s string) {
  5495. m.content = &s
  5496. }
  5497. // Content returns the value of the "content" field in the mutation.
  5498. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5499. v := m.content
  5500. if v == nil {
  5501. return
  5502. }
  5503. return *v, true
  5504. }
  5505. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5506. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5508. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5509. if !m.op.Is(OpUpdateOne) {
  5510. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5511. }
  5512. if m.id == nil || m.oldValue == nil {
  5513. return v, errors.New("OldContent requires an ID field in the mutation")
  5514. }
  5515. oldValue, err := m.oldValue(ctx)
  5516. if err != nil {
  5517. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5518. }
  5519. return oldValue.Content, nil
  5520. }
  5521. // ResetContent resets all changes to the "content" field.
  5522. func (m *ChatRecordsMutation) ResetContent() {
  5523. m.content = nil
  5524. }
  5525. // SetContentType sets the "content_type" field.
  5526. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5527. m.content_type = &u
  5528. m.addcontent_type = nil
  5529. }
  5530. // ContentType returns the value of the "content_type" field in the mutation.
  5531. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5532. v := m.content_type
  5533. if v == nil {
  5534. return
  5535. }
  5536. return *v, true
  5537. }
  5538. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5539. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5541. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5542. if !m.op.Is(OpUpdateOne) {
  5543. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5544. }
  5545. if m.id == nil || m.oldValue == nil {
  5546. return v, errors.New("OldContentType requires an ID field in the mutation")
  5547. }
  5548. oldValue, err := m.oldValue(ctx)
  5549. if err != nil {
  5550. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5551. }
  5552. return oldValue.ContentType, nil
  5553. }
  5554. // AddContentType adds u to the "content_type" field.
  5555. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5556. if m.addcontent_type != nil {
  5557. *m.addcontent_type += u
  5558. } else {
  5559. m.addcontent_type = &u
  5560. }
  5561. }
  5562. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5563. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5564. v := m.addcontent_type
  5565. if v == nil {
  5566. return
  5567. }
  5568. return *v, true
  5569. }
  5570. // ResetContentType resets all changes to the "content_type" field.
  5571. func (m *ChatRecordsMutation) ResetContentType() {
  5572. m.content_type = nil
  5573. m.addcontent_type = nil
  5574. }
  5575. // SetSessionID sets the "session_id" field.
  5576. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5577. m.session_id = &u
  5578. m.addsession_id = nil
  5579. }
  5580. // SessionID returns the value of the "session_id" field in the mutation.
  5581. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5582. v := m.session_id
  5583. if v == nil {
  5584. return
  5585. }
  5586. return *v, true
  5587. }
  5588. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5589. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5591. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5592. if !m.op.Is(OpUpdateOne) {
  5593. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5594. }
  5595. if m.id == nil || m.oldValue == nil {
  5596. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5597. }
  5598. oldValue, err := m.oldValue(ctx)
  5599. if err != nil {
  5600. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5601. }
  5602. return oldValue.SessionID, nil
  5603. }
  5604. // AddSessionID adds u to the "session_id" field.
  5605. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5606. if m.addsession_id != nil {
  5607. *m.addsession_id += u
  5608. } else {
  5609. m.addsession_id = &u
  5610. }
  5611. }
  5612. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5613. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5614. v := m.addsession_id
  5615. if v == nil {
  5616. return
  5617. }
  5618. return *v, true
  5619. }
  5620. // ResetSessionID resets all changes to the "session_id" field.
  5621. func (m *ChatRecordsMutation) ResetSessionID() {
  5622. m.session_id = nil
  5623. m.addsession_id = nil
  5624. }
  5625. // SetUserID sets the "user_id" field.
  5626. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5627. m.user_id = &u
  5628. m.adduser_id = nil
  5629. }
  5630. // UserID returns the value of the "user_id" field in the mutation.
  5631. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5632. v := m.user_id
  5633. if v == nil {
  5634. return
  5635. }
  5636. return *v, true
  5637. }
  5638. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5639. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5641. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5642. if !m.op.Is(OpUpdateOne) {
  5643. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5644. }
  5645. if m.id == nil || m.oldValue == nil {
  5646. return v, errors.New("OldUserID requires an ID field in the mutation")
  5647. }
  5648. oldValue, err := m.oldValue(ctx)
  5649. if err != nil {
  5650. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5651. }
  5652. return oldValue.UserID, nil
  5653. }
  5654. // AddUserID adds u to the "user_id" field.
  5655. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5656. if m.adduser_id != nil {
  5657. *m.adduser_id += u
  5658. } else {
  5659. m.adduser_id = &u
  5660. }
  5661. }
  5662. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5663. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5664. v := m.adduser_id
  5665. if v == nil {
  5666. return
  5667. }
  5668. return *v, true
  5669. }
  5670. // ResetUserID resets all changes to the "user_id" field.
  5671. func (m *ChatRecordsMutation) ResetUserID() {
  5672. m.user_id = nil
  5673. m.adduser_id = nil
  5674. }
  5675. // SetBotID sets the "bot_id" field.
  5676. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5677. m.bot_id = &u
  5678. m.addbot_id = nil
  5679. }
  5680. // BotID returns the value of the "bot_id" field in the mutation.
  5681. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5682. v := m.bot_id
  5683. if v == nil {
  5684. return
  5685. }
  5686. return *v, true
  5687. }
  5688. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5689. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5691. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5692. if !m.op.Is(OpUpdateOne) {
  5693. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5694. }
  5695. if m.id == nil || m.oldValue == nil {
  5696. return v, errors.New("OldBotID requires an ID field in the mutation")
  5697. }
  5698. oldValue, err := m.oldValue(ctx)
  5699. if err != nil {
  5700. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5701. }
  5702. return oldValue.BotID, nil
  5703. }
  5704. // AddBotID adds u to the "bot_id" field.
  5705. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5706. if m.addbot_id != nil {
  5707. *m.addbot_id += u
  5708. } else {
  5709. m.addbot_id = &u
  5710. }
  5711. }
  5712. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5713. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5714. v := m.addbot_id
  5715. if v == nil {
  5716. return
  5717. }
  5718. return *v, true
  5719. }
  5720. // ResetBotID resets all changes to the "bot_id" field.
  5721. func (m *ChatRecordsMutation) ResetBotID() {
  5722. m.bot_id = nil
  5723. m.addbot_id = nil
  5724. }
  5725. // SetBotType sets the "bot_type" field.
  5726. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5727. m.bot_type = &u
  5728. m.addbot_type = nil
  5729. }
  5730. // BotType returns the value of the "bot_type" field in the mutation.
  5731. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5732. v := m.bot_type
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5739. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5741. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldBotType requires an ID field in the mutation")
  5747. }
  5748. oldValue, err := m.oldValue(ctx)
  5749. if err != nil {
  5750. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5751. }
  5752. return oldValue.BotType, nil
  5753. }
  5754. // AddBotType adds u to the "bot_type" field.
  5755. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5756. if m.addbot_type != nil {
  5757. *m.addbot_type += u
  5758. } else {
  5759. m.addbot_type = &u
  5760. }
  5761. }
  5762. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5763. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5764. v := m.addbot_type
  5765. if v == nil {
  5766. return
  5767. }
  5768. return *v, true
  5769. }
  5770. // ResetBotType resets all changes to the "bot_type" field.
  5771. func (m *ChatRecordsMutation) ResetBotType() {
  5772. m.bot_type = nil
  5773. m.addbot_type = nil
  5774. }
  5775. // Where appends a list predicates to the ChatRecordsMutation builder.
  5776. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5777. m.predicates = append(m.predicates, ps...)
  5778. }
  5779. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5780. // users can use type-assertion to append predicates that do not depend on any generated package.
  5781. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5782. p := make([]predicate.ChatRecords, len(ps))
  5783. for i := range ps {
  5784. p[i] = ps[i]
  5785. }
  5786. m.Where(p...)
  5787. }
  5788. // Op returns the operation name.
  5789. func (m *ChatRecordsMutation) Op() Op {
  5790. return m.op
  5791. }
  5792. // SetOp allows setting the mutation operation.
  5793. func (m *ChatRecordsMutation) SetOp(op Op) {
  5794. m.op = op
  5795. }
  5796. // Type returns the node type of this mutation (ChatRecords).
  5797. func (m *ChatRecordsMutation) Type() string {
  5798. return m.typ
  5799. }
  5800. // Fields returns all fields that were changed during this mutation. Note that in
  5801. // order to get all numeric fields that were incremented/decremented, call
  5802. // AddedFields().
  5803. func (m *ChatRecordsMutation) Fields() []string {
  5804. fields := make([]string, 0, 9)
  5805. if m.created_at != nil {
  5806. fields = append(fields, chatrecords.FieldCreatedAt)
  5807. }
  5808. if m.updated_at != nil {
  5809. fields = append(fields, chatrecords.FieldUpdatedAt)
  5810. }
  5811. if m.deleted_at != nil {
  5812. fields = append(fields, chatrecords.FieldDeletedAt)
  5813. }
  5814. if m.content != nil {
  5815. fields = append(fields, chatrecords.FieldContent)
  5816. }
  5817. if m.content_type != nil {
  5818. fields = append(fields, chatrecords.FieldContentType)
  5819. }
  5820. if m.session_id != nil {
  5821. fields = append(fields, chatrecords.FieldSessionID)
  5822. }
  5823. if m.user_id != nil {
  5824. fields = append(fields, chatrecords.FieldUserID)
  5825. }
  5826. if m.bot_id != nil {
  5827. fields = append(fields, chatrecords.FieldBotID)
  5828. }
  5829. if m.bot_type != nil {
  5830. fields = append(fields, chatrecords.FieldBotType)
  5831. }
  5832. return fields
  5833. }
  5834. // Field returns the value of a field with the given name. The second boolean
  5835. // return value indicates that this field was not set, or was not defined in the
  5836. // schema.
  5837. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5838. switch name {
  5839. case chatrecords.FieldCreatedAt:
  5840. return m.CreatedAt()
  5841. case chatrecords.FieldUpdatedAt:
  5842. return m.UpdatedAt()
  5843. case chatrecords.FieldDeletedAt:
  5844. return m.DeletedAt()
  5845. case chatrecords.FieldContent:
  5846. return m.Content()
  5847. case chatrecords.FieldContentType:
  5848. return m.ContentType()
  5849. case chatrecords.FieldSessionID:
  5850. return m.SessionID()
  5851. case chatrecords.FieldUserID:
  5852. return m.UserID()
  5853. case chatrecords.FieldBotID:
  5854. return m.BotID()
  5855. case chatrecords.FieldBotType:
  5856. return m.BotType()
  5857. }
  5858. return nil, false
  5859. }
  5860. // OldField returns the old value of the field from the database. An error is
  5861. // returned if the mutation operation is not UpdateOne, or the query to the
  5862. // database failed.
  5863. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5864. switch name {
  5865. case chatrecords.FieldCreatedAt:
  5866. return m.OldCreatedAt(ctx)
  5867. case chatrecords.FieldUpdatedAt:
  5868. return m.OldUpdatedAt(ctx)
  5869. case chatrecords.FieldDeletedAt:
  5870. return m.OldDeletedAt(ctx)
  5871. case chatrecords.FieldContent:
  5872. return m.OldContent(ctx)
  5873. case chatrecords.FieldContentType:
  5874. return m.OldContentType(ctx)
  5875. case chatrecords.FieldSessionID:
  5876. return m.OldSessionID(ctx)
  5877. case chatrecords.FieldUserID:
  5878. return m.OldUserID(ctx)
  5879. case chatrecords.FieldBotID:
  5880. return m.OldBotID(ctx)
  5881. case chatrecords.FieldBotType:
  5882. return m.OldBotType(ctx)
  5883. }
  5884. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5885. }
  5886. // SetField sets the value of a field with the given name. It returns an error if
  5887. // the field is not defined in the schema, or if the type mismatched the field
  5888. // type.
  5889. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5890. switch name {
  5891. case chatrecords.FieldCreatedAt:
  5892. v, ok := value.(time.Time)
  5893. if !ok {
  5894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5895. }
  5896. m.SetCreatedAt(v)
  5897. return nil
  5898. case chatrecords.FieldUpdatedAt:
  5899. v, ok := value.(time.Time)
  5900. if !ok {
  5901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5902. }
  5903. m.SetUpdatedAt(v)
  5904. return nil
  5905. case chatrecords.FieldDeletedAt:
  5906. v, ok := value.(time.Time)
  5907. if !ok {
  5908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5909. }
  5910. m.SetDeletedAt(v)
  5911. return nil
  5912. case chatrecords.FieldContent:
  5913. v, ok := value.(string)
  5914. if !ok {
  5915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5916. }
  5917. m.SetContent(v)
  5918. return nil
  5919. case chatrecords.FieldContentType:
  5920. v, ok := value.(uint8)
  5921. if !ok {
  5922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5923. }
  5924. m.SetContentType(v)
  5925. return nil
  5926. case chatrecords.FieldSessionID:
  5927. v, ok := value.(uint64)
  5928. if !ok {
  5929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5930. }
  5931. m.SetSessionID(v)
  5932. return nil
  5933. case chatrecords.FieldUserID:
  5934. v, ok := value.(uint64)
  5935. if !ok {
  5936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5937. }
  5938. m.SetUserID(v)
  5939. return nil
  5940. case chatrecords.FieldBotID:
  5941. v, ok := value.(uint64)
  5942. if !ok {
  5943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5944. }
  5945. m.SetBotID(v)
  5946. return nil
  5947. case chatrecords.FieldBotType:
  5948. v, ok := value.(uint8)
  5949. if !ok {
  5950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5951. }
  5952. m.SetBotType(v)
  5953. return nil
  5954. }
  5955. return fmt.Errorf("unknown ChatRecords field %s", name)
  5956. }
  5957. // AddedFields returns all numeric fields that were incremented/decremented during
  5958. // this mutation.
  5959. func (m *ChatRecordsMutation) AddedFields() []string {
  5960. var fields []string
  5961. if m.addcontent_type != nil {
  5962. fields = append(fields, chatrecords.FieldContentType)
  5963. }
  5964. if m.addsession_id != nil {
  5965. fields = append(fields, chatrecords.FieldSessionID)
  5966. }
  5967. if m.adduser_id != nil {
  5968. fields = append(fields, chatrecords.FieldUserID)
  5969. }
  5970. if m.addbot_id != nil {
  5971. fields = append(fields, chatrecords.FieldBotID)
  5972. }
  5973. if m.addbot_type != nil {
  5974. fields = append(fields, chatrecords.FieldBotType)
  5975. }
  5976. return fields
  5977. }
  5978. // AddedField returns the numeric value that was incremented/decremented on a field
  5979. // with the given name. The second boolean return value indicates that this field
  5980. // was not set, or was not defined in the schema.
  5981. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5982. switch name {
  5983. case chatrecords.FieldContentType:
  5984. return m.AddedContentType()
  5985. case chatrecords.FieldSessionID:
  5986. return m.AddedSessionID()
  5987. case chatrecords.FieldUserID:
  5988. return m.AddedUserID()
  5989. case chatrecords.FieldBotID:
  5990. return m.AddedBotID()
  5991. case chatrecords.FieldBotType:
  5992. return m.AddedBotType()
  5993. }
  5994. return nil, false
  5995. }
  5996. // AddField adds the value to the field with the given name. It returns an error if
  5997. // the field is not defined in the schema, or if the type mismatched the field
  5998. // type.
  5999. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6000. switch name {
  6001. case chatrecords.FieldContentType:
  6002. v, ok := value.(int8)
  6003. if !ok {
  6004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6005. }
  6006. m.AddContentType(v)
  6007. return nil
  6008. case chatrecords.FieldSessionID:
  6009. v, ok := value.(int64)
  6010. if !ok {
  6011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6012. }
  6013. m.AddSessionID(v)
  6014. return nil
  6015. case chatrecords.FieldUserID:
  6016. v, ok := value.(int64)
  6017. if !ok {
  6018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6019. }
  6020. m.AddUserID(v)
  6021. return nil
  6022. case chatrecords.FieldBotID:
  6023. v, ok := value.(int64)
  6024. if !ok {
  6025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6026. }
  6027. m.AddBotID(v)
  6028. return nil
  6029. case chatrecords.FieldBotType:
  6030. v, ok := value.(int8)
  6031. if !ok {
  6032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6033. }
  6034. m.AddBotType(v)
  6035. return nil
  6036. }
  6037. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6038. }
  6039. // ClearedFields returns all nullable fields that were cleared during this
  6040. // mutation.
  6041. func (m *ChatRecordsMutation) ClearedFields() []string {
  6042. var fields []string
  6043. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6044. fields = append(fields, chatrecords.FieldDeletedAt)
  6045. }
  6046. return fields
  6047. }
  6048. // FieldCleared returns a boolean indicating if a field with the given name was
  6049. // cleared in this mutation.
  6050. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6051. _, ok := m.clearedFields[name]
  6052. return ok
  6053. }
  6054. // ClearField clears the value of the field with the given name. It returns an
  6055. // error if the field is not defined in the schema.
  6056. func (m *ChatRecordsMutation) ClearField(name string) error {
  6057. switch name {
  6058. case chatrecords.FieldDeletedAt:
  6059. m.ClearDeletedAt()
  6060. return nil
  6061. }
  6062. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6063. }
  6064. // ResetField resets all changes in the mutation for the field with the given name.
  6065. // It returns an error if the field is not defined in the schema.
  6066. func (m *ChatRecordsMutation) ResetField(name string) error {
  6067. switch name {
  6068. case chatrecords.FieldCreatedAt:
  6069. m.ResetCreatedAt()
  6070. return nil
  6071. case chatrecords.FieldUpdatedAt:
  6072. m.ResetUpdatedAt()
  6073. return nil
  6074. case chatrecords.FieldDeletedAt:
  6075. m.ResetDeletedAt()
  6076. return nil
  6077. case chatrecords.FieldContent:
  6078. m.ResetContent()
  6079. return nil
  6080. case chatrecords.FieldContentType:
  6081. m.ResetContentType()
  6082. return nil
  6083. case chatrecords.FieldSessionID:
  6084. m.ResetSessionID()
  6085. return nil
  6086. case chatrecords.FieldUserID:
  6087. m.ResetUserID()
  6088. return nil
  6089. case chatrecords.FieldBotID:
  6090. m.ResetBotID()
  6091. return nil
  6092. case chatrecords.FieldBotType:
  6093. m.ResetBotType()
  6094. return nil
  6095. }
  6096. return fmt.Errorf("unknown ChatRecords field %s", name)
  6097. }
  6098. // AddedEdges returns all edge names that were set/added in this mutation.
  6099. func (m *ChatRecordsMutation) AddedEdges() []string {
  6100. edges := make([]string, 0, 0)
  6101. return edges
  6102. }
  6103. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6104. // name in this mutation.
  6105. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6106. return nil
  6107. }
  6108. // RemovedEdges returns all edge names that were removed in this mutation.
  6109. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6110. edges := make([]string, 0, 0)
  6111. return edges
  6112. }
  6113. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6114. // the given name in this mutation.
  6115. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6116. return nil
  6117. }
  6118. // ClearedEdges returns all edge names that were cleared in this mutation.
  6119. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6120. edges := make([]string, 0, 0)
  6121. return edges
  6122. }
  6123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6124. // was cleared in this mutation.
  6125. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6126. return false
  6127. }
  6128. // ClearEdge clears the value of the edge with the given name. It returns an error
  6129. // if that edge is not defined in the schema.
  6130. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6131. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6132. }
  6133. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6134. // It returns an error if the edge is not defined in the schema.
  6135. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6136. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6137. }
  6138. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6139. type ChatSessionMutation struct {
  6140. config
  6141. op Op
  6142. typ string
  6143. id *uint64
  6144. created_at *time.Time
  6145. updated_at *time.Time
  6146. deleted_at *time.Time
  6147. name *string
  6148. user_id *uint64
  6149. adduser_id *int64
  6150. bot_id *uint64
  6151. addbot_id *int64
  6152. bot_type *uint8
  6153. addbot_type *int8
  6154. clearedFields map[string]struct{}
  6155. done bool
  6156. oldValue func(context.Context) (*ChatSession, error)
  6157. predicates []predicate.ChatSession
  6158. }
  6159. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6160. // chatsessionOption allows management of the mutation configuration using functional options.
  6161. type chatsessionOption func(*ChatSessionMutation)
  6162. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6163. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6164. m := &ChatSessionMutation{
  6165. config: c,
  6166. op: op,
  6167. typ: TypeChatSession,
  6168. clearedFields: make(map[string]struct{}),
  6169. }
  6170. for _, opt := range opts {
  6171. opt(m)
  6172. }
  6173. return m
  6174. }
  6175. // withChatSessionID sets the ID field of the mutation.
  6176. func withChatSessionID(id uint64) chatsessionOption {
  6177. return func(m *ChatSessionMutation) {
  6178. var (
  6179. err error
  6180. once sync.Once
  6181. value *ChatSession
  6182. )
  6183. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6184. once.Do(func() {
  6185. if m.done {
  6186. err = errors.New("querying old values post mutation is not allowed")
  6187. } else {
  6188. value, err = m.Client().ChatSession.Get(ctx, id)
  6189. }
  6190. })
  6191. return value, err
  6192. }
  6193. m.id = &id
  6194. }
  6195. }
  6196. // withChatSession sets the old ChatSession of the mutation.
  6197. func withChatSession(node *ChatSession) chatsessionOption {
  6198. return func(m *ChatSessionMutation) {
  6199. m.oldValue = func(context.Context) (*ChatSession, error) {
  6200. return node, nil
  6201. }
  6202. m.id = &node.ID
  6203. }
  6204. }
  6205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6206. // executed in a transaction (ent.Tx), a transactional client is returned.
  6207. func (m ChatSessionMutation) Client() *Client {
  6208. client := &Client{config: m.config}
  6209. client.init()
  6210. return client
  6211. }
  6212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6213. // it returns an error otherwise.
  6214. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6215. if _, ok := m.driver.(*txDriver); !ok {
  6216. return nil, errors.New("ent: mutation is not running in a transaction")
  6217. }
  6218. tx := &Tx{config: m.config}
  6219. tx.init()
  6220. return tx, nil
  6221. }
  6222. // SetID sets the value of the id field. Note that this
  6223. // operation is only accepted on creation of ChatSession entities.
  6224. func (m *ChatSessionMutation) SetID(id uint64) {
  6225. m.id = &id
  6226. }
  6227. // ID returns the ID value in the mutation. Note that the ID is only available
  6228. // if it was provided to the builder or after it was returned from the database.
  6229. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6230. if m.id == nil {
  6231. return
  6232. }
  6233. return *m.id, true
  6234. }
  6235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6236. // That means, if the mutation is applied within a transaction with an isolation level such
  6237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6238. // or updated by the mutation.
  6239. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6240. switch {
  6241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6242. id, exists := m.ID()
  6243. if exists {
  6244. return []uint64{id}, nil
  6245. }
  6246. fallthrough
  6247. case m.op.Is(OpUpdate | OpDelete):
  6248. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6249. default:
  6250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6251. }
  6252. }
  6253. // SetCreatedAt sets the "created_at" field.
  6254. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6255. m.created_at = &t
  6256. }
  6257. // CreatedAt returns the value of the "created_at" field in the mutation.
  6258. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6259. v := m.created_at
  6260. if v == nil {
  6261. return
  6262. }
  6263. return *v, true
  6264. }
  6265. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6266. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6268. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6269. if !m.op.Is(OpUpdateOne) {
  6270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6271. }
  6272. if m.id == nil || m.oldValue == nil {
  6273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6274. }
  6275. oldValue, err := m.oldValue(ctx)
  6276. if err != nil {
  6277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6278. }
  6279. return oldValue.CreatedAt, nil
  6280. }
  6281. // ResetCreatedAt resets all changes to the "created_at" field.
  6282. func (m *ChatSessionMutation) ResetCreatedAt() {
  6283. m.created_at = nil
  6284. }
  6285. // SetUpdatedAt sets the "updated_at" field.
  6286. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6287. m.updated_at = &t
  6288. }
  6289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6290. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6291. v := m.updated_at
  6292. if v == nil {
  6293. return
  6294. }
  6295. return *v, true
  6296. }
  6297. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6298. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6300. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6301. if !m.op.Is(OpUpdateOne) {
  6302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6303. }
  6304. if m.id == nil || m.oldValue == nil {
  6305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6306. }
  6307. oldValue, err := m.oldValue(ctx)
  6308. if err != nil {
  6309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6310. }
  6311. return oldValue.UpdatedAt, nil
  6312. }
  6313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6314. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6315. m.updated_at = nil
  6316. }
  6317. // SetDeletedAt sets the "deleted_at" field.
  6318. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6319. m.deleted_at = &t
  6320. }
  6321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6322. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6323. v := m.deleted_at
  6324. if v == nil {
  6325. return
  6326. }
  6327. return *v, true
  6328. }
  6329. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6330. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6332. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6333. if !m.op.Is(OpUpdateOne) {
  6334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6335. }
  6336. if m.id == nil || m.oldValue == nil {
  6337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6338. }
  6339. oldValue, err := m.oldValue(ctx)
  6340. if err != nil {
  6341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6342. }
  6343. return oldValue.DeletedAt, nil
  6344. }
  6345. // ClearDeletedAt clears the value of the "deleted_at" field.
  6346. func (m *ChatSessionMutation) ClearDeletedAt() {
  6347. m.deleted_at = nil
  6348. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6349. }
  6350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6351. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6352. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6353. return ok
  6354. }
  6355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6356. func (m *ChatSessionMutation) ResetDeletedAt() {
  6357. m.deleted_at = nil
  6358. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6359. }
  6360. // SetName sets the "name" field.
  6361. func (m *ChatSessionMutation) SetName(s string) {
  6362. m.name = &s
  6363. }
  6364. // Name returns the value of the "name" field in the mutation.
  6365. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6366. v := m.name
  6367. if v == nil {
  6368. return
  6369. }
  6370. return *v, true
  6371. }
  6372. // OldName returns the old "name" field's value of the ChatSession entity.
  6373. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6375. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6376. if !m.op.Is(OpUpdateOne) {
  6377. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6378. }
  6379. if m.id == nil || m.oldValue == nil {
  6380. return v, errors.New("OldName requires an ID field in the mutation")
  6381. }
  6382. oldValue, err := m.oldValue(ctx)
  6383. if err != nil {
  6384. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6385. }
  6386. return oldValue.Name, nil
  6387. }
  6388. // ResetName resets all changes to the "name" field.
  6389. func (m *ChatSessionMutation) ResetName() {
  6390. m.name = nil
  6391. }
  6392. // SetUserID sets the "user_id" field.
  6393. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6394. m.user_id = &u
  6395. m.adduser_id = nil
  6396. }
  6397. // UserID returns the value of the "user_id" field in the mutation.
  6398. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6399. v := m.user_id
  6400. if v == nil {
  6401. return
  6402. }
  6403. return *v, true
  6404. }
  6405. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6406. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6408. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6409. if !m.op.Is(OpUpdateOne) {
  6410. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6411. }
  6412. if m.id == nil || m.oldValue == nil {
  6413. return v, errors.New("OldUserID requires an ID field in the mutation")
  6414. }
  6415. oldValue, err := m.oldValue(ctx)
  6416. if err != nil {
  6417. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6418. }
  6419. return oldValue.UserID, nil
  6420. }
  6421. // AddUserID adds u to the "user_id" field.
  6422. func (m *ChatSessionMutation) AddUserID(u int64) {
  6423. if m.adduser_id != nil {
  6424. *m.adduser_id += u
  6425. } else {
  6426. m.adduser_id = &u
  6427. }
  6428. }
  6429. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6430. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6431. v := m.adduser_id
  6432. if v == nil {
  6433. return
  6434. }
  6435. return *v, true
  6436. }
  6437. // ResetUserID resets all changes to the "user_id" field.
  6438. func (m *ChatSessionMutation) ResetUserID() {
  6439. m.user_id = nil
  6440. m.adduser_id = nil
  6441. }
  6442. // SetBotID sets the "bot_id" field.
  6443. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6444. m.bot_id = &u
  6445. m.addbot_id = nil
  6446. }
  6447. // BotID returns the value of the "bot_id" field in the mutation.
  6448. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6449. v := m.bot_id
  6450. if v == nil {
  6451. return
  6452. }
  6453. return *v, true
  6454. }
  6455. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6456. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6458. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6459. if !m.op.Is(OpUpdateOne) {
  6460. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6461. }
  6462. if m.id == nil || m.oldValue == nil {
  6463. return v, errors.New("OldBotID requires an ID field in the mutation")
  6464. }
  6465. oldValue, err := m.oldValue(ctx)
  6466. if err != nil {
  6467. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6468. }
  6469. return oldValue.BotID, nil
  6470. }
  6471. // AddBotID adds u to the "bot_id" field.
  6472. func (m *ChatSessionMutation) AddBotID(u int64) {
  6473. if m.addbot_id != nil {
  6474. *m.addbot_id += u
  6475. } else {
  6476. m.addbot_id = &u
  6477. }
  6478. }
  6479. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6480. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6481. v := m.addbot_id
  6482. if v == nil {
  6483. return
  6484. }
  6485. return *v, true
  6486. }
  6487. // ResetBotID resets all changes to the "bot_id" field.
  6488. func (m *ChatSessionMutation) ResetBotID() {
  6489. m.bot_id = nil
  6490. m.addbot_id = nil
  6491. }
  6492. // SetBotType sets the "bot_type" field.
  6493. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6494. m.bot_type = &u
  6495. m.addbot_type = nil
  6496. }
  6497. // BotType returns the value of the "bot_type" field in the mutation.
  6498. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6499. v := m.bot_type
  6500. if v == nil {
  6501. return
  6502. }
  6503. return *v, true
  6504. }
  6505. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6506. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6508. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6509. if !m.op.Is(OpUpdateOne) {
  6510. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6511. }
  6512. if m.id == nil || m.oldValue == nil {
  6513. return v, errors.New("OldBotType requires an ID field in the mutation")
  6514. }
  6515. oldValue, err := m.oldValue(ctx)
  6516. if err != nil {
  6517. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6518. }
  6519. return oldValue.BotType, nil
  6520. }
  6521. // AddBotType adds u to the "bot_type" field.
  6522. func (m *ChatSessionMutation) AddBotType(u int8) {
  6523. if m.addbot_type != nil {
  6524. *m.addbot_type += u
  6525. } else {
  6526. m.addbot_type = &u
  6527. }
  6528. }
  6529. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6530. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6531. v := m.addbot_type
  6532. if v == nil {
  6533. return
  6534. }
  6535. return *v, true
  6536. }
  6537. // ResetBotType resets all changes to the "bot_type" field.
  6538. func (m *ChatSessionMutation) ResetBotType() {
  6539. m.bot_type = nil
  6540. m.addbot_type = nil
  6541. }
  6542. // Where appends a list predicates to the ChatSessionMutation builder.
  6543. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6544. m.predicates = append(m.predicates, ps...)
  6545. }
  6546. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6547. // users can use type-assertion to append predicates that do not depend on any generated package.
  6548. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6549. p := make([]predicate.ChatSession, len(ps))
  6550. for i := range ps {
  6551. p[i] = ps[i]
  6552. }
  6553. m.Where(p...)
  6554. }
  6555. // Op returns the operation name.
  6556. func (m *ChatSessionMutation) Op() Op {
  6557. return m.op
  6558. }
  6559. // SetOp allows setting the mutation operation.
  6560. func (m *ChatSessionMutation) SetOp(op Op) {
  6561. m.op = op
  6562. }
  6563. // Type returns the node type of this mutation (ChatSession).
  6564. func (m *ChatSessionMutation) Type() string {
  6565. return m.typ
  6566. }
  6567. // Fields returns all fields that were changed during this mutation. Note that in
  6568. // order to get all numeric fields that were incremented/decremented, call
  6569. // AddedFields().
  6570. func (m *ChatSessionMutation) Fields() []string {
  6571. fields := make([]string, 0, 7)
  6572. if m.created_at != nil {
  6573. fields = append(fields, chatsession.FieldCreatedAt)
  6574. }
  6575. if m.updated_at != nil {
  6576. fields = append(fields, chatsession.FieldUpdatedAt)
  6577. }
  6578. if m.deleted_at != nil {
  6579. fields = append(fields, chatsession.FieldDeletedAt)
  6580. }
  6581. if m.name != nil {
  6582. fields = append(fields, chatsession.FieldName)
  6583. }
  6584. if m.user_id != nil {
  6585. fields = append(fields, chatsession.FieldUserID)
  6586. }
  6587. if m.bot_id != nil {
  6588. fields = append(fields, chatsession.FieldBotID)
  6589. }
  6590. if m.bot_type != nil {
  6591. fields = append(fields, chatsession.FieldBotType)
  6592. }
  6593. return fields
  6594. }
  6595. // Field returns the value of a field with the given name. The second boolean
  6596. // return value indicates that this field was not set, or was not defined in the
  6597. // schema.
  6598. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6599. switch name {
  6600. case chatsession.FieldCreatedAt:
  6601. return m.CreatedAt()
  6602. case chatsession.FieldUpdatedAt:
  6603. return m.UpdatedAt()
  6604. case chatsession.FieldDeletedAt:
  6605. return m.DeletedAt()
  6606. case chatsession.FieldName:
  6607. return m.Name()
  6608. case chatsession.FieldUserID:
  6609. return m.UserID()
  6610. case chatsession.FieldBotID:
  6611. return m.BotID()
  6612. case chatsession.FieldBotType:
  6613. return m.BotType()
  6614. }
  6615. return nil, false
  6616. }
  6617. // OldField returns the old value of the field from the database. An error is
  6618. // returned if the mutation operation is not UpdateOne, or the query to the
  6619. // database failed.
  6620. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6621. switch name {
  6622. case chatsession.FieldCreatedAt:
  6623. return m.OldCreatedAt(ctx)
  6624. case chatsession.FieldUpdatedAt:
  6625. return m.OldUpdatedAt(ctx)
  6626. case chatsession.FieldDeletedAt:
  6627. return m.OldDeletedAt(ctx)
  6628. case chatsession.FieldName:
  6629. return m.OldName(ctx)
  6630. case chatsession.FieldUserID:
  6631. return m.OldUserID(ctx)
  6632. case chatsession.FieldBotID:
  6633. return m.OldBotID(ctx)
  6634. case chatsession.FieldBotType:
  6635. return m.OldBotType(ctx)
  6636. }
  6637. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6638. }
  6639. // SetField sets the value of a field with the given name. It returns an error if
  6640. // the field is not defined in the schema, or if the type mismatched the field
  6641. // type.
  6642. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6643. switch name {
  6644. case chatsession.FieldCreatedAt:
  6645. v, ok := value.(time.Time)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetCreatedAt(v)
  6650. return nil
  6651. case chatsession.FieldUpdatedAt:
  6652. v, ok := value.(time.Time)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetUpdatedAt(v)
  6657. return nil
  6658. case chatsession.FieldDeletedAt:
  6659. v, ok := value.(time.Time)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetDeletedAt(v)
  6664. return nil
  6665. case chatsession.FieldName:
  6666. v, ok := value.(string)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetName(v)
  6671. return nil
  6672. case chatsession.FieldUserID:
  6673. v, ok := value.(uint64)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetUserID(v)
  6678. return nil
  6679. case chatsession.FieldBotID:
  6680. v, ok := value.(uint64)
  6681. if !ok {
  6682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6683. }
  6684. m.SetBotID(v)
  6685. return nil
  6686. case chatsession.FieldBotType:
  6687. v, ok := value.(uint8)
  6688. if !ok {
  6689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6690. }
  6691. m.SetBotType(v)
  6692. return nil
  6693. }
  6694. return fmt.Errorf("unknown ChatSession field %s", name)
  6695. }
  6696. // AddedFields returns all numeric fields that were incremented/decremented during
  6697. // this mutation.
  6698. func (m *ChatSessionMutation) AddedFields() []string {
  6699. var fields []string
  6700. if m.adduser_id != nil {
  6701. fields = append(fields, chatsession.FieldUserID)
  6702. }
  6703. if m.addbot_id != nil {
  6704. fields = append(fields, chatsession.FieldBotID)
  6705. }
  6706. if m.addbot_type != nil {
  6707. fields = append(fields, chatsession.FieldBotType)
  6708. }
  6709. return fields
  6710. }
  6711. // AddedField returns the numeric value that was incremented/decremented on a field
  6712. // with the given name. The second boolean return value indicates that this field
  6713. // was not set, or was not defined in the schema.
  6714. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6715. switch name {
  6716. case chatsession.FieldUserID:
  6717. return m.AddedUserID()
  6718. case chatsession.FieldBotID:
  6719. return m.AddedBotID()
  6720. case chatsession.FieldBotType:
  6721. return m.AddedBotType()
  6722. }
  6723. return nil, false
  6724. }
  6725. // AddField adds the value to the field with the given name. It returns an error if
  6726. // the field is not defined in the schema, or if the type mismatched the field
  6727. // type.
  6728. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6729. switch name {
  6730. case chatsession.FieldUserID:
  6731. v, ok := value.(int64)
  6732. if !ok {
  6733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6734. }
  6735. m.AddUserID(v)
  6736. return nil
  6737. case chatsession.FieldBotID:
  6738. v, ok := value.(int64)
  6739. if !ok {
  6740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6741. }
  6742. m.AddBotID(v)
  6743. return nil
  6744. case chatsession.FieldBotType:
  6745. v, ok := value.(int8)
  6746. if !ok {
  6747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6748. }
  6749. m.AddBotType(v)
  6750. return nil
  6751. }
  6752. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6753. }
  6754. // ClearedFields returns all nullable fields that were cleared during this
  6755. // mutation.
  6756. func (m *ChatSessionMutation) ClearedFields() []string {
  6757. var fields []string
  6758. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6759. fields = append(fields, chatsession.FieldDeletedAt)
  6760. }
  6761. return fields
  6762. }
  6763. // FieldCleared returns a boolean indicating if a field with the given name was
  6764. // cleared in this mutation.
  6765. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6766. _, ok := m.clearedFields[name]
  6767. return ok
  6768. }
  6769. // ClearField clears the value of the field with the given name. It returns an
  6770. // error if the field is not defined in the schema.
  6771. func (m *ChatSessionMutation) ClearField(name string) error {
  6772. switch name {
  6773. case chatsession.FieldDeletedAt:
  6774. m.ClearDeletedAt()
  6775. return nil
  6776. }
  6777. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6778. }
  6779. // ResetField resets all changes in the mutation for the field with the given name.
  6780. // It returns an error if the field is not defined in the schema.
  6781. func (m *ChatSessionMutation) ResetField(name string) error {
  6782. switch name {
  6783. case chatsession.FieldCreatedAt:
  6784. m.ResetCreatedAt()
  6785. return nil
  6786. case chatsession.FieldUpdatedAt:
  6787. m.ResetUpdatedAt()
  6788. return nil
  6789. case chatsession.FieldDeletedAt:
  6790. m.ResetDeletedAt()
  6791. return nil
  6792. case chatsession.FieldName:
  6793. m.ResetName()
  6794. return nil
  6795. case chatsession.FieldUserID:
  6796. m.ResetUserID()
  6797. return nil
  6798. case chatsession.FieldBotID:
  6799. m.ResetBotID()
  6800. return nil
  6801. case chatsession.FieldBotType:
  6802. m.ResetBotType()
  6803. return nil
  6804. }
  6805. return fmt.Errorf("unknown ChatSession field %s", name)
  6806. }
  6807. // AddedEdges returns all edge names that were set/added in this mutation.
  6808. func (m *ChatSessionMutation) AddedEdges() []string {
  6809. edges := make([]string, 0, 0)
  6810. return edges
  6811. }
  6812. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6813. // name in this mutation.
  6814. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6815. return nil
  6816. }
  6817. // RemovedEdges returns all edge names that were removed in this mutation.
  6818. func (m *ChatSessionMutation) RemovedEdges() []string {
  6819. edges := make([]string, 0, 0)
  6820. return edges
  6821. }
  6822. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6823. // the given name in this mutation.
  6824. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6825. return nil
  6826. }
  6827. // ClearedEdges returns all edge names that were cleared in this mutation.
  6828. func (m *ChatSessionMutation) ClearedEdges() []string {
  6829. edges := make([]string, 0, 0)
  6830. return edges
  6831. }
  6832. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6833. // was cleared in this mutation.
  6834. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6835. return false
  6836. }
  6837. // ClearEdge clears the value of the edge with the given name. It returns an error
  6838. // if that edge is not defined in the schema.
  6839. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6840. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6841. }
  6842. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6843. // It returns an error if the edge is not defined in the schema.
  6844. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6845. return fmt.Errorf("unknown ChatSession edge %s", name)
  6846. }
  6847. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6848. type ContactMutation struct {
  6849. config
  6850. op Op
  6851. typ string
  6852. id *uint64
  6853. created_at *time.Time
  6854. updated_at *time.Time
  6855. status *uint8
  6856. addstatus *int8
  6857. deleted_at *time.Time
  6858. wx_wxid *string
  6859. _type *int
  6860. add_type *int
  6861. wxid *string
  6862. account *string
  6863. nickname *string
  6864. markname *string
  6865. headimg *string
  6866. sex *int
  6867. addsex *int
  6868. starrole *string
  6869. dontseeit *int
  6870. adddontseeit *int
  6871. dontseeme *int
  6872. adddontseeme *int
  6873. lag *string
  6874. gid *string
  6875. gname *string
  6876. v3 *string
  6877. organization_id *uint64
  6878. addorganization_id *int64
  6879. clearedFields map[string]struct{}
  6880. contact_relationships map[uint64]struct{}
  6881. removedcontact_relationships map[uint64]struct{}
  6882. clearedcontact_relationships bool
  6883. contact_messages map[uint64]struct{}
  6884. removedcontact_messages map[uint64]struct{}
  6885. clearedcontact_messages bool
  6886. done bool
  6887. oldValue func(context.Context) (*Contact, error)
  6888. predicates []predicate.Contact
  6889. }
  6890. var _ ent.Mutation = (*ContactMutation)(nil)
  6891. // contactOption allows management of the mutation configuration using functional options.
  6892. type contactOption func(*ContactMutation)
  6893. // newContactMutation creates new mutation for the Contact entity.
  6894. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6895. m := &ContactMutation{
  6896. config: c,
  6897. op: op,
  6898. typ: TypeContact,
  6899. clearedFields: make(map[string]struct{}),
  6900. }
  6901. for _, opt := range opts {
  6902. opt(m)
  6903. }
  6904. return m
  6905. }
  6906. // withContactID sets the ID field of the mutation.
  6907. func withContactID(id uint64) contactOption {
  6908. return func(m *ContactMutation) {
  6909. var (
  6910. err error
  6911. once sync.Once
  6912. value *Contact
  6913. )
  6914. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6915. once.Do(func() {
  6916. if m.done {
  6917. err = errors.New("querying old values post mutation is not allowed")
  6918. } else {
  6919. value, err = m.Client().Contact.Get(ctx, id)
  6920. }
  6921. })
  6922. return value, err
  6923. }
  6924. m.id = &id
  6925. }
  6926. }
  6927. // withContact sets the old Contact of the mutation.
  6928. func withContact(node *Contact) contactOption {
  6929. return func(m *ContactMutation) {
  6930. m.oldValue = func(context.Context) (*Contact, error) {
  6931. return node, nil
  6932. }
  6933. m.id = &node.ID
  6934. }
  6935. }
  6936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6937. // executed in a transaction (ent.Tx), a transactional client is returned.
  6938. func (m ContactMutation) Client() *Client {
  6939. client := &Client{config: m.config}
  6940. client.init()
  6941. return client
  6942. }
  6943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6944. // it returns an error otherwise.
  6945. func (m ContactMutation) Tx() (*Tx, error) {
  6946. if _, ok := m.driver.(*txDriver); !ok {
  6947. return nil, errors.New("ent: mutation is not running in a transaction")
  6948. }
  6949. tx := &Tx{config: m.config}
  6950. tx.init()
  6951. return tx, nil
  6952. }
  6953. // SetID sets the value of the id field. Note that this
  6954. // operation is only accepted on creation of Contact entities.
  6955. func (m *ContactMutation) SetID(id uint64) {
  6956. m.id = &id
  6957. }
  6958. // ID returns the ID value in the mutation. Note that the ID is only available
  6959. // if it was provided to the builder or after it was returned from the database.
  6960. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6961. if m.id == nil {
  6962. return
  6963. }
  6964. return *m.id, true
  6965. }
  6966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6967. // That means, if the mutation is applied within a transaction with an isolation level such
  6968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6969. // or updated by the mutation.
  6970. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6971. switch {
  6972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6973. id, exists := m.ID()
  6974. if exists {
  6975. return []uint64{id}, nil
  6976. }
  6977. fallthrough
  6978. case m.op.Is(OpUpdate | OpDelete):
  6979. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6980. default:
  6981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6982. }
  6983. }
  6984. // SetCreatedAt sets the "created_at" field.
  6985. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6986. m.created_at = &t
  6987. }
  6988. // CreatedAt returns the value of the "created_at" field in the mutation.
  6989. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6990. v := m.created_at
  6991. if v == nil {
  6992. return
  6993. }
  6994. return *v, true
  6995. }
  6996. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6997. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6999. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7000. if !m.op.Is(OpUpdateOne) {
  7001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7002. }
  7003. if m.id == nil || m.oldValue == nil {
  7004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7005. }
  7006. oldValue, err := m.oldValue(ctx)
  7007. if err != nil {
  7008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7009. }
  7010. return oldValue.CreatedAt, nil
  7011. }
  7012. // ResetCreatedAt resets all changes to the "created_at" field.
  7013. func (m *ContactMutation) ResetCreatedAt() {
  7014. m.created_at = nil
  7015. }
  7016. // SetUpdatedAt sets the "updated_at" field.
  7017. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7018. m.updated_at = &t
  7019. }
  7020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7021. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7022. v := m.updated_at
  7023. if v == nil {
  7024. return
  7025. }
  7026. return *v, true
  7027. }
  7028. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7029. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7031. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7032. if !m.op.Is(OpUpdateOne) {
  7033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7034. }
  7035. if m.id == nil || m.oldValue == nil {
  7036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7037. }
  7038. oldValue, err := m.oldValue(ctx)
  7039. if err != nil {
  7040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7041. }
  7042. return oldValue.UpdatedAt, nil
  7043. }
  7044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7045. func (m *ContactMutation) ResetUpdatedAt() {
  7046. m.updated_at = nil
  7047. }
  7048. // SetStatus sets the "status" field.
  7049. func (m *ContactMutation) SetStatus(u uint8) {
  7050. m.status = &u
  7051. m.addstatus = nil
  7052. }
  7053. // Status returns the value of the "status" field in the mutation.
  7054. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7055. v := m.status
  7056. if v == nil {
  7057. return
  7058. }
  7059. return *v, true
  7060. }
  7061. // OldStatus returns the old "status" field's value of the Contact entity.
  7062. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7064. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7065. if !m.op.Is(OpUpdateOne) {
  7066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7067. }
  7068. if m.id == nil || m.oldValue == nil {
  7069. return v, errors.New("OldStatus requires an ID field in the mutation")
  7070. }
  7071. oldValue, err := m.oldValue(ctx)
  7072. if err != nil {
  7073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7074. }
  7075. return oldValue.Status, nil
  7076. }
  7077. // AddStatus adds u to the "status" field.
  7078. func (m *ContactMutation) AddStatus(u int8) {
  7079. if m.addstatus != nil {
  7080. *m.addstatus += u
  7081. } else {
  7082. m.addstatus = &u
  7083. }
  7084. }
  7085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7086. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7087. v := m.addstatus
  7088. if v == nil {
  7089. return
  7090. }
  7091. return *v, true
  7092. }
  7093. // ClearStatus clears the value of the "status" field.
  7094. func (m *ContactMutation) ClearStatus() {
  7095. m.status = nil
  7096. m.addstatus = nil
  7097. m.clearedFields[contact.FieldStatus] = struct{}{}
  7098. }
  7099. // StatusCleared returns if the "status" field was cleared in this mutation.
  7100. func (m *ContactMutation) StatusCleared() bool {
  7101. _, ok := m.clearedFields[contact.FieldStatus]
  7102. return ok
  7103. }
  7104. // ResetStatus resets all changes to the "status" field.
  7105. func (m *ContactMutation) ResetStatus() {
  7106. m.status = nil
  7107. m.addstatus = nil
  7108. delete(m.clearedFields, contact.FieldStatus)
  7109. }
  7110. // SetDeletedAt sets the "deleted_at" field.
  7111. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7112. m.deleted_at = &t
  7113. }
  7114. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7115. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7116. v := m.deleted_at
  7117. if v == nil {
  7118. return
  7119. }
  7120. return *v, true
  7121. }
  7122. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7125. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7126. if !m.op.Is(OpUpdateOne) {
  7127. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7128. }
  7129. if m.id == nil || m.oldValue == nil {
  7130. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7131. }
  7132. oldValue, err := m.oldValue(ctx)
  7133. if err != nil {
  7134. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7135. }
  7136. return oldValue.DeletedAt, nil
  7137. }
  7138. // ClearDeletedAt clears the value of the "deleted_at" field.
  7139. func (m *ContactMutation) ClearDeletedAt() {
  7140. m.deleted_at = nil
  7141. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7142. }
  7143. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7144. func (m *ContactMutation) DeletedAtCleared() bool {
  7145. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7146. return ok
  7147. }
  7148. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7149. func (m *ContactMutation) ResetDeletedAt() {
  7150. m.deleted_at = nil
  7151. delete(m.clearedFields, contact.FieldDeletedAt)
  7152. }
  7153. // SetWxWxid sets the "wx_wxid" field.
  7154. func (m *ContactMutation) SetWxWxid(s string) {
  7155. m.wx_wxid = &s
  7156. }
  7157. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7158. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7159. v := m.wx_wxid
  7160. if v == nil {
  7161. return
  7162. }
  7163. return *v, true
  7164. }
  7165. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7166. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7168. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7169. if !m.op.Is(OpUpdateOne) {
  7170. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7171. }
  7172. if m.id == nil || m.oldValue == nil {
  7173. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7174. }
  7175. oldValue, err := m.oldValue(ctx)
  7176. if err != nil {
  7177. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7178. }
  7179. return oldValue.WxWxid, nil
  7180. }
  7181. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7182. func (m *ContactMutation) ResetWxWxid() {
  7183. m.wx_wxid = nil
  7184. }
  7185. // SetType sets the "type" field.
  7186. func (m *ContactMutation) SetType(i int) {
  7187. m._type = &i
  7188. m.add_type = nil
  7189. }
  7190. // GetType returns the value of the "type" field in the mutation.
  7191. func (m *ContactMutation) GetType() (r int, exists bool) {
  7192. v := m._type
  7193. if v == nil {
  7194. return
  7195. }
  7196. return *v, true
  7197. }
  7198. // OldType returns the old "type" field's value of the Contact entity.
  7199. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7201. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7202. if !m.op.Is(OpUpdateOne) {
  7203. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7204. }
  7205. if m.id == nil || m.oldValue == nil {
  7206. return v, errors.New("OldType requires an ID field in the mutation")
  7207. }
  7208. oldValue, err := m.oldValue(ctx)
  7209. if err != nil {
  7210. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7211. }
  7212. return oldValue.Type, nil
  7213. }
  7214. // AddType adds i to the "type" field.
  7215. func (m *ContactMutation) AddType(i int) {
  7216. if m.add_type != nil {
  7217. *m.add_type += i
  7218. } else {
  7219. m.add_type = &i
  7220. }
  7221. }
  7222. // AddedType returns the value that was added to the "type" field in this mutation.
  7223. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7224. v := m.add_type
  7225. if v == nil {
  7226. return
  7227. }
  7228. return *v, true
  7229. }
  7230. // ClearType clears the value of the "type" field.
  7231. func (m *ContactMutation) ClearType() {
  7232. m._type = nil
  7233. m.add_type = nil
  7234. m.clearedFields[contact.FieldType] = struct{}{}
  7235. }
  7236. // TypeCleared returns if the "type" field was cleared in this mutation.
  7237. func (m *ContactMutation) TypeCleared() bool {
  7238. _, ok := m.clearedFields[contact.FieldType]
  7239. return ok
  7240. }
  7241. // ResetType resets all changes to the "type" field.
  7242. func (m *ContactMutation) ResetType() {
  7243. m._type = nil
  7244. m.add_type = nil
  7245. delete(m.clearedFields, contact.FieldType)
  7246. }
  7247. // SetWxid sets the "wxid" field.
  7248. func (m *ContactMutation) SetWxid(s string) {
  7249. m.wxid = &s
  7250. }
  7251. // Wxid returns the value of the "wxid" field in the mutation.
  7252. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7253. v := m.wxid
  7254. if v == nil {
  7255. return
  7256. }
  7257. return *v, true
  7258. }
  7259. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7260. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7262. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7263. if !m.op.Is(OpUpdateOne) {
  7264. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7265. }
  7266. if m.id == nil || m.oldValue == nil {
  7267. return v, errors.New("OldWxid requires an ID field in the mutation")
  7268. }
  7269. oldValue, err := m.oldValue(ctx)
  7270. if err != nil {
  7271. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7272. }
  7273. return oldValue.Wxid, nil
  7274. }
  7275. // ResetWxid resets all changes to the "wxid" field.
  7276. func (m *ContactMutation) ResetWxid() {
  7277. m.wxid = nil
  7278. }
  7279. // SetAccount sets the "account" field.
  7280. func (m *ContactMutation) SetAccount(s string) {
  7281. m.account = &s
  7282. }
  7283. // Account returns the value of the "account" field in the mutation.
  7284. func (m *ContactMutation) Account() (r string, exists bool) {
  7285. v := m.account
  7286. if v == nil {
  7287. return
  7288. }
  7289. return *v, true
  7290. }
  7291. // OldAccount returns the old "account" field's value of the Contact entity.
  7292. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7294. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7295. if !m.op.Is(OpUpdateOne) {
  7296. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7297. }
  7298. if m.id == nil || m.oldValue == nil {
  7299. return v, errors.New("OldAccount requires an ID field in the mutation")
  7300. }
  7301. oldValue, err := m.oldValue(ctx)
  7302. if err != nil {
  7303. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7304. }
  7305. return oldValue.Account, nil
  7306. }
  7307. // ResetAccount resets all changes to the "account" field.
  7308. func (m *ContactMutation) ResetAccount() {
  7309. m.account = nil
  7310. }
  7311. // SetNickname sets the "nickname" field.
  7312. func (m *ContactMutation) SetNickname(s string) {
  7313. m.nickname = &s
  7314. }
  7315. // Nickname returns the value of the "nickname" field in the mutation.
  7316. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7317. v := m.nickname
  7318. if v == nil {
  7319. return
  7320. }
  7321. return *v, true
  7322. }
  7323. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7324. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7326. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7327. if !m.op.Is(OpUpdateOne) {
  7328. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7329. }
  7330. if m.id == nil || m.oldValue == nil {
  7331. return v, errors.New("OldNickname requires an ID field in the mutation")
  7332. }
  7333. oldValue, err := m.oldValue(ctx)
  7334. if err != nil {
  7335. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7336. }
  7337. return oldValue.Nickname, nil
  7338. }
  7339. // ResetNickname resets all changes to the "nickname" field.
  7340. func (m *ContactMutation) ResetNickname() {
  7341. m.nickname = nil
  7342. }
  7343. // SetMarkname sets the "markname" field.
  7344. func (m *ContactMutation) SetMarkname(s string) {
  7345. m.markname = &s
  7346. }
  7347. // Markname returns the value of the "markname" field in the mutation.
  7348. func (m *ContactMutation) Markname() (r string, exists bool) {
  7349. v := m.markname
  7350. if v == nil {
  7351. return
  7352. }
  7353. return *v, true
  7354. }
  7355. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7356. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7358. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7359. if !m.op.Is(OpUpdateOne) {
  7360. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7361. }
  7362. if m.id == nil || m.oldValue == nil {
  7363. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7364. }
  7365. oldValue, err := m.oldValue(ctx)
  7366. if err != nil {
  7367. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7368. }
  7369. return oldValue.Markname, nil
  7370. }
  7371. // ResetMarkname resets all changes to the "markname" field.
  7372. func (m *ContactMutation) ResetMarkname() {
  7373. m.markname = nil
  7374. }
  7375. // SetHeadimg sets the "headimg" field.
  7376. func (m *ContactMutation) SetHeadimg(s string) {
  7377. m.headimg = &s
  7378. }
  7379. // Headimg returns the value of the "headimg" field in the mutation.
  7380. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7381. v := m.headimg
  7382. if v == nil {
  7383. return
  7384. }
  7385. return *v, true
  7386. }
  7387. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7388. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7390. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7391. if !m.op.Is(OpUpdateOne) {
  7392. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7393. }
  7394. if m.id == nil || m.oldValue == nil {
  7395. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7396. }
  7397. oldValue, err := m.oldValue(ctx)
  7398. if err != nil {
  7399. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7400. }
  7401. return oldValue.Headimg, nil
  7402. }
  7403. // ResetHeadimg resets all changes to the "headimg" field.
  7404. func (m *ContactMutation) ResetHeadimg() {
  7405. m.headimg = nil
  7406. }
  7407. // SetSex sets the "sex" field.
  7408. func (m *ContactMutation) SetSex(i int) {
  7409. m.sex = &i
  7410. m.addsex = nil
  7411. }
  7412. // Sex returns the value of the "sex" field in the mutation.
  7413. func (m *ContactMutation) Sex() (r int, exists bool) {
  7414. v := m.sex
  7415. if v == nil {
  7416. return
  7417. }
  7418. return *v, true
  7419. }
  7420. // OldSex returns the old "sex" field's value of the Contact entity.
  7421. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7423. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7424. if !m.op.Is(OpUpdateOne) {
  7425. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7426. }
  7427. if m.id == nil || m.oldValue == nil {
  7428. return v, errors.New("OldSex requires an ID field in the mutation")
  7429. }
  7430. oldValue, err := m.oldValue(ctx)
  7431. if err != nil {
  7432. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7433. }
  7434. return oldValue.Sex, nil
  7435. }
  7436. // AddSex adds i to the "sex" field.
  7437. func (m *ContactMutation) AddSex(i int) {
  7438. if m.addsex != nil {
  7439. *m.addsex += i
  7440. } else {
  7441. m.addsex = &i
  7442. }
  7443. }
  7444. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7445. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7446. v := m.addsex
  7447. if v == nil {
  7448. return
  7449. }
  7450. return *v, true
  7451. }
  7452. // ResetSex resets all changes to the "sex" field.
  7453. func (m *ContactMutation) ResetSex() {
  7454. m.sex = nil
  7455. m.addsex = nil
  7456. }
  7457. // SetStarrole sets the "starrole" field.
  7458. func (m *ContactMutation) SetStarrole(s string) {
  7459. m.starrole = &s
  7460. }
  7461. // Starrole returns the value of the "starrole" field in the mutation.
  7462. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7463. v := m.starrole
  7464. if v == nil {
  7465. return
  7466. }
  7467. return *v, true
  7468. }
  7469. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7470. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7472. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7473. if !m.op.Is(OpUpdateOne) {
  7474. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7475. }
  7476. if m.id == nil || m.oldValue == nil {
  7477. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7478. }
  7479. oldValue, err := m.oldValue(ctx)
  7480. if err != nil {
  7481. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7482. }
  7483. return oldValue.Starrole, nil
  7484. }
  7485. // ResetStarrole resets all changes to the "starrole" field.
  7486. func (m *ContactMutation) ResetStarrole() {
  7487. m.starrole = nil
  7488. }
  7489. // SetDontseeit sets the "dontseeit" field.
  7490. func (m *ContactMutation) SetDontseeit(i int) {
  7491. m.dontseeit = &i
  7492. m.adddontseeit = nil
  7493. }
  7494. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7495. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7496. v := m.dontseeit
  7497. if v == nil {
  7498. return
  7499. }
  7500. return *v, true
  7501. }
  7502. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7503. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7505. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7506. if !m.op.Is(OpUpdateOne) {
  7507. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7508. }
  7509. if m.id == nil || m.oldValue == nil {
  7510. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7511. }
  7512. oldValue, err := m.oldValue(ctx)
  7513. if err != nil {
  7514. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7515. }
  7516. return oldValue.Dontseeit, nil
  7517. }
  7518. // AddDontseeit adds i to the "dontseeit" field.
  7519. func (m *ContactMutation) AddDontseeit(i int) {
  7520. if m.adddontseeit != nil {
  7521. *m.adddontseeit += i
  7522. } else {
  7523. m.adddontseeit = &i
  7524. }
  7525. }
  7526. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7527. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7528. v := m.adddontseeit
  7529. if v == nil {
  7530. return
  7531. }
  7532. return *v, true
  7533. }
  7534. // ResetDontseeit resets all changes to the "dontseeit" field.
  7535. func (m *ContactMutation) ResetDontseeit() {
  7536. m.dontseeit = nil
  7537. m.adddontseeit = nil
  7538. }
  7539. // SetDontseeme sets the "dontseeme" field.
  7540. func (m *ContactMutation) SetDontseeme(i int) {
  7541. m.dontseeme = &i
  7542. m.adddontseeme = nil
  7543. }
  7544. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7545. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7546. v := m.dontseeme
  7547. if v == nil {
  7548. return
  7549. }
  7550. return *v, true
  7551. }
  7552. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7553. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7555. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7556. if !m.op.Is(OpUpdateOne) {
  7557. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7558. }
  7559. if m.id == nil || m.oldValue == nil {
  7560. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7561. }
  7562. oldValue, err := m.oldValue(ctx)
  7563. if err != nil {
  7564. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7565. }
  7566. return oldValue.Dontseeme, nil
  7567. }
  7568. // AddDontseeme adds i to the "dontseeme" field.
  7569. func (m *ContactMutation) AddDontseeme(i int) {
  7570. if m.adddontseeme != nil {
  7571. *m.adddontseeme += i
  7572. } else {
  7573. m.adddontseeme = &i
  7574. }
  7575. }
  7576. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7577. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7578. v := m.adddontseeme
  7579. if v == nil {
  7580. return
  7581. }
  7582. return *v, true
  7583. }
  7584. // ResetDontseeme resets all changes to the "dontseeme" field.
  7585. func (m *ContactMutation) ResetDontseeme() {
  7586. m.dontseeme = nil
  7587. m.adddontseeme = nil
  7588. }
  7589. // SetLag sets the "lag" field.
  7590. func (m *ContactMutation) SetLag(s string) {
  7591. m.lag = &s
  7592. }
  7593. // Lag returns the value of the "lag" field in the mutation.
  7594. func (m *ContactMutation) Lag() (r string, exists bool) {
  7595. v := m.lag
  7596. if v == nil {
  7597. return
  7598. }
  7599. return *v, true
  7600. }
  7601. // OldLag returns the old "lag" field's value of the Contact entity.
  7602. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7604. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7605. if !m.op.Is(OpUpdateOne) {
  7606. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7607. }
  7608. if m.id == nil || m.oldValue == nil {
  7609. return v, errors.New("OldLag requires an ID field in the mutation")
  7610. }
  7611. oldValue, err := m.oldValue(ctx)
  7612. if err != nil {
  7613. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7614. }
  7615. return oldValue.Lag, nil
  7616. }
  7617. // ResetLag resets all changes to the "lag" field.
  7618. func (m *ContactMutation) ResetLag() {
  7619. m.lag = nil
  7620. }
  7621. // SetGid sets the "gid" field.
  7622. func (m *ContactMutation) SetGid(s string) {
  7623. m.gid = &s
  7624. }
  7625. // Gid returns the value of the "gid" field in the mutation.
  7626. func (m *ContactMutation) Gid() (r string, exists bool) {
  7627. v := m.gid
  7628. if v == nil {
  7629. return
  7630. }
  7631. return *v, true
  7632. }
  7633. // OldGid returns the old "gid" field's value of the Contact entity.
  7634. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7636. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7637. if !m.op.Is(OpUpdateOne) {
  7638. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7639. }
  7640. if m.id == nil || m.oldValue == nil {
  7641. return v, errors.New("OldGid requires an ID field in the mutation")
  7642. }
  7643. oldValue, err := m.oldValue(ctx)
  7644. if err != nil {
  7645. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7646. }
  7647. return oldValue.Gid, nil
  7648. }
  7649. // ResetGid resets all changes to the "gid" field.
  7650. func (m *ContactMutation) ResetGid() {
  7651. m.gid = nil
  7652. }
  7653. // SetGname sets the "gname" field.
  7654. func (m *ContactMutation) SetGname(s string) {
  7655. m.gname = &s
  7656. }
  7657. // Gname returns the value of the "gname" field in the mutation.
  7658. func (m *ContactMutation) Gname() (r string, exists bool) {
  7659. v := m.gname
  7660. if v == nil {
  7661. return
  7662. }
  7663. return *v, true
  7664. }
  7665. // OldGname returns the old "gname" field's value of the Contact entity.
  7666. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7668. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7669. if !m.op.Is(OpUpdateOne) {
  7670. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7671. }
  7672. if m.id == nil || m.oldValue == nil {
  7673. return v, errors.New("OldGname requires an ID field in the mutation")
  7674. }
  7675. oldValue, err := m.oldValue(ctx)
  7676. if err != nil {
  7677. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7678. }
  7679. return oldValue.Gname, nil
  7680. }
  7681. // ResetGname resets all changes to the "gname" field.
  7682. func (m *ContactMutation) ResetGname() {
  7683. m.gname = nil
  7684. }
  7685. // SetV3 sets the "v3" field.
  7686. func (m *ContactMutation) SetV3(s string) {
  7687. m.v3 = &s
  7688. }
  7689. // V3 returns the value of the "v3" field in the mutation.
  7690. func (m *ContactMutation) V3() (r string, exists bool) {
  7691. v := m.v3
  7692. if v == nil {
  7693. return
  7694. }
  7695. return *v, true
  7696. }
  7697. // OldV3 returns the old "v3" field's value of the Contact entity.
  7698. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7700. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7701. if !m.op.Is(OpUpdateOne) {
  7702. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7703. }
  7704. if m.id == nil || m.oldValue == nil {
  7705. return v, errors.New("OldV3 requires an ID field in the mutation")
  7706. }
  7707. oldValue, err := m.oldValue(ctx)
  7708. if err != nil {
  7709. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7710. }
  7711. return oldValue.V3, nil
  7712. }
  7713. // ResetV3 resets all changes to the "v3" field.
  7714. func (m *ContactMutation) ResetV3() {
  7715. m.v3 = nil
  7716. }
  7717. // SetOrganizationID sets the "organization_id" field.
  7718. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7719. m.organization_id = &u
  7720. m.addorganization_id = nil
  7721. }
  7722. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7723. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7724. v := m.organization_id
  7725. if v == nil {
  7726. return
  7727. }
  7728. return *v, true
  7729. }
  7730. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7731. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7733. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7734. if !m.op.Is(OpUpdateOne) {
  7735. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7736. }
  7737. if m.id == nil || m.oldValue == nil {
  7738. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7739. }
  7740. oldValue, err := m.oldValue(ctx)
  7741. if err != nil {
  7742. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7743. }
  7744. return oldValue.OrganizationID, nil
  7745. }
  7746. // AddOrganizationID adds u to the "organization_id" field.
  7747. func (m *ContactMutation) AddOrganizationID(u int64) {
  7748. if m.addorganization_id != nil {
  7749. *m.addorganization_id += u
  7750. } else {
  7751. m.addorganization_id = &u
  7752. }
  7753. }
  7754. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7755. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7756. v := m.addorganization_id
  7757. if v == nil {
  7758. return
  7759. }
  7760. return *v, true
  7761. }
  7762. // ClearOrganizationID clears the value of the "organization_id" field.
  7763. func (m *ContactMutation) ClearOrganizationID() {
  7764. m.organization_id = nil
  7765. m.addorganization_id = nil
  7766. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7767. }
  7768. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7769. func (m *ContactMutation) OrganizationIDCleared() bool {
  7770. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7771. return ok
  7772. }
  7773. // ResetOrganizationID resets all changes to the "organization_id" field.
  7774. func (m *ContactMutation) ResetOrganizationID() {
  7775. m.organization_id = nil
  7776. m.addorganization_id = nil
  7777. delete(m.clearedFields, contact.FieldOrganizationID)
  7778. }
  7779. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7780. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7781. if m.contact_relationships == nil {
  7782. m.contact_relationships = make(map[uint64]struct{})
  7783. }
  7784. for i := range ids {
  7785. m.contact_relationships[ids[i]] = struct{}{}
  7786. }
  7787. }
  7788. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7789. func (m *ContactMutation) ClearContactRelationships() {
  7790. m.clearedcontact_relationships = true
  7791. }
  7792. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7793. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7794. return m.clearedcontact_relationships
  7795. }
  7796. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7797. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7798. if m.removedcontact_relationships == nil {
  7799. m.removedcontact_relationships = make(map[uint64]struct{})
  7800. }
  7801. for i := range ids {
  7802. delete(m.contact_relationships, ids[i])
  7803. m.removedcontact_relationships[ids[i]] = struct{}{}
  7804. }
  7805. }
  7806. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7807. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7808. for id := range m.removedcontact_relationships {
  7809. ids = append(ids, id)
  7810. }
  7811. return
  7812. }
  7813. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7814. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7815. for id := range m.contact_relationships {
  7816. ids = append(ids, id)
  7817. }
  7818. return
  7819. }
  7820. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7821. func (m *ContactMutation) ResetContactRelationships() {
  7822. m.contact_relationships = nil
  7823. m.clearedcontact_relationships = false
  7824. m.removedcontact_relationships = nil
  7825. }
  7826. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7827. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7828. if m.contact_messages == nil {
  7829. m.contact_messages = make(map[uint64]struct{})
  7830. }
  7831. for i := range ids {
  7832. m.contact_messages[ids[i]] = struct{}{}
  7833. }
  7834. }
  7835. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7836. func (m *ContactMutation) ClearContactMessages() {
  7837. m.clearedcontact_messages = true
  7838. }
  7839. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7840. func (m *ContactMutation) ContactMessagesCleared() bool {
  7841. return m.clearedcontact_messages
  7842. }
  7843. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7844. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7845. if m.removedcontact_messages == nil {
  7846. m.removedcontact_messages = make(map[uint64]struct{})
  7847. }
  7848. for i := range ids {
  7849. delete(m.contact_messages, ids[i])
  7850. m.removedcontact_messages[ids[i]] = struct{}{}
  7851. }
  7852. }
  7853. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7854. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7855. for id := range m.removedcontact_messages {
  7856. ids = append(ids, id)
  7857. }
  7858. return
  7859. }
  7860. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7861. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7862. for id := range m.contact_messages {
  7863. ids = append(ids, id)
  7864. }
  7865. return
  7866. }
  7867. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7868. func (m *ContactMutation) ResetContactMessages() {
  7869. m.contact_messages = nil
  7870. m.clearedcontact_messages = false
  7871. m.removedcontact_messages = nil
  7872. }
  7873. // Where appends a list predicates to the ContactMutation builder.
  7874. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7875. m.predicates = append(m.predicates, ps...)
  7876. }
  7877. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7878. // users can use type-assertion to append predicates that do not depend on any generated package.
  7879. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7880. p := make([]predicate.Contact, len(ps))
  7881. for i := range ps {
  7882. p[i] = ps[i]
  7883. }
  7884. m.Where(p...)
  7885. }
  7886. // Op returns the operation name.
  7887. func (m *ContactMutation) Op() Op {
  7888. return m.op
  7889. }
  7890. // SetOp allows setting the mutation operation.
  7891. func (m *ContactMutation) SetOp(op Op) {
  7892. m.op = op
  7893. }
  7894. // Type returns the node type of this mutation (Contact).
  7895. func (m *ContactMutation) Type() string {
  7896. return m.typ
  7897. }
  7898. // Fields returns all fields that were changed during this mutation. Note that in
  7899. // order to get all numeric fields that were incremented/decremented, call
  7900. // AddedFields().
  7901. func (m *ContactMutation) Fields() []string {
  7902. fields := make([]string, 0, 20)
  7903. if m.created_at != nil {
  7904. fields = append(fields, contact.FieldCreatedAt)
  7905. }
  7906. if m.updated_at != nil {
  7907. fields = append(fields, contact.FieldUpdatedAt)
  7908. }
  7909. if m.status != nil {
  7910. fields = append(fields, contact.FieldStatus)
  7911. }
  7912. if m.deleted_at != nil {
  7913. fields = append(fields, contact.FieldDeletedAt)
  7914. }
  7915. if m.wx_wxid != nil {
  7916. fields = append(fields, contact.FieldWxWxid)
  7917. }
  7918. if m._type != nil {
  7919. fields = append(fields, contact.FieldType)
  7920. }
  7921. if m.wxid != nil {
  7922. fields = append(fields, contact.FieldWxid)
  7923. }
  7924. if m.account != nil {
  7925. fields = append(fields, contact.FieldAccount)
  7926. }
  7927. if m.nickname != nil {
  7928. fields = append(fields, contact.FieldNickname)
  7929. }
  7930. if m.markname != nil {
  7931. fields = append(fields, contact.FieldMarkname)
  7932. }
  7933. if m.headimg != nil {
  7934. fields = append(fields, contact.FieldHeadimg)
  7935. }
  7936. if m.sex != nil {
  7937. fields = append(fields, contact.FieldSex)
  7938. }
  7939. if m.starrole != nil {
  7940. fields = append(fields, contact.FieldStarrole)
  7941. }
  7942. if m.dontseeit != nil {
  7943. fields = append(fields, contact.FieldDontseeit)
  7944. }
  7945. if m.dontseeme != nil {
  7946. fields = append(fields, contact.FieldDontseeme)
  7947. }
  7948. if m.lag != nil {
  7949. fields = append(fields, contact.FieldLag)
  7950. }
  7951. if m.gid != nil {
  7952. fields = append(fields, contact.FieldGid)
  7953. }
  7954. if m.gname != nil {
  7955. fields = append(fields, contact.FieldGname)
  7956. }
  7957. if m.v3 != nil {
  7958. fields = append(fields, contact.FieldV3)
  7959. }
  7960. if m.organization_id != nil {
  7961. fields = append(fields, contact.FieldOrganizationID)
  7962. }
  7963. return fields
  7964. }
  7965. // Field returns the value of a field with the given name. The second boolean
  7966. // return value indicates that this field was not set, or was not defined in the
  7967. // schema.
  7968. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7969. switch name {
  7970. case contact.FieldCreatedAt:
  7971. return m.CreatedAt()
  7972. case contact.FieldUpdatedAt:
  7973. return m.UpdatedAt()
  7974. case contact.FieldStatus:
  7975. return m.Status()
  7976. case contact.FieldDeletedAt:
  7977. return m.DeletedAt()
  7978. case contact.FieldWxWxid:
  7979. return m.WxWxid()
  7980. case contact.FieldType:
  7981. return m.GetType()
  7982. case contact.FieldWxid:
  7983. return m.Wxid()
  7984. case contact.FieldAccount:
  7985. return m.Account()
  7986. case contact.FieldNickname:
  7987. return m.Nickname()
  7988. case contact.FieldMarkname:
  7989. return m.Markname()
  7990. case contact.FieldHeadimg:
  7991. return m.Headimg()
  7992. case contact.FieldSex:
  7993. return m.Sex()
  7994. case contact.FieldStarrole:
  7995. return m.Starrole()
  7996. case contact.FieldDontseeit:
  7997. return m.Dontseeit()
  7998. case contact.FieldDontseeme:
  7999. return m.Dontseeme()
  8000. case contact.FieldLag:
  8001. return m.Lag()
  8002. case contact.FieldGid:
  8003. return m.Gid()
  8004. case contact.FieldGname:
  8005. return m.Gname()
  8006. case contact.FieldV3:
  8007. return m.V3()
  8008. case contact.FieldOrganizationID:
  8009. return m.OrganizationID()
  8010. }
  8011. return nil, false
  8012. }
  8013. // OldField returns the old value of the field from the database. An error is
  8014. // returned if the mutation operation is not UpdateOne, or the query to the
  8015. // database failed.
  8016. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8017. switch name {
  8018. case contact.FieldCreatedAt:
  8019. return m.OldCreatedAt(ctx)
  8020. case contact.FieldUpdatedAt:
  8021. return m.OldUpdatedAt(ctx)
  8022. case contact.FieldStatus:
  8023. return m.OldStatus(ctx)
  8024. case contact.FieldDeletedAt:
  8025. return m.OldDeletedAt(ctx)
  8026. case contact.FieldWxWxid:
  8027. return m.OldWxWxid(ctx)
  8028. case contact.FieldType:
  8029. return m.OldType(ctx)
  8030. case contact.FieldWxid:
  8031. return m.OldWxid(ctx)
  8032. case contact.FieldAccount:
  8033. return m.OldAccount(ctx)
  8034. case contact.FieldNickname:
  8035. return m.OldNickname(ctx)
  8036. case contact.FieldMarkname:
  8037. return m.OldMarkname(ctx)
  8038. case contact.FieldHeadimg:
  8039. return m.OldHeadimg(ctx)
  8040. case contact.FieldSex:
  8041. return m.OldSex(ctx)
  8042. case contact.FieldStarrole:
  8043. return m.OldStarrole(ctx)
  8044. case contact.FieldDontseeit:
  8045. return m.OldDontseeit(ctx)
  8046. case contact.FieldDontseeme:
  8047. return m.OldDontseeme(ctx)
  8048. case contact.FieldLag:
  8049. return m.OldLag(ctx)
  8050. case contact.FieldGid:
  8051. return m.OldGid(ctx)
  8052. case contact.FieldGname:
  8053. return m.OldGname(ctx)
  8054. case contact.FieldV3:
  8055. return m.OldV3(ctx)
  8056. case contact.FieldOrganizationID:
  8057. return m.OldOrganizationID(ctx)
  8058. }
  8059. return nil, fmt.Errorf("unknown Contact field %s", name)
  8060. }
  8061. // SetField sets the value of a field with the given name. It returns an error if
  8062. // the field is not defined in the schema, or if the type mismatched the field
  8063. // type.
  8064. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8065. switch name {
  8066. case contact.FieldCreatedAt:
  8067. v, ok := value.(time.Time)
  8068. if !ok {
  8069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8070. }
  8071. m.SetCreatedAt(v)
  8072. return nil
  8073. case contact.FieldUpdatedAt:
  8074. v, ok := value.(time.Time)
  8075. if !ok {
  8076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8077. }
  8078. m.SetUpdatedAt(v)
  8079. return nil
  8080. case contact.FieldStatus:
  8081. v, ok := value.(uint8)
  8082. if !ok {
  8083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8084. }
  8085. m.SetStatus(v)
  8086. return nil
  8087. case contact.FieldDeletedAt:
  8088. v, ok := value.(time.Time)
  8089. if !ok {
  8090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8091. }
  8092. m.SetDeletedAt(v)
  8093. return nil
  8094. case contact.FieldWxWxid:
  8095. v, ok := value.(string)
  8096. if !ok {
  8097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8098. }
  8099. m.SetWxWxid(v)
  8100. return nil
  8101. case contact.FieldType:
  8102. v, ok := value.(int)
  8103. if !ok {
  8104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8105. }
  8106. m.SetType(v)
  8107. return nil
  8108. case contact.FieldWxid:
  8109. v, ok := value.(string)
  8110. if !ok {
  8111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8112. }
  8113. m.SetWxid(v)
  8114. return nil
  8115. case contact.FieldAccount:
  8116. v, ok := value.(string)
  8117. if !ok {
  8118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8119. }
  8120. m.SetAccount(v)
  8121. return nil
  8122. case contact.FieldNickname:
  8123. v, ok := value.(string)
  8124. if !ok {
  8125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8126. }
  8127. m.SetNickname(v)
  8128. return nil
  8129. case contact.FieldMarkname:
  8130. v, ok := value.(string)
  8131. if !ok {
  8132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8133. }
  8134. m.SetMarkname(v)
  8135. return nil
  8136. case contact.FieldHeadimg:
  8137. v, ok := value.(string)
  8138. if !ok {
  8139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8140. }
  8141. m.SetHeadimg(v)
  8142. return nil
  8143. case contact.FieldSex:
  8144. v, ok := value.(int)
  8145. if !ok {
  8146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8147. }
  8148. m.SetSex(v)
  8149. return nil
  8150. case contact.FieldStarrole:
  8151. v, ok := value.(string)
  8152. if !ok {
  8153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8154. }
  8155. m.SetStarrole(v)
  8156. return nil
  8157. case contact.FieldDontseeit:
  8158. v, ok := value.(int)
  8159. if !ok {
  8160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8161. }
  8162. m.SetDontseeit(v)
  8163. return nil
  8164. case contact.FieldDontseeme:
  8165. v, ok := value.(int)
  8166. if !ok {
  8167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8168. }
  8169. m.SetDontseeme(v)
  8170. return nil
  8171. case contact.FieldLag:
  8172. v, ok := value.(string)
  8173. if !ok {
  8174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8175. }
  8176. m.SetLag(v)
  8177. return nil
  8178. case contact.FieldGid:
  8179. v, ok := value.(string)
  8180. if !ok {
  8181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8182. }
  8183. m.SetGid(v)
  8184. return nil
  8185. case contact.FieldGname:
  8186. v, ok := value.(string)
  8187. if !ok {
  8188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8189. }
  8190. m.SetGname(v)
  8191. return nil
  8192. case contact.FieldV3:
  8193. v, ok := value.(string)
  8194. if !ok {
  8195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8196. }
  8197. m.SetV3(v)
  8198. return nil
  8199. case contact.FieldOrganizationID:
  8200. v, ok := value.(uint64)
  8201. if !ok {
  8202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8203. }
  8204. m.SetOrganizationID(v)
  8205. return nil
  8206. }
  8207. return fmt.Errorf("unknown Contact field %s", name)
  8208. }
  8209. // AddedFields returns all numeric fields that were incremented/decremented during
  8210. // this mutation.
  8211. func (m *ContactMutation) AddedFields() []string {
  8212. var fields []string
  8213. if m.addstatus != nil {
  8214. fields = append(fields, contact.FieldStatus)
  8215. }
  8216. if m.add_type != nil {
  8217. fields = append(fields, contact.FieldType)
  8218. }
  8219. if m.addsex != nil {
  8220. fields = append(fields, contact.FieldSex)
  8221. }
  8222. if m.adddontseeit != nil {
  8223. fields = append(fields, contact.FieldDontseeit)
  8224. }
  8225. if m.adddontseeme != nil {
  8226. fields = append(fields, contact.FieldDontseeme)
  8227. }
  8228. if m.addorganization_id != nil {
  8229. fields = append(fields, contact.FieldOrganizationID)
  8230. }
  8231. return fields
  8232. }
  8233. // AddedField returns the numeric value that was incremented/decremented on a field
  8234. // with the given name. The second boolean return value indicates that this field
  8235. // was not set, or was not defined in the schema.
  8236. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8237. switch name {
  8238. case contact.FieldStatus:
  8239. return m.AddedStatus()
  8240. case contact.FieldType:
  8241. return m.AddedType()
  8242. case contact.FieldSex:
  8243. return m.AddedSex()
  8244. case contact.FieldDontseeit:
  8245. return m.AddedDontseeit()
  8246. case contact.FieldDontseeme:
  8247. return m.AddedDontseeme()
  8248. case contact.FieldOrganizationID:
  8249. return m.AddedOrganizationID()
  8250. }
  8251. return nil, false
  8252. }
  8253. // AddField adds the value to the field with the given name. It returns an error if
  8254. // the field is not defined in the schema, or if the type mismatched the field
  8255. // type.
  8256. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8257. switch name {
  8258. case contact.FieldStatus:
  8259. v, ok := value.(int8)
  8260. if !ok {
  8261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8262. }
  8263. m.AddStatus(v)
  8264. return nil
  8265. case contact.FieldType:
  8266. v, ok := value.(int)
  8267. if !ok {
  8268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8269. }
  8270. m.AddType(v)
  8271. return nil
  8272. case contact.FieldSex:
  8273. v, ok := value.(int)
  8274. if !ok {
  8275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8276. }
  8277. m.AddSex(v)
  8278. return nil
  8279. case contact.FieldDontseeit:
  8280. v, ok := value.(int)
  8281. if !ok {
  8282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8283. }
  8284. m.AddDontseeit(v)
  8285. return nil
  8286. case contact.FieldDontseeme:
  8287. v, ok := value.(int)
  8288. if !ok {
  8289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8290. }
  8291. m.AddDontseeme(v)
  8292. return nil
  8293. case contact.FieldOrganizationID:
  8294. v, ok := value.(int64)
  8295. if !ok {
  8296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8297. }
  8298. m.AddOrganizationID(v)
  8299. return nil
  8300. }
  8301. return fmt.Errorf("unknown Contact numeric field %s", name)
  8302. }
  8303. // ClearedFields returns all nullable fields that were cleared during this
  8304. // mutation.
  8305. func (m *ContactMutation) ClearedFields() []string {
  8306. var fields []string
  8307. if m.FieldCleared(contact.FieldStatus) {
  8308. fields = append(fields, contact.FieldStatus)
  8309. }
  8310. if m.FieldCleared(contact.FieldDeletedAt) {
  8311. fields = append(fields, contact.FieldDeletedAt)
  8312. }
  8313. if m.FieldCleared(contact.FieldType) {
  8314. fields = append(fields, contact.FieldType)
  8315. }
  8316. if m.FieldCleared(contact.FieldOrganizationID) {
  8317. fields = append(fields, contact.FieldOrganizationID)
  8318. }
  8319. return fields
  8320. }
  8321. // FieldCleared returns a boolean indicating if a field with the given name was
  8322. // cleared in this mutation.
  8323. func (m *ContactMutation) FieldCleared(name string) bool {
  8324. _, ok := m.clearedFields[name]
  8325. return ok
  8326. }
  8327. // ClearField clears the value of the field with the given name. It returns an
  8328. // error if the field is not defined in the schema.
  8329. func (m *ContactMutation) ClearField(name string) error {
  8330. switch name {
  8331. case contact.FieldStatus:
  8332. m.ClearStatus()
  8333. return nil
  8334. case contact.FieldDeletedAt:
  8335. m.ClearDeletedAt()
  8336. return nil
  8337. case contact.FieldType:
  8338. m.ClearType()
  8339. return nil
  8340. case contact.FieldOrganizationID:
  8341. m.ClearOrganizationID()
  8342. return nil
  8343. }
  8344. return fmt.Errorf("unknown Contact nullable field %s", name)
  8345. }
  8346. // ResetField resets all changes in the mutation for the field with the given name.
  8347. // It returns an error if the field is not defined in the schema.
  8348. func (m *ContactMutation) ResetField(name string) error {
  8349. switch name {
  8350. case contact.FieldCreatedAt:
  8351. m.ResetCreatedAt()
  8352. return nil
  8353. case contact.FieldUpdatedAt:
  8354. m.ResetUpdatedAt()
  8355. return nil
  8356. case contact.FieldStatus:
  8357. m.ResetStatus()
  8358. return nil
  8359. case contact.FieldDeletedAt:
  8360. m.ResetDeletedAt()
  8361. return nil
  8362. case contact.FieldWxWxid:
  8363. m.ResetWxWxid()
  8364. return nil
  8365. case contact.FieldType:
  8366. m.ResetType()
  8367. return nil
  8368. case contact.FieldWxid:
  8369. m.ResetWxid()
  8370. return nil
  8371. case contact.FieldAccount:
  8372. m.ResetAccount()
  8373. return nil
  8374. case contact.FieldNickname:
  8375. m.ResetNickname()
  8376. return nil
  8377. case contact.FieldMarkname:
  8378. m.ResetMarkname()
  8379. return nil
  8380. case contact.FieldHeadimg:
  8381. m.ResetHeadimg()
  8382. return nil
  8383. case contact.FieldSex:
  8384. m.ResetSex()
  8385. return nil
  8386. case contact.FieldStarrole:
  8387. m.ResetStarrole()
  8388. return nil
  8389. case contact.FieldDontseeit:
  8390. m.ResetDontseeit()
  8391. return nil
  8392. case contact.FieldDontseeme:
  8393. m.ResetDontseeme()
  8394. return nil
  8395. case contact.FieldLag:
  8396. m.ResetLag()
  8397. return nil
  8398. case contact.FieldGid:
  8399. m.ResetGid()
  8400. return nil
  8401. case contact.FieldGname:
  8402. m.ResetGname()
  8403. return nil
  8404. case contact.FieldV3:
  8405. m.ResetV3()
  8406. return nil
  8407. case contact.FieldOrganizationID:
  8408. m.ResetOrganizationID()
  8409. return nil
  8410. }
  8411. return fmt.Errorf("unknown Contact field %s", name)
  8412. }
  8413. // AddedEdges returns all edge names that were set/added in this mutation.
  8414. func (m *ContactMutation) AddedEdges() []string {
  8415. edges := make([]string, 0, 2)
  8416. if m.contact_relationships != nil {
  8417. edges = append(edges, contact.EdgeContactRelationships)
  8418. }
  8419. if m.contact_messages != nil {
  8420. edges = append(edges, contact.EdgeContactMessages)
  8421. }
  8422. return edges
  8423. }
  8424. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8425. // name in this mutation.
  8426. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8427. switch name {
  8428. case contact.EdgeContactRelationships:
  8429. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8430. for id := range m.contact_relationships {
  8431. ids = append(ids, id)
  8432. }
  8433. return ids
  8434. case contact.EdgeContactMessages:
  8435. ids := make([]ent.Value, 0, len(m.contact_messages))
  8436. for id := range m.contact_messages {
  8437. ids = append(ids, id)
  8438. }
  8439. return ids
  8440. }
  8441. return nil
  8442. }
  8443. // RemovedEdges returns all edge names that were removed in this mutation.
  8444. func (m *ContactMutation) RemovedEdges() []string {
  8445. edges := make([]string, 0, 2)
  8446. if m.removedcontact_relationships != nil {
  8447. edges = append(edges, contact.EdgeContactRelationships)
  8448. }
  8449. if m.removedcontact_messages != nil {
  8450. edges = append(edges, contact.EdgeContactMessages)
  8451. }
  8452. return edges
  8453. }
  8454. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8455. // the given name in this mutation.
  8456. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8457. switch name {
  8458. case contact.EdgeContactRelationships:
  8459. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8460. for id := range m.removedcontact_relationships {
  8461. ids = append(ids, id)
  8462. }
  8463. return ids
  8464. case contact.EdgeContactMessages:
  8465. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8466. for id := range m.removedcontact_messages {
  8467. ids = append(ids, id)
  8468. }
  8469. return ids
  8470. }
  8471. return nil
  8472. }
  8473. // ClearedEdges returns all edge names that were cleared in this mutation.
  8474. func (m *ContactMutation) ClearedEdges() []string {
  8475. edges := make([]string, 0, 2)
  8476. if m.clearedcontact_relationships {
  8477. edges = append(edges, contact.EdgeContactRelationships)
  8478. }
  8479. if m.clearedcontact_messages {
  8480. edges = append(edges, contact.EdgeContactMessages)
  8481. }
  8482. return edges
  8483. }
  8484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8485. // was cleared in this mutation.
  8486. func (m *ContactMutation) EdgeCleared(name string) bool {
  8487. switch name {
  8488. case contact.EdgeContactRelationships:
  8489. return m.clearedcontact_relationships
  8490. case contact.EdgeContactMessages:
  8491. return m.clearedcontact_messages
  8492. }
  8493. return false
  8494. }
  8495. // ClearEdge clears the value of the edge with the given name. It returns an error
  8496. // if that edge is not defined in the schema.
  8497. func (m *ContactMutation) ClearEdge(name string) error {
  8498. switch name {
  8499. }
  8500. return fmt.Errorf("unknown Contact unique edge %s", name)
  8501. }
  8502. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8503. // It returns an error if the edge is not defined in the schema.
  8504. func (m *ContactMutation) ResetEdge(name string) error {
  8505. switch name {
  8506. case contact.EdgeContactRelationships:
  8507. m.ResetContactRelationships()
  8508. return nil
  8509. case contact.EdgeContactMessages:
  8510. m.ResetContactMessages()
  8511. return nil
  8512. }
  8513. return fmt.Errorf("unknown Contact edge %s", name)
  8514. }
  8515. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8516. type EmployeeMutation struct {
  8517. config
  8518. op Op
  8519. typ string
  8520. id *uint64
  8521. created_at *time.Time
  8522. updated_at *time.Time
  8523. deleted_at *time.Time
  8524. title *string
  8525. avatar *string
  8526. tags *string
  8527. hire_count *int
  8528. addhire_count *int
  8529. service_count *int
  8530. addservice_count *int
  8531. achievement_count *int
  8532. addachievement_count *int
  8533. intro *string
  8534. estimate *string
  8535. skill *string
  8536. ability_type *string
  8537. scene *string
  8538. switch_in *string
  8539. video_url *string
  8540. organization_id *uint64
  8541. addorganization_id *int64
  8542. category_id *uint64
  8543. addcategory_id *int64
  8544. api_base *string
  8545. api_key *string
  8546. ai_info *string
  8547. is_vip *int
  8548. addis_vip *int
  8549. chat_url *string
  8550. clearedFields map[string]struct{}
  8551. em_work_experiences map[uint64]struct{}
  8552. removedem_work_experiences map[uint64]struct{}
  8553. clearedem_work_experiences bool
  8554. em_tutorial map[uint64]struct{}
  8555. removedem_tutorial map[uint64]struct{}
  8556. clearedem_tutorial bool
  8557. done bool
  8558. oldValue func(context.Context) (*Employee, error)
  8559. predicates []predicate.Employee
  8560. }
  8561. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8562. // employeeOption allows management of the mutation configuration using functional options.
  8563. type employeeOption func(*EmployeeMutation)
  8564. // newEmployeeMutation creates new mutation for the Employee entity.
  8565. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8566. m := &EmployeeMutation{
  8567. config: c,
  8568. op: op,
  8569. typ: TypeEmployee,
  8570. clearedFields: make(map[string]struct{}),
  8571. }
  8572. for _, opt := range opts {
  8573. opt(m)
  8574. }
  8575. return m
  8576. }
  8577. // withEmployeeID sets the ID field of the mutation.
  8578. func withEmployeeID(id uint64) employeeOption {
  8579. return func(m *EmployeeMutation) {
  8580. var (
  8581. err error
  8582. once sync.Once
  8583. value *Employee
  8584. )
  8585. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8586. once.Do(func() {
  8587. if m.done {
  8588. err = errors.New("querying old values post mutation is not allowed")
  8589. } else {
  8590. value, err = m.Client().Employee.Get(ctx, id)
  8591. }
  8592. })
  8593. return value, err
  8594. }
  8595. m.id = &id
  8596. }
  8597. }
  8598. // withEmployee sets the old Employee of the mutation.
  8599. func withEmployee(node *Employee) employeeOption {
  8600. return func(m *EmployeeMutation) {
  8601. m.oldValue = func(context.Context) (*Employee, error) {
  8602. return node, nil
  8603. }
  8604. m.id = &node.ID
  8605. }
  8606. }
  8607. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8608. // executed in a transaction (ent.Tx), a transactional client is returned.
  8609. func (m EmployeeMutation) Client() *Client {
  8610. client := &Client{config: m.config}
  8611. client.init()
  8612. return client
  8613. }
  8614. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8615. // it returns an error otherwise.
  8616. func (m EmployeeMutation) Tx() (*Tx, error) {
  8617. if _, ok := m.driver.(*txDriver); !ok {
  8618. return nil, errors.New("ent: mutation is not running in a transaction")
  8619. }
  8620. tx := &Tx{config: m.config}
  8621. tx.init()
  8622. return tx, nil
  8623. }
  8624. // SetID sets the value of the id field. Note that this
  8625. // operation is only accepted on creation of Employee entities.
  8626. func (m *EmployeeMutation) SetID(id uint64) {
  8627. m.id = &id
  8628. }
  8629. // ID returns the ID value in the mutation. Note that the ID is only available
  8630. // if it was provided to the builder or after it was returned from the database.
  8631. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8632. if m.id == nil {
  8633. return
  8634. }
  8635. return *m.id, true
  8636. }
  8637. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8638. // That means, if the mutation is applied within a transaction with an isolation level such
  8639. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8640. // or updated by the mutation.
  8641. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8642. switch {
  8643. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8644. id, exists := m.ID()
  8645. if exists {
  8646. return []uint64{id}, nil
  8647. }
  8648. fallthrough
  8649. case m.op.Is(OpUpdate | OpDelete):
  8650. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8651. default:
  8652. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8653. }
  8654. }
  8655. // SetCreatedAt sets the "created_at" field.
  8656. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8657. m.created_at = &t
  8658. }
  8659. // CreatedAt returns the value of the "created_at" field in the mutation.
  8660. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8661. v := m.created_at
  8662. if v == nil {
  8663. return
  8664. }
  8665. return *v, true
  8666. }
  8667. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8668. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8670. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8671. if !m.op.Is(OpUpdateOne) {
  8672. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8673. }
  8674. if m.id == nil || m.oldValue == nil {
  8675. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8676. }
  8677. oldValue, err := m.oldValue(ctx)
  8678. if err != nil {
  8679. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8680. }
  8681. return oldValue.CreatedAt, nil
  8682. }
  8683. // ResetCreatedAt resets all changes to the "created_at" field.
  8684. func (m *EmployeeMutation) ResetCreatedAt() {
  8685. m.created_at = nil
  8686. }
  8687. // SetUpdatedAt sets the "updated_at" field.
  8688. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8689. m.updated_at = &t
  8690. }
  8691. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8692. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8693. v := m.updated_at
  8694. if v == nil {
  8695. return
  8696. }
  8697. return *v, true
  8698. }
  8699. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8702. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8703. if !m.op.Is(OpUpdateOne) {
  8704. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8705. }
  8706. if m.id == nil || m.oldValue == nil {
  8707. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8708. }
  8709. oldValue, err := m.oldValue(ctx)
  8710. if err != nil {
  8711. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8712. }
  8713. return oldValue.UpdatedAt, nil
  8714. }
  8715. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8716. func (m *EmployeeMutation) ResetUpdatedAt() {
  8717. m.updated_at = nil
  8718. }
  8719. // SetDeletedAt sets the "deleted_at" field.
  8720. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8721. m.deleted_at = &t
  8722. }
  8723. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8724. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8725. v := m.deleted_at
  8726. if v == nil {
  8727. return
  8728. }
  8729. return *v, true
  8730. }
  8731. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8734. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8735. if !m.op.Is(OpUpdateOne) {
  8736. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8737. }
  8738. if m.id == nil || m.oldValue == nil {
  8739. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8740. }
  8741. oldValue, err := m.oldValue(ctx)
  8742. if err != nil {
  8743. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8744. }
  8745. return oldValue.DeletedAt, nil
  8746. }
  8747. // ClearDeletedAt clears the value of the "deleted_at" field.
  8748. func (m *EmployeeMutation) ClearDeletedAt() {
  8749. m.deleted_at = nil
  8750. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8751. }
  8752. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8753. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8754. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8755. return ok
  8756. }
  8757. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8758. func (m *EmployeeMutation) ResetDeletedAt() {
  8759. m.deleted_at = nil
  8760. delete(m.clearedFields, employee.FieldDeletedAt)
  8761. }
  8762. // SetTitle sets the "title" field.
  8763. func (m *EmployeeMutation) SetTitle(s string) {
  8764. m.title = &s
  8765. }
  8766. // Title returns the value of the "title" field in the mutation.
  8767. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8768. v := m.title
  8769. if v == nil {
  8770. return
  8771. }
  8772. return *v, true
  8773. }
  8774. // OldTitle returns the old "title" field's value of the Employee entity.
  8775. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8777. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8778. if !m.op.Is(OpUpdateOne) {
  8779. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8780. }
  8781. if m.id == nil || m.oldValue == nil {
  8782. return v, errors.New("OldTitle requires an ID field in the mutation")
  8783. }
  8784. oldValue, err := m.oldValue(ctx)
  8785. if err != nil {
  8786. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8787. }
  8788. return oldValue.Title, nil
  8789. }
  8790. // ResetTitle resets all changes to the "title" field.
  8791. func (m *EmployeeMutation) ResetTitle() {
  8792. m.title = nil
  8793. }
  8794. // SetAvatar sets the "avatar" field.
  8795. func (m *EmployeeMutation) SetAvatar(s string) {
  8796. m.avatar = &s
  8797. }
  8798. // Avatar returns the value of the "avatar" field in the mutation.
  8799. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8800. v := m.avatar
  8801. if v == nil {
  8802. return
  8803. }
  8804. return *v, true
  8805. }
  8806. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8807. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8809. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8810. if !m.op.Is(OpUpdateOne) {
  8811. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8812. }
  8813. if m.id == nil || m.oldValue == nil {
  8814. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8815. }
  8816. oldValue, err := m.oldValue(ctx)
  8817. if err != nil {
  8818. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8819. }
  8820. return oldValue.Avatar, nil
  8821. }
  8822. // ResetAvatar resets all changes to the "avatar" field.
  8823. func (m *EmployeeMutation) ResetAvatar() {
  8824. m.avatar = nil
  8825. }
  8826. // SetTags sets the "tags" field.
  8827. func (m *EmployeeMutation) SetTags(s string) {
  8828. m.tags = &s
  8829. }
  8830. // Tags returns the value of the "tags" field in the mutation.
  8831. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8832. v := m.tags
  8833. if v == nil {
  8834. return
  8835. }
  8836. return *v, true
  8837. }
  8838. // OldTags returns the old "tags" field's value of the Employee entity.
  8839. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8841. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8842. if !m.op.Is(OpUpdateOne) {
  8843. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8844. }
  8845. if m.id == nil || m.oldValue == nil {
  8846. return v, errors.New("OldTags requires an ID field in the mutation")
  8847. }
  8848. oldValue, err := m.oldValue(ctx)
  8849. if err != nil {
  8850. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8851. }
  8852. return oldValue.Tags, nil
  8853. }
  8854. // ResetTags resets all changes to the "tags" field.
  8855. func (m *EmployeeMutation) ResetTags() {
  8856. m.tags = nil
  8857. }
  8858. // SetHireCount sets the "hire_count" field.
  8859. func (m *EmployeeMutation) SetHireCount(i int) {
  8860. m.hire_count = &i
  8861. m.addhire_count = nil
  8862. }
  8863. // HireCount returns the value of the "hire_count" field in the mutation.
  8864. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8865. v := m.hire_count
  8866. if v == nil {
  8867. return
  8868. }
  8869. return *v, true
  8870. }
  8871. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8872. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8874. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8875. if !m.op.Is(OpUpdateOne) {
  8876. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8877. }
  8878. if m.id == nil || m.oldValue == nil {
  8879. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8880. }
  8881. oldValue, err := m.oldValue(ctx)
  8882. if err != nil {
  8883. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8884. }
  8885. return oldValue.HireCount, nil
  8886. }
  8887. // AddHireCount adds i to the "hire_count" field.
  8888. func (m *EmployeeMutation) AddHireCount(i int) {
  8889. if m.addhire_count != nil {
  8890. *m.addhire_count += i
  8891. } else {
  8892. m.addhire_count = &i
  8893. }
  8894. }
  8895. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8896. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8897. v := m.addhire_count
  8898. if v == nil {
  8899. return
  8900. }
  8901. return *v, true
  8902. }
  8903. // ResetHireCount resets all changes to the "hire_count" field.
  8904. func (m *EmployeeMutation) ResetHireCount() {
  8905. m.hire_count = nil
  8906. m.addhire_count = nil
  8907. }
  8908. // SetServiceCount sets the "service_count" field.
  8909. func (m *EmployeeMutation) SetServiceCount(i int) {
  8910. m.service_count = &i
  8911. m.addservice_count = nil
  8912. }
  8913. // ServiceCount returns the value of the "service_count" field in the mutation.
  8914. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8915. v := m.service_count
  8916. if v == nil {
  8917. return
  8918. }
  8919. return *v, true
  8920. }
  8921. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8922. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8924. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8925. if !m.op.Is(OpUpdateOne) {
  8926. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8927. }
  8928. if m.id == nil || m.oldValue == nil {
  8929. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8930. }
  8931. oldValue, err := m.oldValue(ctx)
  8932. if err != nil {
  8933. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8934. }
  8935. return oldValue.ServiceCount, nil
  8936. }
  8937. // AddServiceCount adds i to the "service_count" field.
  8938. func (m *EmployeeMutation) AddServiceCount(i int) {
  8939. if m.addservice_count != nil {
  8940. *m.addservice_count += i
  8941. } else {
  8942. m.addservice_count = &i
  8943. }
  8944. }
  8945. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8946. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8947. v := m.addservice_count
  8948. if v == nil {
  8949. return
  8950. }
  8951. return *v, true
  8952. }
  8953. // ResetServiceCount resets all changes to the "service_count" field.
  8954. func (m *EmployeeMutation) ResetServiceCount() {
  8955. m.service_count = nil
  8956. m.addservice_count = nil
  8957. }
  8958. // SetAchievementCount sets the "achievement_count" field.
  8959. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8960. m.achievement_count = &i
  8961. m.addachievement_count = nil
  8962. }
  8963. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8964. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8965. v := m.achievement_count
  8966. if v == nil {
  8967. return
  8968. }
  8969. return *v, true
  8970. }
  8971. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8972. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8974. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8975. if !m.op.Is(OpUpdateOne) {
  8976. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8977. }
  8978. if m.id == nil || m.oldValue == nil {
  8979. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8980. }
  8981. oldValue, err := m.oldValue(ctx)
  8982. if err != nil {
  8983. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8984. }
  8985. return oldValue.AchievementCount, nil
  8986. }
  8987. // AddAchievementCount adds i to the "achievement_count" field.
  8988. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8989. if m.addachievement_count != nil {
  8990. *m.addachievement_count += i
  8991. } else {
  8992. m.addachievement_count = &i
  8993. }
  8994. }
  8995. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8996. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8997. v := m.addachievement_count
  8998. if v == nil {
  8999. return
  9000. }
  9001. return *v, true
  9002. }
  9003. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9004. func (m *EmployeeMutation) ResetAchievementCount() {
  9005. m.achievement_count = nil
  9006. m.addachievement_count = nil
  9007. }
  9008. // SetIntro sets the "intro" field.
  9009. func (m *EmployeeMutation) SetIntro(s string) {
  9010. m.intro = &s
  9011. }
  9012. // Intro returns the value of the "intro" field in the mutation.
  9013. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9014. v := m.intro
  9015. if v == nil {
  9016. return
  9017. }
  9018. return *v, true
  9019. }
  9020. // OldIntro returns the old "intro" field's value of the Employee entity.
  9021. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9023. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9024. if !m.op.Is(OpUpdateOne) {
  9025. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9026. }
  9027. if m.id == nil || m.oldValue == nil {
  9028. return v, errors.New("OldIntro requires an ID field in the mutation")
  9029. }
  9030. oldValue, err := m.oldValue(ctx)
  9031. if err != nil {
  9032. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9033. }
  9034. return oldValue.Intro, nil
  9035. }
  9036. // ResetIntro resets all changes to the "intro" field.
  9037. func (m *EmployeeMutation) ResetIntro() {
  9038. m.intro = nil
  9039. }
  9040. // SetEstimate sets the "estimate" field.
  9041. func (m *EmployeeMutation) SetEstimate(s string) {
  9042. m.estimate = &s
  9043. }
  9044. // Estimate returns the value of the "estimate" field in the mutation.
  9045. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9046. v := m.estimate
  9047. if v == nil {
  9048. return
  9049. }
  9050. return *v, true
  9051. }
  9052. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9053. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9055. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9056. if !m.op.Is(OpUpdateOne) {
  9057. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9058. }
  9059. if m.id == nil || m.oldValue == nil {
  9060. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9061. }
  9062. oldValue, err := m.oldValue(ctx)
  9063. if err != nil {
  9064. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9065. }
  9066. return oldValue.Estimate, nil
  9067. }
  9068. // ResetEstimate resets all changes to the "estimate" field.
  9069. func (m *EmployeeMutation) ResetEstimate() {
  9070. m.estimate = nil
  9071. }
  9072. // SetSkill sets the "skill" field.
  9073. func (m *EmployeeMutation) SetSkill(s string) {
  9074. m.skill = &s
  9075. }
  9076. // Skill returns the value of the "skill" field in the mutation.
  9077. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9078. v := m.skill
  9079. if v == nil {
  9080. return
  9081. }
  9082. return *v, true
  9083. }
  9084. // OldSkill returns the old "skill" field's value of the Employee entity.
  9085. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9087. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9088. if !m.op.Is(OpUpdateOne) {
  9089. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9090. }
  9091. if m.id == nil || m.oldValue == nil {
  9092. return v, errors.New("OldSkill requires an ID field in the mutation")
  9093. }
  9094. oldValue, err := m.oldValue(ctx)
  9095. if err != nil {
  9096. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9097. }
  9098. return oldValue.Skill, nil
  9099. }
  9100. // ResetSkill resets all changes to the "skill" field.
  9101. func (m *EmployeeMutation) ResetSkill() {
  9102. m.skill = nil
  9103. }
  9104. // SetAbilityType sets the "ability_type" field.
  9105. func (m *EmployeeMutation) SetAbilityType(s string) {
  9106. m.ability_type = &s
  9107. }
  9108. // AbilityType returns the value of the "ability_type" field in the mutation.
  9109. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9110. v := m.ability_type
  9111. if v == nil {
  9112. return
  9113. }
  9114. return *v, true
  9115. }
  9116. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9117. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9119. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9120. if !m.op.Is(OpUpdateOne) {
  9121. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9122. }
  9123. if m.id == nil || m.oldValue == nil {
  9124. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9125. }
  9126. oldValue, err := m.oldValue(ctx)
  9127. if err != nil {
  9128. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9129. }
  9130. return oldValue.AbilityType, nil
  9131. }
  9132. // ResetAbilityType resets all changes to the "ability_type" field.
  9133. func (m *EmployeeMutation) ResetAbilityType() {
  9134. m.ability_type = nil
  9135. }
  9136. // SetScene sets the "scene" field.
  9137. func (m *EmployeeMutation) SetScene(s string) {
  9138. m.scene = &s
  9139. }
  9140. // Scene returns the value of the "scene" field in the mutation.
  9141. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9142. v := m.scene
  9143. if v == nil {
  9144. return
  9145. }
  9146. return *v, true
  9147. }
  9148. // OldScene returns the old "scene" field's value of the Employee entity.
  9149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9151. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9152. if !m.op.Is(OpUpdateOne) {
  9153. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9154. }
  9155. if m.id == nil || m.oldValue == nil {
  9156. return v, errors.New("OldScene requires an ID field in the mutation")
  9157. }
  9158. oldValue, err := m.oldValue(ctx)
  9159. if err != nil {
  9160. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9161. }
  9162. return oldValue.Scene, nil
  9163. }
  9164. // ResetScene resets all changes to the "scene" field.
  9165. func (m *EmployeeMutation) ResetScene() {
  9166. m.scene = nil
  9167. }
  9168. // SetSwitchIn sets the "switch_in" field.
  9169. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9170. m.switch_in = &s
  9171. }
  9172. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9173. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9174. v := m.switch_in
  9175. if v == nil {
  9176. return
  9177. }
  9178. return *v, true
  9179. }
  9180. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9181. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9183. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9184. if !m.op.Is(OpUpdateOne) {
  9185. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9186. }
  9187. if m.id == nil || m.oldValue == nil {
  9188. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9189. }
  9190. oldValue, err := m.oldValue(ctx)
  9191. if err != nil {
  9192. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9193. }
  9194. return oldValue.SwitchIn, nil
  9195. }
  9196. // ResetSwitchIn resets all changes to the "switch_in" field.
  9197. func (m *EmployeeMutation) ResetSwitchIn() {
  9198. m.switch_in = nil
  9199. }
  9200. // SetVideoURL sets the "video_url" field.
  9201. func (m *EmployeeMutation) SetVideoURL(s string) {
  9202. m.video_url = &s
  9203. }
  9204. // VideoURL returns the value of the "video_url" field in the mutation.
  9205. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9206. v := m.video_url
  9207. if v == nil {
  9208. return
  9209. }
  9210. return *v, true
  9211. }
  9212. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9213. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9215. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9216. if !m.op.Is(OpUpdateOne) {
  9217. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9218. }
  9219. if m.id == nil || m.oldValue == nil {
  9220. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9221. }
  9222. oldValue, err := m.oldValue(ctx)
  9223. if err != nil {
  9224. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9225. }
  9226. return oldValue.VideoURL, nil
  9227. }
  9228. // ResetVideoURL resets all changes to the "video_url" field.
  9229. func (m *EmployeeMutation) ResetVideoURL() {
  9230. m.video_url = nil
  9231. }
  9232. // SetOrganizationID sets the "organization_id" field.
  9233. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9234. m.organization_id = &u
  9235. m.addorganization_id = nil
  9236. }
  9237. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9238. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9239. v := m.organization_id
  9240. if v == nil {
  9241. return
  9242. }
  9243. return *v, true
  9244. }
  9245. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9246. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9248. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9249. if !m.op.Is(OpUpdateOne) {
  9250. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9251. }
  9252. if m.id == nil || m.oldValue == nil {
  9253. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9254. }
  9255. oldValue, err := m.oldValue(ctx)
  9256. if err != nil {
  9257. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9258. }
  9259. return oldValue.OrganizationID, nil
  9260. }
  9261. // AddOrganizationID adds u to the "organization_id" field.
  9262. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9263. if m.addorganization_id != nil {
  9264. *m.addorganization_id += u
  9265. } else {
  9266. m.addorganization_id = &u
  9267. }
  9268. }
  9269. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9270. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9271. v := m.addorganization_id
  9272. if v == nil {
  9273. return
  9274. }
  9275. return *v, true
  9276. }
  9277. // ResetOrganizationID resets all changes to the "organization_id" field.
  9278. func (m *EmployeeMutation) ResetOrganizationID() {
  9279. m.organization_id = nil
  9280. m.addorganization_id = nil
  9281. }
  9282. // SetCategoryID sets the "category_id" field.
  9283. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9284. m.category_id = &u
  9285. m.addcategory_id = nil
  9286. }
  9287. // CategoryID returns the value of the "category_id" field in the mutation.
  9288. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9289. v := m.category_id
  9290. if v == nil {
  9291. return
  9292. }
  9293. return *v, true
  9294. }
  9295. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9296. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9298. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9299. if !m.op.Is(OpUpdateOne) {
  9300. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9301. }
  9302. if m.id == nil || m.oldValue == nil {
  9303. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9304. }
  9305. oldValue, err := m.oldValue(ctx)
  9306. if err != nil {
  9307. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9308. }
  9309. return oldValue.CategoryID, nil
  9310. }
  9311. // AddCategoryID adds u to the "category_id" field.
  9312. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9313. if m.addcategory_id != nil {
  9314. *m.addcategory_id += u
  9315. } else {
  9316. m.addcategory_id = &u
  9317. }
  9318. }
  9319. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9320. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9321. v := m.addcategory_id
  9322. if v == nil {
  9323. return
  9324. }
  9325. return *v, true
  9326. }
  9327. // ResetCategoryID resets all changes to the "category_id" field.
  9328. func (m *EmployeeMutation) ResetCategoryID() {
  9329. m.category_id = nil
  9330. m.addcategory_id = nil
  9331. }
  9332. // SetAPIBase sets the "api_base" field.
  9333. func (m *EmployeeMutation) SetAPIBase(s string) {
  9334. m.api_base = &s
  9335. }
  9336. // APIBase returns the value of the "api_base" field in the mutation.
  9337. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9338. v := m.api_base
  9339. if v == nil {
  9340. return
  9341. }
  9342. return *v, true
  9343. }
  9344. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9345. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9347. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9348. if !m.op.Is(OpUpdateOne) {
  9349. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9350. }
  9351. if m.id == nil || m.oldValue == nil {
  9352. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9353. }
  9354. oldValue, err := m.oldValue(ctx)
  9355. if err != nil {
  9356. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9357. }
  9358. return oldValue.APIBase, nil
  9359. }
  9360. // ResetAPIBase resets all changes to the "api_base" field.
  9361. func (m *EmployeeMutation) ResetAPIBase() {
  9362. m.api_base = nil
  9363. }
  9364. // SetAPIKey sets the "api_key" field.
  9365. func (m *EmployeeMutation) SetAPIKey(s string) {
  9366. m.api_key = &s
  9367. }
  9368. // APIKey returns the value of the "api_key" field in the mutation.
  9369. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9370. v := m.api_key
  9371. if v == nil {
  9372. return
  9373. }
  9374. return *v, true
  9375. }
  9376. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9377. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9379. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9380. if !m.op.Is(OpUpdateOne) {
  9381. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9382. }
  9383. if m.id == nil || m.oldValue == nil {
  9384. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9385. }
  9386. oldValue, err := m.oldValue(ctx)
  9387. if err != nil {
  9388. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9389. }
  9390. return oldValue.APIKey, nil
  9391. }
  9392. // ResetAPIKey resets all changes to the "api_key" field.
  9393. func (m *EmployeeMutation) ResetAPIKey() {
  9394. m.api_key = nil
  9395. }
  9396. // SetAiInfo sets the "ai_info" field.
  9397. func (m *EmployeeMutation) SetAiInfo(s string) {
  9398. m.ai_info = &s
  9399. }
  9400. // AiInfo returns the value of the "ai_info" field in the mutation.
  9401. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9402. v := m.ai_info
  9403. if v == nil {
  9404. return
  9405. }
  9406. return *v, true
  9407. }
  9408. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9409. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9411. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9412. if !m.op.Is(OpUpdateOne) {
  9413. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9414. }
  9415. if m.id == nil || m.oldValue == nil {
  9416. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9417. }
  9418. oldValue, err := m.oldValue(ctx)
  9419. if err != nil {
  9420. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9421. }
  9422. return oldValue.AiInfo, nil
  9423. }
  9424. // ClearAiInfo clears the value of the "ai_info" field.
  9425. func (m *EmployeeMutation) ClearAiInfo() {
  9426. m.ai_info = nil
  9427. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9428. }
  9429. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9430. func (m *EmployeeMutation) AiInfoCleared() bool {
  9431. _, ok := m.clearedFields[employee.FieldAiInfo]
  9432. return ok
  9433. }
  9434. // ResetAiInfo resets all changes to the "ai_info" field.
  9435. func (m *EmployeeMutation) ResetAiInfo() {
  9436. m.ai_info = nil
  9437. delete(m.clearedFields, employee.FieldAiInfo)
  9438. }
  9439. // SetIsVip sets the "is_vip" field.
  9440. func (m *EmployeeMutation) SetIsVip(i int) {
  9441. m.is_vip = &i
  9442. m.addis_vip = nil
  9443. }
  9444. // IsVip returns the value of the "is_vip" field in the mutation.
  9445. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9446. v := m.is_vip
  9447. if v == nil {
  9448. return
  9449. }
  9450. return *v, true
  9451. }
  9452. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9453. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9455. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9456. if !m.op.Is(OpUpdateOne) {
  9457. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9458. }
  9459. if m.id == nil || m.oldValue == nil {
  9460. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9461. }
  9462. oldValue, err := m.oldValue(ctx)
  9463. if err != nil {
  9464. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9465. }
  9466. return oldValue.IsVip, nil
  9467. }
  9468. // AddIsVip adds i to the "is_vip" field.
  9469. func (m *EmployeeMutation) AddIsVip(i int) {
  9470. if m.addis_vip != nil {
  9471. *m.addis_vip += i
  9472. } else {
  9473. m.addis_vip = &i
  9474. }
  9475. }
  9476. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9477. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9478. v := m.addis_vip
  9479. if v == nil {
  9480. return
  9481. }
  9482. return *v, true
  9483. }
  9484. // ResetIsVip resets all changes to the "is_vip" field.
  9485. func (m *EmployeeMutation) ResetIsVip() {
  9486. m.is_vip = nil
  9487. m.addis_vip = nil
  9488. }
  9489. // SetChatURL sets the "chat_url" field.
  9490. func (m *EmployeeMutation) SetChatURL(s string) {
  9491. m.chat_url = &s
  9492. }
  9493. // ChatURL returns the value of the "chat_url" field in the mutation.
  9494. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9495. v := m.chat_url
  9496. if v == nil {
  9497. return
  9498. }
  9499. return *v, true
  9500. }
  9501. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9502. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9504. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9505. if !m.op.Is(OpUpdateOne) {
  9506. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9507. }
  9508. if m.id == nil || m.oldValue == nil {
  9509. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9510. }
  9511. oldValue, err := m.oldValue(ctx)
  9512. if err != nil {
  9513. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9514. }
  9515. return oldValue.ChatURL, nil
  9516. }
  9517. // ResetChatURL resets all changes to the "chat_url" field.
  9518. func (m *EmployeeMutation) ResetChatURL() {
  9519. m.chat_url = nil
  9520. }
  9521. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9522. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9523. if m.em_work_experiences == nil {
  9524. m.em_work_experiences = make(map[uint64]struct{})
  9525. }
  9526. for i := range ids {
  9527. m.em_work_experiences[ids[i]] = struct{}{}
  9528. }
  9529. }
  9530. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9531. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9532. m.clearedem_work_experiences = true
  9533. }
  9534. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9535. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9536. return m.clearedem_work_experiences
  9537. }
  9538. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9539. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9540. if m.removedem_work_experiences == nil {
  9541. m.removedem_work_experiences = make(map[uint64]struct{})
  9542. }
  9543. for i := range ids {
  9544. delete(m.em_work_experiences, ids[i])
  9545. m.removedem_work_experiences[ids[i]] = struct{}{}
  9546. }
  9547. }
  9548. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9549. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9550. for id := range m.removedem_work_experiences {
  9551. ids = append(ids, id)
  9552. }
  9553. return
  9554. }
  9555. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9556. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9557. for id := range m.em_work_experiences {
  9558. ids = append(ids, id)
  9559. }
  9560. return
  9561. }
  9562. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9563. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9564. m.em_work_experiences = nil
  9565. m.clearedem_work_experiences = false
  9566. m.removedem_work_experiences = nil
  9567. }
  9568. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9569. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9570. if m.em_tutorial == nil {
  9571. m.em_tutorial = make(map[uint64]struct{})
  9572. }
  9573. for i := range ids {
  9574. m.em_tutorial[ids[i]] = struct{}{}
  9575. }
  9576. }
  9577. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9578. func (m *EmployeeMutation) ClearEmTutorial() {
  9579. m.clearedem_tutorial = true
  9580. }
  9581. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9582. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9583. return m.clearedem_tutorial
  9584. }
  9585. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9586. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9587. if m.removedem_tutorial == nil {
  9588. m.removedem_tutorial = make(map[uint64]struct{})
  9589. }
  9590. for i := range ids {
  9591. delete(m.em_tutorial, ids[i])
  9592. m.removedem_tutorial[ids[i]] = struct{}{}
  9593. }
  9594. }
  9595. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9596. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9597. for id := range m.removedem_tutorial {
  9598. ids = append(ids, id)
  9599. }
  9600. return
  9601. }
  9602. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9603. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9604. for id := range m.em_tutorial {
  9605. ids = append(ids, id)
  9606. }
  9607. return
  9608. }
  9609. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9610. func (m *EmployeeMutation) ResetEmTutorial() {
  9611. m.em_tutorial = nil
  9612. m.clearedem_tutorial = false
  9613. m.removedem_tutorial = nil
  9614. }
  9615. // Where appends a list predicates to the EmployeeMutation builder.
  9616. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9617. m.predicates = append(m.predicates, ps...)
  9618. }
  9619. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9620. // users can use type-assertion to append predicates that do not depend on any generated package.
  9621. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9622. p := make([]predicate.Employee, len(ps))
  9623. for i := range ps {
  9624. p[i] = ps[i]
  9625. }
  9626. m.Where(p...)
  9627. }
  9628. // Op returns the operation name.
  9629. func (m *EmployeeMutation) Op() Op {
  9630. return m.op
  9631. }
  9632. // SetOp allows setting the mutation operation.
  9633. func (m *EmployeeMutation) SetOp(op Op) {
  9634. m.op = op
  9635. }
  9636. // Type returns the node type of this mutation (Employee).
  9637. func (m *EmployeeMutation) Type() string {
  9638. return m.typ
  9639. }
  9640. // Fields returns all fields that were changed during this mutation. Note that in
  9641. // order to get all numeric fields that were incremented/decremented, call
  9642. // AddedFields().
  9643. func (m *EmployeeMutation) Fields() []string {
  9644. fields := make([]string, 0, 23)
  9645. if m.created_at != nil {
  9646. fields = append(fields, employee.FieldCreatedAt)
  9647. }
  9648. if m.updated_at != nil {
  9649. fields = append(fields, employee.FieldUpdatedAt)
  9650. }
  9651. if m.deleted_at != nil {
  9652. fields = append(fields, employee.FieldDeletedAt)
  9653. }
  9654. if m.title != nil {
  9655. fields = append(fields, employee.FieldTitle)
  9656. }
  9657. if m.avatar != nil {
  9658. fields = append(fields, employee.FieldAvatar)
  9659. }
  9660. if m.tags != nil {
  9661. fields = append(fields, employee.FieldTags)
  9662. }
  9663. if m.hire_count != nil {
  9664. fields = append(fields, employee.FieldHireCount)
  9665. }
  9666. if m.service_count != nil {
  9667. fields = append(fields, employee.FieldServiceCount)
  9668. }
  9669. if m.achievement_count != nil {
  9670. fields = append(fields, employee.FieldAchievementCount)
  9671. }
  9672. if m.intro != nil {
  9673. fields = append(fields, employee.FieldIntro)
  9674. }
  9675. if m.estimate != nil {
  9676. fields = append(fields, employee.FieldEstimate)
  9677. }
  9678. if m.skill != nil {
  9679. fields = append(fields, employee.FieldSkill)
  9680. }
  9681. if m.ability_type != nil {
  9682. fields = append(fields, employee.FieldAbilityType)
  9683. }
  9684. if m.scene != nil {
  9685. fields = append(fields, employee.FieldScene)
  9686. }
  9687. if m.switch_in != nil {
  9688. fields = append(fields, employee.FieldSwitchIn)
  9689. }
  9690. if m.video_url != nil {
  9691. fields = append(fields, employee.FieldVideoURL)
  9692. }
  9693. if m.organization_id != nil {
  9694. fields = append(fields, employee.FieldOrganizationID)
  9695. }
  9696. if m.category_id != nil {
  9697. fields = append(fields, employee.FieldCategoryID)
  9698. }
  9699. if m.api_base != nil {
  9700. fields = append(fields, employee.FieldAPIBase)
  9701. }
  9702. if m.api_key != nil {
  9703. fields = append(fields, employee.FieldAPIKey)
  9704. }
  9705. if m.ai_info != nil {
  9706. fields = append(fields, employee.FieldAiInfo)
  9707. }
  9708. if m.is_vip != nil {
  9709. fields = append(fields, employee.FieldIsVip)
  9710. }
  9711. if m.chat_url != nil {
  9712. fields = append(fields, employee.FieldChatURL)
  9713. }
  9714. return fields
  9715. }
  9716. // Field returns the value of a field with the given name. The second boolean
  9717. // return value indicates that this field was not set, or was not defined in the
  9718. // schema.
  9719. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9720. switch name {
  9721. case employee.FieldCreatedAt:
  9722. return m.CreatedAt()
  9723. case employee.FieldUpdatedAt:
  9724. return m.UpdatedAt()
  9725. case employee.FieldDeletedAt:
  9726. return m.DeletedAt()
  9727. case employee.FieldTitle:
  9728. return m.Title()
  9729. case employee.FieldAvatar:
  9730. return m.Avatar()
  9731. case employee.FieldTags:
  9732. return m.Tags()
  9733. case employee.FieldHireCount:
  9734. return m.HireCount()
  9735. case employee.FieldServiceCount:
  9736. return m.ServiceCount()
  9737. case employee.FieldAchievementCount:
  9738. return m.AchievementCount()
  9739. case employee.FieldIntro:
  9740. return m.Intro()
  9741. case employee.FieldEstimate:
  9742. return m.Estimate()
  9743. case employee.FieldSkill:
  9744. return m.Skill()
  9745. case employee.FieldAbilityType:
  9746. return m.AbilityType()
  9747. case employee.FieldScene:
  9748. return m.Scene()
  9749. case employee.FieldSwitchIn:
  9750. return m.SwitchIn()
  9751. case employee.FieldVideoURL:
  9752. return m.VideoURL()
  9753. case employee.FieldOrganizationID:
  9754. return m.OrganizationID()
  9755. case employee.FieldCategoryID:
  9756. return m.CategoryID()
  9757. case employee.FieldAPIBase:
  9758. return m.APIBase()
  9759. case employee.FieldAPIKey:
  9760. return m.APIKey()
  9761. case employee.FieldAiInfo:
  9762. return m.AiInfo()
  9763. case employee.FieldIsVip:
  9764. return m.IsVip()
  9765. case employee.FieldChatURL:
  9766. return m.ChatURL()
  9767. }
  9768. return nil, false
  9769. }
  9770. // OldField returns the old value of the field from the database. An error is
  9771. // returned if the mutation operation is not UpdateOne, or the query to the
  9772. // database failed.
  9773. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9774. switch name {
  9775. case employee.FieldCreatedAt:
  9776. return m.OldCreatedAt(ctx)
  9777. case employee.FieldUpdatedAt:
  9778. return m.OldUpdatedAt(ctx)
  9779. case employee.FieldDeletedAt:
  9780. return m.OldDeletedAt(ctx)
  9781. case employee.FieldTitle:
  9782. return m.OldTitle(ctx)
  9783. case employee.FieldAvatar:
  9784. return m.OldAvatar(ctx)
  9785. case employee.FieldTags:
  9786. return m.OldTags(ctx)
  9787. case employee.FieldHireCount:
  9788. return m.OldHireCount(ctx)
  9789. case employee.FieldServiceCount:
  9790. return m.OldServiceCount(ctx)
  9791. case employee.FieldAchievementCount:
  9792. return m.OldAchievementCount(ctx)
  9793. case employee.FieldIntro:
  9794. return m.OldIntro(ctx)
  9795. case employee.FieldEstimate:
  9796. return m.OldEstimate(ctx)
  9797. case employee.FieldSkill:
  9798. return m.OldSkill(ctx)
  9799. case employee.FieldAbilityType:
  9800. return m.OldAbilityType(ctx)
  9801. case employee.FieldScene:
  9802. return m.OldScene(ctx)
  9803. case employee.FieldSwitchIn:
  9804. return m.OldSwitchIn(ctx)
  9805. case employee.FieldVideoURL:
  9806. return m.OldVideoURL(ctx)
  9807. case employee.FieldOrganizationID:
  9808. return m.OldOrganizationID(ctx)
  9809. case employee.FieldCategoryID:
  9810. return m.OldCategoryID(ctx)
  9811. case employee.FieldAPIBase:
  9812. return m.OldAPIBase(ctx)
  9813. case employee.FieldAPIKey:
  9814. return m.OldAPIKey(ctx)
  9815. case employee.FieldAiInfo:
  9816. return m.OldAiInfo(ctx)
  9817. case employee.FieldIsVip:
  9818. return m.OldIsVip(ctx)
  9819. case employee.FieldChatURL:
  9820. return m.OldChatURL(ctx)
  9821. }
  9822. return nil, fmt.Errorf("unknown Employee field %s", name)
  9823. }
  9824. // SetField sets the value of a field with the given name. It returns an error if
  9825. // the field is not defined in the schema, or if the type mismatched the field
  9826. // type.
  9827. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9828. switch name {
  9829. case employee.FieldCreatedAt:
  9830. v, ok := value.(time.Time)
  9831. if !ok {
  9832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9833. }
  9834. m.SetCreatedAt(v)
  9835. return nil
  9836. case employee.FieldUpdatedAt:
  9837. v, ok := value.(time.Time)
  9838. if !ok {
  9839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9840. }
  9841. m.SetUpdatedAt(v)
  9842. return nil
  9843. case employee.FieldDeletedAt:
  9844. v, ok := value.(time.Time)
  9845. if !ok {
  9846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9847. }
  9848. m.SetDeletedAt(v)
  9849. return nil
  9850. case employee.FieldTitle:
  9851. v, ok := value.(string)
  9852. if !ok {
  9853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9854. }
  9855. m.SetTitle(v)
  9856. return nil
  9857. case employee.FieldAvatar:
  9858. v, ok := value.(string)
  9859. if !ok {
  9860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9861. }
  9862. m.SetAvatar(v)
  9863. return nil
  9864. case employee.FieldTags:
  9865. v, ok := value.(string)
  9866. if !ok {
  9867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9868. }
  9869. m.SetTags(v)
  9870. return nil
  9871. case employee.FieldHireCount:
  9872. v, ok := value.(int)
  9873. if !ok {
  9874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9875. }
  9876. m.SetHireCount(v)
  9877. return nil
  9878. case employee.FieldServiceCount:
  9879. v, ok := value.(int)
  9880. if !ok {
  9881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9882. }
  9883. m.SetServiceCount(v)
  9884. return nil
  9885. case employee.FieldAchievementCount:
  9886. v, ok := value.(int)
  9887. if !ok {
  9888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9889. }
  9890. m.SetAchievementCount(v)
  9891. return nil
  9892. case employee.FieldIntro:
  9893. v, ok := value.(string)
  9894. if !ok {
  9895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9896. }
  9897. m.SetIntro(v)
  9898. return nil
  9899. case employee.FieldEstimate:
  9900. v, ok := value.(string)
  9901. if !ok {
  9902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9903. }
  9904. m.SetEstimate(v)
  9905. return nil
  9906. case employee.FieldSkill:
  9907. v, ok := value.(string)
  9908. if !ok {
  9909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9910. }
  9911. m.SetSkill(v)
  9912. return nil
  9913. case employee.FieldAbilityType:
  9914. v, ok := value.(string)
  9915. if !ok {
  9916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9917. }
  9918. m.SetAbilityType(v)
  9919. return nil
  9920. case employee.FieldScene:
  9921. v, ok := value.(string)
  9922. if !ok {
  9923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9924. }
  9925. m.SetScene(v)
  9926. return nil
  9927. case employee.FieldSwitchIn:
  9928. v, ok := value.(string)
  9929. if !ok {
  9930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9931. }
  9932. m.SetSwitchIn(v)
  9933. return nil
  9934. case employee.FieldVideoURL:
  9935. v, ok := value.(string)
  9936. if !ok {
  9937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9938. }
  9939. m.SetVideoURL(v)
  9940. return nil
  9941. case employee.FieldOrganizationID:
  9942. v, ok := value.(uint64)
  9943. if !ok {
  9944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9945. }
  9946. m.SetOrganizationID(v)
  9947. return nil
  9948. case employee.FieldCategoryID:
  9949. v, ok := value.(uint64)
  9950. if !ok {
  9951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9952. }
  9953. m.SetCategoryID(v)
  9954. return nil
  9955. case employee.FieldAPIBase:
  9956. v, ok := value.(string)
  9957. if !ok {
  9958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9959. }
  9960. m.SetAPIBase(v)
  9961. return nil
  9962. case employee.FieldAPIKey:
  9963. v, ok := value.(string)
  9964. if !ok {
  9965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9966. }
  9967. m.SetAPIKey(v)
  9968. return nil
  9969. case employee.FieldAiInfo:
  9970. v, ok := value.(string)
  9971. if !ok {
  9972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9973. }
  9974. m.SetAiInfo(v)
  9975. return nil
  9976. case employee.FieldIsVip:
  9977. v, ok := value.(int)
  9978. if !ok {
  9979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9980. }
  9981. m.SetIsVip(v)
  9982. return nil
  9983. case employee.FieldChatURL:
  9984. v, ok := value.(string)
  9985. if !ok {
  9986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9987. }
  9988. m.SetChatURL(v)
  9989. return nil
  9990. }
  9991. return fmt.Errorf("unknown Employee field %s", name)
  9992. }
  9993. // AddedFields returns all numeric fields that were incremented/decremented during
  9994. // this mutation.
  9995. func (m *EmployeeMutation) AddedFields() []string {
  9996. var fields []string
  9997. if m.addhire_count != nil {
  9998. fields = append(fields, employee.FieldHireCount)
  9999. }
  10000. if m.addservice_count != nil {
  10001. fields = append(fields, employee.FieldServiceCount)
  10002. }
  10003. if m.addachievement_count != nil {
  10004. fields = append(fields, employee.FieldAchievementCount)
  10005. }
  10006. if m.addorganization_id != nil {
  10007. fields = append(fields, employee.FieldOrganizationID)
  10008. }
  10009. if m.addcategory_id != nil {
  10010. fields = append(fields, employee.FieldCategoryID)
  10011. }
  10012. if m.addis_vip != nil {
  10013. fields = append(fields, employee.FieldIsVip)
  10014. }
  10015. return fields
  10016. }
  10017. // AddedField returns the numeric value that was incremented/decremented on a field
  10018. // with the given name. The second boolean return value indicates that this field
  10019. // was not set, or was not defined in the schema.
  10020. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10021. switch name {
  10022. case employee.FieldHireCount:
  10023. return m.AddedHireCount()
  10024. case employee.FieldServiceCount:
  10025. return m.AddedServiceCount()
  10026. case employee.FieldAchievementCount:
  10027. return m.AddedAchievementCount()
  10028. case employee.FieldOrganizationID:
  10029. return m.AddedOrganizationID()
  10030. case employee.FieldCategoryID:
  10031. return m.AddedCategoryID()
  10032. case employee.FieldIsVip:
  10033. return m.AddedIsVip()
  10034. }
  10035. return nil, false
  10036. }
  10037. // AddField adds the value to the field with the given name. It returns an error if
  10038. // the field is not defined in the schema, or if the type mismatched the field
  10039. // type.
  10040. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10041. switch name {
  10042. case employee.FieldHireCount:
  10043. v, ok := value.(int)
  10044. if !ok {
  10045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10046. }
  10047. m.AddHireCount(v)
  10048. return nil
  10049. case employee.FieldServiceCount:
  10050. v, ok := value.(int)
  10051. if !ok {
  10052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10053. }
  10054. m.AddServiceCount(v)
  10055. return nil
  10056. case employee.FieldAchievementCount:
  10057. v, ok := value.(int)
  10058. if !ok {
  10059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10060. }
  10061. m.AddAchievementCount(v)
  10062. return nil
  10063. case employee.FieldOrganizationID:
  10064. v, ok := value.(int64)
  10065. if !ok {
  10066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10067. }
  10068. m.AddOrganizationID(v)
  10069. return nil
  10070. case employee.FieldCategoryID:
  10071. v, ok := value.(int64)
  10072. if !ok {
  10073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10074. }
  10075. m.AddCategoryID(v)
  10076. return nil
  10077. case employee.FieldIsVip:
  10078. v, ok := value.(int)
  10079. if !ok {
  10080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10081. }
  10082. m.AddIsVip(v)
  10083. return nil
  10084. }
  10085. return fmt.Errorf("unknown Employee numeric field %s", name)
  10086. }
  10087. // ClearedFields returns all nullable fields that were cleared during this
  10088. // mutation.
  10089. func (m *EmployeeMutation) ClearedFields() []string {
  10090. var fields []string
  10091. if m.FieldCleared(employee.FieldDeletedAt) {
  10092. fields = append(fields, employee.FieldDeletedAt)
  10093. }
  10094. if m.FieldCleared(employee.FieldAiInfo) {
  10095. fields = append(fields, employee.FieldAiInfo)
  10096. }
  10097. return fields
  10098. }
  10099. // FieldCleared returns a boolean indicating if a field with the given name was
  10100. // cleared in this mutation.
  10101. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10102. _, ok := m.clearedFields[name]
  10103. return ok
  10104. }
  10105. // ClearField clears the value of the field with the given name. It returns an
  10106. // error if the field is not defined in the schema.
  10107. func (m *EmployeeMutation) ClearField(name string) error {
  10108. switch name {
  10109. case employee.FieldDeletedAt:
  10110. m.ClearDeletedAt()
  10111. return nil
  10112. case employee.FieldAiInfo:
  10113. m.ClearAiInfo()
  10114. return nil
  10115. }
  10116. return fmt.Errorf("unknown Employee nullable field %s", name)
  10117. }
  10118. // ResetField resets all changes in the mutation for the field with the given name.
  10119. // It returns an error if the field is not defined in the schema.
  10120. func (m *EmployeeMutation) ResetField(name string) error {
  10121. switch name {
  10122. case employee.FieldCreatedAt:
  10123. m.ResetCreatedAt()
  10124. return nil
  10125. case employee.FieldUpdatedAt:
  10126. m.ResetUpdatedAt()
  10127. return nil
  10128. case employee.FieldDeletedAt:
  10129. m.ResetDeletedAt()
  10130. return nil
  10131. case employee.FieldTitle:
  10132. m.ResetTitle()
  10133. return nil
  10134. case employee.FieldAvatar:
  10135. m.ResetAvatar()
  10136. return nil
  10137. case employee.FieldTags:
  10138. m.ResetTags()
  10139. return nil
  10140. case employee.FieldHireCount:
  10141. m.ResetHireCount()
  10142. return nil
  10143. case employee.FieldServiceCount:
  10144. m.ResetServiceCount()
  10145. return nil
  10146. case employee.FieldAchievementCount:
  10147. m.ResetAchievementCount()
  10148. return nil
  10149. case employee.FieldIntro:
  10150. m.ResetIntro()
  10151. return nil
  10152. case employee.FieldEstimate:
  10153. m.ResetEstimate()
  10154. return nil
  10155. case employee.FieldSkill:
  10156. m.ResetSkill()
  10157. return nil
  10158. case employee.FieldAbilityType:
  10159. m.ResetAbilityType()
  10160. return nil
  10161. case employee.FieldScene:
  10162. m.ResetScene()
  10163. return nil
  10164. case employee.FieldSwitchIn:
  10165. m.ResetSwitchIn()
  10166. return nil
  10167. case employee.FieldVideoURL:
  10168. m.ResetVideoURL()
  10169. return nil
  10170. case employee.FieldOrganizationID:
  10171. m.ResetOrganizationID()
  10172. return nil
  10173. case employee.FieldCategoryID:
  10174. m.ResetCategoryID()
  10175. return nil
  10176. case employee.FieldAPIBase:
  10177. m.ResetAPIBase()
  10178. return nil
  10179. case employee.FieldAPIKey:
  10180. m.ResetAPIKey()
  10181. return nil
  10182. case employee.FieldAiInfo:
  10183. m.ResetAiInfo()
  10184. return nil
  10185. case employee.FieldIsVip:
  10186. m.ResetIsVip()
  10187. return nil
  10188. case employee.FieldChatURL:
  10189. m.ResetChatURL()
  10190. return nil
  10191. }
  10192. return fmt.Errorf("unknown Employee field %s", name)
  10193. }
  10194. // AddedEdges returns all edge names that were set/added in this mutation.
  10195. func (m *EmployeeMutation) AddedEdges() []string {
  10196. edges := make([]string, 0, 2)
  10197. if m.em_work_experiences != nil {
  10198. edges = append(edges, employee.EdgeEmWorkExperiences)
  10199. }
  10200. if m.em_tutorial != nil {
  10201. edges = append(edges, employee.EdgeEmTutorial)
  10202. }
  10203. return edges
  10204. }
  10205. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10206. // name in this mutation.
  10207. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10208. switch name {
  10209. case employee.EdgeEmWorkExperiences:
  10210. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10211. for id := range m.em_work_experiences {
  10212. ids = append(ids, id)
  10213. }
  10214. return ids
  10215. case employee.EdgeEmTutorial:
  10216. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10217. for id := range m.em_tutorial {
  10218. ids = append(ids, id)
  10219. }
  10220. return ids
  10221. }
  10222. return nil
  10223. }
  10224. // RemovedEdges returns all edge names that were removed in this mutation.
  10225. func (m *EmployeeMutation) RemovedEdges() []string {
  10226. edges := make([]string, 0, 2)
  10227. if m.removedem_work_experiences != nil {
  10228. edges = append(edges, employee.EdgeEmWorkExperiences)
  10229. }
  10230. if m.removedem_tutorial != nil {
  10231. edges = append(edges, employee.EdgeEmTutorial)
  10232. }
  10233. return edges
  10234. }
  10235. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10236. // the given name in this mutation.
  10237. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10238. switch name {
  10239. case employee.EdgeEmWorkExperiences:
  10240. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10241. for id := range m.removedem_work_experiences {
  10242. ids = append(ids, id)
  10243. }
  10244. return ids
  10245. case employee.EdgeEmTutorial:
  10246. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10247. for id := range m.removedem_tutorial {
  10248. ids = append(ids, id)
  10249. }
  10250. return ids
  10251. }
  10252. return nil
  10253. }
  10254. // ClearedEdges returns all edge names that were cleared in this mutation.
  10255. func (m *EmployeeMutation) ClearedEdges() []string {
  10256. edges := make([]string, 0, 2)
  10257. if m.clearedem_work_experiences {
  10258. edges = append(edges, employee.EdgeEmWorkExperiences)
  10259. }
  10260. if m.clearedem_tutorial {
  10261. edges = append(edges, employee.EdgeEmTutorial)
  10262. }
  10263. return edges
  10264. }
  10265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10266. // was cleared in this mutation.
  10267. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10268. switch name {
  10269. case employee.EdgeEmWorkExperiences:
  10270. return m.clearedem_work_experiences
  10271. case employee.EdgeEmTutorial:
  10272. return m.clearedem_tutorial
  10273. }
  10274. return false
  10275. }
  10276. // ClearEdge clears the value of the edge with the given name. It returns an error
  10277. // if that edge is not defined in the schema.
  10278. func (m *EmployeeMutation) ClearEdge(name string) error {
  10279. switch name {
  10280. }
  10281. return fmt.Errorf("unknown Employee unique edge %s", name)
  10282. }
  10283. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10284. // It returns an error if the edge is not defined in the schema.
  10285. func (m *EmployeeMutation) ResetEdge(name string) error {
  10286. switch name {
  10287. case employee.EdgeEmWorkExperiences:
  10288. m.ResetEmWorkExperiences()
  10289. return nil
  10290. case employee.EdgeEmTutorial:
  10291. m.ResetEmTutorial()
  10292. return nil
  10293. }
  10294. return fmt.Errorf("unknown Employee edge %s", name)
  10295. }
  10296. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10297. type EmployeeConfigMutation struct {
  10298. config
  10299. op Op
  10300. typ string
  10301. id *uint64
  10302. created_at *time.Time
  10303. updated_at *time.Time
  10304. deleted_at *time.Time
  10305. stype *string
  10306. title *string
  10307. photo *string
  10308. organization_id *uint64
  10309. addorganization_id *int64
  10310. clearedFields map[string]struct{}
  10311. done bool
  10312. oldValue func(context.Context) (*EmployeeConfig, error)
  10313. predicates []predicate.EmployeeConfig
  10314. }
  10315. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10316. // employeeconfigOption allows management of the mutation configuration using functional options.
  10317. type employeeconfigOption func(*EmployeeConfigMutation)
  10318. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10319. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10320. m := &EmployeeConfigMutation{
  10321. config: c,
  10322. op: op,
  10323. typ: TypeEmployeeConfig,
  10324. clearedFields: make(map[string]struct{}),
  10325. }
  10326. for _, opt := range opts {
  10327. opt(m)
  10328. }
  10329. return m
  10330. }
  10331. // withEmployeeConfigID sets the ID field of the mutation.
  10332. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10333. return func(m *EmployeeConfigMutation) {
  10334. var (
  10335. err error
  10336. once sync.Once
  10337. value *EmployeeConfig
  10338. )
  10339. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10340. once.Do(func() {
  10341. if m.done {
  10342. err = errors.New("querying old values post mutation is not allowed")
  10343. } else {
  10344. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10345. }
  10346. })
  10347. return value, err
  10348. }
  10349. m.id = &id
  10350. }
  10351. }
  10352. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10353. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10354. return func(m *EmployeeConfigMutation) {
  10355. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10356. return node, nil
  10357. }
  10358. m.id = &node.ID
  10359. }
  10360. }
  10361. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10362. // executed in a transaction (ent.Tx), a transactional client is returned.
  10363. func (m EmployeeConfigMutation) Client() *Client {
  10364. client := &Client{config: m.config}
  10365. client.init()
  10366. return client
  10367. }
  10368. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10369. // it returns an error otherwise.
  10370. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10371. if _, ok := m.driver.(*txDriver); !ok {
  10372. return nil, errors.New("ent: mutation is not running in a transaction")
  10373. }
  10374. tx := &Tx{config: m.config}
  10375. tx.init()
  10376. return tx, nil
  10377. }
  10378. // SetID sets the value of the id field. Note that this
  10379. // operation is only accepted on creation of EmployeeConfig entities.
  10380. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10381. m.id = &id
  10382. }
  10383. // ID returns the ID value in the mutation. Note that the ID is only available
  10384. // if it was provided to the builder or after it was returned from the database.
  10385. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10386. if m.id == nil {
  10387. return
  10388. }
  10389. return *m.id, true
  10390. }
  10391. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10392. // That means, if the mutation is applied within a transaction with an isolation level such
  10393. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10394. // or updated by the mutation.
  10395. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10396. switch {
  10397. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10398. id, exists := m.ID()
  10399. if exists {
  10400. return []uint64{id}, nil
  10401. }
  10402. fallthrough
  10403. case m.op.Is(OpUpdate | OpDelete):
  10404. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10405. default:
  10406. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10407. }
  10408. }
  10409. // SetCreatedAt sets the "created_at" field.
  10410. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10411. m.created_at = &t
  10412. }
  10413. // CreatedAt returns the value of the "created_at" field in the mutation.
  10414. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10415. v := m.created_at
  10416. if v == nil {
  10417. return
  10418. }
  10419. return *v, true
  10420. }
  10421. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10422. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10424. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10425. if !m.op.Is(OpUpdateOne) {
  10426. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10427. }
  10428. if m.id == nil || m.oldValue == nil {
  10429. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10430. }
  10431. oldValue, err := m.oldValue(ctx)
  10432. if err != nil {
  10433. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10434. }
  10435. return oldValue.CreatedAt, nil
  10436. }
  10437. // ResetCreatedAt resets all changes to the "created_at" field.
  10438. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10439. m.created_at = nil
  10440. }
  10441. // SetUpdatedAt sets the "updated_at" field.
  10442. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10443. m.updated_at = &t
  10444. }
  10445. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10446. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10447. v := m.updated_at
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10454. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10456. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10462. }
  10463. oldValue, err := m.oldValue(ctx)
  10464. if err != nil {
  10465. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10466. }
  10467. return oldValue.UpdatedAt, nil
  10468. }
  10469. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10470. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10471. m.updated_at = nil
  10472. }
  10473. // SetDeletedAt sets the "deleted_at" field.
  10474. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10475. m.deleted_at = &t
  10476. }
  10477. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10478. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10479. v := m.deleted_at
  10480. if v == nil {
  10481. return
  10482. }
  10483. return *v, true
  10484. }
  10485. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10486. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10488. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10489. if !m.op.Is(OpUpdateOne) {
  10490. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10491. }
  10492. if m.id == nil || m.oldValue == nil {
  10493. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10494. }
  10495. oldValue, err := m.oldValue(ctx)
  10496. if err != nil {
  10497. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10498. }
  10499. return oldValue.DeletedAt, nil
  10500. }
  10501. // ClearDeletedAt clears the value of the "deleted_at" field.
  10502. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10503. m.deleted_at = nil
  10504. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10505. }
  10506. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10507. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10508. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10509. return ok
  10510. }
  10511. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10512. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10513. m.deleted_at = nil
  10514. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10515. }
  10516. // SetStype sets the "stype" field.
  10517. func (m *EmployeeConfigMutation) SetStype(s string) {
  10518. m.stype = &s
  10519. }
  10520. // Stype returns the value of the "stype" field in the mutation.
  10521. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10522. v := m.stype
  10523. if v == nil {
  10524. return
  10525. }
  10526. return *v, true
  10527. }
  10528. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10529. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10531. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10532. if !m.op.Is(OpUpdateOne) {
  10533. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10534. }
  10535. if m.id == nil || m.oldValue == nil {
  10536. return v, errors.New("OldStype requires an ID field in the mutation")
  10537. }
  10538. oldValue, err := m.oldValue(ctx)
  10539. if err != nil {
  10540. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10541. }
  10542. return oldValue.Stype, nil
  10543. }
  10544. // ResetStype resets all changes to the "stype" field.
  10545. func (m *EmployeeConfigMutation) ResetStype() {
  10546. m.stype = nil
  10547. }
  10548. // SetTitle sets the "title" field.
  10549. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10550. m.title = &s
  10551. }
  10552. // Title returns the value of the "title" field in the mutation.
  10553. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10554. v := m.title
  10555. if v == nil {
  10556. return
  10557. }
  10558. return *v, true
  10559. }
  10560. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10561. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10563. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10564. if !m.op.Is(OpUpdateOne) {
  10565. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10566. }
  10567. if m.id == nil || m.oldValue == nil {
  10568. return v, errors.New("OldTitle requires an ID field in the mutation")
  10569. }
  10570. oldValue, err := m.oldValue(ctx)
  10571. if err != nil {
  10572. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10573. }
  10574. return oldValue.Title, nil
  10575. }
  10576. // ResetTitle resets all changes to the "title" field.
  10577. func (m *EmployeeConfigMutation) ResetTitle() {
  10578. m.title = nil
  10579. }
  10580. // SetPhoto sets the "photo" field.
  10581. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10582. m.photo = &s
  10583. }
  10584. // Photo returns the value of the "photo" field in the mutation.
  10585. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10586. v := m.photo
  10587. if v == nil {
  10588. return
  10589. }
  10590. return *v, true
  10591. }
  10592. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10593. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10595. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10596. if !m.op.Is(OpUpdateOne) {
  10597. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10598. }
  10599. if m.id == nil || m.oldValue == nil {
  10600. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10601. }
  10602. oldValue, err := m.oldValue(ctx)
  10603. if err != nil {
  10604. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10605. }
  10606. return oldValue.Photo, nil
  10607. }
  10608. // ResetPhoto resets all changes to the "photo" field.
  10609. func (m *EmployeeConfigMutation) ResetPhoto() {
  10610. m.photo = nil
  10611. }
  10612. // SetOrganizationID sets the "organization_id" field.
  10613. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10614. m.organization_id = &u
  10615. m.addorganization_id = nil
  10616. }
  10617. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10618. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10619. v := m.organization_id
  10620. if v == nil {
  10621. return
  10622. }
  10623. return *v, true
  10624. }
  10625. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10626. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10628. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10629. if !m.op.Is(OpUpdateOne) {
  10630. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10631. }
  10632. if m.id == nil || m.oldValue == nil {
  10633. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10634. }
  10635. oldValue, err := m.oldValue(ctx)
  10636. if err != nil {
  10637. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10638. }
  10639. return oldValue.OrganizationID, nil
  10640. }
  10641. // AddOrganizationID adds u to the "organization_id" field.
  10642. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10643. if m.addorganization_id != nil {
  10644. *m.addorganization_id += u
  10645. } else {
  10646. m.addorganization_id = &u
  10647. }
  10648. }
  10649. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10650. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10651. v := m.addorganization_id
  10652. if v == nil {
  10653. return
  10654. }
  10655. return *v, true
  10656. }
  10657. // ClearOrganizationID clears the value of the "organization_id" field.
  10658. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10659. m.organization_id = nil
  10660. m.addorganization_id = nil
  10661. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10662. }
  10663. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10664. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10665. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10666. return ok
  10667. }
  10668. // ResetOrganizationID resets all changes to the "organization_id" field.
  10669. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10670. m.organization_id = nil
  10671. m.addorganization_id = nil
  10672. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10673. }
  10674. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10675. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10676. m.predicates = append(m.predicates, ps...)
  10677. }
  10678. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10679. // users can use type-assertion to append predicates that do not depend on any generated package.
  10680. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10681. p := make([]predicate.EmployeeConfig, len(ps))
  10682. for i := range ps {
  10683. p[i] = ps[i]
  10684. }
  10685. m.Where(p...)
  10686. }
  10687. // Op returns the operation name.
  10688. func (m *EmployeeConfigMutation) Op() Op {
  10689. return m.op
  10690. }
  10691. // SetOp allows setting the mutation operation.
  10692. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10693. m.op = op
  10694. }
  10695. // Type returns the node type of this mutation (EmployeeConfig).
  10696. func (m *EmployeeConfigMutation) Type() string {
  10697. return m.typ
  10698. }
  10699. // Fields returns all fields that were changed during this mutation. Note that in
  10700. // order to get all numeric fields that were incremented/decremented, call
  10701. // AddedFields().
  10702. func (m *EmployeeConfigMutation) Fields() []string {
  10703. fields := make([]string, 0, 7)
  10704. if m.created_at != nil {
  10705. fields = append(fields, employeeconfig.FieldCreatedAt)
  10706. }
  10707. if m.updated_at != nil {
  10708. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10709. }
  10710. if m.deleted_at != nil {
  10711. fields = append(fields, employeeconfig.FieldDeletedAt)
  10712. }
  10713. if m.stype != nil {
  10714. fields = append(fields, employeeconfig.FieldStype)
  10715. }
  10716. if m.title != nil {
  10717. fields = append(fields, employeeconfig.FieldTitle)
  10718. }
  10719. if m.photo != nil {
  10720. fields = append(fields, employeeconfig.FieldPhoto)
  10721. }
  10722. if m.organization_id != nil {
  10723. fields = append(fields, employeeconfig.FieldOrganizationID)
  10724. }
  10725. return fields
  10726. }
  10727. // Field returns the value of a field with the given name. The second boolean
  10728. // return value indicates that this field was not set, or was not defined in the
  10729. // schema.
  10730. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10731. switch name {
  10732. case employeeconfig.FieldCreatedAt:
  10733. return m.CreatedAt()
  10734. case employeeconfig.FieldUpdatedAt:
  10735. return m.UpdatedAt()
  10736. case employeeconfig.FieldDeletedAt:
  10737. return m.DeletedAt()
  10738. case employeeconfig.FieldStype:
  10739. return m.Stype()
  10740. case employeeconfig.FieldTitle:
  10741. return m.Title()
  10742. case employeeconfig.FieldPhoto:
  10743. return m.Photo()
  10744. case employeeconfig.FieldOrganizationID:
  10745. return m.OrganizationID()
  10746. }
  10747. return nil, false
  10748. }
  10749. // OldField returns the old value of the field from the database. An error is
  10750. // returned if the mutation operation is not UpdateOne, or the query to the
  10751. // database failed.
  10752. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10753. switch name {
  10754. case employeeconfig.FieldCreatedAt:
  10755. return m.OldCreatedAt(ctx)
  10756. case employeeconfig.FieldUpdatedAt:
  10757. return m.OldUpdatedAt(ctx)
  10758. case employeeconfig.FieldDeletedAt:
  10759. return m.OldDeletedAt(ctx)
  10760. case employeeconfig.FieldStype:
  10761. return m.OldStype(ctx)
  10762. case employeeconfig.FieldTitle:
  10763. return m.OldTitle(ctx)
  10764. case employeeconfig.FieldPhoto:
  10765. return m.OldPhoto(ctx)
  10766. case employeeconfig.FieldOrganizationID:
  10767. return m.OldOrganizationID(ctx)
  10768. }
  10769. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10770. }
  10771. // SetField sets the value of a field with the given name. It returns an error if
  10772. // the field is not defined in the schema, or if the type mismatched the field
  10773. // type.
  10774. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10775. switch name {
  10776. case employeeconfig.FieldCreatedAt:
  10777. v, ok := value.(time.Time)
  10778. if !ok {
  10779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10780. }
  10781. m.SetCreatedAt(v)
  10782. return nil
  10783. case employeeconfig.FieldUpdatedAt:
  10784. v, ok := value.(time.Time)
  10785. if !ok {
  10786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10787. }
  10788. m.SetUpdatedAt(v)
  10789. return nil
  10790. case employeeconfig.FieldDeletedAt:
  10791. v, ok := value.(time.Time)
  10792. if !ok {
  10793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10794. }
  10795. m.SetDeletedAt(v)
  10796. return nil
  10797. case employeeconfig.FieldStype:
  10798. v, ok := value.(string)
  10799. if !ok {
  10800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10801. }
  10802. m.SetStype(v)
  10803. return nil
  10804. case employeeconfig.FieldTitle:
  10805. v, ok := value.(string)
  10806. if !ok {
  10807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10808. }
  10809. m.SetTitle(v)
  10810. return nil
  10811. case employeeconfig.FieldPhoto:
  10812. v, ok := value.(string)
  10813. if !ok {
  10814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10815. }
  10816. m.SetPhoto(v)
  10817. return nil
  10818. case employeeconfig.FieldOrganizationID:
  10819. v, ok := value.(uint64)
  10820. if !ok {
  10821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10822. }
  10823. m.SetOrganizationID(v)
  10824. return nil
  10825. }
  10826. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10827. }
  10828. // AddedFields returns all numeric fields that were incremented/decremented during
  10829. // this mutation.
  10830. func (m *EmployeeConfigMutation) AddedFields() []string {
  10831. var fields []string
  10832. if m.addorganization_id != nil {
  10833. fields = append(fields, employeeconfig.FieldOrganizationID)
  10834. }
  10835. return fields
  10836. }
  10837. // AddedField returns the numeric value that was incremented/decremented on a field
  10838. // with the given name. The second boolean return value indicates that this field
  10839. // was not set, or was not defined in the schema.
  10840. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10841. switch name {
  10842. case employeeconfig.FieldOrganizationID:
  10843. return m.AddedOrganizationID()
  10844. }
  10845. return nil, false
  10846. }
  10847. // AddField adds the value to the field with the given name. It returns an error if
  10848. // the field is not defined in the schema, or if the type mismatched the field
  10849. // type.
  10850. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10851. switch name {
  10852. case employeeconfig.FieldOrganizationID:
  10853. v, ok := value.(int64)
  10854. if !ok {
  10855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10856. }
  10857. m.AddOrganizationID(v)
  10858. return nil
  10859. }
  10860. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10861. }
  10862. // ClearedFields returns all nullable fields that were cleared during this
  10863. // mutation.
  10864. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10865. var fields []string
  10866. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10867. fields = append(fields, employeeconfig.FieldDeletedAt)
  10868. }
  10869. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10870. fields = append(fields, employeeconfig.FieldOrganizationID)
  10871. }
  10872. return fields
  10873. }
  10874. // FieldCleared returns a boolean indicating if a field with the given name was
  10875. // cleared in this mutation.
  10876. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10877. _, ok := m.clearedFields[name]
  10878. return ok
  10879. }
  10880. // ClearField clears the value of the field with the given name. It returns an
  10881. // error if the field is not defined in the schema.
  10882. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10883. switch name {
  10884. case employeeconfig.FieldDeletedAt:
  10885. m.ClearDeletedAt()
  10886. return nil
  10887. case employeeconfig.FieldOrganizationID:
  10888. m.ClearOrganizationID()
  10889. return nil
  10890. }
  10891. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10892. }
  10893. // ResetField resets all changes in the mutation for the field with the given name.
  10894. // It returns an error if the field is not defined in the schema.
  10895. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10896. switch name {
  10897. case employeeconfig.FieldCreatedAt:
  10898. m.ResetCreatedAt()
  10899. return nil
  10900. case employeeconfig.FieldUpdatedAt:
  10901. m.ResetUpdatedAt()
  10902. return nil
  10903. case employeeconfig.FieldDeletedAt:
  10904. m.ResetDeletedAt()
  10905. return nil
  10906. case employeeconfig.FieldStype:
  10907. m.ResetStype()
  10908. return nil
  10909. case employeeconfig.FieldTitle:
  10910. m.ResetTitle()
  10911. return nil
  10912. case employeeconfig.FieldPhoto:
  10913. m.ResetPhoto()
  10914. return nil
  10915. case employeeconfig.FieldOrganizationID:
  10916. m.ResetOrganizationID()
  10917. return nil
  10918. }
  10919. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10920. }
  10921. // AddedEdges returns all edge names that were set/added in this mutation.
  10922. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10923. edges := make([]string, 0, 0)
  10924. return edges
  10925. }
  10926. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10927. // name in this mutation.
  10928. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10929. return nil
  10930. }
  10931. // RemovedEdges returns all edge names that were removed in this mutation.
  10932. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10933. edges := make([]string, 0, 0)
  10934. return edges
  10935. }
  10936. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10937. // the given name in this mutation.
  10938. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10939. return nil
  10940. }
  10941. // ClearedEdges returns all edge names that were cleared in this mutation.
  10942. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10943. edges := make([]string, 0, 0)
  10944. return edges
  10945. }
  10946. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10947. // was cleared in this mutation.
  10948. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10949. return false
  10950. }
  10951. // ClearEdge clears the value of the edge with the given name. It returns an error
  10952. // if that edge is not defined in the schema.
  10953. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10954. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10955. }
  10956. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10957. // It returns an error if the edge is not defined in the schema.
  10958. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10959. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10960. }
  10961. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10962. type LabelMutation struct {
  10963. config
  10964. op Op
  10965. typ string
  10966. id *uint64
  10967. created_at *time.Time
  10968. updated_at *time.Time
  10969. status *uint8
  10970. addstatus *int8
  10971. _type *int
  10972. add_type *int
  10973. name *string
  10974. from *int
  10975. addfrom *int
  10976. mode *int
  10977. addmode *int
  10978. conditions *string
  10979. organization_id *uint64
  10980. addorganization_id *int64
  10981. clearedFields map[string]struct{}
  10982. label_relationships map[uint64]struct{}
  10983. removedlabel_relationships map[uint64]struct{}
  10984. clearedlabel_relationships bool
  10985. done bool
  10986. oldValue func(context.Context) (*Label, error)
  10987. predicates []predicate.Label
  10988. }
  10989. var _ ent.Mutation = (*LabelMutation)(nil)
  10990. // labelOption allows management of the mutation configuration using functional options.
  10991. type labelOption func(*LabelMutation)
  10992. // newLabelMutation creates new mutation for the Label entity.
  10993. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10994. m := &LabelMutation{
  10995. config: c,
  10996. op: op,
  10997. typ: TypeLabel,
  10998. clearedFields: make(map[string]struct{}),
  10999. }
  11000. for _, opt := range opts {
  11001. opt(m)
  11002. }
  11003. return m
  11004. }
  11005. // withLabelID sets the ID field of the mutation.
  11006. func withLabelID(id uint64) labelOption {
  11007. return func(m *LabelMutation) {
  11008. var (
  11009. err error
  11010. once sync.Once
  11011. value *Label
  11012. )
  11013. m.oldValue = func(ctx context.Context) (*Label, error) {
  11014. once.Do(func() {
  11015. if m.done {
  11016. err = errors.New("querying old values post mutation is not allowed")
  11017. } else {
  11018. value, err = m.Client().Label.Get(ctx, id)
  11019. }
  11020. })
  11021. return value, err
  11022. }
  11023. m.id = &id
  11024. }
  11025. }
  11026. // withLabel sets the old Label of the mutation.
  11027. func withLabel(node *Label) labelOption {
  11028. return func(m *LabelMutation) {
  11029. m.oldValue = func(context.Context) (*Label, error) {
  11030. return node, nil
  11031. }
  11032. m.id = &node.ID
  11033. }
  11034. }
  11035. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11036. // executed in a transaction (ent.Tx), a transactional client is returned.
  11037. func (m LabelMutation) Client() *Client {
  11038. client := &Client{config: m.config}
  11039. client.init()
  11040. return client
  11041. }
  11042. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11043. // it returns an error otherwise.
  11044. func (m LabelMutation) Tx() (*Tx, error) {
  11045. if _, ok := m.driver.(*txDriver); !ok {
  11046. return nil, errors.New("ent: mutation is not running in a transaction")
  11047. }
  11048. tx := &Tx{config: m.config}
  11049. tx.init()
  11050. return tx, nil
  11051. }
  11052. // SetID sets the value of the id field. Note that this
  11053. // operation is only accepted on creation of Label entities.
  11054. func (m *LabelMutation) SetID(id uint64) {
  11055. m.id = &id
  11056. }
  11057. // ID returns the ID value in the mutation. Note that the ID is only available
  11058. // if it was provided to the builder or after it was returned from the database.
  11059. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11060. if m.id == nil {
  11061. return
  11062. }
  11063. return *m.id, true
  11064. }
  11065. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11066. // That means, if the mutation is applied within a transaction with an isolation level such
  11067. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11068. // or updated by the mutation.
  11069. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11070. switch {
  11071. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11072. id, exists := m.ID()
  11073. if exists {
  11074. return []uint64{id}, nil
  11075. }
  11076. fallthrough
  11077. case m.op.Is(OpUpdate | OpDelete):
  11078. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11079. default:
  11080. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11081. }
  11082. }
  11083. // SetCreatedAt sets the "created_at" field.
  11084. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11085. m.created_at = &t
  11086. }
  11087. // CreatedAt returns the value of the "created_at" field in the mutation.
  11088. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11089. v := m.created_at
  11090. if v == nil {
  11091. return
  11092. }
  11093. return *v, true
  11094. }
  11095. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11096. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11098. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11099. if !m.op.Is(OpUpdateOne) {
  11100. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11101. }
  11102. if m.id == nil || m.oldValue == nil {
  11103. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11104. }
  11105. oldValue, err := m.oldValue(ctx)
  11106. if err != nil {
  11107. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11108. }
  11109. return oldValue.CreatedAt, nil
  11110. }
  11111. // ResetCreatedAt resets all changes to the "created_at" field.
  11112. func (m *LabelMutation) ResetCreatedAt() {
  11113. m.created_at = nil
  11114. }
  11115. // SetUpdatedAt sets the "updated_at" field.
  11116. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11117. m.updated_at = &t
  11118. }
  11119. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11120. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11121. v := m.updated_at
  11122. if v == nil {
  11123. return
  11124. }
  11125. return *v, true
  11126. }
  11127. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11128. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11130. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11131. if !m.op.Is(OpUpdateOne) {
  11132. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11133. }
  11134. if m.id == nil || m.oldValue == nil {
  11135. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11136. }
  11137. oldValue, err := m.oldValue(ctx)
  11138. if err != nil {
  11139. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11140. }
  11141. return oldValue.UpdatedAt, nil
  11142. }
  11143. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11144. func (m *LabelMutation) ResetUpdatedAt() {
  11145. m.updated_at = nil
  11146. }
  11147. // SetStatus sets the "status" field.
  11148. func (m *LabelMutation) SetStatus(u uint8) {
  11149. m.status = &u
  11150. m.addstatus = nil
  11151. }
  11152. // Status returns the value of the "status" field in the mutation.
  11153. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11154. v := m.status
  11155. if v == nil {
  11156. return
  11157. }
  11158. return *v, true
  11159. }
  11160. // OldStatus returns the old "status" field's value of the Label entity.
  11161. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11163. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11164. if !m.op.Is(OpUpdateOne) {
  11165. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11166. }
  11167. if m.id == nil || m.oldValue == nil {
  11168. return v, errors.New("OldStatus requires an ID field in the mutation")
  11169. }
  11170. oldValue, err := m.oldValue(ctx)
  11171. if err != nil {
  11172. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11173. }
  11174. return oldValue.Status, nil
  11175. }
  11176. // AddStatus adds u to the "status" field.
  11177. func (m *LabelMutation) AddStatus(u int8) {
  11178. if m.addstatus != nil {
  11179. *m.addstatus += u
  11180. } else {
  11181. m.addstatus = &u
  11182. }
  11183. }
  11184. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11185. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11186. v := m.addstatus
  11187. if v == nil {
  11188. return
  11189. }
  11190. return *v, true
  11191. }
  11192. // ClearStatus clears the value of the "status" field.
  11193. func (m *LabelMutation) ClearStatus() {
  11194. m.status = nil
  11195. m.addstatus = nil
  11196. m.clearedFields[label.FieldStatus] = struct{}{}
  11197. }
  11198. // StatusCleared returns if the "status" field was cleared in this mutation.
  11199. func (m *LabelMutation) StatusCleared() bool {
  11200. _, ok := m.clearedFields[label.FieldStatus]
  11201. return ok
  11202. }
  11203. // ResetStatus resets all changes to the "status" field.
  11204. func (m *LabelMutation) ResetStatus() {
  11205. m.status = nil
  11206. m.addstatus = nil
  11207. delete(m.clearedFields, label.FieldStatus)
  11208. }
  11209. // SetType sets the "type" field.
  11210. func (m *LabelMutation) SetType(i int) {
  11211. m._type = &i
  11212. m.add_type = nil
  11213. }
  11214. // GetType returns the value of the "type" field in the mutation.
  11215. func (m *LabelMutation) GetType() (r int, exists bool) {
  11216. v := m._type
  11217. if v == nil {
  11218. return
  11219. }
  11220. return *v, true
  11221. }
  11222. // OldType returns the old "type" field's value of the Label entity.
  11223. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11225. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11226. if !m.op.Is(OpUpdateOne) {
  11227. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11228. }
  11229. if m.id == nil || m.oldValue == nil {
  11230. return v, errors.New("OldType requires an ID field in the mutation")
  11231. }
  11232. oldValue, err := m.oldValue(ctx)
  11233. if err != nil {
  11234. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11235. }
  11236. return oldValue.Type, nil
  11237. }
  11238. // AddType adds i to the "type" field.
  11239. func (m *LabelMutation) AddType(i int) {
  11240. if m.add_type != nil {
  11241. *m.add_type += i
  11242. } else {
  11243. m.add_type = &i
  11244. }
  11245. }
  11246. // AddedType returns the value that was added to the "type" field in this mutation.
  11247. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11248. v := m.add_type
  11249. if v == nil {
  11250. return
  11251. }
  11252. return *v, true
  11253. }
  11254. // ResetType resets all changes to the "type" field.
  11255. func (m *LabelMutation) ResetType() {
  11256. m._type = nil
  11257. m.add_type = nil
  11258. }
  11259. // SetName sets the "name" field.
  11260. func (m *LabelMutation) SetName(s string) {
  11261. m.name = &s
  11262. }
  11263. // Name returns the value of the "name" field in the mutation.
  11264. func (m *LabelMutation) Name() (r string, exists bool) {
  11265. v := m.name
  11266. if v == nil {
  11267. return
  11268. }
  11269. return *v, true
  11270. }
  11271. // OldName returns the old "name" field's value of the Label entity.
  11272. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11274. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11275. if !m.op.Is(OpUpdateOne) {
  11276. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11277. }
  11278. if m.id == nil || m.oldValue == nil {
  11279. return v, errors.New("OldName requires an ID field in the mutation")
  11280. }
  11281. oldValue, err := m.oldValue(ctx)
  11282. if err != nil {
  11283. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11284. }
  11285. return oldValue.Name, nil
  11286. }
  11287. // ResetName resets all changes to the "name" field.
  11288. func (m *LabelMutation) ResetName() {
  11289. m.name = nil
  11290. }
  11291. // SetFrom sets the "from" field.
  11292. func (m *LabelMutation) SetFrom(i int) {
  11293. m.from = &i
  11294. m.addfrom = nil
  11295. }
  11296. // From returns the value of the "from" field in the mutation.
  11297. func (m *LabelMutation) From() (r int, exists bool) {
  11298. v := m.from
  11299. if v == nil {
  11300. return
  11301. }
  11302. return *v, true
  11303. }
  11304. // OldFrom returns the old "from" field's value of the Label entity.
  11305. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11307. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11308. if !m.op.Is(OpUpdateOne) {
  11309. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11310. }
  11311. if m.id == nil || m.oldValue == nil {
  11312. return v, errors.New("OldFrom requires an ID field in the mutation")
  11313. }
  11314. oldValue, err := m.oldValue(ctx)
  11315. if err != nil {
  11316. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11317. }
  11318. return oldValue.From, nil
  11319. }
  11320. // AddFrom adds i to the "from" field.
  11321. func (m *LabelMutation) AddFrom(i int) {
  11322. if m.addfrom != nil {
  11323. *m.addfrom += i
  11324. } else {
  11325. m.addfrom = &i
  11326. }
  11327. }
  11328. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11329. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11330. v := m.addfrom
  11331. if v == nil {
  11332. return
  11333. }
  11334. return *v, true
  11335. }
  11336. // ResetFrom resets all changes to the "from" field.
  11337. func (m *LabelMutation) ResetFrom() {
  11338. m.from = nil
  11339. m.addfrom = nil
  11340. }
  11341. // SetMode sets the "mode" field.
  11342. func (m *LabelMutation) SetMode(i int) {
  11343. m.mode = &i
  11344. m.addmode = nil
  11345. }
  11346. // Mode returns the value of the "mode" field in the mutation.
  11347. func (m *LabelMutation) Mode() (r int, exists bool) {
  11348. v := m.mode
  11349. if v == nil {
  11350. return
  11351. }
  11352. return *v, true
  11353. }
  11354. // OldMode returns the old "mode" field's value of the Label entity.
  11355. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11357. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11358. if !m.op.Is(OpUpdateOne) {
  11359. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11360. }
  11361. if m.id == nil || m.oldValue == nil {
  11362. return v, errors.New("OldMode requires an ID field in the mutation")
  11363. }
  11364. oldValue, err := m.oldValue(ctx)
  11365. if err != nil {
  11366. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11367. }
  11368. return oldValue.Mode, nil
  11369. }
  11370. // AddMode adds i to the "mode" field.
  11371. func (m *LabelMutation) AddMode(i int) {
  11372. if m.addmode != nil {
  11373. *m.addmode += i
  11374. } else {
  11375. m.addmode = &i
  11376. }
  11377. }
  11378. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11379. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11380. v := m.addmode
  11381. if v == nil {
  11382. return
  11383. }
  11384. return *v, true
  11385. }
  11386. // ResetMode resets all changes to the "mode" field.
  11387. func (m *LabelMutation) ResetMode() {
  11388. m.mode = nil
  11389. m.addmode = nil
  11390. }
  11391. // SetConditions sets the "conditions" field.
  11392. func (m *LabelMutation) SetConditions(s string) {
  11393. m.conditions = &s
  11394. }
  11395. // Conditions returns the value of the "conditions" field in the mutation.
  11396. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11397. v := m.conditions
  11398. if v == nil {
  11399. return
  11400. }
  11401. return *v, true
  11402. }
  11403. // OldConditions returns the old "conditions" field's value of the Label entity.
  11404. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11406. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11407. if !m.op.Is(OpUpdateOne) {
  11408. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11409. }
  11410. if m.id == nil || m.oldValue == nil {
  11411. return v, errors.New("OldConditions requires an ID field in the mutation")
  11412. }
  11413. oldValue, err := m.oldValue(ctx)
  11414. if err != nil {
  11415. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11416. }
  11417. return oldValue.Conditions, nil
  11418. }
  11419. // ClearConditions clears the value of the "conditions" field.
  11420. func (m *LabelMutation) ClearConditions() {
  11421. m.conditions = nil
  11422. m.clearedFields[label.FieldConditions] = struct{}{}
  11423. }
  11424. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11425. func (m *LabelMutation) ConditionsCleared() bool {
  11426. _, ok := m.clearedFields[label.FieldConditions]
  11427. return ok
  11428. }
  11429. // ResetConditions resets all changes to the "conditions" field.
  11430. func (m *LabelMutation) ResetConditions() {
  11431. m.conditions = nil
  11432. delete(m.clearedFields, label.FieldConditions)
  11433. }
  11434. // SetOrganizationID sets the "organization_id" field.
  11435. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11436. m.organization_id = &u
  11437. m.addorganization_id = nil
  11438. }
  11439. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11440. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11441. v := m.organization_id
  11442. if v == nil {
  11443. return
  11444. }
  11445. return *v, true
  11446. }
  11447. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11448. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11450. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11451. if !m.op.Is(OpUpdateOne) {
  11452. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11453. }
  11454. if m.id == nil || m.oldValue == nil {
  11455. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11456. }
  11457. oldValue, err := m.oldValue(ctx)
  11458. if err != nil {
  11459. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11460. }
  11461. return oldValue.OrganizationID, nil
  11462. }
  11463. // AddOrganizationID adds u to the "organization_id" field.
  11464. func (m *LabelMutation) AddOrganizationID(u int64) {
  11465. if m.addorganization_id != nil {
  11466. *m.addorganization_id += u
  11467. } else {
  11468. m.addorganization_id = &u
  11469. }
  11470. }
  11471. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11472. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11473. v := m.addorganization_id
  11474. if v == nil {
  11475. return
  11476. }
  11477. return *v, true
  11478. }
  11479. // ClearOrganizationID clears the value of the "organization_id" field.
  11480. func (m *LabelMutation) ClearOrganizationID() {
  11481. m.organization_id = nil
  11482. m.addorganization_id = nil
  11483. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11484. }
  11485. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11486. func (m *LabelMutation) OrganizationIDCleared() bool {
  11487. _, ok := m.clearedFields[label.FieldOrganizationID]
  11488. return ok
  11489. }
  11490. // ResetOrganizationID resets all changes to the "organization_id" field.
  11491. func (m *LabelMutation) ResetOrganizationID() {
  11492. m.organization_id = nil
  11493. m.addorganization_id = nil
  11494. delete(m.clearedFields, label.FieldOrganizationID)
  11495. }
  11496. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11497. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11498. if m.label_relationships == nil {
  11499. m.label_relationships = make(map[uint64]struct{})
  11500. }
  11501. for i := range ids {
  11502. m.label_relationships[ids[i]] = struct{}{}
  11503. }
  11504. }
  11505. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11506. func (m *LabelMutation) ClearLabelRelationships() {
  11507. m.clearedlabel_relationships = true
  11508. }
  11509. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11510. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11511. return m.clearedlabel_relationships
  11512. }
  11513. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11514. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11515. if m.removedlabel_relationships == nil {
  11516. m.removedlabel_relationships = make(map[uint64]struct{})
  11517. }
  11518. for i := range ids {
  11519. delete(m.label_relationships, ids[i])
  11520. m.removedlabel_relationships[ids[i]] = struct{}{}
  11521. }
  11522. }
  11523. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11524. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11525. for id := range m.removedlabel_relationships {
  11526. ids = append(ids, id)
  11527. }
  11528. return
  11529. }
  11530. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11531. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11532. for id := range m.label_relationships {
  11533. ids = append(ids, id)
  11534. }
  11535. return
  11536. }
  11537. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11538. func (m *LabelMutation) ResetLabelRelationships() {
  11539. m.label_relationships = nil
  11540. m.clearedlabel_relationships = false
  11541. m.removedlabel_relationships = nil
  11542. }
  11543. // Where appends a list predicates to the LabelMutation builder.
  11544. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11545. m.predicates = append(m.predicates, ps...)
  11546. }
  11547. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11548. // users can use type-assertion to append predicates that do not depend on any generated package.
  11549. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11550. p := make([]predicate.Label, len(ps))
  11551. for i := range ps {
  11552. p[i] = ps[i]
  11553. }
  11554. m.Where(p...)
  11555. }
  11556. // Op returns the operation name.
  11557. func (m *LabelMutation) Op() Op {
  11558. return m.op
  11559. }
  11560. // SetOp allows setting the mutation operation.
  11561. func (m *LabelMutation) SetOp(op Op) {
  11562. m.op = op
  11563. }
  11564. // Type returns the node type of this mutation (Label).
  11565. func (m *LabelMutation) Type() string {
  11566. return m.typ
  11567. }
  11568. // Fields returns all fields that were changed during this mutation. Note that in
  11569. // order to get all numeric fields that were incremented/decremented, call
  11570. // AddedFields().
  11571. func (m *LabelMutation) Fields() []string {
  11572. fields := make([]string, 0, 9)
  11573. if m.created_at != nil {
  11574. fields = append(fields, label.FieldCreatedAt)
  11575. }
  11576. if m.updated_at != nil {
  11577. fields = append(fields, label.FieldUpdatedAt)
  11578. }
  11579. if m.status != nil {
  11580. fields = append(fields, label.FieldStatus)
  11581. }
  11582. if m._type != nil {
  11583. fields = append(fields, label.FieldType)
  11584. }
  11585. if m.name != nil {
  11586. fields = append(fields, label.FieldName)
  11587. }
  11588. if m.from != nil {
  11589. fields = append(fields, label.FieldFrom)
  11590. }
  11591. if m.mode != nil {
  11592. fields = append(fields, label.FieldMode)
  11593. }
  11594. if m.conditions != nil {
  11595. fields = append(fields, label.FieldConditions)
  11596. }
  11597. if m.organization_id != nil {
  11598. fields = append(fields, label.FieldOrganizationID)
  11599. }
  11600. return fields
  11601. }
  11602. // Field returns the value of a field with the given name. The second boolean
  11603. // return value indicates that this field was not set, or was not defined in the
  11604. // schema.
  11605. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11606. switch name {
  11607. case label.FieldCreatedAt:
  11608. return m.CreatedAt()
  11609. case label.FieldUpdatedAt:
  11610. return m.UpdatedAt()
  11611. case label.FieldStatus:
  11612. return m.Status()
  11613. case label.FieldType:
  11614. return m.GetType()
  11615. case label.FieldName:
  11616. return m.Name()
  11617. case label.FieldFrom:
  11618. return m.From()
  11619. case label.FieldMode:
  11620. return m.Mode()
  11621. case label.FieldConditions:
  11622. return m.Conditions()
  11623. case label.FieldOrganizationID:
  11624. return m.OrganizationID()
  11625. }
  11626. return nil, false
  11627. }
  11628. // OldField returns the old value of the field from the database. An error is
  11629. // returned if the mutation operation is not UpdateOne, or the query to the
  11630. // database failed.
  11631. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11632. switch name {
  11633. case label.FieldCreatedAt:
  11634. return m.OldCreatedAt(ctx)
  11635. case label.FieldUpdatedAt:
  11636. return m.OldUpdatedAt(ctx)
  11637. case label.FieldStatus:
  11638. return m.OldStatus(ctx)
  11639. case label.FieldType:
  11640. return m.OldType(ctx)
  11641. case label.FieldName:
  11642. return m.OldName(ctx)
  11643. case label.FieldFrom:
  11644. return m.OldFrom(ctx)
  11645. case label.FieldMode:
  11646. return m.OldMode(ctx)
  11647. case label.FieldConditions:
  11648. return m.OldConditions(ctx)
  11649. case label.FieldOrganizationID:
  11650. return m.OldOrganizationID(ctx)
  11651. }
  11652. return nil, fmt.Errorf("unknown Label field %s", name)
  11653. }
  11654. // SetField sets the value of a field with the given name. It returns an error if
  11655. // the field is not defined in the schema, or if the type mismatched the field
  11656. // type.
  11657. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11658. switch name {
  11659. case label.FieldCreatedAt:
  11660. v, ok := value.(time.Time)
  11661. if !ok {
  11662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11663. }
  11664. m.SetCreatedAt(v)
  11665. return nil
  11666. case label.FieldUpdatedAt:
  11667. v, ok := value.(time.Time)
  11668. if !ok {
  11669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11670. }
  11671. m.SetUpdatedAt(v)
  11672. return nil
  11673. case label.FieldStatus:
  11674. v, ok := value.(uint8)
  11675. if !ok {
  11676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11677. }
  11678. m.SetStatus(v)
  11679. return nil
  11680. case label.FieldType:
  11681. v, ok := value.(int)
  11682. if !ok {
  11683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11684. }
  11685. m.SetType(v)
  11686. return nil
  11687. case label.FieldName:
  11688. v, ok := value.(string)
  11689. if !ok {
  11690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11691. }
  11692. m.SetName(v)
  11693. return nil
  11694. case label.FieldFrom:
  11695. v, ok := value.(int)
  11696. if !ok {
  11697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11698. }
  11699. m.SetFrom(v)
  11700. return nil
  11701. case label.FieldMode:
  11702. v, ok := value.(int)
  11703. if !ok {
  11704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11705. }
  11706. m.SetMode(v)
  11707. return nil
  11708. case label.FieldConditions:
  11709. v, ok := value.(string)
  11710. if !ok {
  11711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11712. }
  11713. m.SetConditions(v)
  11714. return nil
  11715. case label.FieldOrganizationID:
  11716. v, ok := value.(uint64)
  11717. if !ok {
  11718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11719. }
  11720. m.SetOrganizationID(v)
  11721. return nil
  11722. }
  11723. return fmt.Errorf("unknown Label field %s", name)
  11724. }
  11725. // AddedFields returns all numeric fields that were incremented/decremented during
  11726. // this mutation.
  11727. func (m *LabelMutation) AddedFields() []string {
  11728. var fields []string
  11729. if m.addstatus != nil {
  11730. fields = append(fields, label.FieldStatus)
  11731. }
  11732. if m.add_type != nil {
  11733. fields = append(fields, label.FieldType)
  11734. }
  11735. if m.addfrom != nil {
  11736. fields = append(fields, label.FieldFrom)
  11737. }
  11738. if m.addmode != nil {
  11739. fields = append(fields, label.FieldMode)
  11740. }
  11741. if m.addorganization_id != nil {
  11742. fields = append(fields, label.FieldOrganizationID)
  11743. }
  11744. return fields
  11745. }
  11746. // AddedField returns the numeric value that was incremented/decremented on a field
  11747. // with the given name. The second boolean return value indicates that this field
  11748. // was not set, or was not defined in the schema.
  11749. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11750. switch name {
  11751. case label.FieldStatus:
  11752. return m.AddedStatus()
  11753. case label.FieldType:
  11754. return m.AddedType()
  11755. case label.FieldFrom:
  11756. return m.AddedFrom()
  11757. case label.FieldMode:
  11758. return m.AddedMode()
  11759. case label.FieldOrganizationID:
  11760. return m.AddedOrganizationID()
  11761. }
  11762. return nil, false
  11763. }
  11764. // AddField adds the value to the field with the given name. It returns an error if
  11765. // the field is not defined in the schema, or if the type mismatched the field
  11766. // type.
  11767. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11768. switch name {
  11769. case label.FieldStatus:
  11770. v, ok := value.(int8)
  11771. if !ok {
  11772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11773. }
  11774. m.AddStatus(v)
  11775. return nil
  11776. case label.FieldType:
  11777. v, ok := value.(int)
  11778. if !ok {
  11779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11780. }
  11781. m.AddType(v)
  11782. return nil
  11783. case label.FieldFrom:
  11784. v, ok := value.(int)
  11785. if !ok {
  11786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11787. }
  11788. m.AddFrom(v)
  11789. return nil
  11790. case label.FieldMode:
  11791. v, ok := value.(int)
  11792. if !ok {
  11793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11794. }
  11795. m.AddMode(v)
  11796. return nil
  11797. case label.FieldOrganizationID:
  11798. v, ok := value.(int64)
  11799. if !ok {
  11800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11801. }
  11802. m.AddOrganizationID(v)
  11803. return nil
  11804. }
  11805. return fmt.Errorf("unknown Label numeric field %s", name)
  11806. }
  11807. // ClearedFields returns all nullable fields that were cleared during this
  11808. // mutation.
  11809. func (m *LabelMutation) ClearedFields() []string {
  11810. var fields []string
  11811. if m.FieldCleared(label.FieldStatus) {
  11812. fields = append(fields, label.FieldStatus)
  11813. }
  11814. if m.FieldCleared(label.FieldConditions) {
  11815. fields = append(fields, label.FieldConditions)
  11816. }
  11817. if m.FieldCleared(label.FieldOrganizationID) {
  11818. fields = append(fields, label.FieldOrganizationID)
  11819. }
  11820. return fields
  11821. }
  11822. // FieldCleared returns a boolean indicating if a field with the given name was
  11823. // cleared in this mutation.
  11824. func (m *LabelMutation) FieldCleared(name string) bool {
  11825. _, ok := m.clearedFields[name]
  11826. return ok
  11827. }
  11828. // ClearField clears the value of the field with the given name. It returns an
  11829. // error if the field is not defined in the schema.
  11830. func (m *LabelMutation) ClearField(name string) error {
  11831. switch name {
  11832. case label.FieldStatus:
  11833. m.ClearStatus()
  11834. return nil
  11835. case label.FieldConditions:
  11836. m.ClearConditions()
  11837. return nil
  11838. case label.FieldOrganizationID:
  11839. m.ClearOrganizationID()
  11840. return nil
  11841. }
  11842. return fmt.Errorf("unknown Label nullable field %s", name)
  11843. }
  11844. // ResetField resets all changes in the mutation for the field with the given name.
  11845. // It returns an error if the field is not defined in the schema.
  11846. func (m *LabelMutation) ResetField(name string) error {
  11847. switch name {
  11848. case label.FieldCreatedAt:
  11849. m.ResetCreatedAt()
  11850. return nil
  11851. case label.FieldUpdatedAt:
  11852. m.ResetUpdatedAt()
  11853. return nil
  11854. case label.FieldStatus:
  11855. m.ResetStatus()
  11856. return nil
  11857. case label.FieldType:
  11858. m.ResetType()
  11859. return nil
  11860. case label.FieldName:
  11861. m.ResetName()
  11862. return nil
  11863. case label.FieldFrom:
  11864. m.ResetFrom()
  11865. return nil
  11866. case label.FieldMode:
  11867. m.ResetMode()
  11868. return nil
  11869. case label.FieldConditions:
  11870. m.ResetConditions()
  11871. return nil
  11872. case label.FieldOrganizationID:
  11873. m.ResetOrganizationID()
  11874. return nil
  11875. }
  11876. return fmt.Errorf("unknown Label field %s", name)
  11877. }
  11878. // AddedEdges returns all edge names that were set/added in this mutation.
  11879. func (m *LabelMutation) AddedEdges() []string {
  11880. edges := make([]string, 0, 1)
  11881. if m.label_relationships != nil {
  11882. edges = append(edges, label.EdgeLabelRelationships)
  11883. }
  11884. return edges
  11885. }
  11886. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11887. // name in this mutation.
  11888. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11889. switch name {
  11890. case label.EdgeLabelRelationships:
  11891. ids := make([]ent.Value, 0, len(m.label_relationships))
  11892. for id := range m.label_relationships {
  11893. ids = append(ids, id)
  11894. }
  11895. return ids
  11896. }
  11897. return nil
  11898. }
  11899. // RemovedEdges returns all edge names that were removed in this mutation.
  11900. func (m *LabelMutation) RemovedEdges() []string {
  11901. edges := make([]string, 0, 1)
  11902. if m.removedlabel_relationships != nil {
  11903. edges = append(edges, label.EdgeLabelRelationships)
  11904. }
  11905. return edges
  11906. }
  11907. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11908. // the given name in this mutation.
  11909. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11910. switch name {
  11911. case label.EdgeLabelRelationships:
  11912. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11913. for id := range m.removedlabel_relationships {
  11914. ids = append(ids, id)
  11915. }
  11916. return ids
  11917. }
  11918. return nil
  11919. }
  11920. // ClearedEdges returns all edge names that were cleared in this mutation.
  11921. func (m *LabelMutation) ClearedEdges() []string {
  11922. edges := make([]string, 0, 1)
  11923. if m.clearedlabel_relationships {
  11924. edges = append(edges, label.EdgeLabelRelationships)
  11925. }
  11926. return edges
  11927. }
  11928. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11929. // was cleared in this mutation.
  11930. func (m *LabelMutation) EdgeCleared(name string) bool {
  11931. switch name {
  11932. case label.EdgeLabelRelationships:
  11933. return m.clearedlabel_relationships
  11934. }
  11935. return false
  11936. }
  11937. // ClearEdge clears the value of the edge with the given name. It returns an error
  11938. // if that edge is not defined in the schema.
  11939. func (m *LabelMutation) ClearEdge(name string) error {
  11940. switch name {
  11941. }
  11942. return fmt.Errorf("unknown Label unique edge %s", name)
  11943. }
  11944. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11945. // It returns an error if the edge is not defined in the schema.
  11946. func (m *LabelMutation) ResetEdge(name string) error {
  11947. switch name {
  11948. case label.EdgeLabelRelationships:
  11949. m.ResetLabelRelationships()
  11950. return nil
  11951. }
  11952. return fmt.Errorf("unknown Label edge %s", name)
  11953. }
  11954. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11955. type LabelRelationshipMutation struct {
  11956. config
  11957. op Op
  11958. typ string
  11959. id *uint64
  11960. created_at *time.Time
  11961. updated_at *time.Time
  11962. status *uint8
  11963. addstatus *int8
  11964. deleted_at *time.Time
  11965. organization_id *uint64
  11966. addorganization_id *int64
  11967. clearedFields map[string]struct{}
  11968. contacts *uint64
  11969. clearedcontacts bool
  11970. labels *uint64
  11971. clearedlabels bool
  11972. done bool
  11973. oldValue func(context.Context) (*LabelRelationship, error)
  11974. predicates []predicate.LabelRelationship
  11975. }
  11976. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11977. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11978. type labelrelationshipOption func(*LabelRelationshipMutation)
  11979. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11980. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11981. m := &LabelRelationshipMutation{
  11982. config: c,
  11983. op: op,
  11984. typ: TypeLabelRelationship,
  11985. clearedFields: make(map[string]struct{}),
  11986. }
  11987. for _, opt := range opts {
  11988. opt(m)
  11989. }
  11990. return m
  11991. }
  11992. // withLabelRelationshipID sets the ID field of the mutation.
  11993. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11994. return func(m *LabelRelationshipMutation) {
  11995. var (
  11996. err error
  11997. once sync.Once
  11998. value *LabelRelationship
  11999. )
  12000. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  12001. once.Do(func() {
  12002. if m.done {
  12003. err = errors.New("querying old values post mutation is not allowed")
  12004. } else {
  12005. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12006. }
  12007. })
  12008. return value, err
  12009. }
  12010. m.id = &id
  12011. }
  12012. }
  12013. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12014. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12015. return func(m *LabelRelationshipMutation) {
  12016. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12017. return node, nil
  12018. }
  12019. m.id = &node.ID
  12020. }
  12021. }
  12022. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12023. // executed in a transaction (ent.Tx), a transactional client is returned.
  12024. func (m LabelRelationshipMutation) Client() *Client {
  12025. client := &Client{config: m.config}
  12026. client.init()
  12027. return client
  12028. }
  12029. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12030. // it returns an error otherwise.
  12031. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12032. if _, ok := m.driver.(*txDriver); !ok {
  12033. return nil, errors.New("ent: mutation is not running in a transaction")
  12034. }
  12035. tx := &Tx{config: m.config}
  12036. tx.init()
  12037. return tx, nil
  12038. }
  12039. // SetID sets the value of the id field. Note that this
  12040. // operation is only accepted on creation of LabelRelationship entities.
  12041. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12042. m.id = &id
  12043. }
  12044. // ID returns the ID value in the mutation. Note that the ID is only available
  12045. // if it was provided to the builder or after it was returned from the database.
  12046. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12047. if m.id == nil {
  12048. return
  12049. }
  12050. return *m.id, true
  12051. }
  12052. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12053. // That means, if the mutation is applied within a transaction with an isolation level such
  12054. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12055. // or updated by the mutation.
  12056. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12057. switch {
  12058. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12059. id, exists := m.ID()
  12060. if exists {
  12061. return []uint64{id}, nil
  12062. }
  12063. fallthrough
  12064. case m.op.Is(OpUpdate | OpDelete):
  12065. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12066. default:
  12067. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12068. }
  12069. }
  12070. // SetCreatedAt sets the "created_at" field.
  12071. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12072. m.created_at = &t
  12073. }
  12074. // CreatedAt returns the value of the "created_at" field in the mutation.
  12075. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12076. v := m.created_at
  12077. if v == nil {
  12078. return
  12079. }
  12080. return *v, true
  12081. }
  12082. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12083. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12085. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12086. if !m.op.Is(OpUpdateOne) {
  12087. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12088. }
  12089. if m.id == nil || m.oldValue == nil {
  12090. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12091. }
  12092. oldValue, err := m.oldValue(ctx)
  12093. if err != nil {
  12094. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12095. }
  12096. return oldValue.CreatedAt, nil
  12097. }
  12098. // ResetCreatedAt resets all changes to the "created_at" field.
  12099. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12100. m.created_at = nil
  12101. }
  12102. // SetUpdatedAt sets the "updated_at" field.
  12103. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12104. m.updated_at = &t
  12105. }
  12106. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12107. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12108. v := m.updated_at
  12109. if v == nil {
  12110. return
  12111. }
  12112. return *v, true
  12113. }
  12114. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12115. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12117. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12118. if !m.op.Is(OpUpdateOne) {
  12119. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12120. }
  12121. if m.id == nil || m.oldValue == nil {
  12122. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12123. }
  12124. oldValue, err := m.oldValue(ctx)
  12125. if err != nil {
  12126. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12127. }
  12128. return oldValue.UpdatedAt, nil
  12129. }
  12130. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12131. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12132. m.updated_at = nil
  12133. }
  12134. // SetStatus sets the "status" field.
  12135. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12136. m.status = &u
  12137. m.addstatus = nil
  12138. }
  12139. // Status returns the value of the "status" field in the mutation.
  12140. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12141. v := m.status
  12142. if v == nil {
  12143. return
  12144. }
  12145. return *v, true
  12146. }
  12147. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12148. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12150. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12151. if !m.op.Is(OpUpdateOne) {
  12152. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12153. }
  12154. if m.id == nil || m.oldValue == nil {
  12155. return v, errors.New("OldStatus requires an ID field in the mutation")
  12156. }
  12157. oldValue, err := m.oldValue(ctx)
  12158. if err != nil {
  12159. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12160. }
  12161. return oldValue.Status, nil
  12162. }
  12163. // AddStatus adds u to the "status" field.
  12164. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12165. if m.addstatus != nil {
  12166. *m.addstatus += u
  12167. } else {
  12168. m.addstatus = &u
  12169. }
  12170. }
  12171. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12172. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12173. v := m.addstatus
  12174. if v == nil {
  12175. return
  12176. }
  12177. return *v, true
  12178. }
  12179. // ClearStatus clears the value of the "status" field.
  12180. func (m *LabelRelationshipMutation) ClearStatus() {
  12181. m.status = nil
  12182. m.addstatus = nil
  12183. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12184. }
  12185. // StatusCleared returns if the "status" field was cleared in this mutation.
  12186. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12187. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12188. return ok
  12189. }
  12190. // ResetStatus resets all changes to the "status" field.
  12191. func (m *LabelRelationshipMutation) ResetStatus() {
  12192. m.status = nil
  12193. m.addstatus = nil
  12194. delete(m.clearedFields, labelrelationship.FieldStatus)
  12195. }
  12196. // SetDeletedAt sets the "deleted_at" field.
  12197. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12198. m.deleted_at = &t
  12199. }
  12200. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12201. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12202. v := m.deleted_at
  12203. if v == nil {
  12204. return
  12205. }
  12206. return *v, true
  12207. }
  12208. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12209. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12211. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12212. if !m.op.Is(OpUpdateOne) {
  12213. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12214. }
  12215. if m.id == nil || m.oldValue == nil {
  12216. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12217. }
  12218. oldValue, err := m.oldValue(ctx)
  12219. if err != nil {
  12220. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12221. }
  12222. return oldValue.DeletedAt, nil
  12223. }
  12224. // ClearDeletedAt clears the value of the "deleted_at" field.
  12225. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12226. m.deleted_at = nil
  12227. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12228. }
  12229. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12230. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12231. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12232. return ok
  12233. }
  12234. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12235. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12236. m.deleted_at = nil
  12237. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12238. }
  12239. // SetLabelID sets the "label_id" field.
  12240. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12241. m.labels = &u
  12242. }
  12243. // LabelID returns the value of the "label_id" field in the mutation.
  12244. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12245. v := m.labels
  12246. if v == nil {
  12247. return
  12248. }
  12249. return *v, true
  12250. }
  12251. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12252. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12254. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12255. if !m.op.Is(OpUpdateOne) {
  12256. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12257. }
  12258. if m.id == nil || m.oldValue == nil {
  12259. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12260. }
  12261. oldValue, err := m.oldValue(ctx)
  12262. if err != nil {
  12263. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12264. }
  12265. return oldValue.LabelID, nil
  12266. }
  12267. // ResetLabelID resets all changes to the "label_id" field.
  12268. func (m *LabelRelationshipMutation) ResetLabelID() {
  12269. m.labels = nil
  12270. }
  12271. // SetContactID sets the "contact_id" field.
  12272. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12273. m.contacts = &u
  12274. }
  12275. // ContactID returns the value of the "contact_id" field in the mutation.
  12276. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12277. v := m.contacts
  12278. if v == nil {
  12279. return
  12280. }
  12281. return *v, true
  12282. }
  12283. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12284. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12286. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12287. if !m.op.Is(OpUpdateOne) {
  12288. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12289. }
  12290. if m.id == nil || m.oldValue == nil {
  12291. return v, errors.New("OldContactID requires an ID field in the mutation")
  12292. }
  12293. oldValue, err := m.oldValue(ctx)
  12294. if err != nil {
  12295. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12296. }
  12297. return oldValue.ContactID, nil
  12298. }
  12299. // ResetContactID resets all changes to the "contact_id" field.
  12300. func (m *LabelRelationshipMutation) ResetContactID() {
  12301. m.contacts = nil
  12302. }
  12303. // SetOrganizationID sets the "organization_id" field.
  12304. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12305. m.organization_id = &u
  12306. m.addorganization_id = nil
  12307. }
  12308. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12309. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12310. v := m.organization_id
  12311. if v == nil {
  12312. return
  12313. }
  12314. return *v, true
  12315. }
  12316. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12317. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12319. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12320. if !m.op.Is(OpUpdateOne) {
  12321. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12322. }
  12323. if m.id == nil || m.oldValue == nil {
  12324. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12325. }
  12326. oldValue, err := m.oldValue(ctx)
  12327. if err != nil {
  12328. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12329. }
  12330. return oldValue.OrganizationID, nil
  12331. }
  12332. // AddOrganizationID adds u to the "organization_id" field.
  12333. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12334. if m.addorganization_id != nil {
  12335. *m.addorganization_id += u
  12336. } else {
  12337. m.addorganization_id = &u
  12338. }
  12339. }
  12340. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12341. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12342. v := m.addorganization_id
  12343. if v == nil {
  12344. return
  12345. }
  12346. return *v, true
  12347. }
  12348. // ClearOrganizationID clears the value of the "organization_id" field.
  12349. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12350. m.organization_id = nil
  12351. m.addorganization_id = nil
  12352. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12353. }
  12354. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12355. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12356. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12357. return ok
  12358. }
  12359. // ResetOrganizationID resets all changes to the "organization_id" field.
  12360. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12361. m.organization_id = nil
  12362. m.addorganization_id = nil
  12363. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12364. }
  12365. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12366. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12367. m.contacts = &id
  12368. }
  12369. // ClearContacts clears the "contacts" edge to the Contact entity.
  12370. func (m *LabelRelationshipMutation) ClearContacts() {
  12371. m.clearedcontacts = true
  12372. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12373. }
  12374. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12375. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12376. return m.clearedcontacts
  12377. }
  12378. // ContactsID returns the "contacts" edge ID in the mutation.
  12379. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12380. if m.contacts != nil {
  12381. return *m.contacts, true
  12382. }
  12383. return
  12384. }
  12385. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12386. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12387. // ContactsID instead. It exists only for internal usage by the builders.
  12388. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12389. if id := m.contacts; id != nil {
  12390. ids = append(ids, *id)
  12391. }
  12392. return
  12393. }
  12394. // ResetContacts resets all changes to the "contacts" edge.
  12395. func (m *LabelRelationshipMutation) ResetContacts() {
  12396. m.contacts = nil
  12397. m.clearedcontacts = false
  12398. }
  12399. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12400. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12401. m.labels = &id
  12402. }
  12403. // ClearLabels clears the "labels" edge to the Label entity.
  12404. func (m *LabelRelationshipMutation) ClearLabels() {
  12405. m.clearedlabels = true
  12406. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12407. }
  12408. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12409. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12410. return m.clearedlabels
  12411. }
  12412. // LabelsID returns the "labels" edge ID in the mutation.
  12413. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12414. if m.labels != nil {
  12415. return *m.labels, true
  12416. }
  12417. return
  12418. }
  12419. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12420. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12421. // LabelsID instead. It exists only for internal usage by the builders.
  12422. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12423. if id := m.labels; id != nil {
  12424. ids = append(ids, *id)
  12425. }
  12426. return
  12427. }
  12428. // ResetLabels resets all changes to the "labels" edge.
  12429. func (m *LabelRelationshipMutation) ResetLabels() {
  12430. m.labels = nil
  12431. m.clearedlabels = false
  12432. }
  12433. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12434. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12435. m.predicates = append(m.predicates, ps...)
  12436. }
  12437. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12438. // users can use type-assertion to append predicates that do not depend on any generated package.
  12439. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12440. p := make([]predicate.LabelRelationship, len(ps))
  12441. for i := range ps {
  12442. p[i] = ps[i]
  12443. }
  12444. m.Where(p...)
  12445. }
  12446. // Op returns the operation name.
  12447. func (m *LabelRelationshipMutation) Op() Op {
  12448. return m.op
  12449. }
  12450. // SetOp allows setting the mutation operation.
  12451. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12452. m.op = op
  12453. }
  12454. // Type returns the node type of this mutation (LabelRelationship).
  12455. func (m *LabelRelationshipMutation) Type() string {
  12456. return m.typ
  12457. }
  12458. // Fields returns all fields that were changed during this mutation. Note that in
  12459. // order to get all numeric fields that were incremented/decremented, call
  12460. // AddedFields().
  12461. func (m *LabelRelationshipMutation) Fields() []string {
  12462. fields := make([]string, 0, 7)
  12463. if m.created_at != nil {
  12464. fields = append(fields, labelrelationship.FieldCreatedAt)
  12465. }
  12466. if m.updated_at != nil {
  12467. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12468. }
  12469. if m.status != nil {
  12470. fields = append(fields, labelrelationship.FieldStatus)
  12471. }
  12472. if m.deleted_at != nil {
  12473. fields = append(fields, labelrelationship.FieldDeletedAt)
  12474. }
  12475. if m.labels != nil {
  12476. fields = append(fields, labelrelationship.FieldLabelID)
  12477. }
  12478. if m.contacts != nil {
  12479. fields = append(fields, labelrelationship.FieldContactID)
  12480. }
  12481. if m.organization_id != nil {
  12482. fields = append(fields, labelrelationship.FieldOrganizationID)
  12483. }
  12484. return fields
  12485. }
  12486. // Field returns the value of a field with the given name. The second boolean
  12487. // return value indicates that this field was not set, or was not defined in the
  12488. // schema.
  12489. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12490. switch name {
  12491. case labelrelationship.FieldCreatedAt:
  12492. return m.CreatedAt()
  12493. case labelrelationship.FieldUpdatedAt:
  12494. return m.UpdatedAt()
  12495. case labelrelationship.FieldStatus:
  12496. return m.Status()
  12497. case labelrelationship.FieldDeletedAt:
  12498. return m.DeletedAt()
  12499. case labelrelationship.FieldLabelID:
  12500. return m.LabelID()
  12501. case labelrelationship.FieldContactID:
  12502. return m.ContactID()
  12503. case labelrelationship.FieldOrganizationID:
  12504. return m.OrganizationID()
  12505. }
  12506. return nil, false
  12507. }
  12508. // OldField returns the old value of the field from the database. An error is
  12509. // returned if the mutation operation is not UpdateOne, or the query to the
  12510. // database failed.
  12511. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12512. switch name {
  12513. case labelrelationship.FieldCreatedAt:
  12514. return m.OldCreatedAt(ctx)
  12515. case labelrelationship.FieldUpdatedAt:
  12516. return m.OldUpdatedAt(ctx)
  12517. case labelrelationship.FieldStatus:
  12518. return m.OldStatus(ctx)
  12519. case labelrelationship.FieldDeletedAt:
  12520. return m.OldDeletedAt(ctx)
  12521. case labelrelationship.FieldLabelID:
  12522. return m.OldLabelID(ctx)
  12523. case labelrelationship.FieldContactID:
  12524. return m.OldContactID(ctx)
  12525. case labelrelationship.FieldOrganizationID:
  12526. return m.OldOrganizationID(ctx)
  12527. }
  12528. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12529. }
  12530. // SetField sets the value of a field with the given name. It returns an error if
  12531. // the field is not defined in the schema, or if the type mismatched the field
  12532. // type.
  12533. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12534. switch name {
  12535. case labelrelationship.FieldCreatedAt:
  12536. v, ok := value.(time.Time)
  12537. if !ok {
  12538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12539. }
  12540. m.SetCreatedAt(v)
  12541. return nil
  12542. case labelrelationship.FieldUpdatedAt:
  12543. v, ok := value.(time.Time)
  12544. if !ok {
  12545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12546. }
  12547. m.SetUpdatedAt(v)
  12548. return nil
  12549. case labelrelationship.FieldStatus:
  12550. v, ok := value.(uint8)
  12551. if !ok {
  12552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12553. }
  12554. m.SetStatus(v)
  12555. return nil
  12556. case labelrelationship.FieldDeletedAt:
  12557. v, ok := value.(time.Time)
  12558. if !ok {
  12559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12560. }
  12561. m.SetDeletedAt(v)
  12562. return nil
  12563. case labelrelationship.FieldLabelID:
  12564. v, ok := value.(uint64)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.SetLabelID(v)
  12569. return nil
  12570. case labelrelationship.FieldContactID:
  12571. v, ok := value.(uint64)
  12572. if !ok {
  12573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12574. }
  12575. m.SetContactID(v)
  12576. return nil
  12577. case labelrelationship.FieldOrganizationID:
  12578. v, ok := value.(uint64)
  12579. if !ok {
  12580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12581. }
  12582. m.SetOrganizationID(v)
  12583. return nil
  12584. }
  12585. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12586. }
  12587. // AddedFields returns all numeric fields that were incremented/decremented during
  12588. // this mutation.
  12589. func (m *LabelRelationshipMutation) AddedFields() []string {
  12590. var fields []string
  12591. if m.addstatus != nil {
  12592. fields = append(fields, labelrelationship.FieldStatus)
  12593. }
  12594. if m.addorganization_id != nil {
  12595. fields = append(fields, labelrelationship.FieldOrganizationID)
  12596. }
  12597. return fields
  12598. }
  12599. // AddedField returns the numeric value that was incremented/decremented on a field
  12600. // with the given name. The second boolean return value indicates that this field
  12601. // was not set, or was not defined in the schema.
  12602. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12603. switch name {
  12604. case labelrelationship.FieldStatus:
  12605. return m.AddedStatus()
  12606. case labelrelationship.FieldOrganizationID:
  12607. return m.AddedOrganizationID()
  12608. }
  12609. return nil, false
  12610. }
  12611. // AddField adds the value to the field with the given name. It returns an error if
  12612. // the field is not defined in the schema, or if the type mismatched the field
  12613. // type.
  12614. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12615. switch name {
  12616. case labelrelationship.FieldStatus:
  12617. v, ok := value.(int8)
  12618. if !ok {
  12619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12620. }
  12621. m.AddStatus(v)
  12622. return nil
  12623. case labelrelationship.FieldOrganizationID:
  12624. v, ok := value.(int64)
  12625. if !ok {
  12626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12627. }
  12628. m.AddOrganizationID(v)
  12629. return nil
  12630. }
  12631. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12632. }
  12633. // ClearedFields returns all nullable fields that were cleared during this
  12634. // mutation.
  12635. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12636. var fields []string
  12637. if m.FieldCleared(labelrelationship.FieldStatus) {
  12638. fields = append(fields, labelrelationship.FieldStatus)
  12639. }
  12640. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12641. fields = append(fields, labelrelationship.FieldDeletedAt)
  12642. }
  12643. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12644. fields = append(fields, labelrelationship.FieldOrganizationID)
  12645. }
  12646. return fields
  12647. }
  12648. // FieldCleared returns a boolean indicating if a field with the given name was
  12649. // cleared in this mutation.
  12650. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12651. _, ok := m.clearedFields[name]
  12652. return ok
  12653. }
  12654. // ClearField clears the value of the field with the given name. It returns an
  12655. // error if the field is not defined in the schema.
  12656. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12657. switch name {
  12658. case labelrelationship.FieldStatus:
  12659. m.ClearStatus()
  12660. return nil
  12661. case labelrelationship.FieldDeletedAt:
  12662. m.ClearDeletedAt()
  12663. return nil
  12664. case labelrelationship.FieldOrganizationID:
  12665. m.ClearOrganizationID()
  12666. return nil
  12667. }
  12668. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12669. }
  12670. // ResetField resets all changes in the mutation for the field with the given name.
  12671. // It returns an error if the field is not defined in the schema.
  12672. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12673. switch name {
  12674. case labelrelationship.FieldCreatedAt:
  12675. m.ResetCreatedAt()
  12676. return nil
  12677. case labelrelationship.FieldUpdatedAt:
  12678. m.ResetUpdatedAt()
  12679. return nil
  12680. case labelrelationship.FieldStatus:
  12681. m.ResetStatus()
  12682. return nil
  12683. case labelrelationship.FieldDeletedAt:
  12684. m.ResetDeletedAt()
  12685. return nil
  12686. case labelrelationship.FieldLabelID:
  12687. m.ResetLabelID()
  12688. return nil
  12689. case labelrelationship.FieldContactID:
  12690. m.ResetContactID()
  12691. return nil
  12692. case labelrelationship.FieldOrganizationID:
  12693. m.ResetOrganizationID()
  12694. return nil
  12695. }
  12696. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12697. }
  12698. // AddedEdges returns all edge names that were set/added in this mutation.
  12699. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12700. edges := make([]string, 0, 2)
  12701. if m.contacts != nil {
  12702. edges = append(edges, labelrelationship.EdgeContacts)
  12703. }
  12704. if m.labels != nil {
  12705. edges = append(edges, labelrelationship.EdgeLabels)
  12706. }
  12707. return edges
  12708. }
  12709. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12710. // name in this mutation.
  12711. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12712. switch name {
  12713. case labelrelationship.EdgeContacts:
  12714. if id := m.contacts; id != nil {
  12715. return []ent.Value{*id}
  12716. }
  12717. case labelrelationship.EdgeLabels:
  12718. if id := m.labels; id != nil {
  12719. return []ent.Value{*id}
  12720. }
  12721. }
  12722. return nil
  12723. }
  12724. // RemovedEdges returns all edge names that were removed in this mutation.
  12725. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12726. edges := make([]string, 0, 2)
  12727. return edges
  12728. }
  12729. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12730. // the given name in this mutation.
  12731. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12732. return nil
  12733. }
  12734. // ClearedEdges returns all edge names that were cleared in this mutation.
  12735. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12736. edges := make([]string, 0, 2)
  12737. if m.clearedcontacts {
  12738. edges = append(edges, labelrelationship.EdgeContacts)
  12739. }
  12740. if m.clearedlabels {
  12741. edges = append(edges, labelrelationship.EdgeLabels)
  12742. }
  12743. return edges
  12744. }
  12745. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12746. // was cleared in this mutation.
  12747. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12748. switch name {
  12749. case labelrelationship.EdgeContacts:
  12750. return m.clearedcontacts
  12751. case labelrelationship.EdgeLabels:
  12752. return m.clearedlabels
  12753. }
  12754. return false
  12755. }
  12756. // ClearEdge clears the value of the edge with the given name. It returns an error
  12757. // if that edge is not defined in the schema.
  12758. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12759. switch name {
  12760. case labelrelationship.EdgeContacts:
  12761. m.ClearContacts()
  12762. return nil
  12763. case labelrelationship.EdgeLabels:
  12764. m.ClearLabels()
  12765. return nil
  12766. }
  12767. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12768. }
  12769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12770. // It returns an error if the edge is not defined in the schema.
  12771. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12772. switch name {
  12773. case labelrelationship.EdgeContacts:
  12774. m.ResetContacts()
  12775. return nil
  12776. case labelrelationship.EdgeLabels:
  12777. m.ResetLabels()
  12778. return nil
  12779. }
  12780. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12781. }
  12782. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  12783. type LabelTaggingMutation struct {
  12784. config
  12785. op Op
  12786. typ string
  12787. id *uint64
  12788. created_at *time.Time
  12789. updated_at *time.Time
  12790. status *uint8
  12791. addstatus *int8
  12792. deleted_at *time.Time
  12793. organization_id *uint64
  12794. addorganization_id *int64
  12795. _type *int
  12796. add_type *int
  12797. conditions *string
  12798. action_label_add *[]uint64
  12799. appendaction_label_add []uint64
  12800. action_label_del *[]uint64
  12801. appendaction_label_del []uint64
  12802. clearedFields map[string]struct{}
  12803. done bool
  12804. oldValue func(context.Context) (*LabelTagging, error)
  12805. predicates []predicate.LabelTagging
  12806. }
  12807. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  12808. // labeltaggingOption allows management of the mutation configuration using functional options.
  12809. type labeltaggingOption func(*LabelTaggingMutation)
  12810. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  12811. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  12812. m := &LabelTaggingMutation{
  12813. config: c,
  12814. op: op,
  12815. typ: TypeLabelTagging,
  12816. clearedFields: make(map[string]struct{}),
  12817. }
  12818. for _, opt := range opts {
  12819. opt(m)
  12820. }
  12821. return m
  12822. }
  12823. // withLabelTaggingID sets the ID field of the mutation.
  12824. func withLabelTaggingID(id uint64) labeltaggingOption {
  12825. return func(m *LabelTaggingMutation) {
  12826. var (
  12827. err error
  12828. once sync.Once
  12829. value *LabelTagging
  12830. )
  12831. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  12832. once.Do(func() {
  12833. if m.done {
  12834. err = errors.New("querying old values post mutation is not allowed")
  12835. } else {
  12836. value, err = m.Client().LabelTagging.Get(ctx, id)
  12837. }
  12838. })
  12839. return value, err
  12840. }
  12841. m.id = &id
  12842. }
  12843. }
  12844. // withLabelTagging sets the old LabelTagging of the mutation.
  12845. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  12846. return func(m *LabelTaggingMutation) {
  12847. m.oldValue = func(context.Context) (*LabelTagging, error) {
  12848. return node, nil
  12849. }
  12850. m.id = &node.ID
  12851. }
  12852. }
  12853. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12854. // executed in a transaction (ent.Tx), a transactional client is returned.
  12855. func (m LabelTaggingMutation) Client() *Client {
  12856. client := &Client{config: m.config}
  12857. client.init()
  12858. return client
  12859. }
  12860. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12861. // it returns an error otherwise.
  12862. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  12863. if _, ok := m.driver.(*txDriver); !ok {
  12864. return nil, errors.New("ent: mutation is not running in a transaction")
  12865. }
  12866. tx := &Tx{config: m.config}
  12867. tx.init()
  12868. return tx, nil
  12869. }
  12870. // SetID sets the value of the id field. Note that this
  12871. // operation is only accepted on creation of LabelTagging entities.
  12872. func (m *LabelTaggingMutation) SetID(id uint64) {
  12873. m.id = &id
  12874. }
  12875. // ID returns the ID value in the mutation. Note that the ID is only available
  12876. // if it was provided to the builder or after it was returned from the database.
  12877. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  12878. if m.id == nil {
  12879. return
  12880. }
  12881. return *m.id, true
  12882. }
  12883. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12884. // That means, if the mutation is applied within a transaction with an isolation level such
  12885. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12886. // or updated by the mutation.
  12887. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  12888. switch {
  12889. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12890. id, exists := m.ID()
  12891. if exists {
  12892. return []uint64{id}, nil
  12893. }
  12894. fallthrough
  12895. case m.op.Is(OpUpdate | OpDelete):
  12896. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  12897. default:
  12898. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12899. }
  12900. }
  12901. // SetCreatedAt sets the "created_at" field.
  12902. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  12903. m.created_at = &t
  12904. }
  12905. // CreatedAt returns the value of the "created_at" field in the mutation.
  12906. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  12907. v := m.created_at
  12908. if v == nil {
  12909. return
  12910. }
  12911. return *v, true
  12912. }
  12913. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  12914. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12916. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12917. if !m.op.Is(OpUpdateOne) {
  12918. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12919. }
  12920. if m.id == nil || m.oldValue == nil {
  12921. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12922. }
  12923. oldValue, err := m.oldValue(ctx)
  12924. if err != nil {
  12925. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12926. }
  12927. return oldValue.CreatedAt, nil
  12928. }
  12929. // ResetCreatedAt resets all changes to the "created_at" field.
  12930. func (m *LabelTaggingMutation) ResetCreatedAt() {
  12931. m.created_at = nil
  12932. }
  12933. // SetUpdatedAt sets the "updated_at" field.
  12934. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  12935. m.updated_at = &t
  12936. }
  12937. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12938. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  12939. v := m.updated_at
  12940. if v == nil {
  12941. return
  12942. }
  12943. return *v, true
  12944. }
  12945. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  12946. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12948. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12949. if !m.op.Is(OpUpdateOne) {
  12950. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12951. }
  12952. if m.id == nil || m.oldValue == nil {
  12953. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12954. }
  12955. oldValue, err := m.oldValue(ctx)
  12956. if err != nil {
  12957. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12958. }
  12959. return oldValue.UpdatedAt, nil
  12960. }
  12961. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12962. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  12963. m.updated_at = nil
  12964. }
  12965. // SetStatus sets the "status" field.
  12966. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  12967. m.status = &u
  12968. m.addstatus = nil
  12969. }
  12970. // Status returns the value of the "status" field in the mutation.
  12971. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  12972. v := m.status
  12973. if v == nil {
  12974. return
  12975. }
  12976. return *v, true
  12977. }
  12978. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  12979. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12981. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12982. if !m.op.Is(OpUpdateOne) {
  12983. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12984. }
  12985. if m.id == nil || m.oldValue == nil {
  12986. return v, errors.New("OldStatus requires an ID field in the mutation")
  12987. }
  12988. oldValue, err := m.oldValue(ctx)
  12989. if err != nil {
  12990. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12991. }
  12992. return oldValue.Status, nil
  12993. }
  12994. // AddStatus adds u to the "status" field.
  12995. func (m *LabelTaggingMutation) AddStatus(u int8) {
  12996. if m.addstatus != nil {
  12997. *m.addstatus += u
  12998. } else {
  12999. m.addstatus = &u
  13000. }
  13001. }
  13002. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13003. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  13004. v := m.addstatus
  13005. if v == nil {
  13006. return
  13007. }
  13008. return *v, true
  13009. }
  13010. // ClearStatus clears the value of the "status" field.
  13011. func (m *LabelTaggingMutation) ClearStatus() {
  13012. m.status = nil
  13013. m.addstatus = nil
  13014. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  13015. }
  13016. // StatusCleared returns if the "status" field was cleared in this mutation.
  13017. func (m *LabelTaggingMutation) StatusCleared() bool {
  13018. _, ok := m.clearedFields[labeltagging.FieldStatus]
  13019. return ok
  13020. }
  13021. // ResetStatus resets all changes to the "status" field.
  13022. func (m *LabelTaggingMutation) ResetStatus() {
  13023. m.status = nil
  13024. m.addstatus = nil
  13025. delete(m.clearedFields, labeltagging.FieldStatus)
  13026. }
  13027. // SetDeletedAt sets the "deleted_at" field.
  13028. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  13029. m.deleted_at = &t
  13030. }
  13031. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13032. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  13033. v := m.deleted_at
  13034. if v == nil {
  13035. return
  13036. }
  13037. return *v, true
  13038. }
  13039. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  13040. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13042. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13043. if !m.op.Is(OpUpdateOne) {
  13044. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13045. }
  13046. if m.id == nil || m.oldValue == nil {
  13047. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13048. }
  13049. oldValue, err := m.oldValue(ctx)
  13050. if err != nil {
  13051. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13052. }
  13053. return oldValue.DeletedAt, nil
  13054. }
  13055. // ClearDeletedAt clears the value of the "deleted_at" field.
  13056. func (m *LabelTaggingMutation) ClearDeletedAt() {
  13057. m.deleted_at = nil
  13058. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  13059. }
  13060. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13061. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  13062. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  13063. return ok
  13064. }
  13065. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13066. func (m *LabelTaggingMutation) ResetDeletedAt() {
  13067. m.deleted_at = nil
  13068. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  13069. }
  13070. // SetOrganizationID sets the "organization_id" field.
  13071. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  13072. m.organization_id = &u
  13073. m.addorganization_id = nil
  13074. }
  13075. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13076. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  13077. v := m.organization_id
  13078. if v == nil {
  13079. return
  13080. }
  13081. return *v, true
  13082. }
  13083. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  13084. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13086. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13087. if !m.op.Is(OpUpdateOne) {
  13088. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13089. }
  13090. if m.id == nil || m.oldValue == nil {
  13091. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13092. }
  13093. oldValue, err := m.oldValue(ctx)
  13094. if err != nil {
  13095. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13096. }
  13097. return oldValue.OrganizationID, nil
  13098. }
  13099. // AddOrganizationID adds u to the "organization_id" field.
  13100. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  13101. if m.addorganization_id != nil {
  13102. *m.addorganization_id += u
  13103. } else {
  13104. m.addorganization_id = &u
  13105. }
  13106. }
  13107. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13108. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  13109. v := m.addorganization_id
  13110. if v == nil {
  13111. return
  13112. }
  13113. return *v, true
  13114. }
  13115. // ResetOrganizationID resets all changes to the "organization_id" field.
  13116. func (m *LabelTaggingMutation) ResetOrganizationID() {
  13117. m.organization_id = nil
  13118. m.addorganization_id = nil
  13119. }
  13120. // SetType sets the "type" field.
  13121. func (m *LabelTaggingMutation) SetType(i int) {
  13122. m._type = &i
  13123. m.add_type = nil
  13124. }
  13125. // GetType returns the value of the "type" field in the mutation.
  13126. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  13127. v := m._type
  13128. if v == nil {
  13129. return
  13130. }
  13131. return *v, true
  13132. }
  13133. // OldType returns the old "type" field's value of the LabelTagging entity.
  13134. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13136. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  13137. if !m.op.Is(OpUpdateOne) {
  13138. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13139. }
  13140. if m.id == nil || m.oldValue == nil {
  13141. return v, errors.New("OldType requires an ID field in the mutation")
  13142. }
  13143. oldValue, err := m.oldValue(ctx)
  13144. if err != nil {
  13145. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13146. }
  13147. return oldValue.Type, nil
  13148. }
  13149. // AddType adds i to the "type" field.
  13150. func (m *LabelTaggingMutation) AddType(i int) {
  13151. if m.add_type != nil {
  13152. *m.add_type += i
  13153. } else {
  13154. m.add_type = &i
  13155. }
  13156. }
  13157. // AddedType returns the value that was added to the "type" field in this mutation.
  13158. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  13159. v := m.add_type
  13160. if v == nil {
  13161. return
  13162. }
  13163. return *v, true
  13164. }
  13165. // ResetType resets all changes to the "type" field.
  13166. func (m *LabelTaggingMutation) ResetType() {
  13167. m._type = nil
  13168. m.add_type = nil
  13169. }
  13170. // SetConditions sets the "conditions" field.
  13171. func (m *LabelTaggingMutation) SetConditions(s string) {
  13172. m.conditions = &s
  13173. }
  13174. // Conditions returns the value of the "conditions" field in the mutation.
  13175. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  13176. v := m.conditions
  13177. if v == nil {
  13178. return
  13179. }
  13180. return *v, true
  13181. }
  13182. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  13183. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13185. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  13186. if !m.op.Is(OpUpdateOne) {
  13187. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13188. }
  13189. if m.id == nil || m.oldValue == nil {
  13190. return v, errors.New("OldConditions requires an ID field in the mutation")
  13191. }
  13192. oldValue, err := m.oldValue(ctx)
  13193. if err != nil {
  13194. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13195. }
  13196. return oldValue.Conditions, nil
  13197. }
  13198. // ResetConditions resets all changes to the "conditions" field.
  13199. func (m *LabelTaggingMutation) ResetConditions() {
  13200. m.conditions = nil
  13201. }
  13202. // SetActionLabelAdd sets the "action_label_add" field.
  13203. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  13204. m.action_label_add = &u
  13205. m.appendaction_label_add = nil
  13206. }
  13207. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  13208. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  13209. v := m.action_label_add
  13210. if v == nil {
  13211. return
  13212. }
  13213. return *v, true
  13214. }
  13215. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  13216. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13218. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  13219. if !m.op.Is(OpUpdateOne) {
  13220. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  13221. }
  13222. if m.id == nil || m.oldValue == nil {
  13223. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  13224. }
  13225. oldValue, err := m.oldValue(ctx)
  13226. if err != nil {
  13227. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  13228. }
  13229. return oldValue.ActionLabelAdd, nil
  13230. }
  13231. // AppendActionLabelAdd adds u to the "action_label_add" field.
  13232. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  13233. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  13234. }
  13235. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  13236. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  13237. if len(m.appendaction_label_add) == 0 {
  13238. return nil, false
  13239. }
  13240. return m.appendaction_label_add, true
  13241. }
  13242. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  13243. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  13244. m.action_label_add = nil
  13245. m.appendaction_label_add = nil
  13246. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  13247. }
  13248. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  13249. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  13250. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  13251. return ok
  13252. }
  13253. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  13254. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  13255. m.action_label_add = nil
  13256. m.appendaction_label_add = nil
  13257. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  13258. }
  13259. // SetActionLabelDel sets the "action_label_del" field.
  13260. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  13261. m.action_label_del = &u
  13262. m.appendaction_label_del = nil
  13263. }
  13264. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  13265. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  13266. v := m.action_label_del
  13267. if v == nil {
  13268. return
  13269. }
  13270. return *v, true
  13271. }
  13272. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  13273. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13275. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  13276. if !m.op.Is(OpUpdateOne) {
  13277. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  13278. }
  13279. if m.id == nil || m.oldValue == nil {
  13280. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  13281. }
  13282. oldValue, err := m.oldValue(ctx)
  13283. if err != nil {
  13284. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  13285. }
  13286. return oldValue.ActionLabelDel, nil
  13287. }
  13288. // AppendActionLabelDel adds u to the "action_label_del" field.
  13289. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  13290. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  13291. }
  13292. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  13293. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  13294. if len(m.appendaction_label_del) == 0 {
  13295. return nil, false
  13296. }
  13297. return m.appendaction_label_del, true
  13298. }
  13299. // ClearActionLabelDel clears the value of the "action_label_del" field.
  13300. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  13301. m.action_label_del = nil
  13302. m.appendaction_label_del = nil
  13303. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  13304. }
  13305. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  13306. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  13307. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  13308. return ok
  13309. }
  13310. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  13311. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  13312. m.action_label_del = nil
  13313. m.appendaction_label_del = nil
  13314. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  13315. }
  13316. // Where appends a list predicates to the LabelTaggingMutation builder.
  13317. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  13318. m.predicates = append(m.predicates, ps...)
  13319. }
  13320. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  13321. // users can use type-assertion to append predicates that do not depend on any generated package.
  13322. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  13323. p := make([]predicate.LabelTagging, len(ps))
  13324. for i := range ps {
  13325. p[i] = ps[i]
  13326. }
  13327. m.Where(p...)
  13328. }
  13329. // Op returns the operation name.
  13330. func (m *LabelTaggingMutation) Op() Op {
  13331. return m.op
  13332. }
  13333. // SetOp allows setting the mutation operation.
  13334. func (m *LabelTaggingMutation) SetOp(op Op) {
  13335. m.op = op
  13336. }
  13337. // Type returns the node type of this mutation (LabelTagging).
  13338. func (m *LabelTaggingMutation) Type() string {
  13339. return m.typ
  13340. }
  13341. // Fields returns all fields that were changed during this mutation. Note that in
  13342. // order to get all numeric fields that were incremented/decremented, call
  13343. // AddedFields().
  13344. func (m *LabelTaggingMutation) Fields() []string {
  13345. fields := make([]string, 0, 9)
  13346. if m.created_at != nil {
  13347. fields = append(fields, labeltagging.FieldCreatedAt)
  13348. }
  13349. if m.updated_at != nil {
  13350. fields = append(fields, labeltagging.FieldUpdatedAt)
  13351. }
  13352. if m.status != nil {
  13353. fields = append(fields, labeltagging.FieldStatus)
  13354. }
  13355. if m.deleted_at != nil {
  13356. fields = append(fields, labeltagging.FieldDeletedAt)
  13357. }
  13358. if m.organization_id != nil {
  13359. fields = append(fields, labeltagging.FieldOrganizationID)
  13360. }
  13361. if m._type != nil {
  13362. fields = append(fields, labeltagging.FieldType)
  13363. }
  13364. if m.conditions != nil {
  13365. fields = append(fields, labeltagging.FieldConditions)
  13366. }
  13367. if m.action_label_add != nil {
  13368. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13369. }
  13370. if m.action_label_del != nil {
  13371. fields = append(fields, labeltagging.FieldActionLabelDel)
  13372. }
  13373. return fields
  13374. }
  13375. // Field returns the value of a field with the given name. The second boolean
  13376. // return value indicates that this field was not set, or was not defined in the
  13377. // schema.
  13378. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  13379. switch name {
  13380. case labeltagging.FieldCreatedAt:
  13381. return m.CreatedAt()
  13382. case labeltagging.FieldUpdatedAt:
  13383. return m.UpdatedAt()
  13384. case labeltagging.FieldStatus:
  13385. return m.Status()
  13386. case labeltagging.FieldDeletedAt:
  13387. return m.DeletedAt()
  13388. case labeltagging.FieldOrganizationID:
  13389. return m.OrganizationID()
  13390. case labeltagging.FieldType:
  13391. return m.GetType()
  13392. case labeltagging.FieldConditions:
  13393. return m.Conditions()
  13394. case labeltagging.FieldActionLabelAdd:
  13395. return m.ActionLabelAdd()
  13396. case labeltagging.FieldActionLabelDel:
  13397. return m.ActionLabelDel()
  13398. }
  13399. return nil, false
  13400. }
  13401. // OldField returns the old value of the field from the database. An error is
  13402. // returned if the mutation operation is not UpdateOne, or the query to the
  13403. // database failed.
  13404. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13405. switch name {
  13406. case labeltagging.FieldCreatedAt:
  13407. return m.OldCreatedAt(ctx)
  13408. case labeltagging.FieldUpdatedAt:
  13409. return m.OldUpdatedAt(ctx)
  13410. case labeltagging.FieldStatus:
  13411. return m.OldStatus(ctx)
  13412. case labeltagging.FieldDeletedAt:
  13413. return m.OldDeletedAt(ctx)
  13414. case labeltagging.FieldOrganizationID:
  13415. return m.OldOrganizationID(ctx)
  13416. case labeltagging.FieldType:
  13417. return m.OldType(ctx)
  13418. case labeltagging.FieldConditions:
  13419. return m.OldConditions(ctx)
  13420. case labeltagging.FieldActionLabelAdd:
  13421. return m.OldActionLabelAdd(ctx)
  13422. case labeltagging.FieldActionLabelDel:
  13423. return m.OldActionLabelDel(ctx)
  13424. }
  13425. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  13426. }
  13427. // SetField sets the value of a field with the given name. It returns an error if
  13428. // the field is not defined in the schema, or if the type mismatched the field
  13429. // type.
  13430. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  13431. switch name {
  13432. case labeltagging.FieldCreatedAt:
  13433. v, ok := value.(time.Time)
  13434. if !ok {
  13435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13436. }
  13437. m.SetCreatedAt(v)
  13438. return nil
  13439. case labeltagging.FieldUpdatedAt:
  13440. v, ok := value.(time.Time)
  13441. if !ok {
  13442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13443. }
  13444. m.SetUpdatedAt(v)
  13445. return nil
  13446. case labeltagging.FieldStatus:
  13447. v, ok := value.(uint8)
  13448. if !ok {
  13449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13450. }
  13451. m.SetStatus(v)
  13452. return nil
  13453. case labeltagging.FieldDeletedAt:
  13454. v, ok := value.(time.Time)
  13455. if !ok {
  13456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13457. }
  13458. m.SetDeletedAt(v)
  13459. return nil
  13460. case labeltagging.FieldOrganizationID:
  13461. v, ok := value.(uint64)
  13462. if !ok {
  13463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13464. }
  13465. m.SetOrganizationID(v)
  13466. return nil
  13467. case labeltagging.FieldType:
  13468. v, ok := value.(int)
  13469. if !ok {
  13470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13471. }
  13472. m.SetType(v)
  13473. return nil
  13474. case labeltagging.FieldConditions:
  13475. v, ok := value.(string)
  13476. if !ok {
  13477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13478. }
  13479. m.SetConditions(v)
  13480. return nil
  13481. case labeltagging.FieldActionLabelAdd:
  13482. v, ok := value.([]uint64)
  13483. if !ok {
  13484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13485. }
  13486. m.SetActionLabelAdd(v)
  13487. return nil
  13488. case labeltagging.FieldActionLabelDel:
  13489. v, ok := value.([]uint64)
  13490. if !ok {
  13491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13492. }
  13493. m.SetActionLabelDel(v)
  13494. return nil
  13495. }
  13496. return fmt.Errorf("unknown LabelTagging field %s", name)
  13497. }
  13498. // AddedFields returns all numeric fields that were incremented/decremented during
  13499. // this mutation.
  13500. func (m *LabelTaggingMutation) AddedFields() []string {
  13501. var fields []string
  13502. if m.addstatus != nil {
  13503. fields = append(fields, labeltagging.FieldStatus)
  13504. }
  13505. if m.addorganization_id != nil {
  13506. fields = append(fields, labeltagging.FieldOrganizationID)
  13507. }
  13508. if m.add_type != nil {
  13509. fields = append(fields, labeltagging.FieldType)
  13510. }
  13511. return fields
  13512. }
  13513. // AddedField returns the numeric value that was incremented/decremented on a field
  13514. // with the given name. The second boolean return value indicates that this field
  13515. // was not set, or was not defined in the schema.
  13516. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  13517. switch name {
  13518. case labeltagging.FieldStatus:
  13519. return m.AddedStatus()
  13520. case labeltagging.FieldOrganizationID:
  13521. return m.AddedOrganizationID()
  13522. case labeltagging.FieldType:
  13523. return m.AddedType()
  13524. }
  13525. return nil, false
  13526. }
  13527. // AddField adds the value to the field with the given name. It returns an error if
  13528. // the field is not defined in the schema, or if the type mismatched the field
  13529. // type.
  13530. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  13531. switch name {
  13532. case labeltagging.FieldStatus:
  13533. v, ok := value.(int8)
  13534. if !ok {
  13535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13536. }
  13537. m.AddStatus(v)
  13538. return nil
  13539. case labeltagging.FieldOrganizationID:
  13540. v, ok := value.(int64)
  13541. if !ok {
  13542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13543. }
  13544. m.AddOrganizationID(v)
  13545. return nil
  13546. case labeltagging.FieldType:
  13547. v, ok := value.(int)
  13548. if !ok {
  13549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13550. }
  13551. m.AddType(v)
  13552. return nil
  13553. }
  13554. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  13555. }
  13556. // ClearedFields returns all nullable fields that were cleared during this
  13557. // mutation.
  13558. func (m *LabelTaggingMutation) ClearedFields() []string {
  13559. var fields []string
  13560. if m.FieldCleared(labeltagging.FieldStatus) {
  13561. fields = append(fields, labeltagging.FieldStatus)
  13562. }
  13563. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  13564. fields = append(fields, labeltagging.FieldDeletedAt)
  13565. }
  13566. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  13567. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13568. }
  13569. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  13570. fields = append(fields, labeltagging.FieldActionLabelDel)
  13571. }
  13572. return fields
  13573. }
  13574. // FieldCleared returns a boolean indicating if a field with the given name was
  13575. // cleared in this mutation.
  13576. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  13577. _, ok := m.clearedFields[name]
  13578. return ok
  13579. }
  13580. // ClearField clears the value of the field with the given name. It returns an
  13581. // error if the field is not defined in the schema.
  13582. func (m *LabelTaggingMutation) ClearField(name string) error {
  13583. switch name {
  13584. case labeltagging.FieldStatus:
  13585. m.ClearStatus()
  13586. return nil
  13587. case labeltagging.FieldDeletedAt:
  13588. m.ClearDeletedAt()
  13589. return nil
  13590. case labeltagging.FieldActionLabelAdd:
  13591. m.ClearActionLabelAdd()
  13592. return nil
  13593. case labeltagging.FieldActionLabelDel:
  13594. m.ClearActionLabelDel()
  13595. return nil
  13596. }
  13597. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  13598. }
  13599. // ResetField resets all changes in the mutation for the field with the given name.
  13600. // It returns an error if the field is not defined in the schema.
  13601. func (m *LabelTaggingMutation) ResetField(name string) error {
  13602. switch name {
  13603. case labeltagging.FieldCreatedAt:
  13604. m.ResetCreatedAt()
  13605. return nil
  13606. case labeltagging.FieldUpdatedAt:
  13607. m.ResetUpdatedAt()
  13608. return nil
  13609. case labeltagging.FieldStatus:
  13610. m.ResetStatus()
  13611. return nil
  13612. case labeltagging.FieldDeletedAt:
  13613. m.ResetDeletedAt()
  13614. return nil
  13615. case labeltagging.FieldOrganizationID:
  13616. m.ResetOrganizationID()
  13617. return nil
  13618. case labeltagging.FieldType:
  13619. m.ResetType()
  13620. return nil
  13621. case labeltagging.FieldConditions:
  13622. m.ResetConditions()
  13623. return nil
  13624. case labeltagging.FieldActionLabelAdd:
  13625. m.ResetActionLabelAdd()
  13626. return nil
  13627. case labeltagging.FieldActionLabelDel:
  13628. m.ResetActionLabelDel()
  13629. return nil
  13630. }
  13631. return fmt.Errorf("unknown LabelTagging field %s", name)
  13632. }
  13633. // AddedEdges returns all edge names that were set/added in this mutation.
  13634. func (m *LabelTaggingMutation) AddedEdges() []string {
  13635. edges := make([]string, 0, 0)
  13636. return edges
  13637. }
  13638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13639. // name in this mutation.
  13640. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  13641. return nil
  13642. }
  13643. // RemovedEdges returns all edge names that were removed in this mutation.
  13644. func (m *LabelTaggingMutation) RemovedEdges() []string {
  13645. edges := make([]string, 0, 0)
  13646. return edges
  13647. }
  13648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13649. // the given name in this mutation.
  13650. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  13651. return nil
  13652. }
  13653. // ClearedEdges returns all edge names that were cleared in this mutation.
  13654. func (m *LabelTaggingMutation) ClearedEdges() []string {
  13655. edges := make([]string, 0, 0)
  13656. return edges
  13657. }
  13658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13659. // was cleared in this mutation.
  13660. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  13661. return false
  13662. }
  13663. // ClearEdge clears the value of the edge with the given name. It returns an error
  13664. // if that edge is not defined in the schema.
  13665. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  13666. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  13667. }
  13668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13669. // It returns an error if the edge is not defined in the schema.
  13670. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  13671. return fmt.Errorf("unknown LabelTagging edge %s", name)
  13672. }
  13673. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  13674. type MessageMutation struct {
  13675. config
  13676. op Op
  13677. typ string
  13678. id *int
  13679. wx_wxid *string
  13680. wxid *string
  13681. content *string
  13682. clearedFields map[string]struct{}
  13683. done bool
  13684. oldValue func(context.Context) (*Message, error)
  13685. predicates []predicate.Message
  13686. }
  13687. var _ ent.Mutation = (*MessageMutation)(nil)
  13688. // messageOption allows management of the mutation configuration using functional options.
  13689. type messageOption func(*MessageMutation)
  13690. // newMessageMutation creates new mutation for the Message entity.
  13691. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  13692. m := &MessageMutation{
  13693. config: c,
  13694. op: op,
  13695. typ: TypeMessage,
  13696. clearedFields: make(map[string]struct{}),
  13697. }
  13698. for _, opt := range opts {
  13699. opt(m)
  13700. }
  13701. return m
  13702. }
  13703. // withMessageID sets the ID field of the mutation.
  13704. func withMessageID(id int) messageOption {
  13705. return func(m *MessageMutation) {
  13706. var (
  13707. err error
  13708. once sync.Once
  13709. value *Message
  13710. )
  13711. m.oldValue = func(ctx context.Context) (*Message, error) {
  13712. once.Do(func() {
  13713. if m.done {
  13714. err = errors.New("querying old values post mutation is not allowed")
  13715. } else {
  13716. value, err = m.Client().Message.Get(ctx, id)
  13717. }
  13718. })
  13719. return value, err
  13720. }
  13721. m.id = &id
  13722. }
  13723. }
  13724. // withMessage sets the old Message of the mutation.
  13725. func withMessage(node *Message) messageOption {
  13726. return func(m *MessageMutation) {
  13727. m.oldValue = func(context.Context) (*Message, error) {
  13728. return node, nil
  13729. }
  13730. m.id = &node.ID
  13731. }
  13732. }
  13733. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13734. // executed in a transaction (ent.Tx), a transactional client is returned.
  13735. func (m MessageMutation) Client() *Client {
  13736. client := &Client{config: m.config}
  13737. client.init()
  13738. return client
  13739. }
  13740. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13741. // it returns an error otherwise.
  13742. func (m MessageMutation) Tx() (*Tx, error) {
  13743. if _, ok := m.driver.(*txDriver); !ok {
  13744. return nil, errors.New("ent: mutation is not running in a transaction")
  13745. }
  13746. tx := &Tx{config: m.config}
  13747. tx.init()
  13748. return tx, nil
  13749. }
  13750. // ID returns the ID value in the mutation. Note that the ID is only available
  13751. // if it was provided to the builder or after it was returned from the database.
  13752. func (m *MessageMutation) ID() (id int, exists bool) {
  13753. if m.id == nil {
  13754. return
  13755. }
  13756. return *m.id, true
  13757. }
  13758. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13759. // That means, if the mutation is applied within a transaction with an isolation level such
  13760. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13761. // or updated by the mutation.
  13762. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  13763. switch {
  13764. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13765. id, exists := m.ID()
  13766. if exists {
  13767. return []int{id}, nil
  13768. }
  13769. fallthrough
  13770. case m.op.Is(OpUpdate | OpDelete):
  13771. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  13772. default:
  13773. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13774. }
  13775. }
  13776. // SetWxWxid sets the "wx_wxid" field.
  13777. func (m *MessageMutation) SetWxWxid(s string) {
  13778. m.wx_wxid = &s
  13779. }
  13780. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  13781. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  13782. v := m.wx_wxid
  13783. if v == nil {
  13784. return
  13785. }
  13786. return *v, true
  13787. }
  13788. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  13789. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13791. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  13792. if !m.op.Is(OpUpdateOne) {
  13793. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  13794. }
  13795. if m.id == nil || m.oldValue == nil {
  13796. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  13797. }
  13798. oldValue, err := m.oldValue(ctx)
  13799. if err != nil {
  13800. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  13801. }
  13802. return oldValue.WxWxid, nil
  13803. }
  13804. // ClearWxWxid clears the value of the "wx_wxid" field.
  13805. func (m *MessageMutation) ClearWxWxid() {
  13806. m.wx_wxid = nil
  13807. m.clearedFields[message.FieldWxWxid] = struct{}{}
  13808. }
  13809. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  13810. func (m *MessageMutation) WxWxidCleared() bool {
  13811. _, ok := m.clearedFields[message.FieldWxWxid]
  13812. return ok
  13813. }
  13814. // ResetWxWxid resets all changes to the "wx_wxid" field.
  13815. func (m *MessageMutation) ResetWxWxid() {
  13816. m.wx_wxid = nil
  13817. delete(m.clearedFields, message.FieldWxWxid)
  13818. }
  13819. // SetWxid sets the "wxid" field.
  13820. func (m *MessageMutation) SetWxid(s string) {
  13821. m.wxid = &s
  13822. }
  13823. // Wxid returns the value of the "wxid" field in the mutation.
  13824. func (m *MessageMutation) Wxid() (r string, exists bool) {
  13825. v := m.wxid
  13826. if v == nil {
  13827. return
  13828. }
  13829. return *v, true
  13830. }
  13831. // OldWxid returns the old "wxid" field's value of the Message entity.
  13832. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13834. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  13835. if !m.op.Is(OpUpdateOne) {
  13836. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13837. }
  13838. if m.id == nil || m.oldValue == nil {
  13839. return v, errors.New("OldWxid requires an ID field in the mutation")
  13840. }
  13841. oldValue, err := m.oldValue(ctx)
  13842. if err != nil {
  13843. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13844. }
  13845. return oldValue.Wxid, nil
  13846. }
  13847. // ResetWxid resets all changes to the "wxid" field.
  13848. func (m *MessageMutation) ResetWxid() {
  13849. m.wxid = nil
  13850. }
  13851. // SetContent sets the "content" field.
  13852. func (m *MessageMutation) SetContent(s string) {
  13853. m.content = &s
  13854. }
  13855. // Content returns the value of the "content" field in the mutation.
  13856. func (m *MessageMutation) Content() (r string, exists bool) {
  13857. v := m.content
  13858. if v == nil {
  13859. return
  13860. }
  13861. return *v, true
  13862. }
  13863. // OldContent returns the old "content" field's value of the Message entity.
  13864. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13866. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  13867. if !m.op.Is(OpUpdateOne) {
  13868. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13869. }
  13870. if m.id == nil || m.oldValue == nil {
  13871. return v, errors.New("OldContent requires an ID field in the mutation")
  13872. }
  13873. oldValue, err := m.oldValue(ctx)
  13874. if err != nil {
  13875. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13876. }
  13877. return oldValue.Content, nil
  13878. }
  13879. // ResetContent resets all changes to the "content" field.
  13880. func (m *MessageMutation) ResetContent() {
  13881. m.content = nil
  13882. }
  13883. // Where appends a list predicates to the MessageMutation builder.
  13884. func (m *MessageMutation) Where(ps ...predicate.Message) {
  13885. m.predicates = append(m.predicates, ps...)
  13886. }
  13887. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  13888. // users can use type-assertion to append predicates that do not depend on any generated package.
  13889. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  13890. p := make([]predicate.Message, len(ps))
  13891. for i := range ps {
  13892. p[i] = ps[i]
  13893. }
  13894. m.Where(p...)
  13895. }
  13896. // Op returns the operation name.
  13897. func (m *MessageMutation) Op() Op {
  13898. return m.op
  13899. }
  13900. // SetOp allows setting the mutation operation.
  13901. func (m *MessageMutation) SetOp(op Op) {
  13902. m.op = op
  13903. }
  13904. // Type returns the node type of this mutation (Message).
  13905. func (m *MessageMutation) Type() string {
  13906. return m.typ
  13907. }
  13908. // Fields returns all fields that were changed during this mutation. Note that in
  13909. // order to get all numeric fields that were incremented/decremented, call
  13910. // AddedFields().
  13911. func (m *MessageMutation) Fields() []string {
  13912. fields := make([]string, 0, 3)
  13913. if m.wx_wxid != nil {
  13914. fields = append(fields, message.FieldWxWxid)
  13915. }
  13916. if m.wxid != nil {
  13917. fields = append(fields, message.FieldWxid)
  13918. }
  13919. if m.content != nil {
  13920. fields = append(fields, message.FieldContent)
  13921. }
  13922. return fields
  13923. }
  13924. // Field returns the value of a field with the given name. The second boolean
  13925. // return value indicates that this field was not set, or was not defined in the
  13926. // schema.
  13927. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13928. switch name {
  13929. case message.FieldWxWxid:
  13930. return m.WxWxid()
  13931. case message.FieldWxid:
  13932. return m.Wxid()
  13933. case message.FieldContent:
  13934. return m.Content()
  13935. }
  13936. return nil, false
  13937. }
  13938. // OldField returns the old value of the field from the database. An error is
  13939. // returned if the mutation operation is not UpdateOne, or the query to the
  13940. // database failed.
  13941. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13942. switch name {
  13943. case message.FieldWxWxid:
  13944. return m.OldWxWxid(ctx)
  13945. case message.FieldWxid:
  13946. return m.OldWxid(ctx)
  13947. case message.FieldContent:
  13948. return m.OldContent(ctx)
  13949. }
  13950. return nil, fmt.Errorf("unknown Message field %s", name)
  13951. }
  13952. // SetField sets the value of a field with the given name. It returns an error if
  13953. // the field is not defined in the schema, or if the type mismatched the field
  13954. // type.
  13955. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13956. switch name {
  13957. case message.FieldWxWxid:
  13958. v, ok := value.(string)
  13959. if !ok {
  13960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13961. }
  13962. m.SetWxWxid(v)
  13963. return nil
  13964. case message.FieldWxid:
  13965. v, ok := value.(string)
  13966. if !ok {
  13967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13968. }
  13969. m.SetWxid(v)
  13970. return nil
  13971. case message.FieldContent:
  13972. v, ok := value.(string)
  13973. if !ok {
  13974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13975. }
  13976. m.SetContent(v)
  13977. return nil
  13978. }
  13979. return fmt.Errorf("unknown Message field %s", name)
  13980. }
  13981. // AddedFields returns all numeric fields that were incremented/decremented during
  13982. // this mutation.
  13983. func (m *MessageMutation) AddedFields() []string {
  13984. return nil
  13985. }
  13986. // AddedField returns the numeric value that was incremented/decremented on a field
  13987. // with the given name. The second boolean return value indicates that this field
  13988. // was not set, or was not defined in the schema.
  13989. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13990. return nil, false
  13991. }
  13992. // AddField adds the value to the field with the given name. It returns an error if
  13993. // the field is not defined in the schema, or if the type mismatched the field
  13994. // type.
  13995. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13996. switch name {
  13997. }
  13998. return fmt.Errorf("unknown Message numeric field %s", name)
  13999. }
  14000. // ClearedFields returns all nullable fields that were cleared during this
  14001. // mutation.
  14002. func (m *MessageMutation) ClearedFields() []string {
  14003. var fields []string
  14004. if m.FieldCleared(message.FieldWxWxid) {
  14005. fields = append(fields, message.FieldWxWxid)
  14006. }
  14007. return fields
  14008. }
  14009. // FieldCleared returns a boolean indicating if a field with the given name was
  14010. // cleared in this mutation.
  14011. func (m *MessageMutation) FieldCleared(name string) bool {
  14012. _, ok := m.clearedFields[name]
  14013. return ok
  14014. }
  14015. // ClearField clears the value of the field with the given name. It returns an
  14016. // error if the field is not defined in the schema.
  14017. func (m *MessageMutation) ClearField(name string) error {
  14018. switch name {
  14019. case message.FieldWxWxid:
  14020. m.ClearWxWxid()
  14021. return nil
  14022. }
  14023. return fmt.Errorf("unknown Message nullable field %s", name)
  14024. }
  14025. // ResetField resets all changes in the mutation for the field with the given name.
  14026. // It returns an error if the field is not defined in the schema.
  14027. func (m *MessageMutation) ResetField(name string) error {
  14028. switch name {
  14029. case message.FieldWxWxid:
  14030. m.ResetWxWxid()
  14031. return nil
  14032. case message.FieldWxid:
  14033. m.ResetWxid()
  14034. return nil
  14035. case message.FieldContent:
  14036. m.ResetContent()
  14037. return nil
  14038. }
  14039. return fmt.Errorf("unknown Message field %s", name)
  14040. }
  14041. // AddedEdges returns all edge names that were set/added in this mutation.
  14042. func (m *MessageMutation) AddedEdges() []string {
  14043. edges := make([]string, 0, 0)
  14044. return edges
  14045. }
  14046. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14047. // name in this mutation.
  14048. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  14049. return nil
  14050. }
  14051. // RemovedEdges returns all edge names that were removed in this mutation.
  14052. func (m *MessageMutation) RemovedEdges() []string {
  14053. edges := make([]string, 0, 0)
  14054. return edges
  14055. }
  14056. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14057. // the given name in this mutation.
  14058. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  14059. return nil
  14060. }
  14061. // ClearedEdges returns all edge names that were cleared in this mutation.
  14062. func (m *MessageMutation) ClearedEdges() []string {
  14063. edges := make([]string, 0, 0)
  14064. return edges
  14065. }
  14066. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14067. // was cleared in this mutation.
  14068. func (m *MessageMutation) EdgeCleared(name string) bool {
  14069. return false
  14070. }
  14071. // ClearEdge clears the value of the edge with the given name. It returns an error
  14072. // if that edge is not defined in the schema.
  14073. func (m *MessageMutation) ClearEdge(name string) error {
  14074. return fmt.Errorf("unknown Message unique edge %s", name)
  14075. }
  14076. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14077. // It returns an error if the edge is not defined in the schema.
  14078. func (m *MessageMutation) ResetEdge(name string) error {
  14079. return fmt.Errorf("unknown Message edge %s", name)
  14080. }
  14081. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  14082. type MessageRecordsMutation struct {
  14083. config
  14084. op Op
  14085. typ string
  14086. id *uint64
  14087. created_at *time.Time
  14088. updated_at *time.Time
  14089. status *uint8
  14090. addstatus *int8
  14091. bot_wxid *string
  14092. contact_type *int
  14093. addcontact_type *int
  14094. contact_wxid *string
  14095. content_type *int
  14096. addcontent_type *int
  14097. content *string
  14098. meta *custom_types.Meta
  14099. error_detail *string
  14100. send_time *time.Time
  14101. source_type *int
  14102. addsource_type *int
  14103. organization_id *uint64
  14104. addorganization_id *int64
  14105. clearedFields map[string]struct{}
  14106. sop_stage *uint64
  14107. clearedsop_stage bool
  14108. sop_node *uint64
  14109. clearedsop_node bool
  14110. message_contact *uint64
  14111. clearedmessage_contact bool
  14112. done bool
  14113. oldValue func(context.Context) (*MessageRecords, error)
  14114. predicates []predicate.MessageRecords
  14115. }
  14116. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  14117. // messagerecordsOption allows management of the mutation configuration using functional options.
  14118. type messagerecordsOption func(*MessageRecordsMutation)
  14119. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  14120. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  14121. m := &MessageRecordsMutation{
  14122. config: c,
  14123. op: op,
  14124. typ: TypeMessageRecords,
  14125. clearedFields: make(map[string]struct{}),
  14126. }
  14127. for _, opt := range opts {
  14128. opt(m)
  14129. }
  14130. return m
  14131. }
  14132. // withMessageRecordsID sets the ID field of the mutation.
  14133. func withMessageRecordsID(id uint64) messagerecordsOption {
  14134. return func(m *MessageRecordsMutation) {
  14135. var (
  14136. err error
  14137. once sync.Once
  14138. value *MessageRecords
  14139. )
  14140. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  14141. once.Do(func() {
  14142. if m.done {
  14143. err = errors.New("querying old values post mutation is not allowed")
  14144. } else {
  14145. value, err = m.Client().MessageRecords.Get(ctx, id)
  14146. }
  14147. })
  14148. return value, err
  14149. }
  14150. m.id = &id
  14151. }
  14152. }
  14153. // withMessageRecords sets the old MessageRecords of the mutation.
  14154. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14155. return func(m *MessageRecordsMutation) {
  14156. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14157. return node, nil
  14158. }
  14159. m.id = &node.ID
  14160. }
  14161. }
  14162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14163. // executed in a transaction (ent.Tx), a transactional client is returned.
  14164. func (m MessageRecordsMutation) Client() *Client {
  14165. client := &Client{config: m.config}
  14166. client.init()
  14167. return client
  14168. }
  14169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14170. // it returns an error otherwise.
  14171. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14172. if _, ok := m.driver.(*txDriver); !ok {
  14173. return nil, errors.New("ent: mutation is not running in a transaction")
  14174. }
  14175. tx := &Tx{config: m.config}
  14176. tx.init()
  14177. return tx, nil
  14178. }
  14179. // SetID sets the value of the id field. Note that this
  14180. // operation is only accepted on creation of MessageRecords entities.
  14181. func (m *MessageRecordsMutation) SetID(id uint64) {
  14182. m.id = &id
  14183. }
  14184. // ID returns the ID value in the mutation. Note that the ID is only available
  14185. // if it was provided to the builder or after it was returned from the database.
  14186. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14187. if m.id == nil {
  14188. return
  14189. }
  14190. return *m.id, true
  14191. }
  14192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14193. // That means, if the mutation is applied within a transaction with an isolation level such
  14194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14195. // or updated by the mutation.
  14196. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14197. switch {
  14198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14199. id, exists := m.ID()
  14200. if exists {
  14201. return []uint64{id}, nil
  14202. }
  14203. fallthrough
  14204. case m.op.Is(OpUpdate | OpDelete):
  14205. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14206. default:
  14207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14208. }
  14209. }
  14210. // SetCreatedAt sets the "created_at" field.
  14211. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14212. m.created_at = &t
  14213. }
  14214. // CreatedAt returns the value of the "created_at" field in the mutation.
  14215. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14216. v := m.created_at
  14217. if v == nil {
  14218. return
  14219. }
  14220. return *v, true
  14221. }
  14222. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14223. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14225. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14226. if !m.op.Is(OpUpdateOne) {
  14227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14228. }
  14229. if m.id == nil || m.oldValue == nil {
  14230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14231. }
  14232. oldValue, err := m.oldValue(ctx)
  14233. if err != nil {
  14234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14235. }
  14236. return oldValue.CreatedAt, nil
  14237. }
  14238. // ResetCreatedAt resets all changes to the "created_at" field.
  14239. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14240. m.created_at = nil
  14241. }
  14242. // SetUpdatedAt sets the "updated_at" field.
  14243. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14244. m.updated_at = &t
  14245. }
  14246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14247. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14248. v := m.updated_at
  14249. if v == nil {
  14250. return
  14251. }
  14252. return *v, true
  14253. }
  14254. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  14255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14257. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14258. if !m.op.Is(OpUpdateOne) {
  14259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14260. }
  14261. if m.id == nil || m.oldValue == nil {
  14262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14263. }
  14264. oldValue, err := m.oldValue(ctx)
  14265. if err != nil {
  14266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14267. }
  14268. return oldValue.UpdatedAt, nil
  14269. }
  14270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14271. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  14272. m.updated_at = nil
  14273. }
  14274. // SetStatus sets the "status" field.
  14275. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  14276. m.status = &u
  14277. m.addstatus = nil
  14278. }
  14279. // Status returns the value of the "status" field in the mutation.
  14280. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  14281. v := m.status
  14282. if v == nil {
  14283. return
  14284. }
  14285. return *v, true
  14286. }
  14287. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  14288. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14290. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14291. if !m.op.Is(OpUpdateOne) {
  14292. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14293. }
  14294. if m.id == nil || m.oldValue == nil {
  14295. return v, errors.New("OldStatus requires an ID field in the mutation")
  14296. }
  14297. oldValue, err := m.oldValue(ctx)
  14298. if err != nil {
  14299. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14300. }
  14301. return oldValue.Status, nil
  14302. }
  14303. // AddStatus adds u to the "status" field.
  14304. func (m *MessageRecordsMutation) AddStatus(u int8) {
  14305. if m.addstatus != nil {
  14306. *m.addstatus += u
  14307. } else {
  14308. m.addstatus = &u
  14309. }
  14310. }
  14311. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14312. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  14313. v := m.addstatus
  14314. if v == nil {
  14315. return
  14316. }
  14317. return *v, true
  14318. }
  14319. // ClearStatus clears the value of the "status" field.
  14320. func (m *MessageRecordsMutation) ClearStatus() {
  14321. m.status = nil
  14322. m.addstatus = nil
  14323. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  14324. }
  14325. // StatusCleared returns if the "status" field was cleared in this mutation.
  14326. func (m *MessageRecordsMutation) StatusCleared() bool {
  14327. _, ok := m.clearedFields[messagerecords.FieldStatus]
  14328. return ok
  14329. }
  14330. // ResetStatus resets all changes to the "status" field.
  14331. func (m *MessageRecordsMutation) ResetStatus() {
  14332. m.status = nil
  14333. m.addstatus = nil
  14334. delete(m.clearedFields, messagerecords.FieldStatus)
  14335. }
  14336. // SetBotWxid sets the "bot_wxid" field.
  14337. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  14338. m.bot_wxid = &s
  14339. }
  14340. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  14341. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  14342. v := m.bot_wxid
  14343. if v == nil {
  14344. return
  14345. }
  14346. return *v, true
  14347. }
  14348. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  14349. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14351. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  14352. if !m.op.Is(OpUpdateOne) {
  14353. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  14354. }
  14355. if m.id == nil || m.oldValue == nil {
  14356. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  14357. }
  14358. oldValue, err := m.oldValue(ctx)
  14359. if err != nil {
  14360. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  14361. }
  14362. return oldValue.BotWxid, nil
  14363. }
  14364. // ResetBotWxid resets all changes to the "bot_wxid" field.
  14365. func (m *MessageRecordsMutation) ResetBotWxid() {
  14366. m.bot_wxid = nil
  14367. }
  14368. // SetContactID sets the "contact_id" field.
  14369. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  14370. m.message_contact = &u
  14371. }
  14372. // ContactID returns the value of the "contact_id" field in the mutation.
  14373. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  14374. v := m.message_contact
  14375. if v == nil {
  14376. return
  14377. }
  14378. return *v, true
  14379. }
  14380. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  14381. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14383. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14384. if !m.op.Is(OpUpdateOne) {
  14385. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14386. }
  14387. if m.id == nil || m.oldValue == nil {
  14388. return v, errors.New("OldContactID requires an ID field in the mutation")
  14389. }
  14390. oldValue, err := m.oldValue(ctx)
  14391. if err != nil {
  14392. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14393. }
  14394. return oldValue.ContactID, nil
  14395. }
  14396. // ClearContactID clears the value of the "contact_id" field.
  14397. func (m *MessageRecordsMutation) ClearContactID() {
  14398. m.message_contact = nil
  14399. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14400. }
  14401. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  14402. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  14403. _, ok := m.clearedFields[messagerecords.FieldContactID]
  14404. return ok
  14405. }
  14406. // ResetContactID resets all changes to the "contact_id" field.
  14407. func (m *MessageRecordsMutation) ResetContactID() {
  14408. m.message_contact = nil
  14409. delete(m.clearedFields, messagerecords.FieldContactID)
  14410. }
  14411. // SetContactType sets the "contact_type" field.
  14412. func (m *MessageRecordsMutation) SetContactType(i int) {
  14413. m.contact_type = &i
  14414. m.addcontact_type = nil
  14415. }
  14416. // ContactType returns the value of the "contact_type" field in the mutation.
  14417. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  14418. v := m.contact_type
  14419. if v == nil {
  14420. return
  14421. }
  14422. return *v, true
  14423. }
  14424. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  14425. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14427. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  14428. if !m.op.Is(OpUpdateOne) {
  14429. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  14430. }
  14431. if m.id == nil || m.oldValue == nil {
  14432. return v, errors.New("OldContactType requires an ID field in the mutation")
  14433. }
  14434. oldValue, err := m.oldValue(ctx)
  14435. if err != nil {
  14436. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  14437. }
  14438. return oldValue.ContactType, nil
  14439. }
  14440. // AddContactType adds i to the "contact_type" field.
  14441. func (m *MessageRecordsMutation) AddContactType(i int) {
  14442. if m.addcontact_type != nil {
  14443. *m.addcontact_type += i
  14444. } else {
  14445. m.addcontact_type = &i
  14446. }
  14447. }
  14448. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  14449. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  14450. v := m.addcontact_type
  14451. if v == nil {
  14452. return
  14453. }
  14454. return *v, true
  14455. }
  14456. // ResetContactType resets all changes to the "contact_type" field.
  14457. func (m *MessageRecordsMutation) ResetContactType() {
  14458. m.contact_type = nil
  14459. m.addcontact_type = nil
  14460. }
  14461. // SetContactWxid sets the "contact_wxid" field.
  14462. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  14463. m.contact_wxid = &s
  14464. }
  14465. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  14466. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  14467. v := m.contact_wxid
  14468. if v == nil {
  14469. return
  14470. }
  14471. return *v, true
  14472. }
  14473. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  14474. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14476. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  14477. if !m.op.Is(OpUpdateOne) {
  14478. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  14479. }
  14480. if m.id == nil || m.oldValue == nil {
  14481. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  14482. }
  14483. oldValue, err := m.oldValue(ctx)
  14484. if err != nil {
  14485. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  14486. }
  14487. return oldValue.ContactWxid, nil
  14488. }
  14489. // ResetContactWxid resets all changes to the "contact_wxid" field.
  14490. func (m *MessageRecordsMutation) ResetContactWxid() {
  14491. m.contact_wxid = nil
  14492. }
  14493. // SetContentType sets the "content_type" field.
  14494. func (m *MessageRecordsMutation) SetContentType(i int) {
  14495. m.content_type = &i
  14496. m.addcontent_type = nil
  14497. }
  14498. // ContentType returns the value of the "content_type" field in the mutation.
  14499. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  14500. v := m.content_type
  14501. if v == nil {
  14502. return
  14503. }
  14504. return *v, true
  14505. }
  14506. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  14507. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14509. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  14510. if !m.op.Is(OpUpdateOne) {
  14511. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  14512. }
  14513. if m.id == nil || m.oldValue == nil {
  14514. return v, errors.New("OldContentType requires an ID field in the mutation")
  14515. }
  14516. oldValue, err := m.oldValue(ctx)
  14517. if err != nil {
  14518. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  14519. }
  14520. return oldValue.ContentType, nil
  14521. }
  14522. // AddContentType adds i to the "content_type" field.
  14523. func (m *MessageRecordsMutation) AddContentType(i int) {
  14524. if m.addcontent_type != nil {
  14525. *m.addcontent_type += i
  14526. } else {
  14527. m.addcontent_type = &i
  14528. }
  14529. }
  14530. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  14531. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  14532. v := m.addcontent_type
  14533. if v == nil {
  14534. return
  14535. }
  14536. return *v, true
  14537. }
  14538. // ResetContentType resets all changes to the "content_type" field.
  14539. func (m *MessageRecordsMutation) ResetContentType() {
  14540. m.content_type = nil
  14541. m.addcontent_type = nil
  14542. }
  14543. // SetContent sets the "content" field.
  14544. func (m *MessageRecordsMutation) SetContent(s string) {
  14545. m.content = &s
  14546. }
  14547. // Content returns the value of the "content" field in the mutation.
  14548. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  14549. v := m.content
  14550. if v == nil {
  14551. return
  14552. }
  14553. return *v, true
  14554. }
  14555. // OldContent returns the old "content" field's value of the MessageRecords entity.
  14556. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14558. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  14559. if !m.op.Is(OpUpdateOne) {
  14560. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14561. }
  14562. if m.id == nil || m.oldValue == nil {
  14563. return v, errors.New("OldContent requires an ID field in the mutation")
  14564. }
  14565. oldValue, err := m.oldValue(ctx)
  14566. if err != nil {
  14567. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14568. }
  14569. return oldValue.Content, nil
  14570. }
  14571. // ResetContent resets all changes to the "content" field.
  14572. func (m *MessageRecordsMutation) ResetContent() {
  14573. m.content = nil
  14574. }
  14575. // SetMeta sets the "meta" field.
  14576. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  14577. m.meta = &ct
  14578. }
  14579. // Meta returns the value of the "meta" field in the mutation.
  14580. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  14581. v := m.meta
  14582. if v == nil {
  14583. return
  14584. }
  14585. return *v, true
  14586. }
  14587. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  14588. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14590. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  14591. if !m.op.Is(OpUpdateOne) {
  14592. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  14593. }
  14594. if m.id == nil || m.oldValue == nil {
  14595. return v, errors.New("OldMeta requires an ID field in the mutation")
  14596. }
  14597. oldValue, err := m.oldValue(ctx)
  14598. if err != nil {
  14599. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  14600. }
  14601. return oldValue.Meta, nil
  14602. }
  14603. // ClearMeta clears the value of the "meta" field.
  14604. func (m *MessageRecordsMutation) ClearMeta() {
  14605. m.meta = nil
  14606. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  14607. }
  14608. // MetaCleared returns if the "meta" field was cleared in this mutation.
  14609. func (m *MessageRecordsMutation) MetaCleared() bool {
  14610. _, ok := m.clearedFields[messagerecords.FieldMeta]
  14611. return ok
  14612. }
  14613. // ResetMeta resets all changes to the "meta" field.
  14614. func (m *MessageRecordsMutation) ResetMeta() {
  14615. m.meta = nil
  14616. delete(m.clearedFields, messagerecords.FieldMeta)
  14617. }
  14618. // SetErrorDetail sets the "error_detail" field.
  14619. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  14620. m.error_detail = &s
  14621. }
  14622. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  14623. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  14624. v := m.error_detail
  14625. if v == nil {
  14626. return
  14627. }
  14628. return *v, true
  14629. }
  14630. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  14631. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14633. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  14634. if !m.op.Is(OpUpdateOne) {
  14635. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  14636. }
  14637. if m.id == nil || m.oldValue == nil {
  14638. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  14639. }
  14640. oldValue, err := m.oldValue(ctx)
  14641. if err != nil {
  14642. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  14643. }
  14644. return oldValue.ErrorDetail, nil
  14645. }
  14646. // ResetErrorDetail resets all changes to the "error_detail" field.
  14647. func (m *MessageRecordsMutation) ResetErrorDetail() {
  14648. m.error_detail = nil
  14649. }
  14650. // SetSendTime sets the "send_time" field.
  14651. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  14652. m.send_time = &t
  14653. }
  14654. // SendTime returns the value of the "send_time" field in the mutation.
  14655. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  14656. v := m.send_time
  14657. if v == nil {
  14658. return
  14659. }
  14660. return *v, true
  14661. }
  14662. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  14663. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14665. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  14666. if !m.op.Is(OpUpdateOne) {
  14667. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  14668. }
  14669. if m.id == nil || m.oldValue == nil {
  14670. return v, errors.New("OldSendTime requires an ID field in the mutation")
  14671. }
  14672. oldValue, err := m.oldValue(ctx)
  14673. if err != nil {
  14674. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  14675. }
  14676. return oldValue.SendTime, nil
  14677. }
  14678. // ClearSendTime clears the value of the "send_time" field.
  14679. func (m *MessageRecordsMutation) ClearSendTime() {
  14680. m.send_time = nil
  14681. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  14682. }
  14683. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  14684. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  14685. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  14686. return ok
  14687. }
  14688. // ResetSendTime resets all changes to the "send_time" field.
  14689. func (m *MessageRecordsMutation) ResetSendTime() {
  14690. m.send_time = nil
  14691. delete(m.clearedFields, messagerecords.FieldSendTime)
  14692. }
  14693. // SetSourceType sets the "source_type" field.
  14694. func (m *MessageRecordsMutation) SetSourceType(i int) {
  14695. m.source_type = &i
  14696. m.addsource_type = nil
  14697. }
  14698. // SourceType returns the value of the "source_type" field in the mutation.
  14699. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  14700. v := m.source_type
  14701. if v == nil {
  14702. return
  14703. }
  14704. return *v, true
  14705. }
  14706. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  14707. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14709. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  14710. if !m.op.Is(OpUpdateOne) {
  14711. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  14712. }
  14713. if m.id == nil || m.oldValue == nil {
  14714. return v, errors.New("OldSourceType requires an ID field in the mutation")
  14715. }
  14716. oldValue, err := m.oldValue(ctx)
  14717. if err != nil {
  14718. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  14719. }
  14720. return oldValue.SourceType, nil
  14721. }
  14722. // AddSourceType adds i to the "source_type" field.
  14723. func (m *MessageRecordsMutation) AddSourceType(i int) {
  14724. if m.addsource_type != nil {
  14725. *m.addsource_type += i
  14726. } else {
  14727. m.addsource_type = &i
  14728. }
  14729. }
  14730. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  14731. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  14732. v := m.addsource_type
  14733. if v == nil {
  14734. return
  14735. }
  14736. return *v, true
  14737. }
  14738. // ResetSourceType resets all changes to the "source_type" field.
  14739. func (m *MessageRecordsMutation) ResetSourceType() {
  14740. m.source_type = nil
  14741. m.addsource_type = nil
  14742. }
  14743. // SetSourceID sets the "source_id" field.
  14744. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  14745. m.sop_stage = &u
  14746. }
  14747. // SourceID returns the value of the "source_id" field in the mutation.
  14748. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  14749. v := m.sop_stage
  14750. if v == nil {
  14751. return
  14752. }
  14753. return *v, true
  14754. }
  14755. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  14756. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14758. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  14759. if !m.op.Is(OpUpdateOne) {
  14760. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  14761. }
  14762. if m.id == nil || m.oldValue == nil {
  14763. return v, errors.New("OldSourceID requires an ID field in the mutation")
  14764. }
  14765. oldValue, err := m.oldValue(ctx)
  14766. if err != nil {
  14767. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  14768. }
  14769. return oldValue.SourceID, nil
  14770. }
  14771. // ClearSourceID clears the value of the "source_id" field.
  14772. func (m *MessageRecordsMutation) ClearSourceID() {
  14773. m.sop_stage = nil
  14774. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14775. }
  14776. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  14777. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  14778. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  14779. return ok
  14780. }
  14781. // ResetSourceID resets all changes to the "source_id" field.
  14782. func (m *MessageRecordsMutation) ResetSourceID() {
  14783. m.sop_stage = nil
  14784. delete(m.clearedFields, messagerecords.FieldSourceID)
  14785. }
  14786. // SetSubSourceID sets the "sub_source_id" field.
  14787. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  14788. m.sop_node = &u
  14789. }
  14790. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  14791. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  14792. v := m.sop_node
  14793. if v == nil {
  14794. return
  14795. }
  14796. return *v, true
  14797. }
  14798. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  14799. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14801. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  14802. if !m.op.Is(OpUpdateOne) {
  14803. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  14804. }
  14805. if m.id == nil || m.oldValue == nil {
  14806. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  14807. }
  14808. oldValue, err := m.oldValue(ctx)
  14809. if err != nil {
  14810. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  14811. }
  14812. return oldValue.SubSourceID, nil
  14813. }
  14814. // ClearSubSourceID clears the value of the "sub_source_id" field.
  14815. func (m *MessageRecordsMutation) ClearSubSourceID() {
  14816. m.sop_node = nil
  14817. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14818. }
  14819. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  14820. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  14821. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  14822. return ok
  14823. }
  14824. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  14825. func (m *MessageRecordsMutation) ResetSubSourceID() {
  14826. m.sop_node = nil
  14827. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  14828. }
  14829. // SetOrganizationID sets the "organization_id" field.
  14830. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  14831. m.organization_id = &u
  14832. m.addorganization_id = nil
  14833. }
  14834. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14835. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  14836. v := m.organization_id
  14837. if v == nil {
  14838. return
  14839. }
  14840. return *v, true
  14841. }
  14842. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  14843. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14845. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14846. if !m.op.Is(OpUpdateOne) {
  14847. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14848. }
  14849. if m.id == nil || m.oldValue == nil {
  14850. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14851. }
  14852. oldValue, err := m.oldValue(ctx)
  14853. if err != nil {
  14854. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14855. }
  14856. return oldValue.OrganizationID, nil
  14857. }
  14858. // AddOrganizationID adds u to the "organization_id" field.
  14859. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  14860. if m.addorganization_id != nil {
  14861. *m.addorganization_id += u
  14862. } else {
  14863. m.addorganization_id = &u
  14864. }
  14865. }
  14866. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14867. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  14868. v := m.addorganization_id
  14869. if v == nil {
  14870. return
  14871. }
  14872. return *v, true
  14873. }
  14874. // ClearOrganizationID clears the value of the "organization_id" field.
  14875. func (m *MessageRecordsMutation) ClearOrganizationID() {
  14876. m.organization_id = nil
  14877. m.addorganization_id = nil
  14878. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  14879. }
  14880. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14881. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  14882. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  14883. return ok
  14884. }
  14885. // ResetOrganizationID resets all changes to the "organization_id" field.
  14886. func (m *MessageRecordsMutation) ResetOrganizationID() {
  14887. m.organization_id = nil
  14888. m.addorganization_id = nil
  14889. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  14890. }
  14891. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14892. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14893. m.sop_stage = &id
  14894. }
  14895. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14896. func (m *MessageRecordsMutation) ClearSopStage() {
  14897. m.clearedsop_stage = true
  14898. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14899. }
  14900. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14901. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14902. return m.SourceIDCleared() || m.clearedsop_stage
  14903. }
  14904. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14905. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14906. if m.sop_stage != nil {
  14907. return *m.sop_stage, true
  14908. }
  14909. return
  14910. }
  14911. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14912. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14913. // SopStageID instead. It exists only for internal usage by the builders.
  14914. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14915. if id := m.sop_stage; id != nil {
  14916. ids = append(ids, *id)
  14917. }
  14918. return
  14919. }
  14920. // ResetSopStage resets all changes to the "sop_stage" edge.
  14921. func (m *MessageRecordsMutation) ResetSopStage() {
  14922. m.sop_stage = nil
  14923. m.clearedsop_stage = false
  14924. }
  14925. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14926. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14927. m.sop_node = &id
  14928. }
  14929. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14930. func (m *MessageRecordsMutation) ClearSopNode() {
  14931. m.clearedsop_node = true
  14932. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14933. }
  14934. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14935. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14936. return m.SubSourceIDCleared() || m.clearedsop_node
  14937. }
  14938. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14939. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14940. if m.sop_node != nil {
  14941. return *m.sop_node, true
  14942. }
  14943. return
  14944. }
  14945. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14946. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14947. // SopNodeID instead. It exists only for internal usage by the builders.
  14948. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14949. if id := m.sop_node; id != nil {
  14950. ids = append(ids, *id)
  14951. }
  14952. return
  14953. }
  14954. // ResetSopNode resets all changes to the "sop_node" edge.
  14955. func (m *MessageRecordsMutation) ResetSopNode() {
  14956. m.sop_node = nil
  14957. m.clearedsop_node = false
  14958. }
  14959. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14960. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14961. m.message_contact = &id
  14962. }
  14963. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14964. func (m *MessageRecordsMutation) ClearMessageContact() {
  14965. m.clearedmessage_contact = true
  14966. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14967. }
  14968. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14969. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14970. return m.ContactIDCleared() || m.clearedmessage_contact
  14971. }
  14972. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14973. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14974. if m.message_contact != nil {
  14975. return *m.message_contact, true
  14976. }
  14977. return
  14978. }
  14979. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14980. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14981. // MessageContactID instead. It exists only for internal usage by the builders.
  14982. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14983. if id := m.message_contact; id != nil {
  14984. ids = append(ids, *id)
  14985. }
  14986. return
  14987. }
  14988. // ResetMessageContact resets all changes to the "message_contact" edge.
  14989. func (m *MessageRecordsMutation) ResetMessageContact() {
  14990. m.message_contact = nil
  14991. m.clearedmessage_contact = false
  14992. }
  14993. // Where appends a list predicates to the MessageRecordsMutation builder.
  14994. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14995. m.predicates = append(m.predicates, ps...)
  14996. }
  14997. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14998. // users can use type-assertion to append predicates that do not depend on any generated package.
  14999. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  15000. p := make([]predicate.MessageRecords, len(ps))
  15001. for i := range ps {
  15002. p[i] = ps[i]
  15003. }
  15004. m.Where(p...)
  15005. }
  15006. // Op returns the operation name.
  15007. func (m *MessageRecordsMutation) Op() Op {
  15008. return m.op
  15009. }
  15010. // SetOp allows setting the mutation operation.
  15011. func (m *MessageRecordsMutation) SetOp(op Op) {
  15012. m.op = op
  15013. }
  15014. // Type returns the node type of this mutation (MessageRecords).
  15015. func (m *MessageRecordsMutation) Type() string {
  15016. return m.typ
  15017. }
  15018. // Fields returns all fields that were changed during this mutation. Note that in
  15019. // order to get all numeric fields that were incremented/decremented, call
  15020. // AddedFields().
  15021. func (m *MessageRecordsMutation) Fields() []string {
  15022. fields := make([]string, 0, 16)
  15023. if m.created_at != nil {
  15024. fields = append(fields, messagerecords.FieldCreatedAt)
  15025. }
  15026. if m.updated_at != nil {
  15027. fields = append(fields, messagerecords.FieldUpdatedAt)
  15028. }
  15029. if m.status != nil {
  15030. fields = append(fields, messagerecords.FieldStatus)
  15031. }
  15032. if m.bot_wxid != nil {
  15033. fields = append(fields, messagerecords.FieldBotWxid)
  15034. }
  15035. if m.message_contact != nil {
  15036. fields = append(fields, messagerecords.FieldContactID)
  15037. }
  15038. if m.contact_type != nil {
  15039. fields = append(fields, messagerecords.FieldContactType)
  15040. }
  15041. if m.contact_wxid != nil {
  15042. fields = append(fields, messagerecords.FieldContactWxid)
  15043. }
  15044. if m.content_type != nil {
  15045. fields = append(fields, messagerecords.FieldContentType)
  15046. }
  15047. if m.content != nil {
  15048. fields = append(fields, messagerecords.FieldContent)
  15049. }
  15050. if m.meta != nil {
  15051. fields = append(fields, messagerecords.FieldMeta)
  15052. }
  15053. if m.error_detail != nil {
  15054. fields = append(fields, messagerecords.FieldErrorDetail)
  15055. }
  15056. if m.send_time != nil {
  15057. fields = append(fields, messagerecords.FieldSendTime)
  15058. }
  15059. if m.source_type != nil {
  15060. fields = append(fields, messagerecords.FieldSourceType)
  15061. }
  15062. if m.sop_stage != nil {
  15063. fields = append(fields, messagerecords.FieldSourceID)
  15064. }
  15065. if m.sop_node != nil {
  15066. fields = append(fields, messagerecords.FieldSubSourceID)
  15067. }
  15068. if m.organization_id != nil {
  15069. fields = append(fields, messagerecords.FieldOrganizationID)
  15070. }
  15071. return fields
  15072. }
  15073. // Field returns the value of a field with the given name. The second boolean
  15074. // return value indicates that this field was not set, or was not defined in the
  15075. // schema.
  15076. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  15077. switch name {
  15078. case messagerecords.FieldCreatedAt:
  15079. return m.CreatedAt()
  15080. case messagerecords.FieldUpdatedAt:
  15081. return m.UpdatedAt()
  15082. case messagerecords.FieldStatus:
  15083. return m.Status()
  15084. case messagerecords.FieldBotWxid:
  15085. return m.BotWxid()
  15086. case messagerecords.FieldContactID:
  15087. return m.ContactID()
  15088. case messagerecords.FieldContactType:
  15089. return m.ContactType()
  15090. case messagerecords.FieldContactWxid:
  15091. return m.ContactWxid()
  15092. case messagerecords.FieldContentType:
  15093. return m.ContentType()
  15094. case messagerecords.FieldContent:
  15095. return m.Content()
  15096. case messagerecords.FieldMeta:
  15097. return m.Meta()
  15098. case messagerecords.FieldErrorDetail:
  15099. return m.ErrorDetail()
  15100. case messagerecords.FieldSendTime:
  15101. return m.SendTime()
  15102. case messagerecords.FieldSourceType:
  15103. return m.SourceType()
  15104. case messagerecords.FieldSourceID:
  15105. return m.SourceID()
  15106. case messagerecords.FieldSubSourceID:
  15107. return m.SubSourceID()
  15108. case messagerecords.FieldOrganizationID:
  15109. return m.OrganizationID()
  15110. }
  15111. return nil, false
  15112. }
  15113. // OldField returns the old value of the field from the database. An error is
  15114. // returned if the mutation operation is not UpdateOne, or the query to the
  15115. // database failed.
  15116. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15117. switch name {
  15118. case messagerecords.FieldCreatedAt:
  15119. return m.OldCreatedAt(ctx)
  15120. case messagerecords.FieldUpdatedAt:
  15121. return m.OldUpdatedAt(ctx)
  15122. case messagerecords.FieldStatus:
  15123. return m.OldStatus(ctx)
  15124. case messagerecords.FieldBotWxid:
  15125. return m.OldBotWxid(ctx)
  15126. case messagerecords.FieldContactID:
  15127. return m.OldContactID(ctx)
  15128. case messagerecords.FieldContactType:
  15129. return m.OldContactType(ctx)
  15130. case messagerecords.FieldContactWxid:
  15131. return m.OldContactWxid(ctx)
  15132. case messagerecords.FieldContentType:
  15133. return m.OldContentType(ctx)
  15134. case messagerecords.FieldContent:
  15135. return m.OldContent(ctx)
  15136. case messagerecords.FieldMeta:
  15137. return m.OldMeta(ctx)
  15138. case messagerecords.FieldErrorDetail:
  15139. return m.OldErrorDetail(ctx)
  15140. case messagerecords.FieldSendTime:
  15141. return m.OldSendTime(ctx)
  15142. case messagerecords.FieldSourceType:
  15143. return m.OldSourceType(ctx)
  15144. case messagerecords.FieldSourceID:
  15145. return m.OldSourceID(ctx)
  15146. case messagerecords.FieldSubSourceID:
  15147. return m.OldSubSourceID(ctx)
  15148. case messagerecords.FieldOrganizationID:
  15149. return m.OldOrganizationID(ctx)
  15150. }
  15151. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15152. }
  15153. // SetField sets the value of a field with the given name. It returns an error if
  15154. // the field is not defined in the schema, or if the type mismatched the field
  15155. // type.
  15156. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15157. switch name {
  15158. case messagerecords.FieldCreatedAt:
  15159. v, ok := value.(time.Time)
  15160. if !ok {
  15161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15162. }
  15163. m.SetCreatedAt(v)
  15164. return nil
  15165. case messagerecords.FieldUpdatedAt:
  15166. v, ok := value.(time.Time)
  15167. if !ok {
  15168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15169. }
  15170. m.SetUpdatedAt(v)
  15171. return nil
  15172. case messagerecords.FieldStatus:
  15173. v, ok := value.(uint8)
  15174. if !ok {
  15175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15176. }
  15177. m.SetStatus(v)
  15178. return nil
  15179. case messagerecords.FieldBotWxid:
  15180. v, ok := value.(string)
  15181. if !ok {
  15182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15183. }
  15184. m.SetBotWxid(v)
  15185. return nil
  15186. case messagerecords.FieldContactID:
  15187. v, ok := value.(uint64)
  15188. if !ok {
  15189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15190. }
  15191. m.SetContactID(v)
  15192. return nil
  15193. case messagerecords.FieldContactType:
  15194. v, ok := value.(int)
  15195. if !ok {
  15196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15197. }
  15198. m.SetContactType(v)
  15199. return nil
  15200. case messagerecords.FieldContactWxid:
  15201. v, ok := value.(string)
  15202. if !ok {
  15203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15204. }
  15205. m.SetContactWxid(v)
  15206. return nil
  15207. case messagerecords.FieldContentType:
  15208. v, ok := value.(int)
  15209. if !ok {
  15210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15211. }
  15212. m.SetContentType(v)
  15213. return nil
  15214. case messagerecords.FieldContent:
  15215. v, ok := value.(string)
  15216. if !ok {
  15217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15218. }
  15219. m.SetContent(v)
  15220. return nil
  15221. case messagerecords.FieldMeta:
  15222. v, ok := value.(custom_types.Meta)
  15223. if !ok {
  15224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15225. }
  15226. m.SetMeta(v)
  15227. return nil
  15228. case messagerecords.FieldErrorDetail:
  15229. v, ok := value.(string)
  15230. if !ok {
  15231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15232. }
  15233. m.SetErrorDetail(v)
  15234. return nil
  15235. case messagerecords.FieldSendTime:
  15236. v, ok := value.(time.Time)
  15237. if !ok {
  15238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15239. }
  15240. m.SetSendTime(v)
  15241. return nil
  15242. case messagerecords.FieldSourceType:
  15243. v, ok := value.(int)
  15244. if !ok {
  15245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15246. }
  15247. m.SetSourceType(v)
  15248. return nil
  15249. case messagerecords.FieldSourceID:
  15250. v, ok := value.(uint64)
  15251. if !ok {
  15252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15253. }
  15254. m.SetSourceID(v)
  15255. return nil
  15256. case messagerecords.FieldSubSourceID:
  15257. v, ok := value.(uint64)
  15258. if !ok {
  15259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15260. }
  15261. m.SetSubSourceID(v)
  15262. return nil
  15263. case messagerecords.FieldOrganizationID:
  15264. v, ok := value.(uint64)
  15265. if !ok {
  15266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15267. }
  15268. m.SetOrganizationID(v)
  15269. return nil
  15270. }
  15271. return fmt.Errorf("unknown MessageRecords field %s", name)
  15272. }
  15273. // AddedFields returns all numeric fields that were incremented/decremented during
  15274. // this mutation.
  15275. func (m *MessageRecordsMutation) AddedFields() []string {
  15276. var fields []string
  15277. if m.addstatus != nil {
  15278. fields = append(fields, messagerecords.FieldStatus)
  15279. }
  15280. if m.addcontact_type != nil {
  15281. fields = append(fields, messagerecords.FieldContactType)
  15282. }
  15283. if m.addcontent_type != nil {
  15284. fields = append(fields, messagerecords.FieldContentType)
  15285. }
  15286. if m.addsource_type != nil {
  15287. fields = append(fields, messagerecords.FieldSourceType)
  15288. }
  15289. if m.addorganization_id != nil {
  15290. fields = append(fields, messagerecords.FieldOrganizationID)
  15291. }
  15292. return fields
  15293. }
  15294. // AddedField returns the numeric value that was incremented/decremented on a field
  15295. // with the given name. The second boolean return value indicates that this field
  15296. // was not set, or was not defined in the schema.
  15297. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  15298. switch name {
  15299. case messagerecords.FieldStatus:
  15300. return m.AddedStatus()
  15301. case messagerecords.FieldContactType:
  15302. return m.AddedContactType()
  15303. case messagerecords.FieldContentType:
  15304. return m.AddedContentType()
  15305. case messagerecords.FieldSourceType:
  15306. return m.AddedSourceType()
  15307. case messagerecords.FieldOrganizationID:
  15308. return m.AddedOrganizationID()
  15309. }
  15310. return nil, false
  15311. }
  15312. // AddField adds the value to the field with the given name. It returns an error if
  15313. // the field is not defined in the schema, or if the type mismatched the field
  15314. // type.
  15315. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  15316. switch name {
  15317. case messagerecords.FieldStatus:
  15318. v, ok := value.(int8)
  15319. if !ok {
  15320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15321. }
  15322. m.AddStatus(v)
  15323. return nil
  15324. case messagerecords.FieldContactType:
  15325. v, ok := value.(int)
  15326. if !ok {
  15327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15328. }
  15329. m.AddContactType(v)
  15330. return nil
  15331. case messagerecords.FieldContentType:
  15332. v, ok := value.(int)
  15333. if !ok {
  15334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15335. }
  15336. m.AddContentType(v)
  15337. return nil
  15338. case messagerecords.FieldSourceType:
  15339. v, ok := value.(int)
  15340. if !ok {
  15341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15342. }
  15343. m.AddSourceType(v)
  15344. return nil
  15345. case messagerecords.FieldOrganizationID:
  15346. v, ok := value.(int64)
  15347. if !ok {
  15348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15349. }
  15350. m.AddOrganizationID(v)
  15351. return nil
  15352. }
  15353. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  15354. }
  15355. // ClearedFields returns all nullable fields that were cleared during this
  15356. // mutation.
  15357. func (m *MessageRecordsMutation) ClearedFields() []string {
  15358. var fields []string
  15359. if m.FieldCleared(messagerecords.FieldStatus) {
  15360. fields = append(fields, messagerecords.FieldStatus)
  15361. }
  15362. if m.FieldCleared(messagerecords.FieldContactID) {
  15363. fields = append(fields, messagerecords.FieldContactID)
  15364. }
  15365. if m.FieldCleared(messagerecords.FieldMeta) {
  15366. fields = append(fields, messagerecords.FieldMeta)
  15367. }
  15368. if m.FieldCleared(messagerecords.FieldSendTime) {
  15369. fields = append(fields, messagerecords.FieldSendTime)
  15370. }
  15371. if m.FieldCleared(messagerecords.FieldSourceID) {
  15372. fields = append(fields, messagerecords.FieldSourceID)
  15373. }
  15374. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  15375. fields = append(fields, messagerecords.FieldSubSourceID)
  15376. }
  15377. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  15378. fields = append(fields, messagerecords.FieldOrganizationID)
  15379. }
  15380. return fields
  15381. }
  15382. // FieldCleared returns a boolean indicating if a field with the given name was
  15383. // cleared in this mutation.
  15384. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  15385. _, ok := m.clearedFields[name]
  15386. return ok
  15387. }
  15388. // ClearField clears the value of the field with the given name. It returns an
  15389. // error if the field is not defined in the schema.
  15390. func (m *MessageRecordsMutation) ClearField(name string) error {
  15391. switch name {
  15392. case messagerecords.FieldStatus:
  15393. m.ClearStatus()
  15394. return nil
  15395. case messagerecords.FieldContactID:
  15396. m.ClearContactID()
  15397. return nil
  15398. case messagerecords.FieldMeta:
  15399. m.ClearMeta()
  15400. return nil
  15401. case messagerecords.FieldSendTime:
  15402. m.ClearSendTime()
  15403. return nil
  15404. case messagerecords.FieldSourceID:
  15405. m.ClearSourceID()
  15406. return nil
  15407. case messagerecords.FieldSubSourceID:
  15408. m.ClearSubSourceID()
  15409. return nil
  15410. case messagerecords.FieldOrganizationID:
  15411. m.ClearOrganizationID()
  15412. return nil
  15413. }
  15414. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  15415. }
  15416. // ResetField resets all changes in the mutation for the field with the given name.
  15417. // It returns an error if the field is not defined in the schema.
  15418. func (m *MessageRecordsMutation) ResetField(name string) error {
  15419. switch name {
  15420. case messagerecords.FieldCreatedAt:
  15421. m.ResetCreatedAt()
  15422. return nil
  15423. case messagerecords.FieldUpdatedAt:
  15424. m.ResetUpdatedAt()
  15425. return nil
  15426. case messagerecords.FieldStatus:
  15427. m.ResetStatus()
  15428. return nil
  15429. case messagerecords.FieldBotWxid:
  15430. m.ResetBotWxid()
  15431. return nil
  15432. case messagerecords.FieldContactID:
  15433. m.ResetContactID()
  15434. return nil
  15435. case messagerecords.FieldContactType:
  15436. m.ResetContactType()
  15437. return nil
  15438. case messagerecords.FieldContactWxid:
  15439. m.ResetContactWxid()
  15440. return nil
  15441. case messagerecords.FieldContentType:
  15442. m.ResetContentType()
  15443. return nil
  15444. case messagerecords.FieldContent:
  15445. m.ResetContent()
  15446. return nil
  15447. case messagerecords.FieldMeta:
  15448. m.ResetMeta()
  15449. return nil
  15450. case messagerecords.FieldErrorDetail:
  15451. m.ResetErrorDetail()
  15452. return nil
  15453. case messagerecords.FieldSendTime:
  15454. m.ResetSendTime()
  15455. return nil
  15456. case messagerecords.FieldSourceType:
  15457. m.ResetSourceType()
  15458. return nil
  15459. case messagerecords.FieldSourceID:
  15460. m.ResetSourceID()
  15461. return nil
  15462. case messagerecords.FieldSubSourceID:
  15463. m.ResetSubSourceID()
  15464. return nil
  15465. case messagerecords.FieldOrganizationID:
  15466. m.ResetOrganizationID()
  15467. return nil
  15468. }
  15469. return fmt.Errorf("unknown MessageRecords field %s", name)
  15470. }
  15471. // AddedEdges returns all edge names that were set/added in this mutation.
  15472. func (m *MessageRecordsMutation) AddedEdges() []string {
  15473. edges := make([]string, 0, 3)
  15474. if m.sop_stage != nil {
  15475. edges = append(edges, messagerecords.EdgeSopStage)
  15476. }
  15477. if m.sop_node != nil {
  15478. edges = append(edges, messagerecords.EdgeSopNode)
  15479. }
  15480. if m.message_contact != nil {
  15481. edges = append(edges, messagerecords.EdgeMessageContact)
  15482. }
  15483. return edges
  15484. }
  15485. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15486. // name in this mutation.
  15487. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  15488. switch name {
  15489. case messagerecords.EdgeSopStage:
  15490. if id := m.sop_stage; id != nil {
  15491. return []ent.Value{*id}
  15492. }
  15493. case messagerecords.EdgeSopNode:
  15494. if id := m.sop_node; id != nil {
  15495. return []ent.Value{*id}
  15496. }
  15497. case messagerecords.EdgeMessageContact:
  15498. if id := m.message_contact; id != nil {
  15499. return []ent.Value{*id}
  15500. }
  15501. }
  15502. return nil
  15503. }
  15504. // RemovedEdges returns all edge names that were removed in this mutation.
  15505. func (m *MessageRecordsMutation) RemovedEdges() []string {
  15506. edges := make([]string, 0, 3)
  15507. return edges
  15508. }
  15509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15510. // the given name in this mutation.
  15511. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  15512. return nil
  15513. }
  15514. // ClearedEdges returns all edge names that were cleared in this mutation.
  15515. func (m *MessageRecordsMutation) ClearedEdges() []string {
  15516. edges := make([]string, 0, 3)
  15517. if m.clearedsop_stage {
  15518. edges = append(edges, messagerecords.EdgeSopStage)
  15519. }
  15520. if m.clearedsop_node {
  15521. edges = append(edges, messagerecords.EdgeSopNode)
  15522. }
  15523. if m.clearedmessage_contact {
  15524. edges = append(edges, messagerecords.EdgeMessageContact)
  15525. }
  15526. return edges
  15527. }
  15528. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15529. // was cleared in this mutation.
  15530. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  15531. switch name {
  15532. case messagerecords.EdgeSopStage:
  15533. return m.clearedsop_stage
  15534. case messagerecords.EdgeSopNode:
  15535. return m.clearedsop_node
  15536. case messagerecords.EdgeMessageContact:
  15537. return m.clearedmessage_contact
  15538. }
  15539. return false
  15540. }
  15541. // ClearEdge clears the value of the edge with the given name. It returns an error
  15542. // if that edge is not defined in the schema.
  15543. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  15544. switch name {
  15545. case messagerecords.EdgeSopStage:
  15546. m.ClearSopStage()
  15547. return nil
  15548. case messagerecords.EdgeSopNode:
  15549. m.ClearSopNode()
  15550. return nil
  15551. case messagerecords.EdgeMessageContact:
  15552. m.ClearMessageContact()
  15553. return nil
  15554. }
  15555. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  15556. }
  15557. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15558. // It returns an error if the edge is not defined in the schema.
  15559. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  15560. switch name {
  15561. case messagerecords.EdgeSopStage:
  15562. m.ResetSopStage()
  15563. return nil
  15564. case messagerecords.EdgeSopNode:
  15565. m.ResetSopNode()
  15566. return nil
  15567. case messagerecords.EdgeMessageContact:
  15568. m.ResetMessageContact()
  15569. return nil
  15570. }
  15571. return fmt.Errorf("unknown MessageRecords edge %s", name)
  15572. }
  15573. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  15574. type MsgMutation struct {
  15575. config
  15576. op Op
  15577. typ string
  15578. id *uint64
  15579. created_at *time.Time
  15580. updated_at *time.Time
  15581. deleted_at *time.Time
  15582. status *uint8
  15583. addstatus *int8
  15584. fromwxid *string
  15585. toid *string
  15586. msgtype *int32
  15587. addmsgtype *int32
  15588. msg *string
  15589. batch_no *string
  15590. clearedFields map[string]struct{}
  15591. done bool
  15592. oldValue func(context.Context) (*Msg, error)
  15593. predicates []predicate.Msg
  15594. }
  15595. var _ ent.Mutation = (*MsgMutation)(nil)
  15596. // msgOption allows management of the mutation configuration using functional options.
  15597. type msgOption func(*MsgMutation)
  15598. // newMsgMutation creates new mutation for the Msg entity.
  15599. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  15600. m := &MsgMutation{
  15601. config: c,
  15602. op: op,
  15603. typ: TypeMsg,
  15604. clearedFields: make(map[string]struct{}),
  15605. }
  15606. for _, opt := range opts {
  15607. opt(m)
  15608. }
  15609. return m
  15610. }
  15611. // withMsgID sets the ID field of the mutation.
  15612. func withMsgID(id uint64) msgOption {
  15613. return func(m *MsgMutation) {
  15614. var (
  15615. err error
  15616. once sync.Once
  15617. value *Msg
  15618. )
  15619. m.oldValue = func(ctx context.Context) (*Msg, error) {
  15620. once.Do(func() {
  15621. if m.done {
  15622. err = errors.New("querying old values post mutation is not allowed")
  15623. } else {
  15624. value, err = m.Client().Msg.Get(ctx, id)
  15625. }
  15626. })
  15627. return value, err
  15628. }
  15629. m.id = &id
  15630. }
  15631. }
  15632. // withMsg sets the old Msg of the mutation.
  15633. func withMsg(node *Msg) msgOption {
  15634. return func(m *MsgMutation) {
  15635. m.oldValue = func(context.Context) (*Msg, error) {
  15636. return node, nil
  15637. }
  15638. m.id = &node.ID
  15639. }
  15640. }
  15641. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15642. // executed in a transaction (ent.Tx), a transactional client is returned.
  15643. func (m MsgMutation) Client() *Client {
  15644. client := &Client{config: m.config}
  15645. client.init()
  15646. return client
  15647. }
  15648. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15649. // it returns an error otherwise.
  15650. func (m MsgMutation) Tx() (*Tx, error) {
  15651. if _, ok := m.driver.(*txDriver); !ok {
  15652. return nil, errors.New("ent: mutation is not running in a transaction")
  15653. }
  15654. tx := &Tx{config: m.config}
  15655. tx.init()
  15656. return tx, nil
  15657. }
  15658. // SetID sets the value of the id field. Note that this
  15659. // operation is only accepted on creation of Msg entities.
  15660. func (m *MsgMutation) SetID(id uint64) {
  15661. m.id = &id
  15662. }
  15663. // ID returns the ID value in the mutation. Note that the ID is only available
  15664. // if it was provided to the builder or after it was returned from the database.
  15665. func (m *MsgMutation) ID() (id uint64, exists bool) {
  15666. if m.id == nil {
  15667. return
  15668. }
  15669. return *m.id, true
  15670. }
  15671. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15672. // That means, if the mutation is applied within a transaction with an isolation level such
  15673. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15674. // or updated by the mutation.
  15675. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  15676. switch {
  15677. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15678. id, exists := m.ID()
  15679. if exists {
  15680. return []uint64{id}, nil
  15681. }
  15682. fallthrough
  15683. case m.op.Is(OpUpdate | OpDelete):
  15684. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  15685. default:
  15686. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15687. }
  15688. }
  15689. // SetCreatedAt sets the "created_at" field.
  15690. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  15691. m.created_at = &t
  15692. }
  15693. // CreatedAt returns the value of the "created_at" field in the mutation.
  15694. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  15695. v := m.created_at
  15696. if v == nil {
  15697. return
  15698. }
  15699. return *v, true
  15700. }
  15701. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  15702. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15704. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15705. if !m.op.Is(OpUpdateOne) {
  15706. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15707. }
  15708. if m.id == nil || m.oldValue == nil {
  15709. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15710. }
  15711. oldValue, err := m.oldValue(ctx)
  15712. if err != nil {
  15713. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15714. }
  15715. return oldValue.CreatedAt, nil
  15716. }
  15717. // ResetCreatedAt resets all changes to the "created_at" field.
  15718. func (m *MsgMutation) ResetCreatedAt() {
  15719. m.created_at = nil
  15720. }
  15721. // SetUpdatedAt sets the "updated_at" field.
  15722. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  15723. m.updated_at = &t
  15724. }
  15725. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15726. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  15727. v := m.updated_at
  15728. if v == nil {
  15729. return
  15730. }
  15731. return *v, true
  15732. }
  15733. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  15734. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15736. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15737. if !m.op.Is(OpUpdateOne) {
  15738. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15739. }
  15740. if m.id == nil || m.oldValue == nil {
  15741. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15742. }
  15743. oldValue, err := m.oldValue(ctx)
  15744. if err != nil {
  15745. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15746. }
  15747. return oldValue.UpdatedAt, nil
  15748. }
  15749. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15750. func (m *MsgMutation) ResetUpdatedAt() {
  15751. m.updated_at = nil
  15752. }
  15753. // SetDeletedAt sets the "deleted_at" field.
  15754. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  15755. m.deleted_at = &t
  15756. }
  15757. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15758. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  15759. v := m.deleted_at
  15760. if v == nil {
  15761. return
  15762. }
  15763. return *v, true
  15764. }
  15765. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  15766. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15768. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15769. if !m.op.Is(OpUpdateOne) {
  15770. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15771. }
  15772. if m.id == nil || m.oldValue == nil {
  15773. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15774. }
  15775. oldValue, err := m.oldValue(ctx)
  15776. if err != nil {
  15777. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15778. }
  15779. return oldValue.DeletedAt, nil
  15780. }
  15781. // ClearDeletedAt clears the value of the "deleted_at" field.
  15782. func (m *MsgMutation) ClearDeletedAt() {
  15783. m.deleted_at = nil
  15784. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  15785. }
  15786. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15787. func (m *MsgMutation) DeletedAtCleared() bool {
  15788. _, ok := m.clearedFields[msg.FieldDeletedAt]
  15789. return ok
  15790. }
  15791. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15792. func (m *MsgMutation) ResetDeletedAt() {
  15793. m.deleted_at = nil
  15794. delete(m.clearedFields, msg.FieldDeletedAt)
  15795. }
  15796. // SetStatus sets the "status" field.
  15797. func (m *MsgMutation) SetStatus(u uint8) {
  15798. m.status = &u
  15799. m.addstatus = nil
  15800. }
  15801. // Status returns the value of the "status" field in the mutation.
  15802. func (m *MsgMutation) Status() (r uint8, exists bool) {
  15803. v := m.status
  15804. if v == nil {
  15805. return
  15806. }
  15807. return *v, true
  15808. }
  15809. // OldStatus returns the old "status" field's value of the Msg entity.
  15810. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15812. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15813. if !m.op.Is(OpUpdateOne) {
  15814. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15815. }
  15816. if m.id == nil || m.oldValue == nil {
  15817. return v, errors.New("OldStatus requires an ID field in the mutation")
  15818. }
  15819. oldValue, err := m.oldValue(ctx)
  15820. if err != nil {
  15821. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15822. }
  15823. return oldValue.Status, nil
  15824. }
  15825. // AddStatus adds u to the "status" field.
  15826. func (m *MsgMutation) AddStatus(u int8) {
  15827. if m.addstatus != nil {
  15828. *m.addstatus += u
  15829. } else {
  15830. m.addstatus = &u
  15831. }
  15832. }
  15833. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15834. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  15835. v := m.addstatus
  15836. if v == nil {
  15837. return
  15838. }
  15839. return *v, true
  15840. }
  15841. // ClearStatus clears the value of the "status" field.
  15842. func (m *MsgMutation) ClearStatus() {
  15843. m.status = nil
  15844. m.addstatus = nil
  15845. m.clearedFields[msg.FieldStatus] = struct{}{}
  15846. }
  15847. // StatusCleared returns if the "status" field was cleared in this mutation.
  15848. func (m *MsgMutation) StatusCleared() bool {
  15849. _, ok := m.clearedFields[msg.FieldStatus]
  15850. return ok
  15851. }
  15852. // ResetStatus resets all changes to the "status" field.
  15853. func (m *MsgMutation) ResetStatus() {
  15854. m.status = nil
  15855. m.addstatus = nil
  15856. delete(m.clearedFields, msg.FieldStatus)
  15857. }
  15858. // SetFromwxid sets the "fromwxid" field.
  15859. func (m *MsgMutation) SetFromwxid(s string) {
  15860. m.fromwxid = &s
  15861. }
  15862. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  15863. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  15864. v := m.fromwxid
  15865. if v == nil {
  15866. return
  15867. }
  15868. return *v, true
  15869. }
  15870. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  15871. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15873. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  15874. if !m.op.Is(OpUpdateOne) {
  15875. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  15876. }
  15877. if m.id == nil || m.oldValue == nil {
  15878. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  15879. }
  15880. oldValue, err := m.oldValue(ctx)
  15881. if err != nil {
  15882. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  15883. }
  15884. return oldValue.Fromwxid, nil
  15885. }
  15886. // ClearFromwxid clears the value of the "fromwxid" field.
  15887. func (m *MsgMutation) ClearFromwxid() {
  15888. m.fromwxid = nil
  15889. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  15890. }
  15891. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  15892. func (m *MsgMutation) FromwxidCleared() bool {
  15893. _, ok := m.clearedFields[msg.FieldFromwxid]
  15894. return ok
  15895. }
  15896. // ResetFromwxid resets all changes to the "fromwxid" field.
  15897. func (m *MsgMutation) ResetFromwxid() {
  15898. m.fromwxid = nil
  15899. delete(m.clearedFields, msg.FieldFromwxid)
  15900. }
  15901. // SetToid sets the "toid" field.
  15902. func (m *MsgMutation) SetToid(s string) {
  15903. m.toid = &s
  15904. }
  15905. // Toid returns the value of the "toid" field in the mutation.
  15906. func (m *MsgMutation) Toid() (r string, exists bool) {
  15907. v := m.toid
  15908. if v == nil {
  15909. return
  15910. }
  15911. return *v, true
  15912. }
  15913. // OldToid returns the old "toid" field's value of the Msg entity.
  15914. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15916. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15917. if !m.op.Is(OpUpdateOne) {
  15918. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15919. }
  15920. if m.id == nil || m.oldValue == nil {
  15921. return v, errors.New("OldToid requires an ID field in the mutation")
  15922. }
  15923. oldValue, err := m.oldValue(ctx)
  15924. if err != nil {
  15925. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15926. }
  15927. return oldValue.Toid, nil
  15928. }
  15929. // ClearToid clears the value of the "toid" field.
  15930. func (m *MsgMutation) ClearToid() {
  15931. m.toid = nil
  15932. m.clearedFields[msg.FieldToid] = struct{}{}
  15933. }
  15934. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15935. func (m *MsgMutation) ToidCleared() bool {
  15936. _, ok := m.clearedFields[msg.FieldToid]
  15937. return ok
  15938. }
  15939. // ResetToid resets all changes to the "toid" field.
  15940. func (m *MsgMutation) ResetToid() {
  15941. m.toid = nil
  15942. delete(m.clearedFields, msg.FieldToid)
  15943. }
  15944. // SetMsgtype sets the "msgtype" field.
  15945. func (m *MsgMutation) SetMsgtype(i int32) {
  15946. m.msgtype = &i
  15947. m.addmsgtype = nil
  15948. }
  15949. // Msgtype returns the value of the "msgtype" field in the mutation.
  15950. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15951. v := m.msgtype
  15952. if v == nil {
  15953. return
  15954. }
  15955. return *v, true
  15956. }
  15957. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15958. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15960. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15961. if !m.op.Is(OpUpdateOne) {
  15962. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15963. }
  15964. if m.id == nil || m.oldValue == nil {
  15965. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15966. }
  15967. oldValue, err := m.oldValue(ctx)
  15968. if err != nil {
  15969. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15970. }
  15971. return oldValue.Msgtype, nil
  15972. }
  15973. // AddMsgtype adds i to the "msgtype" field.
  15974. func (m *MsgMutation) AddMsgtype(i int32) {
  15975. if m.addmsgtype != nil {
  15976. *m.addmsgtype += i
  15977. } else {
  15978. m.addmsgtype = &i
  15979. }
  15980. }
  15981. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15982. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15983. v := m.addmsgtype
  15984. if v == nil {
  15985. return
  15986. }
  15987. return *v, true
  15988. }
  15989. // ClearMsgtype clears the value of the "msgtype" field.
  15990. func (m *MsgMutation) ClearMsgtype() {
  15991. m.msgtype = nil
  15992. m.addmsgtype = nil
  15993. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15994. }
  15995. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15996. func (m *MsgMutation) MsgtypeCleared() bool {
  15997. _, ok := m.clearedFields[msg.FieldMsgtype]
  15998. return ok
  15999. }
  16000. // ResetMsgtype resets all changes to the "msgtype" field.
  16001. func (m *MsgMutation) ResetMsgtype() {
  16002. m.msgtype = nil
  16003. m.addmsgtype = nil
  16004. delete(m.clearedFields, msg.FieldMsgtype)
  16005. }
  16006. // SetMsg sets the "msg" field.
  16007. func (m *MsgMutation) SetMsg(s string) {
  16008. m.msg = &s
  16009. }
  16010. // Msg returns the value of the "msg" field in the mutation.
  16011. func (m *MsgMutation) Msg() (r string, exists bool) {
  16012. v := m.msg
  16013. if v == nil {
  16014. return
  16015. }
  16016. return *v, true
  16017. }
  16018. // OldMsg returns the old "msg" field's value of the Msg entity.
  16019. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16021. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  16022. if !m.op.Is(OpUpdateOne) {
  16023. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  16024. }
  16025. if m.id == nil || m.oldValue == nil {
  16026. return v, errors.New("OldMsg requires an ID field in the mutation")
  16027. }
  16028. oldValue, err := m.oldValue(ctx)
  16029. if err != nil {
  16030. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  16031. }
  16032. return oldValue.Msg, nil
  16033. }
  16034. // ClearMsg clears the value of the "msg" field.
  16035. func (m *MsgMutation) ClearMsg() {
  16036. m.msg = nil
  16037. m.clearedFields[msg.FieldMsg] = struct{}{}
  16038. }
  16039. // MsgCleared returns if the "msg" field was cleared in this mutation.
  16040. func (m *MsgMutation) MsgCleared() bool {
  16041. _, ok := m.clearedFields[msg.FieldMsg]
  16042. return ok
  16043. }
  16044. // ResetMsg resets all changes to the "msg" field.
  16045. func (m *MsgMutation) ResetMsg() {
  16046. m.msg = nil
  16047. delete(m.clearedFields, msg.FieldMsg)
  16048. }
  16049. // SetBatchNo sets the "batch_no" field.
  16050. func (m *MsgMutation) SetBatchNo(s string) {
  16051. m.batch_no = &s
  16052. }
  16053. // BatchNo returns the value of the "batch_no" field in the mutation.
  16054. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  16055. v := m.batch_no
  16056. if v == nil {
  16057. return
  16058. }
  16059. return *v, true
  16060. }
  16061. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  16062. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16064. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  16065. if !m.op.Is(OpUpdateOne) {
  16066. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  16067. }
  16068. if m.id == nil || m.oldValue == nil {
  16069. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  16070. }
  16071. oldValue, err := m.oldValue(ctx)
  16072. if err != nil {
  16073. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  16074. }
  16075. return oldValue.BatchNo, nil
  16076. }
  16077. // ClearBatchNo clears the value of the "batch_no" field.
  16078. func (m *MsgMutation) ClearBatchNo() {
  16079. m.batch_no = nil
  16080. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  16081. }
  16082. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  16083. func (m *MsgMutation) BatchNoCleared() bool {
  16084. _, ok := m.clearedFields[msg.FieldBatchNo]
  16085. return ok
  16086. }
  16087. // ResetBatchNo resets all changes to the "batch_no" field.
  16088. func (m *MsgMutation) ResetBatchNo() {
  16089. m.batch_no = nil
  16090. delete(m.clearedFields, msg.FieldBatchNo)
  16091. }
  16092. // Where appends a list predicates to the MsgMutation builder.
  16093. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  16094. m.predicates = append(m.predicates, ps...)
  16095. }
  16096. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  16097. // users can use type-assertion to append predicates that do not depend on any generated package.
  16098. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  16099. p := make([]predicate.Msg, len(ps))
  16100. for i := range ps {
  16101. p[i] = ps[i]
  16102. }
  16103. m.Where(p...)
  16104. }
  16105. // Op returns the operation name.
  16106. func (m *MsgMutation) Op() Op {
  16107. return m.op
  16108. }
  16109. // SetOp allows setting the mutation operation.
  16110. func (m *MsgMutation) SetOp(op Op) {
  16111. m.op = op
  16112. }
  16113. // Type returns the node type of this mutation (Msg).
  16114. func (m *MsgMutation) Type() string {
  16115. return m.typ
  16116. }
  16117. // Fields returns all fields that were changed during this mutation. Note that in
  16118. // order to get all numeric fields that were incremented/decremented, call
  16119. // AddedFields().
  16120. func (m *MsgMutation) Fields() []string {
  16121. fields := make([]string, 0, 9)
  16122. if m.created_at != nil {
  16123. fields = append(fields, msg.FieldCreatedAt)
  16124. }
  16125. if m.updated_at != nil {
  16126. fields = append(fields, msg.FieldUpdatedAt)
  16127. }
  16128. if m.deleted_at != nil {
  16129. fields = append(fields, msg.FieldDeletedAt)
  16130. }
  16131. if m.status != nil {
  16132. fields = append(fields, msg.FieldStatus)
  16133. }
  16134. if m.fromwxid != nil {
  16135. fields = append(fields, msg.FieldFromwxid)
  16136. }
  16137. if m.toid != nil {
  16138. fields = append(fields, msg.FieldToid)
  16139. }
  16140. if m.msgtype != nil {
  16141. fields = append(fields, msg.FieldMsgtype)
  16142. }
  16143. if m.msg != nil {
  16144. fields = append(fields, msg.FieldMsg)
  16145. }
  16146. if m.batch_no != nil {
  16147. fields = append(fields, msg.FieldBatchNo)
  16148. }
  16149. return fields
  16150. }
  16151. // Field returns the value of a field with the given name. The second boolean
  16152. // return value indicates that this field was not set, or was not defined in the
  16153. // schema.
  16154. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16155. switch name {
  16156. case msg.FieldCreatedAt:
  16157. return m.CreatedAt()
  16158. case msg.FieldUpdatedAt:
  16159. return m.UpdatedAt()
  16160. case msg.FieldDeletedAt:
  16161. return m.DeletedAt()
  16162. case msg.FieldStatus:
  16163. return m.Status()
  16164. case msg.FieldFromwxid:
  16165. return m.Fromwxid()
  16166. case msg.FieldToid:
  16167. return m.Toid()
  16168. case msg.FieldMsgtype:
  16169. return m.Msgtype()
  16170. case msg.FieldMsg:
  16171. return m.Msg()
  16172. case msg.FieldBatchNo:
  16173. return m.BatchNo()
  16174. }
  16175. return nil, false
  16176. }
  16177. // OldField returns the old value of the field from the database. An error is
  16178. // returned if the mutation operation is not UpdateOne, or the query to the
  16179. // database failed.
  16180. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16181. switch name {
  16182. case msg.FieldCreatedAt:
  16183. return m.OldCreatedAt(ctx)
  16184. case msg.FieldUpdatedAt:
  16185. return m.OldUpdatedAt(ctx)
  16186. case msg.FieldDeletedAt:
  16187. return m.OldDeletedAt(ctx)
  16188. case msg.FieldStatus:
  16189. return m.OldStatus(ctx)
  16190. case msg.FieldFromwxid:
  16191. return m.OldFromwxid(ctx)
  16192. case msg.FieldToid:
  16193. return m.OldToid(ctx)
  16194. case msg.FieldMsgtype:
  16195. return m.OldMsgtype(ctx)
  16196. case msg.FieldMsg:
  16197. return m.OldMsg(ctx)
  16198. case msg.FieldBatchNo:
  16199. return m.OldBatchNo(ctx)
  16200. }
  16201. return nil, fmt.Errorf("unknown Msg field %s", name)
  16202. }
  16203. // SetField sets the value of a field with the given name. It returns an error if
  16204. // the field is not defined in the schema, or if the type mismatched the field
  16205. // type.
  16206. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16207. switch name {
  16208. case msg.FieldCreatedAt:
  16209. v, ok := value.(time.Time)
  16210. if !ok {
  16211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16212. }
  16213. m.SetCreatedAt(v)
  16214. return nil
  16215. case msg.FieldUpdatedAt:
  16216. v, ok := value.(time.Time)
  16217. if !ok {
  16218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16219. }
  16220. m.SetUpdatedAt(v)
  16221. return nil
  16222. case msg.FieldDeletedAt:
  16223. v, ok := value.(time.Time)
  16224. if !ok {
  16225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16226. }
  16227. m.SetDeletedAt(v)
  16228. return nil
  16229. case msg.FieldStatus:
  16230. v, ok := value.(uint8)
  16231. if !ok {
  16232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16233. }
  16234. m.SetStatus(v)
  16235. return nil
  16236. case msg.FieldFromwxid:
  16237. v, ok := value.(string)
  16238. if !ok {
  16239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16240. }
  16241. m.SetFromwxid(v)
  16242. return nil
  16243. case msg.FieldToid:
  16244. v, ok := value.(string)
  16245. if !ok {
  16246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16247. }
  16248. m.SetToid(v)
  16249. return nil
  16250. case msg.FieldMsgtype:
  16251. v, ok := value.(int32)
  16252. if !ok {
  16253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16254. }
  16255. m.SetMsgtype(v)
  16256. return nil
  16257. case msg.FieldMsg:
  16258. v, ok := value.(string)
  16259. if !ok {
  16260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16261. }
  16262. m.SetMsg(v)
  16263. return nil
  16264. case msg.FieldBatchNo:
  16265. v, ok := value.(string)
  16266. if !ok {
  16267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16268. }
  16269. m.SetBatchNo(v)
  16270. return nil
  16271. }
  16272. return fmt.Errorf("unknown Msg field %s", name)
  16273. }
  16274. // AddedFields returns all numeric fields that were incremented/decremented during
  16275. // this mutation.
  16276. func (m *MsgMutation) AddedFields() []string {
  16277. var fields []string
  16278. if m.addstatus != nil {
  16279. fields = append(fields, msg.FieldStatus)
  16280. }
  16281. if m.addmsgtype != nil {
  16282. fields = append(fields, msg.FieldMsgtype)
  16283. }
  16284. return fields
  16285. }
  16286. // AddedField returns the numeric value that was incremented/decremented on a field
  16287. // with the given name. The second boolean return value indicates that this field
  16288. // was not set, or was not defined in the schema.
  16289. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  16290. switch name {
  16291. case msg.FieldStatus:
  16292. return m.AddedStatus()
  16293. case msg.FieldMsgtype:
  16294. return m.AddedMsgtype()
  16295. }
  16296. return nil, false
  16297. }
  16298. // AddField adds the value to the field with the given name. It returns an error if
  16299. // the field is not defined in the schema, or if the type mismatched the field
  16300. // type.
  16301. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  16302. switch name {
  16303. case msg.FieldStatus:
  16304. v, ok := value.(int8)
  16305. if !ok {
  16306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16307. }
  16308. m.AddStatus(v)
  16309. return nil
  16310. case msg.FieldMsgtype:
  16311. v, ok := value.(int32)
  16312. if !ok {
  16313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16314. }
  16315. m.AddMsgtype(v)
  16316. return nil
  16317. }
  16318. return fmt.Errorf("unknown Msg numeric field %s", name)
  16319. }
  16320. // ClearedFields returns all nullable fields that were cleared during this
  16321. // mutation.
  16322. func (m *MsgMutation) ClearedFields() []string {
  16323. var fields []string
  16324. if m.FieldCleared(msg.FieldDeletedAt) {
  16325. fields = append(fields, msg.FieldDeletedAt)
  16326. }
  16327. if m.FieldCleared(msg.FieldStatus) {
  16328. fields = append(fields, msg.FieldStatus)
  16329. }
  16330. if m.FieldCleared(msg.FieldFromwxid) {
  16331. fields = append(fields, msg.FieldFromwxid)
  16332. }
  16333. if m.FieldCleared(msg.FieldToid) {
  16334. fields = append(fields, msg.FieldToid)
  16335. }
  16336. if m.FieldCleared(msg.FieldMsgtype) {
  16337. fields = append(fields, msg.FieldMsgtype)
  16338. }
  16339. if m.FieldCleared(msg.FieldMsg) {
  16340. fields = append(fields, msg.FieldMsg)
  16341. }
  16342. if m.FieldCleared(msg.FieldBatchNo) {
  16343. fields = append(fields, msg.FieldBatchNo)
  16344. }
  16345. return fields
  16346. }
  16347. // FieldCleared returns a boolean indicating if a field with the given name was
  16348. // cleared in this mutation.
  16349. func (m *MsgMutation) FieldCleared(name string) bool {
  16350. _, ok := m.clearedFields[name]
  16351. return ok
  16352. }
  16353. // ClearField clears the value of the field with the given name. It returns an
  16354. // error if the field is not defined in the schema.
  16355. func (m *MsgMutation) ClearField(name string) error {
  16356. switch name {
  16357. case msg.FieldDeletedAt:
  16358. m.ClearDeletedAt()
  16359. return nil
  16360. case msg.FieldStatus:
  16361. m.ClearStatus()
  16362. return nil
  16363. case msg.FieldFromwxid:
  16364. m.ClearFromwxid()
  16365. return nil
  16366. case msg.FieldToid:
  16367. m.ClearToid()
  16368. return nil
  16369. case msg.FieldMsgtype:
  16370. m.ClearMsgtype()
  16371. return nil
  16372. case msg.FieldMsg:
  16373. m.ClearMsg()
  16374. return nil
  16375. case msg.FieldBatchNo:
  16376. m.ClearBatchNo()
  16377. return nil
  16378. }
  16379. return fmt.Errorf("unknown Msg nullable field %s", name)
  16380. }
  16381. // ResetField resets all changes in the mutation for the field with the given name.
  16382. // It returns an error if the field is not defined in the schema.
  16383. func (m *MsgMutation) ResetField(name string) error {
  16384. switch name {
  16385. case msg.FieldCreatedAt:
  16386. m.ResetCreatedAt()
  16387. return nil
  16388. case msg.FieldUpdatedAt:
  16389. m.ResetUpdatedAt()
  16390. return nil
  16391. case msg.FieldDeletedAt:
  16392. m.ResetDeletedAt()
  16393. return nil
  16394. case msg.FieldStatus:
  16395. m.ResetStatus()
  16396. return nil
  16397. case msg.FieldFromwxid:
  16398. m.ResetFromwxid()
  16399. return nil
  16400. case msg.FieldToid:
  16401. m.ResetToid()
  16402. return nil
  16403. case msg.FieldMsgtype:
  16404. m.ResetMsgtype()
  16405. return nil
  16406. case msg.FieldMsg:
  16407. m.ResetMsg()
  16408. return nil
  16409. case msg.FieldBatchNo:
  16410. m.ResetBatchNo()
  16411. return nil
  16412. }
  16413. return fmt.Errorf("unknown Msg field %s", name)
  16414. }
  16415. // AddedEdges returns all edge names that were set/added in this mutation.
  16416. func (m *MsgMutation) AddedEdges() []string {
  16417. edges := make([]string, 0, 0)
  16418. return edges
  16419. }
  16420. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16421. // name in this mutation.
  16422. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  16423. return nil
  16424. }
  16425. // RemovedEdges returns all edge names that were removed in this mutation.
  16426. func (m *MsgMutation) RemovedEdges() []string {
  16427. edges := make([]string, 0, 0)
  16428. return edges
  16429. }
  16430. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16431. // the given name in this mutation.
  16432. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  16433. return nil
  16434. }
  16435. // ClearedEdges returns all edge names that were cleared in this mutation.
  16436. func (m *MsgMutation) ClearedEdges() []string {
  16437. edges := make([]string, 0, 0)
  16438. return edges
  16439. }
  16440. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16441. // was cleared in this mutation.
  16442. func (m *MsgMutation) EdgeCleared(name string) bool {
  16443. return false
  16444. }
  16445. // ClearEdge clears the value of the edge with the given name. It returns an error
  16446. // if that edge is not defined in the schema.
  16447. func (m *MsgMutation) ClearEdge(name string) error {
  16448. return fmt.Errorf("unknown Msg unique edge %s", name)
  16449. }
  16450. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16451. // It returns an error if the edge is not defined in the schema.
  16452. func (m *MsgMutation) ResetEdge(name string) error {
  16453. return fmt.Errorf("unknown Msg edge %s", name)
  16454. }
  16455. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  16456. type ServerMutation struct {
  16457. config
  16458. op Op
  16459. typ string
  16460. id *uint64
  16461. created_at *time.Time
  16462. updated_at *time.Time
  16463. status *uint8
  16464. addstatus *int8
  16465. deleted_at *time.Time
  16466. name *string
  16467. public_ip *string
  16468. private_ip *string
  16469. admin_port *string
  16470. clearedFields map[string]struct{}
  16471. wxs map[uint64]struct{}
  16472. removedwxs map[uint64]struct{}
  16473. clearedwxs bool
  16474. done bool
  16475. oldValue func(context.Context) (*Server, error)
  16476. predicates []predicate.Server
  16477. }
  16478. var _ ent.Mutation = (*ServerMutation)(nil)
  16479. // serverOption allows management of the mutation configuration using functional options.
  16480. type serverOption func(*ServerMutation)
  16481. // newServerMutation creates new mutation for the Server entity.
  16482. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  16483. m := &ServerMutation{
  16484. config: c,
  16485. op: op,
  16486. typ: TypeServer,
  16487. clearedFields: make(map[string]struct{}),
  16488. }
  16489. for _, opt := range opts {
  16490. opt(m)
  16491. }
  16492. return m
  16493. }
  16494. // withServerID sets the ID field of the mutation.
  16495. func withServerID(id uint64) serverOption {
  16496. return func(m *ServerMutation) {
  16497. var (
  16498. err error
  16499. once sync.Once
  16500. value *Server
  16501. )
  16502. m.oldValue = func(ctx context.Context) (*Server, error) {
  16503. once.Do(func() {
  16504. if m.done {
  16505. err = errors.New("querying old values post mutation is not allowed")
  16506. } else {
  16507. value, err = m.Client().Server.Get(ctx, id)
  16508. }
  16509. })
  16510. return value, err
  16511. }
  16512. m.id = &id
  16513. }
  16514. }
  16515. // withServer sets the old Server of the mutation.
  16516. func withServer(node *Server) serverOption {
  16517. return func(m *ServerMutation) {
  16518. m.oldValue = func(context.Context) (*Server, error) {
  16519. return node, nil
  16520. }
  16521. m.id = &node.ID
  16522. }
  16523. }
  16524. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16525. // executed in a transaction (ent.Tx), a transactional client is returned.
  16526. func (m ServerMutation) Client() *Client {
  16527. client := &Client{config: m.config}
  16528. client.init()
  16529. return client
  16530. }
  16531. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16532. // it returns an error otherwise.
  16533. func (m ServerMutation) Tx() (*Tx, error) {
  16534. if _, ok := m.driver.(*txDriver); !ok {
  16535. return nil, errors.New("ent: mutation is not running in a transaction")
  16536. }
  16537. tx := &Tx{config: m.config}
  16538. tx.init()
  16539. return tx, nil
  16540. }
  16541. // SetID sets the value of the id field. Note that this
  16542. // operation is only accepted on creation of Server entities.
  16543. func (m *ServerMutation) SetID(id uint64) {
  16544. m.id = &id
  16545. }
  16546. // ID returns the ID value in the mutation. Note that the ID is only available
  16547. // if it was provided to the builder or after it was returned from the database.
  16548. func (m *ServerMutation) ID() (id uint64, exists bool) {
  16549. if m.id == nil {
  16550. return
  16551. }
  16552. return *m.id, true
  16553. }
  16554. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16555. // That means, if the mutation is applied within a transaction with an isolation level such
  16556. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16557. // or updated by the mutation.
  16558. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  16559. switch {
  16560. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16561. id, exists := m.ID()
  16562. if exists {
  16563. return []uint64{id}, nil
  16564. }
  16565. fallthrough
  16566. case m.op.Is(OpUpdate | OpDelete):
  16567. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  16568. default:
  16569. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16570. }
  16571. }
  16572. // SetCreatedAt sets the "created_at" field.
  16573. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  16574. m.created_at = &t
  16575. }
  16576. // CreatedAt returns the value of the "created_at" field in the mutation.
  16577. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  16578. v := m.created_at
  16579. if v == nil {
  16580. return
  16581. }
  16582. return *v, true
  16583. }
  16584. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  16585. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16587. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16588. if !m.op.Is(OpUpdateOne) {
  16589. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16590. }
  16591. if m.id == nil || m.oldValue == nil {
  16592. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16593. }
  16594. oldValue, err := m.oldValue(ctx)
  16595. if err != nil {
  16596. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16597. }
  16598. return oldValue.CreatedAt, nil
  16599. }
  16600. // ResetCreatedAt resets all changes to the "created_at" field.
  16601. func (m *ServerMutation) ResetCreatedAt() {
  16602. m.created_at = nil
  16603. }
  16604. // SetUpdatedAt sets the "updated_at" field.
  16605. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  16606. m.updated_at = &t
  16607. }
  16608. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16609. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  16610. v := m.updated_at
  16611. if v == nil {
  16612. return
  16613. }
  16614. return *v, true
  16615. }
  16616. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  16617. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16619. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16620. if !m.op.Is(OpUpdateOne) {
  16621. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16622. }
  16623. if m.id == nil || m.oldValue == nil {
  16624. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16625. }
  16626. oldValue, err := m.oldValue(ctx)
  16627. if err != nil {
  16628. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16629. }
  16630. return oldValue.UpdatedAt, nil
  16631. }
  16632. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16633. func (m *ServerMutation) ResetUpdatedAt() {
  16634. m.updated_at = nil
  16635. }
  16636. // SetStatus sets the "status" field.
  16637. func (m *ServerMutation) SetStatus(u uint8) {
  16638. m.status = &u
  16639. m.addstatus = nil
  16640. }
  16641. // Status returns the value of the "status" field in the mutation.
  16642. func (m *ServerMutation) Status() (r uint8, exists bool) {
  16643. v := m.status
  16644. if v == nil {
  16645. return
  16646. }
  16647. return *v, true
  16648. }
  16649. // OldStatus returns the old "status" field's value of the Server entity.
  16650. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16652. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16653. if !m.op.Is(OpUpdateOne) {
  16654. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16655. }
  16656. if m.id == nil || m.oldValue == nil {
  16657. return v, errors.New("OldStatus requires an ID field in the mutation")
  16658. }
  16659. oldValue, err := m.oldValue(ctx)
  16660. if err != nil {
  16661. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16662. }
  16663. return oldValue.Status, nil
  16664. }
  16665. // AddStatus adds u to the "status" field.
  16666. func (m *ServerMutation) AddStatus(u int8) {
  16667. if m.addstatus != nil {
  16668. *m.addstatus += u
  16669. } else {
  16670. m.addstatus = &u
  16671. }
  16672. }
  16673. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16674. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  16675. v := m.addstatus
  16676. if v == nil {
  16677. return
  16678. }
  16679. return *v, true
  16680. }
  16681. // ClearStatus clears the value of the "status" field.
  16682. func (m *ServerMutation) ClearStatus() {
  16683. m.status = nil
  16684. m.addstatus = nil
  16685. m.clearedFields[server.FieldStatus] = struct{}{}
  16686. }
  16687. // StatusCleared returns if the "status" field was cleared in this mutation.
  16688. func (m *ServerMutation) StatusCleared() bool {
  16689. _, ok := m.clearedFields[server.FieldStatus]
  16690. return ok
  16691. }
  16692. // ResetStatus resets all changes to the "status" field.
  16693. func (m *ServerMutation) ResetStatus() {
  16694. m.status = nil
  16695. m.addstatus = nil
  16696. delete(m.clearedFields, server.FieldStatus)
  16697. }
  16698. // SetDeletedAt sets the "deleted_at" field.
  16699. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  16700. m.deleted_at = &t
  16701. }
  16702. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16703. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  16704. v := m.deleted_at
  16705. if v == nil {
  16706. return
  16707. }
  16708. return *v, true
  16709. }
  16710. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  16711. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16713. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16714. if !m.op.Is(OpUpdateOne) {
  16715. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16716. }
  16717. if m.id == nil || m.oldValue == nil {
  16718. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16719. }
  16720. oldValue, err := m.oldValue(ctx)
  16721. if err != nil {
  16722. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16723. }
  16724. return oldValue.DeletedAt, nil
  16725. }
  16726. // ClearDeletedAt clears the value of the "deleted_at" field.
  16727. func (m *ServerMutation) ClearDeletedAt() {
  16728. m.deleted_at = nil
  16729. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  16730. }
  16731. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16732. func (m *ServerMutation) DeletedAtCleared() bool {
  16733. _, ok := m.clearedFields[server.FieldDeletedAt]
  16734. return ok
  16735. }
  16736. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16737. func (m *ServerMutation) ResetDeletedAt() {
  16738. m.deleted_at = nil
  16739. delete(m.clearedFields, server.FieldDeletedAt)
  16740. }
  16741. // SetName sets the "name" field.
  16742. func (m *ServerMutation) SetName(s string) {
  16743. m.name = &s
  16744. }
  16745. // Name returns the value of the "name" field in the mutation.
  16746. func (m *ServerMutation) Name() (r string, exists bool) {
  16747. v := m.name
  16748. if v == nil {
  16749. return
  16750. }
  16751. return *v, true
  16752. }
  16753. // OldName returns the old "name" field's value of the Server entity.
  16754. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16756. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  16757. if !m.op.Is(OpUpdateOne) {
  16758. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16759. }
  16760. if m.id == nil || m.oldValue == nil {
  16761. return v, errors.New("OldName requires an ID field in the mutation")
  16762. }
  16763. oldValue, err := m.oldValue(ctx)
  16764. if err != nil {
  16765. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16766. }
  16767. return oldValue.Name, nil
  16768. }
  16769. // ResetName resets all changes to the "name" field.
  16770. func (m *ServerMutation) ResetName() {
  16771. m.name = nil
  16772. }
  16773. // SetPublicIP sets the "public_ip" field.
  16774. func (m *ServerMutation) SetPublicIP(s string) {
  16775. m.public_ip = &s
  16776. }
  16777. // PublicIP returns the value of the "public_ip" field in the mutation.
  16778. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  16779. v := m.public_ip
  16780. if v == nil {
  16781. return
  16782. }
  16783. return *v, true
  16784. }
  16785. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  16786. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16788. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  16789. if !m.op.Is(OpUpdateOne) {
  16790. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  16791. }
  16792. if m.id == nil || m.oldValue == nil {
  16793. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  16794. }
  16795. oldValue, err := m.oldValue(ctx)
  16796. if err != nil {
  16797. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  16798. }
  16799. return oldValue.PublicIP, nil
  16800. }
  16801. // ResetPublicIP resets all changes to the "public_ip" field.
  16802. func (m *ServerMutation) ResetPublicIP() {
  16803. m.public_ip = nil
  16804. }
  16805. // SetPrivateIP sets the "private_ip" field.
  16806. func (m *ServerMutation) SetPrivateIP(s string) {
  16807. m.private_ip = &s
  16808. }
  16809. // PrivateIP returns the value of the "private_ip" field in the mutation.
  16810. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  16811. v := m.private_ip
  16812. if v == nil {
  16813. return
  16814. }
  16815. return *v, true
  16816. }
  16817. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  16818. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16820. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  16821. if !m.op.Is(OpUpdateOne) {
  16822. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  16823. }
  16824. if m.id == nil || m.oldValue == nil {
  16825. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  16826. }
  16827. oldValue, err := m.oldValue(ctx)
  16828. if err != nil {
  16829. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  16830. }
  16831. return oldValue.PrivateIP, nil
  16832. }
  16833. // ResetPrivateIP resets all changes to the "private_ip" field.
  16834. func (m *ServerMutation) ResetPrivateIP() {
  16835. m.private_ip = nil
  16836. }
  16837. // SetAdminPort sets the "admin_port" field.
  16838. func (m *ServerMutation) SetAdminPort(s string) {
  16839. m.admin_port = &s
  16840. }
  16841. // AdminPort returns the value of the "admin_port" field in the mutation.
  16842. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  16843. v := m.admin_port
  16844. if v == nil {
  16845. return
  16846. }
  16847. return *v, true
  16848. }
  16849. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  16850. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16852. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  16853. if !m.op.Is(OpUpdateOne) {
  16854. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  16855. }
  16856. if m.id == nil || m.oldValue == nil {
  16857. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  16858. }
  16859. oldValue, err := m.oldValue(ctx)
  16860. if err != nil {
  16861. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  16862. }
  16863. return oldValue.AdminPort, nil
  16864. }
  16865. // ResetAdminPort resets all changes to the "admin_port" field.
  16866. func (m *ServerMutation) ResetAdminPort() {
  16867. m.admin_port = nil
  16868. }
  16869. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  16870. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  16871. if m.wxs == nil {
  16872. m.wxs = make(map[uint64]struct{})
  16873. }
  16874. for i := range ids {
  16875. m.wxs[ids[i]] = struct{}{}
  16876. }
  16877. }
  16878. // ClearWxs clears the "wxs" edge to the Wx entity.
  16879. func (m *ServerMutation) ClearWxs() {
  16880. m.clearedwxs = true
  16881. }
  16882. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  16883. func (m *ServerMutation) WxsCleared() bool {
  16884. return m.clearedwxs
  16885. }
  16886. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  16887. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  16888. if m.removedwxs == nil {
  16889. m.removedwxs = make(map[uint64]struct{})
  16890. }
  16891. for i := range ids {
  16892. delete(m.wxs, ids[i])
  16893. m.removedwxs[ids[i]] = struct{}{}
  16894. }
  16895. }
  16896. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16897. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16898. for id := range m.removedwxs {
  16899. ids = append(ids, id)
  16900. }
  16901. return
  16902. }
  16903. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16904. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16905. for id := range m.wxs {
  16906. ids = append(ids, id)
  16907. }
  16908. return
  16909. }
  16910. // ResetWxs resets all changes to the "wxs" edge.
  16911. func (m *ServerMutation) ResetWxs() {
  16912. m.wxs = nil
  16913. m.clearedwxs = false
  16914. m.removedwxs = nil
  16915. }
  16916. // Where appends a list predicates to the ServerMutation builder.
  16917. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16918. m.predicates = append(m.predicates, ps...)
  16919. }
  16920. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16921. // users can use type-assertion to append predicates that do not depend on any generated package.
  16922. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16923. p := make([]predicate.Server, len(ps))
  16924. for i := range ps {
  16925. p[i] = ps[i]
  16926. }
  16927. m.Where(p...)
  16928. }
  16929. // Op returns the operation name.
  16930. func (m *ServerMutation) Op() Op {
  16931. return m.op
  16932. }
  16933. // SetOp allows setting the mutation operation.
  16934. func (m *ServerMutation) SetOp(op Op) {
  16935. m.op = op
  16936. }
  16937. // Type returns the node type of this mutation (Server).
  16938. func (m *ServerMutation) Type() string {
  16939. return m.typ
  16940. }
  16941. // Fields returns all fields that were changed during this mutation. Note that in
  16942. // order to get all numeric fields that were incremented/decremented, call
  16943. // AddedFields().
  16944. func (m *ServerMutation) Fields() []string {
  16945. fields := make([]string, 0, 8)
  16946. if m.created_at != nil {
  16947. fields = append(fields, server.FieldCreatedAt)
  16948. }
  16949. if m.updated_at != nil {
  16950. fields = append(fields, server.FieldUpdatedAt)
  16951. }
  16952. if m.status != nil {
  16953. fields = append(fields, server.FieldStatus)
  16954. }
  16955. if m.deleted_at != nil {
  16956. fields = append(fields, server.FieldDeletedAt)
  16957. }
  16958. if m.name != nil {
  16959. fields = append(fields, server.FieldName)
  16960. }
  16961. if m.public_ip != nil {
  16962. fields = append(fields, server.FieldPublicIP)
  16963. }
  16964. if m.private_ip != nil {
  16965. fields = append(fields, server.FieldPrivateIP)
  16966. }
  16967. if m.admin_port != nil {
  16968. fields = append(fields, server.FieldAdminPort)
  16969. }
  16970. return fields
  16971. }
  16972. // Field returns the value of a field with the given name. The second boolean
  16973. // return value indicates that this field was not set, or was not defined in the
  16974. // schema.
  16975. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16976. switch name {
  16977. case server.FieldCreatedAt:
  16978. return m.CreatedAt()
  16979. case server.FieldUpdatedAt:
  16980. return m.UpdatedAt()
  16981. case server.FieldStatus:
  16982. return m.Status()
  16983. case server.FieldDeletedAt:
  16984. return m.DeletedAt()
  16985. case server.FieldName:
  16986. return m.Name()
  16987. case server.FieldPublicIP:
  16988. return m.PublicIP()
  16989. case server.FieldPrivateIP:
  16990. return m.PrivateIP()
  16991. case server.FieldAdminPort:
  16992. return m.AdminPort()
  16993. }
  16994. return nil, false
  16995. }
  16996. // OldField returns the old value of the field from the database. An error is
  16997. // returned if the mutation operation is not UpdateOne, or the query to the
  16998. // database failed.
  16999. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17000. switch name {
  17001. case server.FieldCreatedAt:
  17002. return m.OldCreatedAt(ctx)
  17003. case server.FieldUpdatedAt:
  17004. return m.OldUpdatedAt(ctx)
  17005. case server.FieldStatus:
  17006. return m.OldStatus(ctx)
  17007. case server.FieldDeletedAt:
  17008. return m.OldDeletedAt(ctx)
  17009. case server.FieldName:
  17010. return m.OldName(ctx)
  17011. case server.FieldPublicIP:
  17012. return m.OldPublicIP(ctx)
  17013. case server.FieldPrivateIP:
  17014. return m.OldPrivateIP(ctx)
  17015. case server.FieldAdminPort:
  17016. return m.OldAdminPort(ctx)
  17017. }
  17018. return nil, fmt.Errorf("unknown Server field %s", name)
  17019. }
  17020. // SetField sets the value of a field with the given name. It returns an error if
  17021. // the field is not defined in the schema, or if the type mismatched the field
  17022. // type.
  17023. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  17024. switch name {
  17025. case server.FieldCreatedAt:
  17026. v, ok := value.(time.Time)
  17027. if !ok {
  17028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17029. }
  17030. m.SetCreatedAt(v)
  17031. return nil
  17032. case server.FieldUpdatedAt:
  17033. v, ok := value.(time.Time)
  17034. if !ok {
  17035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17036. }
  17037. m.SetUpdatedAt(v)
  17038. return nil
  17039. case server.FieldStatus:
  17040. v, ok := value.(uint8)
  17041. if !ok {
  17042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17043. }
  17044. m.SetStatus(v)
  17045. return nil
  17046. case server.FieldDeletedAt:
  17047. v, ok := value.(time.Time)
  17048. if !ok {
  17049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17050. }
  17051. m.SetDeletedAt(v)
  17052. return nil
  17053. case server.FieldName:
  17054. v, ok := value.(string)
  17055. if !ok {
  17056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17057. }
  17058. m.SetName(v)
  17059. return nil
  17060. case server.FieldPublicIP:
  17061. v, ok := value.(string)
  17062. if !ok {
  17063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17064. }
  17065. m.SetPublicIP(v)
  17066. return nil
  17067. case server.FieldPrivateIP:
  17068. v, ok := value.(string)
  17069. if !ok {
  17070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17071. }
  17072. m.SetPrivateIP(v)
  17073. return nil
  17074. case server.FieldAdminPort:
  17075. v, ok := value.(string)
  17076. if !ok {
  17077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17078. }
  17079. m.SetAdminPort(v)
  17080. return nil
  17081. }
  17082. return fmt.Errorf("unknown Server field %s", name)
  17083. }
  17084. // AddedFields returns all numeric fields that were incremented/decremented during
  17085. // this mutation.
  17086. func (m *ServerMutation) AddedFields() []string {
  17087. var fields []string
  17088. if m.addstatus != nil {
  17089. fields = append(fields, server.FieldStatus)
  17090. }
  17091. return fields
  17092. }
  17093. // AddedField returns the numeric value that was incremented/decremented on a field
  17094. // with the given name. The second boolean return value indicates that this field
  17095. // was not set, or was not defined in the schema.
  17096. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  17097. switch name {
  17098. case server.FieldStatus:
  17099. return m.AddedStatus()
  17100. }
  17101. return nil, false
  17102. }
  17103. // AddField adds the value to the field with the given name. It returns an error if
  17104. // the field is not defined in the schema, or if the type mismatched the field
  17105. // type.
  17106. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  17107. switch name {
  17108. case server.FieldStatus:
  17109. v, ok := value.(int8)
  17110. if !ok {
  17111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17112. }
  17113. m.AddStatus(v)
  17114. return nil
  17115. }
  17116. return fmt.Errorf("unknown Server numeric field %s", name)
  17117. }
  17118. // ClearedFields returns all nullable fields that were cleared during this
  17119. // mutation.
  17120. func (m *ServerMutation) ClearedFields() []string {
  17121. var fields []string
  17122. if m.FieldCleared(server.FieldStatus) {
  17123. fields = append(fields, server.FieldStatus)
  17124. }
  17125. if m.FieldCleared(server.FieldDeletedAt) {
  17126. fields = append(fields, server.FieldDeletedAt)
  17127. }
  17128. return fields
  17129. }
  17130. // FieldCleared returns a boolean indicating if a field with the given name was
  17131. // cleared in this mutation.
  17132. func (m *ServerMutation) FieldCleared(name string) bool {
  17133. _, ok := m.clearedFields[name]
  17134. return ok
  17135. }
  17136. // ClearField clears the value of the field with the given name. It returns an
  17137. // error if the field is not defined in the schema.
  17138. func (m *ServerMutation) ClearField(name string) error {
  17139. switch name {
  17140. case server.FieldStatus:
  17141. m.ClearStatus()
  17142. return nil
  17143. case server.FieldDeletedAt:
  17144. m.ClearDeletedAt()
  17145. return nil
  17146. }
  17147. return fmt.Errorf("unknown Server nullable field %s", name)
  17148. }
  17149. // ResetField resets all changes in the mutation for the field with the given name.
  17150. // It returns an error if the field is not defined in the schema.
  17151. func (m *ServerMutation) ResetField(name string) error {
  17152. switch name {
  17153. case server.FieldCreatedAt:
  17154. m.ResetCreatedAt()
  17155. return nil
  17156. case server.FieldUpdatedAt:
  17157. m.ResetUpdatedAt()
  17158. return nil
  17159. case server.FieldStatus:
  17160. m.ResetStatus()
  17161. return nil
  17162. case server.FieldDeletedAt:
  17163. m.ResetDeletedAt()
  17164. return nil
  17165. case server.FieldName:
  17166. m.ResetName()
  17167. return nil
  17168. case server.FieldPublicIP:
  17169. m.ResetPublicIP()
  17170. return nil
  17171. case server.FieldPrivateIP:
  17172. m.ResetPrivateIP()
  17173. return nil
  17174. case server.FieldAdminPort:
  17175. m.ResetAdminPort()
  17176. return nil
  17177. }
  17178. return fmt.Errorf("unknown Server field %s", name)
  17179. }
  17180. // AddedEdges returns all edge names that were set/added in this mutation.
  17181. func (m *ServerMutation) AddedEdges() []string {
  17182. edges := make([]string, 0, 1)
  17183. if m.wxs != nil {
  17184. edges = append(edges, server.EdgeWxs)
  17185. }
  17186. return edges
  17187. }
  17188. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17189. // name in this mutation.
  17190. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17191. switch name {
  17192. case server.EdgeWxs:
  17193. ids := make([]ent.Value, 0, len(m.wxs))
  17194. for id := range m.wxs {
  17195. ids = append(ids, id)
  17196. }
  17197. return ids
  17198. }
  17199. return nil
  17200. }
  17201. // RemovedEdges returns all edge names that were removed in this mutation.
  17202. func (m *ServerMutation) RemovedEdges() []string {
  17203. edges := make([]string, 0, 1)
  17204. if m.removedwxs != nil {
  17205. edges = append(edges, server.EdgeWxs)
  17206. }
  17207. return edges
  17208. }
  17209. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17210. // the given name in this mutation.
  17211. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17212. switch name {
  17213. case server.EdgeWxs:
  17214. ids := make([]ent.Value, 0, len(m.removedwxs))
  17215. for id := range m.removedwxs {
  17216. ids = append(ids, id)
  17217. }
  17218. return ids
  17219. }
  17220. return nil
  17221. }
  17222. // ClearedEdges returns all edge names that were cleared in this mutation.
  17223. func (m *ServerMutation) ClearedEdges() []string {
  17224. edges := make([]string, 0, 1)
  17225. if m.clearedwxs {
  17226. edges = append(edges, server.EdgeWxs)
  17227. }
  17228. return edges
  17229. }
  17230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17231. // was cleared in this mutation.
  17232. func (m *ServerMutation) EdgeCleared(name string) bool {
  17233. switch name {
  17234. case server.EdgeWxs:
  17235. return m.clearedwxs
  17236. }
  17237. return false
  17238. }
  17239. // ClearEdge clears the value of the edge with the given name. It returns an error
  17240. // if that edge is not defined in the schema.
  17241. func (m *ServerMutation) ClearEdge(name string) error {
  17242. switch name {
  17243. }
  17244. return fmt.Errorf("unknown Server unique edge %s", name)
  17245. }
  17246. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17247. // It returns an error if the edge is not defined in the schema.
  17248. func (m *ServerMutation) ResetEdge(name string) error {
  17249. switch name {
  17250. case server.EdgeWxs:
  17251. m.ResetWxs()
  17252. return nil
  17253. }
  17254. return fmt.Errorf("unknown Server edge %s", name)
  17255. }
  17256. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  17257. type SopNodeMutation struct {
  17258. config
  17259. op Op
  17260. typ string
  17261. id *uint64
  17262. created_at *time.Time
  17263. updated_at *time.Time
  17264. status *uint8
  17265. addstatus *int8
  17266. deleted_at *time.Time
  17267. parent_id *uint64
  17268. addparent_id *int64
  17269. name *string
  17270. condition_type *int
  17271. addcondition_type *int
  17272. condition_list *[]string
  17273. appendcondition_list []string
  17274. no_reply_condition *uint64
  17275. addno_reply_condition *int64
  17276. no_reply_unit *string
  17277. action_message *[]custom_types.Action
  17278. appendaction_message []custom_types.Action
  17279. action_label_add *[]uint64
  17280. appendaction_label_add []uint64
  17281. action_label_del *[]uint64
  17282. appendaction_label_del []uint64
  17283. action_forward **custom_types.ActionForward
  17284. clearedFields map[string]struct{}
  17285. sop_stage *uint64
  17286. clearedsop_stage bool
  17287. node_messages map[uint64]struct{}
  17288. removednode_messages map[uint64]struct{}
  17289. clearednode_messages bool
  17290. done bool
  17291. oldValue func(context.Context) (*SopNode, error)
  17292. predicates []predicate.SopNode
  17293. }
  17294. var _ ent.Mutation = (*SopNodeMutation)(nil)
  17295. // sopnodeOption allows management of the mutation configuration using functional options.
  17296. type sopnodeOption func(*SopNodeMutation)
  17297. // newSopNodeMutation creates new mutation for the SopNode entity.
  17298. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  17299. m := &SopNodeMutation{
  17300. config: c,
  17301. op: op,
  17302. typ: TypeSopNode,
  17303. clearedFields: make(map[string]struct{}),
  17304. }
  17305. for _, opt := range opts {
  17306. opt(m)
  17307. }
  17308. return m
  17309. }
  17310. // withSopNodeID sets the ID field of the mutation.
  17311. func withSopNodeID(id uint64) sopnodeOption {
  17312. return func(m *SopNodeMutation) {
  17313. var (
  17314. err error
  17315. once sync.Once
  17316. value *SopNode
  17317. )
  17318. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  17319. once.Do(func() {
  17320. if m.done {
  17321. err = errors.New("querying old values post mutation is not allowed")
  17322. } else {
  17323. value, err = m.Client().SopNode.Get(ctx, id)
  17324. }
  17325. })
  17326. return value, err
  17327. }
  17328. m.id = &id
  17329. }
  17330. }
  17331. // withSopNode sets the old SopNode of the mutation.
  17332. func withSopNode(node *SopNode) sopnodeOption {
  17333. return func(m *SopNodeMutation) {
  17334. m.oldValue = func(context.Context) (*SopNode, error) {
  17335. return node, nil
  17336. }
  17337. m.id = &node.ID
  17338. }
  17339. }
  17340. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17341. // executed in a transaction (ent.Tx), a transactional client is returned.
  17342. func (m SopNodeMutation) Client() *Client {
  17343. client := &Client{config: m.config}
  17344. client.init()
  17345. return client
  17346. }
  17347. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17348. // it returns an error otherwise.
  17349. func (m SopNodeMutation) Tx() (*Tx, error) {
  17350. if _, ok := m.driver.(*txDriver); !ok {
  17351. return nil, errors.New("ent: mutation is not running in a transaction")
  17352. }
  17353. tx := &Tx{config: m.config}
  17354. tx.init()
  17355. return tx, nil
  17356. }
  17357. // SetID sets the value of the id field. Note that this
  17358. // operation is only accepted on creation of SopNode entities.
  17359. func (m *SopNodeMutation) SetID(id uint64) {
  17360. m.id = &id
  17361. }
  17362. // ID returns the ID value in the mutation. Note that the ID is only available
  17363. // if it was provided to the builder or after it was returned from the database.
  17364. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  17365. if m.id == nil {
  17366. return
  17367. }
  17368. return *m.id, true
  17369. }
  17370. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17371. // That means, if the mutation is applied within a transaction with an isolation level such
  17372. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17373. // or updated by the mutation.
  17374. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17375. switch {
  17376. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17377. id, exists := m.ID()
  17378. if exists {
  17379. return []uint64{id}, nil
  17380. }
  17381. fallthrough
  17382. case m.op.Is(OpUpdate | OpDelete):
  17383. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  17384. default:
  17385. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17386. }
  17387. }
  17388. // SetCreatedAt sets the "created_at" field.
  17389. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  17390. m.created_at = &t
  17391. }
  17392. // CreatedAt returns the value of the "created_at" field in the mutation.
  17393. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  17394. v := m.created_at
  17395. if v == nil {
  17396. return
  17397. }
  17398. return *v, true
  17399. }
  17400. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  17401. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17403. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17404. if !m.op.Is(OpUpdateOne) {
  17405. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17406. }
  17407. if m.id == nil || m.oldValue == nil {
  17408. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17409. }
  17410. oldValue, err := m.oldValue(ctx)
  17411. if err != nil {
  17412. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17413. }
  17414. return oldValue.CreatedAt, nil
  17415. }
  17416. // ResetCreatedAt resets all changes to the "created_at" field.
  17417. func (m *SopNodeMutation) ResetCreatedAt() {
  17418. m.created_at = nil
  17419. }
  17420. // SetUpdatedAt sets the "updated_at" field.
  17421. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  17422. m.updated_at = &t
  17423. }
  17424. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17425. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  17426. v := m.updated_at
  17427. if v == nil {
  17428. return
  17429. }
  17430. return *v, true
  17431. }
  17432. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  17433. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17435. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17436. if !m.op.Is(OpUpdateOne) {
  17437. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17438. }
  17439. if m.id == nil || m.oldValue == nil {
  17440. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17441. }
  17442. oldValue, err := m.oldValue(ctx)
  17443. if err != nil {
  17444. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17445. }
  17446. return oldValue.UpdatedAt, nil
  17447. }
  17448. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17449. func (m *SopNodeMutation) ResetUpdatedAt() {
  17450. m.updated_at = nil
  17451. }
  17452. // SetStatus sets the "status" field.
  17453. func (m *SopNodeMutation) SetStatus(u uint8) {
  17454. m.status = &u
  17455. m.addstatus = nil
  17456. }
  17457. // Status returns the value of the "status" field in the mutation.
  17458. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  17459. v := m.status
  17460. if v == nil {
  17461. return
  17462. }
  17463. return *v, true
  17464. }
  17465. // OldStatus returns the old "status" field's value of the SopNode entity.
  17466. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17468. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17469. if !m.op.Is(OpUpdateOne) {
  17470. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17471. }
  17472. if m.id == nil || m.oldValue == nil {
  17473. return v, errors.New("OldStatus requires an ID field in the mutation")
  17474. }
  17475. oldValue, err := m.oldValue(ctx)
  17476. if err != nil {
  17477. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17478. }
  17479. return oldValue.Status, nil
  17480. }
  17481. // AddStatus adds u to the "status" field.
  17482. func (m *SopNodeMutation) AddStatus(u int8) {
  17483. if m.addstatus != nil {
  17484. *m.addstatus += u
  17485. } else {
  17486. m.addstatus = &u
  17487. }
  17488. }
  17489. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17490. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  17491. v := m.addstatus
  17492. if v == nil {
  17493. return
  17494. }
  17495. return *v, true
  17496. }
  17497. // ClearStatus clears the value of the "status" field.
  17498. func (m *SopNodeMutation) ClearStatus() {
  17499. m.status = nil
  17500. m.addstatus = nil
  17501. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  17502. }
  17503. // StatusCleared returns if the "status" field was cleared in this mutation.
  17504. func (m *SopNodeMutation) StatusCleared() bool {
  17505. _, ok := m.clearedFields[sopnode.FieldStatus]
  17506. return ok
  17507. }
  17508. // ResetStatus resets all changes to the "status" field.
  17509. func (m *SopNodeMutation) ResetStatus() {
  17510. m.status = nil
  17511. m.addstatus = nil
  17512. delete(m.clearedFields, sopnode.FieldStatus)
  17513. }
  17514. // SetDeletedAt sets the "deleted_at" field.
  17515. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  17516. m.deleted_at = &t
  17517. }
  17518. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17519. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  17520. v := m.deleted_at
  17521. if v == nil {
  17522. return
  17523. }
  17524. return *v, true
  17525. }
  17526. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  17527. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17529. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17530. if !m.op.Is(OpUpdateOne) {
  17531. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17532. }
  17533. if m.id == nil || m.oldValue == nil {
  17534. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17535. }
  17536. oldValue, err := m.oldValue(ctx)
  17537. if err != nil {
  17538. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17539. }
  17540. return oldValue.DeletedAt, nil
  17541. }
  17542. // ClearDeletedAt clears the value of the "deleted_at" field.
  17543. func (m *SopNodeMutation) ClearDeletedAt() {
  17544. m.deleted_at = nil
  17545. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  17546. }
  17547. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17548. func (m *SopNodeMutation) DeletedAtCleared() bool {
  17549. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  17550. return ok
  17551. }
  17552. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17553. func (m *SopNodeMutation) ResetDeletedAt() {
  17554. m.deleted_at = nil
  17555. delete(m.clearedFields, sopnode.FieldDeletedAt)
  17556. }
  17557. // SetStageID sets the "stage_id" field.
  17558. func (m *SopNodeMutation) SetStageID(u uint64) {
  17559. m.sop_stage = &u
  17560. }
  17561. // StageID returns the value of the "stage_id" field in the mutation.
  17562. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  17563. v := m.sop_stage
  17564. if v == nil {
  17565. return
  17566. }
  17567. return *v, true
  17568. }
  17569. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  17570. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17572. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  17573. if !m.op.Is(OpUpdateOne) {
  17574. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  17575. }
  17576. if m.id == nil || m.oldValue == nil {
  17577. return v, errors.New("OldStageID requires an ID field in the mutation")
  17578. }
  17579. oldValue, err := m.oldValue(ctx)
  17580. if err != nil {
  17581. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  17582. }
  17583. return oldValue.StageID, nil
  17584. }
  17585. // ResetStageID resets all changes to the "stage_id" field.
  17586. func (m *SopNodeMutation) ResetStageID() {
  17587. m.sop_stage = nil
  17588. }
  17589. // SetParentID sets the "parent_id" field.
  17590. func (m *SopNodeMutation) SetParentID(u uint64) {
  17591. m.parent_id = &u
  17592. m.addparent_id = nil
  17593. }
  17594. // ParentID returns the value of the "parent_id" field in the mutation.
  17595. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  17596. v := m.parent_id
  17597. if v == nil {
  17598. return
  17599. }
  17600. return *v, true
  17601. }
  17602. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  17603. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17605. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  17606. if !m.op.Is(OpUpdateOne) {
  17607. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  17608. }
  17609. if m.id == nil || m.oldValue == nil {
  17610. return v, errors.New("OldParentID requires an ID field in the mutation")
  17611. }
  17612. oldValue, err := m.oldValue(ctx)
  17613. if err != nil {
  17614. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  17615. }
  17616. return oldValue.ParentID, nil
  17617. }
  17618. // AddParentID adds u to the "parent_id" field.
  17619. func (m *SopNodeMutation) AddParentID(u int64) {
  17620. if m.addparent_id != nil {
  17621. *m.addparent_id += u
  17622. } else {
  17623. m.addparent_id = &u
  17624. }
  17625. }
  17626. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  17627. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  17628. v := m.addparent_id
  17629. if v == nil {
  17630. return
  17631. }
  17632. return *v, true
  17633. }
  17634. // ResetParentID resets all changes to the "parent_id" field.
  17635. func (m *SopNodeMutation) ResetParentID() {
  17636. m.parent_id = nil
  17637. m.addparent_id = nil
  17638. }
  17639. // SetName sets the "name" field.
  17640. func (m *SopNodeMutation) SetName(s string) {
  17641. m.name = &s
  17642. }
  17643. // Name returns the value of the "name" field in the mutation.
  17644. func (m *SopNodeMutation) Name() (r string, exists bool) {
  17645. v := m.name
  17646. if v == nil {
  17647. return
  17648. }
  17649. return *v, true
  17650. }
  17651. // OldName returns the old "name" field's value of the SopNode entity.
  17652. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17654. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  17655. if !m.op.Is(OpUpdateOne) {
  17656. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17657. }
  17658. if m.id == nil || m.oldValue == nil {
  17659. return v, errors.New("OldName requires an ID field in the mutation")
  17660. }
  17661. oldValue, err := m.oldValue(ctx)
  17662. if err != nil {
  17663. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17664. }
  17665. return oldValue.Name, nil
  17666. }
  17667. // ResetName resets all changes to the "name" field.
  17668. func (m *SopNodeMutation) ResetName() {
  17669. m.name = nil
  17670. }
  17671. // SetConditionType sets the "condition_type" field.
  17672. func (m *SopNodeMutation) SetConditionType(i int) {
  17673. m.condition_type = &i
  17674. m.addcondition_type = nil
  17675. }
  17676. // ConditionType returns the value of the "condition_type" field in the mutation.
  17677. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  17678. v := m.condition_type
  17679. if v == nil {
  17680. return
  17681. }
  17682. return *v, true
  17683. }
  17684. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  17685. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17687. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17688. if !m.op.Is(OpUpdateOne) {
  17689. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17690. }
  17691. if m.id == nil || m.oldValue == nil {
  17692. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17693. }
  17694. oldValue, err := m.oldValue(ctx)
  17695. if err != nil {
  17696. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17697. }
  17698. return oldValue.ConditionType, nil
  17699. }
  17700. // AddConditionType adds i to the "condition_type" field.
  17701. func (m *SopNodeMutation) AddConditionType(i int) {
  17702. if m.addcondition_type != nil {
  17703. *m.addcondition_type += i
  17704. } else {
  17705. m.addcondition_type = &i
  17706. }
  17707. }
  17708. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17709. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  17710. v := m.addcondition_type
  17711. if v == nil {
  17712. return
  17713. }
  17714. return *v, true
  17715. }
  17716. // ResetConditionType resets all changes to the "condition_type" field.
  17717. func (m *SopNodeMutation) ResetConditionType() {
  17718. m.condition_type = nil
  17719. m.addcondition_type = nil
  17720. }
  17721. // SetConditionList sets the "condition_list" field.
  17722. func (m *SopNodeMutation) SetConditionList(s []string) {
  17723. m.condition_list = &s
  17724. m.appendcondition_list = nil
  17725. }
  17726. // ConditionList returns the value of the "condition_list" field in the mutation.
  17727. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  17728. v := m.condition_list
  17729. if v == nil {
  17730. return
  17731. }
  17732. return *v, true
  17733. }
  17734. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  17735. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17737. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  17738. if !m.op.Is(OpUpdateOne) {
  17739. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17740. }
  17741. if m.id == nil || m.oldValue == nil {
  17742. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17743. }
  17744. oldValue, err := m.oldValue(ctx)
  17745. if err != nil {
  17746. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17747. }
  17748. return oldValue.ConditionList, nil
  17749. }
  17750. // AppendConditionList adds s to the "condition_list" field.
  17751. func (m *SopNodeMutation) AppendConditionList(s []string) {
  17752. m.appendcondition_list = append(m.appendcondition_list, s...)
  17753. }
  17754. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17755. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  17756. if len(m.appendcondition_list) == 0 {
  17757. return nil, false
  17758. }
  17759. return m.appendcondition_list, true
  17760. }
  17761. // ClearConditionList clears the value of the "condition_list" field.
  17762. func (m *SopNodeMutation) ClearConditionList() {
  17763. m.condition_list = nil
  17764. m.appendcondition_list = nil
  17765. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  17766. }
  17767. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  17768. func (m *SopNodeMutation) ConditionListCleared() bool {
  17769. _, ok := m.clearedFields[sopnode.FieldConditionList]
  17770. return ok
  17771. }
  17772. // ResetConditionList resets all changes to the "condition_list" field.
  17773. func (m *SopNodeMutation) ResetConditionList() {
  17774. m.condition_list = nil
  17775. m.appendcondition_list = nil
  17776. delete(m.clearedFields, sopnode.FieldConditionList)
  17777. }
  17778. // SetNoReplyCondition sets the "no_reply_condition" field.
  17779. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  17780. m.no_reply_condition = &u
  17781. m.addno_reply_condition = nil
  17782. }
  17783. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  17784. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  17785. v := m.no_reply_condition
  17786. if v == nil {
  17787. return
  17788. }
  17789. return *v, true
  17790. }
  17791. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  17792. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17794. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  17795. if !m.op.Is(OpUpdateOne) {
  17796. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  17797. }
  17798. if m.id == nil || m.oldValue == nil {
  17799. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  17800. }
  17801. oldValue, err := m.oldValue(ctx)
  17802. if err != nil {
  17803. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  17804. }
  17805. return oldValue.NoReplyCondition, nil
  17806. }
  17807. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  17808. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  17809. if m.addno_reply_condition != nil {
  17810. *m.addno_reply_condition += u
  17811. } else {
  17812. m.addno_reply_condition = &u
  17813. }
  17814. }
  17815. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  17816. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  17817. v := m.addno_reply_condition
  17818. if v == nil {
  17819. return
  17820. }
  17821. return *v, true
  17822. }
  17823. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  17824. func (m *SopNodeMutation) ResetNoReplyCondition() {
  17825. m.no_reply_condition = nil
  17826. m.addno_reply_condition = nil
  17827. }
  17828. // SetNoReplyUnit sets the "no_reply_unit" field.
  17829. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  17830. m.no_reply_unit = &s
  17831. }
  17832. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  17833. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  17834. v := m.no_reply_unit
  17835. if v == nil {
  17836. return
  17837. }
  17838. return *v, true
  17839. }
  17840. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  17841. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17843. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  17844. if !m.op.Is(OpUpdateOne) {
  17845. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  17846. }
  17847. if m.id == nil || m.oldValue == nil {
  17848. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  17849. }
  17850. oldValue, err := m.oldValue(ctx)
  17851. if err != nil {
  17852. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  17853. }
  17854. return oldValue.NoReplyUnit, nil
  17855. }
  17856. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  17857. func (m *SopNodeMutation) ResetNoReplyUnit() {
  17858. m.no_reply_unit = nil
  17859. }
  17860. // SetActionMessage sets the "action_message" field.
  17861. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  17862. m.action_message = &ct
  17863. m.appendaction_message = nil
  17864. }
  17865. // ActionMessage returns the value of the "action_message" field in the mutation.
  17866. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17867. v := m.action_message
  17868. if v == nil {
  17869. return
  17870. }
  17871. return *v, true
  17872. }
  17873. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  17874. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17876. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17877. if !m.op.Is(OpUpdateOne) {
  17878. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17879. }
  17880. if m.id == nil || m.oldValue == nil {
  17881. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17882. }
  17883. oldValue, err := m.oldValue(ctx)
  17884. if err != nil {
  17885. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17886. }
  17887. return oldValue.ActionMessage, nil
  17888. }
  17889. // AppendActionMessage adds ct to the "action_message" field.
  17890. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  17891. m.appendaction_message = append(m.appendaction_message, ct...)
  17892. }
  17893. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17894. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17895. if len(m.appendaction_message) == 0 {
  17896. return nil, false
  17897. }
  17898. return m.appendaction_message, true
  17899. }
  17900. // ClearActionMessage clears the value of the "action_message" field.
  17901. func (m *SopNodeMutation) ClearActionMessage() {
  17902. m.action_message = nil
  17903. m.appendaction_message = nil
  17904. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17905. }
  17906. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17907. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17908. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17909. return ok
  17910. }
  17911. // ResetActionMessage resets all changes to the "action_message" field.
  17912. func (m *SopNodeMutation) ResetActionMessage() {
  17913. m.action_message = nil
  17914. m.appendaction_message = nil
  17915. delete(m.clearedFields, sopnode.FieldActionMessage)
  17916. }
  17917. // SetActionLabelAdd sets the "action_label_add" field.
  17918. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17919. m.action_label_add = &u
  17920. m.appendaction_label_add = nil
  17921. }
  17922. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17923. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17924. v := m.action_label_add
  17925. if v == nil {
  17926. return
  17927. }
  17928. return *v, true
  17929. }
  17930. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17931. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17933. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17934. if !m.op.Is(OpUpdateOne) {
  17935. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17936. }
  17937. if m.id == nil || m.oldValue == nil {
  17938. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17939. }
  17940. oldValue, err := m.oldValue(ctx)
  17941. if err != nil {
  17942. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17943. }
  17944. return oldValue.ActionLabelAdd, nil
  17945. }
  17946. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17947. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17948. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17949. }
  17950. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17951. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17952. if len(m.appendaction_label_add) == 0 {
  17953. return nil, false
  17954. }
  17955. return m.appendaction_label_add, true
  17956. }
  17957. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17958. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17959. m.action_label_add = nil
  17960. m.appendaction_label_add = nil
  17961. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17962. }
  17963. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17964. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17965. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17966. return ok
  17967. }
  17968. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17969. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17970. m.action_label_add = nil
  17971. m.appendaction_label_add = nil
  17972. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17973. }
  17974. // SetActionLabelDel sets the "action_label_del" field.
  17975. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17976. m.action_label_del = &u
  17977. m.appendaction_label_del = nil
  17978. }
  17979. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17980. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17981. v := m.action_label_del
  17982. if v == nil {
  17983. return
  17984. }
  17985. return *v, true
  17986. }
  17987. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17988. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17990. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17991. if !m.op.Is(OpUpdateOne) {
  17992. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17993. }
  17994. if m.id == nil || m.oldValue == nil {
  17995. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17996. }
  17997. oldValue, err := m.oldValue(ctx)
  17998. if err != nil {
  17999. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18000. }
  18001. return oldValue.ActionLabelDel, nil
  18002. }
  18003. // AppendActionLabelDel adds u to the "action_label_del" field.
  18004. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  18005. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18006. }
  18007. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18008. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18009. if len(m.appendaction_label_del) == 0 {
  18010. return nil, false
  18011. }
  18012. return m.appendaction_label_del, true
  18013. }
  18014. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18015. func (m *SopNodeMutation) ClearActionLabelDel() {
  18016. m.action_label_del = nil
  18017. m.appendaction_label_del = nil
  18018. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  18019. }
  18020. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18021. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  18022. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  18023. return ok
  18024. }
  18025. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18026. func (m *SopNodeMutation) ResetActionLabelDel() {
  18027. m.action_label_del = nil
  18028. m.appendaction_label_del = nil
  18029. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  18030. }
  18031. // SetActionForward sets the "action_forward" field.
  18032. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18033. m.action_forward = &ctf
  18034. }
  18035. // ActionForward returns the value of the "action_forward" field in the mutation.
  18036. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18037. v := m.action_forward
  18038. if v == nil {
  18039. return
  18040. }
  18041. return *v, true
  18042. }
  18043. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  18044. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18046. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18047. if !m.op.Is(OpUpdateOne) {
  18048. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18049. }
  18050. if m.id == nil || m.oldValue == nil {
  18051. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18052. }
  18053. oldValue, err := m.oldValue(ctx)
  18054. if err != nil {
  18055. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18056. }
  18057. return oldValue.ActionForward, nil
  18058. }
  18059. // ClearActionForward clears the value of the "action_forward" field.
  18060. func (m *SopNodeMutation) ClearActionForward() {
  18061. m.action_forward = nil
  18062. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  18063. }
  18064. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18065. func (m *SopNodeMutation) ActionForwardCleared() bool {
  18066. _, ok := m.clearedFields[sopnode.FieldActionForward]
  18067. return ok
  18068. }
  18069. // ResetActionForward resets all changes to the "action_forward" field.
  18070. func (m *SopNodeMutation) ResetActionForward() {
  18071. m.action_forward = nil
  18072. delete(m.clearedFields, sopnode.FieldActionForward)
  18073. }
  18074. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18075. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  18076. m.sop_stage = &id
  18077. }
  18078. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18079. func (m *SopNodeMutation) ClearSopStage() {
  18080. m.clearedsop_stage = true
  18081. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  18082. }
  18083. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18084. func (m *SopNodeMutation) SopStageCleared() bool {
  18085. return m.clearedsop_stage
  18086. }
  18087. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18088. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  18089. if m.sop_stage != nil {
  18090. return *m.sop_stage, true
  18091. }
  18092. return
  18093. }
  18094. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18095. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18096. // SopStageID instead. It exists only for internal usage by the builders.
  18097. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  18098. if id := m.sop_stage; id != nil {
  18099. ids = append(ids, *id)
  18100. }
  18101. return
  18102. }
  18103. // ResetSopStage resets all changes to the "sop_stage" edge.
  18104. func (m *SopNodeMutation) ResetSopStage() {
  18105. m.sop_stage = nil
  18106. m.clearedsop_stage = false
  18107. }
  18108. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  18109. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  18110. if m.node_messages == nil {
  18111. m.node_messages = make(map[uint64]struct{})
  18112. }
  18113. for i := range ids {
  18114. m.node_messages[ids[i]] = struct{}{}
  18115. }
  18116. }
  18117. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  18118. func (m *SopNodeMutation) ClearNodeMessages() {
  18119. m.clearednode_messages = true
  18120. }
  18121. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  18122. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  18123. return m.clearednode_messages
  18124. }
  18125. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  18126. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  18127. if m.removednode_messages == nil {
  18128. m.removednode_messages = make(map[uint64]struct{})
  18129. }
  18130. for i := range ids {
  18131. delete(m.node_messages, ids[i])
  18132. m.removednode_messages[ids[i]] = struct{}{}
  18133. }
  18134. }
  18135. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  18136. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  18137. for id := range m.removednode_messages {
  18138. ids = append(ids, id)
  18139. }
  18140. return
  18141. }
  18142. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  18143. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  18144. for id := range m.node_messages {
  18145. ids = append(ids, id)
  18146. }
  18147. return
  18148. }
  18149. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18150. func (m *SopNodeMutation) ResetNodeMessages() {
  18151. m.node_messages = nil
  18152. m.clearednode_messages = false
  18153. m.removednode_messages = nil
  18154. }
  18155. // Where appends a list predicates to the SopNodeMutation builder.
  18156. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18157. m.predicates = append(m.predicates, ps...)
  18158. }
  18159. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18160. // users can use type-assertion to append predicates that do not depend on any generated package.
  18161. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18162. p := make([]predicate.SopNode, len(ps))
  18163. for i := range ps {
  18164. p[i] = ps[i]
  18165. }
  18166. m.Where(p...)
  18167. }
  18168. // Op returns the operation name.
  18169. func (m *SopNodeMutation) Op() Op {
  18170. return m.op
  18171. }
  18172. // SetOp allows setting the mutation operation.
  18173. func (m *SopNodeMutation) SetOp(op Op) {
  18174. m.op = op
  18175. }
  18176. // Type returns the node type of this mutation (SopNode).
  18177. func (m *SopNodeMutation) Type() string {
  18178. return m.typ
  18179. }
  18180. // Fields returns all fields that were changed during this mutation. Note that in
  18181. // order to get all numeric fields that were incremented/decremented, call
  18182. // AddedFields().
  18183. func (m *SopNodeMutation) Fields() []string {
  18184. fields := make([]string, 0, 15)
  18185. if m.created_at != nil {
  18186. fields = append(fields, sopnode.FieldCreatedAt)
  18187. }
  18188. if m.updated_at != nil {
  18189. fields = append(fields, sopnode.FieldUpdatedAt)
  18190. }
  18191. if m.status != nil {
  18192. fields = append(fields, sopnode.FieldStatus)
  18193. }
  18194. if m.deleted_at != nil {
  18195. fields = append(fields, sopnode.FieldDeletedAt)
  18196. }
  18197. if m.sop_stage != nil {
  18198. fields = append(fields, sopnode.FieldStageID)
  18199. }
  18200. if m.parent_id != nil {
  18201. fields = append(fields, sopnode.FieldParentID)
  18202. }
  18203. if m.name != nil {
  18204. fields = append(fields, sopnode.FieldName)
  18205. }
  18206. if m.condition_type != nil {
  18207. fields = append(fields, sopnode.FieldConditionType)
  18208. }
  18209. if m.condition_list != nil {
  18210. fields = append(fields, sopnode.FieldConditionList)
  18211. }
  18212. if m.no_reply_condition != nil {
  18213. fields = append(fields, sopnode.FieldNoReplyCondition)
  18214. }
  18215. if m.no_reply_unit != nil {
  18216. fields = append(fields, sopnode.FieldNoReplyUnit)
  18217. }
  18218. if m.action_message != nil {
  18219. fields = append(fields, sopnode.FieldActionMessage)
  18220. }
  18221. if m.action_label_add != nil {
  18222. fields = append(fields, sopnode.FieldActionLabelAdd)
  18223. }
  18224. if m.action_label_del != nil {
  18225. fields = append(fields, sopnode.FieldActionLabelDel)
  18226. }
  18227. if m.action_forward != nil {
  18228. fields = append(fields, sopnode.FieldActionForward)
  18229. }
  18230. return fields
  18231. }
  18232. // Field returns the value of a field with the given name. The second boolean
  18233. // return value indicates that this field was not set, or was not defined in the
  18234. // schema.
  18235. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18236. switch name {
  18237. case sopnode.FieldCreatedAt:
  18238. return m.CreatedAt()
  18239. case sopnode.FieldUpdatedAt:
  18240. return m.UpdatedAt()
  18241. case sopnode.FieldStatus:
  18242. return m.Status()
  18243. case sopnode.FieldDeletedAt:
  18244. return m.DeletedAt()
  18245. case sopnode.FieldStageID:
  18246. return m.StageID()
  18247. case sopnode.FieldParentID:
  18248. return m.ParentID()
  18249. case sopnode.FieldName:
  18250. return m.Name()
  18251. case sopnode.FieldConditionType:
  18252. return m.ConditionType()
  18253. case sopnode.FieldConditionList:
  18254. return m.ConditionList()
  18255. case sopnode.FieldNoReplyCondition:
  18256. return m.NoReplyCondition()
  18257. case sopnode.FieldNoReplyUnit:
  18258. return m.NoReplyUnit()
  18259. case sopnode.FieldActionMessage:
  18260. return m.ActionMessage()
  18261. case sopnode.FieldActionLabelAdd:
  18262. return m.ActionLabelAdd()
  18263. case sopnode.FieldActionLabelDel:
  18264. return m.ActionLabelDel()
  18265. case sopnode.FieldActionForward:
  18266. return m.ActionForward()
  18267. }
  18268. return nil, false
  18269. }
  18270. // OldField returns the old value of the field from the database. An error is
  18271. // returned if the mutation operation is not UpdateOne, or the query to the
  18272. // database failed.
  18273. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18274. switch name {
  18275. case sopnode.FieldCreatedAt:
  18276. return m.OldCreatedAt(ctx)
  18277. case sopnode.FieldUpdatedAt:
  18278. return m.OldUpdatedAt(ctx)
  18279. case sopnode.FieldStatus:
  18280. return m.OldStatus(ctx)
  18281. case sopnode.FieldDeletedAt:
  18282. return m.OldDeletedAt(ctx)
  18283. case sopnode.FieldStageID:
  18284. return m.OldStageID(ctx)
  18285. case sopnode.FieldParentID:
  18286. return m.OldParentID(ctx)
  18287. case sopnode.FieldName:
  18288. return m.OldName(ctx)
  18289. case sopnode.FieldConditionType:
  18290. return m.OldConditionType(ctx)
  18291. case sopnode.FieldConditionList:
  18292. return m.OldConditionList(ctx)
  18293. case sopnode.FieldNoReplyCondition:
  18294. return m.OldNoReplyCondition(ctx)
  18295. case sopnode.FieldNoReplyUnit:
  18296. return m.OldNoReplyUnit(ctx)
  18297. case sopnode.FieldActionMessage:
  18298. return m.OldActionMessage(ctx)
  18299. case sopnode.FieldActionLabelAdd:
  18300. return m.OldActionLabelAdd(ctx)
  18301. case sopnode.FieldActionLabelDel:
  18302. return m.OldActionLabelDel(ctx)
  18303. case sopnode.FieldActionForward:
  18304. return m.OldActionForward(ctx)
  18305. }
  18306. return nil, fmt.Errorf("unknown SopNode field %s", name)
  18307. }
  18308. // SetField sets the value of a field with the given name. It returns an error if
  18309. // the field is not defined in the schema, or if the type mismatched the field
  18310. // type.
  18311. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  18312. switch name {
  18313. case sopnode.FieldCreatedAt:
  18314. v, ok := value.(time.Time)
  18315. if !ok {
  18316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18317. }
  18318. m.SetCreatedAt(v)
  18319. return nil
  18320. case sopnode.FieldUpdatedAt:
  18321. v, ok := value.(time.Time)
  18322. if !ok {
  18323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18324. }
  18325. m.SetUpdatedAt(v)
  18326. return nil
  18327. case sopnode.FieldStatus:
  18328. v, ok := value.(uint8)
  18329. if !ok {
  18330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18331. }
  18332. m.SetStatus(v)
  18333. return nil
  18334. case sopnode.FieldDeletedAt:
  18335. v, ok := value.(time.Time)
  18336. if !ok {
  18337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18338. }
  18339. m.SetDeletedAt(v)
  18340. return nil
  18341. case sopnode.FieldStageID:
  18342. v, ok := value.(uint64)
  18343. if !ok {
  18344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18345. }
  18346. m.SetStageID(v)
  18347. return nil
  18348. case sopnode.FieldParentID:
  18349. v, ok := value.(uint64)
  18350. if !ok {
  18351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18352. }
  18353. m.SetParentID(v)
  18354. return nil
  18355. case sopnode.FieldName:
  18356. v, ok := value.(string)
  18357. if !ok {
  18358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18359. }
  18360. m.SetName(v)
  18361. return nil
  18362. case sopnode.FieldConditionType:
  18363. v, ok := value.(int)
  18364. if !ok {
  18365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18366. }
  18367. m.SetConditionType(v)
  18368. return nil
  18369. case sopnode.FieldConditionList:
  18370. v, ok := value.([]string)
  18371. if !ok {
  18372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18373. }
  18374. m.SetConditionList(v)
  18375. return nil
  18376. case sopnode.FieldNoReplyCondition:
  18377. v, ok := value.(uint64)
  18378. if !ok {
  18379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18380. }
  18381. m.SetNoReplyCondition(v)
  18382. return nil
  18383. case sopnode.FieldNoReplyUnit:
  18384. v, ok := value.(string)
  18385. if !ok {
  18386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18387. }
  18388. m.SetNoReplyUnit(v)
  18389. return nil
  18390. case sopnode.FieldActionMessage:
  18391. v, ok := value.([]custom_types.Action)
  18392. if !ok {
  18393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18394. }
  18395. m.SetActionMessage(v)
  18396. return nil
  18397. case sopnode.FieldActionLabelAdd:
  18398. v, ok := value.([]uint64)
  18399. if !ok {
  18400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18401. }
  18402. m.SetActionLabelAdd(v)
  18403. return nil
  18404. case sopnode.FieldActionLabelDel:
  18405. v, ok := value.([]uint64)
  18406. if !ok {
  18407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18408. }
  18409. m.SetActionLabelDel(v)
  18410. return nil
  18411. case sopnode.FieldActionForward:
  18412. v, ok := value.(*custom_types.ActionForward)
  18413. if !ok {
  18414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18415. }
  18416. m.SetActionForward(v)
  18417. return nil
  18418. }
  18419. return fmt.Errorf("unknown SopNode field %s", name)
  18420. }
  18421. // AddedFields returns all numeric fields that were incremented/decremented during
  18422. // this mutation.
  18423. func (m *SopNodeMutation) AddedFields() []string {
  18424. var fields []string
  18425. if m.addstatus != nil {
  18426. fields = append(fields, sopnode.FieldStatus)
  18427. }
  18428. if m.addparent_id != nil {
  18429. fields = append(fields, sopnode.FieldParentID)
  18430. }
  18431. if m.addcondition_type != nil {
  18432. fields = append(fields, sopnode.FieldConditionType)
  18433. }
  18434. if m.addno_reply_condition != nil {
  18435. fields = append(fields, sopnode.FieldNoReplyCondition)
  18436. }
  18437. return fields
  18438. }
  18439. // AddedField returns the numeric value that was incremented/decremented on a field
  18440. // with the given name. The second boolean return value indicates that this field
  18441. // was not set, or was not defined in the schema.
  18442. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  18443. switch name {
  18444. case sopnode.FieldStatus:
  18445. return m.AddedStatus()
  18446. case sopnode.FieldParentID:
  18447. return m.AddedParentID()
  18448. case sopnode.FieldConditionType:
  18449. return m.AddedConditionType()
  18450. case sopnode.FieldNoReplyCondition:
  18451. return m.AddedNoReplyCondition()
  18452. }
  18453. return nil, false
  18454. }
  18455. // AddField adds the value to the field with the given name. It returns an error if
  18456. // the field is not defined in the schema, or if the type mismatched the field
  18457. // type.
  18458. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  18459. switch name {
  18460. case sopnode.FieldStatus:
  18461. v, ok := value.(int8)
  18462. if !ok {
  18463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18464. }
  18465. m.AddStatus(v)
  18466. return nil
  18467. case sopnode.FieldParentID:
  18468. v, ok := value.(int64)
  18469. if !ok {
  18470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18471. }
  18472. m.AddParentID(v)
  18473. return nil
  18474. case sopnode.FieldConditionType:
  18475. v, ok := value.(int)
  18476. if !ok {
  18477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18478. }
  18479. m.AddConditionType(v)
  18480. return nil
  18481. case sopnode.FieldNoReplyCondition:
  18482. v, ok := value.(int64)
  18483. if !ok {
  18484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18485. }
  18486. m.AddNoReplyCondition(v)
  18487. return nil
  18488. }
  18489. return fmt.Errorf("unknown SopNode numeric field %s", name)
  18490. }
  18491. // ClearedFields returns all nullable fields that were cleared during this
  18492. // mutation.
  18493. func (m *SopNodeMutation) ClearedFields() []string {
  18494. var fields []string
  18495. if m.FieldCleared(sopnode.FieldStatus) {
  18496. fields = append(fields, sopnode.FieldStatus)
  18497. }
  18498. if m.FieldCleared(sopnode.FieldDeletedAt) {
  18499. fields = append(fields, sopnode.FieldDeletedAt)
  18500. }
  18501. if m.FieldCleared(sopnode.FieldConditionList) {
  18502. fields = append(fields, sopnode.FieldConditionList)
  18503. }
  18504. if m.FieldCleared(sopnode.FieldActionMessage) {
  18505. fields = append(fields, sopnode.FieldActionMessage)
  18506. }
  18507. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  18508. fields = append(fields, sopnode.FieldActionLabelAdd)
  18509. }
  18510. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  18511. fields = append(fields, sopnode.FieldActionLabelDel)
  18512. }
  18513. if m.FieldCleared(sopnode.FieldActionForward) {
  18514. fields = append(fields, sopnode.FieldActionForward)
  18515. }
  18516. return fields
  18517. }
  18518. // FieldCleared returns a boolean indicating if a field with the given name was
  18519. // cleared in this mutation.
  18520. func (m *SopNodeMutation) FieldCleared(name string) bool {
  18521. _, ok := m.clearedFields[name]
  18522. return ok
  18523. }
  18524. // ClearField clears the value of the field with the given name. It returns an
  18525. // error if the field is not defined in the schema.
  18526. func (m *SopNodeMutation) ClearField(name string) error {
  18527. switch name {
  18528. case sopnode.FieldStatus:
  18529. m.ClearStatus()
  18530. return nil
  18531. case sopnode.FieldDeletedAt:
  18532. m.ClearDeletedAt()
  18533. return nil
  18534. case sopnode.FieldConditionList:
  18535. m.ClearConditionList()
  18536. return nil
  18537. case sopnode.FieldActionMessage:
  18538. m.ClearActionMessage()
  18539. return nil
  18540. case sopnode.FieldActionLabelAdd:
  18541. m.ClearActionLabelAdd()
  18542. return nil
  18543. case sopnode.FieldActionLabelDel:
  18544. m.ClearActionLabelDel()
  18545. return nil
  18546. case sopnode.FieldActionForward:
  18547. m.ClearActionForward()
  18548. return nil
  18549. }
  18550. return fmt.Errorf("unknown SopNode nullable field %s", name)
  18551. }
  18552. // ResetField resets all changes in the mutation for the field with the given name.
  18553. // It returns an error if the field is not defined in the schema.
  18554. func (m *SopNodeMutation) ResetField(name string) error {
  18555. switch name {
  18556. case sopnode.FieldCreatedAt:
  18557. m.ResetCreatedAt()
  18558. return nil
  18559. case sopnode.FieldUpdatedAt:
  18560. m.ResetUpdatedAt()
  18561. return nil
  18562. case sopnode.FieldStatus:
  18563. m.ResetStatus()
  18564. return nil
  18565. case sopnode.FieldDeletedAt:
  18566. m.ResetDeletedAt()
  18567. return nil
  18568. case sopnode.FieldStageID:
  18569. m.ResetStageID()
  18570. return nil
  18571. case sopnode.FieldParentID:
  18572. m.ResetParentID()
  18573. return nil
  18574. case sopnode.FieldName:
  18575. m.ResetName()
  18576. return nil
  18577. case sopnode.FieldConditionType:
  18578. m.ResetConditionType()
  18579. return nil
  18580. case sopnode.FieldConditionList:
  18581. m.ResetConditionList()
  18582. return nil
  18583. case sopnode.FieldNoReplyCondition:
  18584. m.ResetNoReplyCondition()
  18585. return nil
  18586. case sopnode.FieldNoReplyUnit:
  18587. m.ResetNoReplyUnit()
  18588. return nil
  18589. case sopnode.FieldActionMessage:
  18590. m.ResetActionMessage()
  18591. return nil
  18592. case sopnode.FieldActionLabelAdd:
  18593. m.ResetActionLabelAdd()
  18594. return nil
  18595. case sopnode.FieldActionLabelDel:
  18596. m.ResetActionLabelDel()
  18597. return nil
  18598. case sopnode.FieldActionForward:
  18599. m.ResetActionForward()
  18600. return nil
  18601. }
  18602. return fmt.Errorf("unknown SopNode field %s", name)
  18603. }
  18604. // AddedEdges returns all edge names that were set/added in this mutation.
  18605. func (m *SopNodeMutation) AddedEdges() []string {
  18606. edges := make([]string, 0, 2)
  18607. if m.sop_stage != nil {
  18608. edges = append(edges, sopnode.EdgeSopStage)
  18609. }
  18610. if m.node_messages != nil {
  18611. edges = append(edges, sopnode.EdgeNodeMessages)
  18612. }
  18613. return edges
  18614. }
  18615. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18616. // name in this mutation.
  18617. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  18618. switch name {
  18619. case sopnode.EdgeSopStage:
  18620. if id := m.sop_stage; id != nil {
  18621. return []ent.Value{*id}
  18622. }
  18623. case sopnode.EdgeNodeMessages:
  18624. ids := make([]ent.Value, 0, len(m.node_messages))
  18625. for id := range m.node_messages {
  18626. ids = append(ids, id)
  18627. }
  18628. return ids
  18629. }
  18630. return nil
  18631. }
  18632. // RemovedEdges returns all edge names that were removed in this mutation.
  18633. func (m *SopNodeMutation) RemovedEdges() []string {
  18634. edges := make([]string, 0, 2)
  18635. if m.removednode_messages != nil {
  18636. edges = append(edges, sopnode.EdgeNodeMessages)
  18637. }
  18638. return edges
  18639. }
  18640. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18641. // the given name in this mutation.
  18642. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  18643. switch name {
  18644. case sopnode.EdgeNodeMessages:
  18645. ids := make([]ent.Value, 0, len(m.removednode_messages))
  18646. for id := range m.removednode_messages {
  18647. ids = append(ids, id)
  18648. }
  18649. return ids
  18650. }
  18651. return nil
  18652. }
  18653. // ClearedEdges returns all edge names that were cleared in this mutation.
  18654. func (m *SopNodeMutation) ClearedEdges() []string {
  18655. edges := make([]string, 0, 2)
  18656. if m.clearedsop_stage {
  18657. edges = append(edges, sopnode.EdgeSopStage)
  18658. }
  18659. if m.clearednode_messages {
  18660. edges = append(edges, sopnode.EdgeNodeMessages)
  18661. }
  18662. return edges
  18663. }
  18664. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18665. // was cleared in this mutation.
  18666. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  18667. switch name {
  18668. case sopnode.EdgeSopStage:
  18669. return m.clearedsop_stage
  18670. case sopnode.EdgeNodeMessages:
  18671. return m.clearednode_messages
  18672. }
  18673. return false
  18674. }
  18675. // ClearEdge clears the value of the edge with the given name. It returns an error
  18676. // if that edge is not defined in the schema.
  18677. func (m *SopNodeMutation) ClearEdge(name string) error {
  18678. switch name {
  18679. case sopnode.EdgeSopStage:
  18680. m.ClearSopStage()
  18681. return nil
  18682. }
  18683. return fmt.Errorf("unknown SopNode unique edge %s", name)
  18684. }
  18685. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18686. // It returns an error if the edge is not defined in the schema.
  18687. func (m *SopNodeMutation) ResetEdge(name string) error {
  18688. switch name {
  18689. case sopnode.EdgeSopStage:
  18690. m.ResetSopStage()
  18691. return nil
  18692. case sopnode.EdgeNodeMessages:
  18693. m.ResetNodeMessages()
  18694. return nil
  18695. }
  18696. return fmt.Errorf("unknown SopNode edge %s", name)
  18697. }
  18698. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  18699. type SopStageMutation struct {
  18700. config
  18701. op Op
  18702. typ string
  18703. id *uint64
  18704. created_at *time.Time
  18705. updated_at *time.Time
  18706. status *uint8
  18707. addstatus *int8
  18708. deleted_at *time.Time
  18709. name *string
  18710. condition_type *int
  18711. addcondition_type *int
  18712. condition_operator *int
  18713. addcondition_operator *int
  18714. condition_list *[]custom_types.Condition
  18715. appendcondition_list []custom_types.Condition
  18716. action_message *[]custom_types.Action
  18717. appendaction_message []custom_types.Action
  18718. action_label_add *[]uint64
  18719. appendaction_label_add []uint64
  18720. action_label_del *[]uint64
  18721. appendaction_label_del []uint64
  18722. action_forward **custom_types.ActionForward
  18723. index_sort *int
  18724. addindex_sort *int
  18725. clearedFields map[string]struct{}
  18726. sop_task *uint64
  18727. clearedsop_task bool
  18728. stage_nodes map[uint64]struct{}
  18729. removedstage_nodes map[uint64]struct{}
  18730. clearedstage_nodes bool
  18731. stage_messages map[uint64]struct{}
  18732. removedstage_messages map[uint64]struct{}
  18733. clearedstage_messages bool
  18734. done bool
  18735. oldValue func(context.Context) (*SopStage, error)
  18736. predicates []predicate.SopStage
  18737. }
  18738. var _ ent.Mutation = (*SopStageMutation)(nil)
  18739. // sopstageOption allows management of the mutation configuration using functional options.
  18740. type sopstageOption func(*SopStageMutation)
  18741. // newSopStageMutation creates new mutation for the SopStage entity.
  18742. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  18743. m := &SopStageMutation{
  18744. config: c,
  18745. op: op,
  18746. typ: TypeSopStage,
  18747. clearedFields: make(map[string]struct{}),
  18748. }
  18749. for _, opt := range opts {
  18750. opt(m)
  18751. }
  18752. return m
  18753. }
  18754. // withSopStageID sets the ID field of the mutation.
  18755. func withSopStageID(id uint64) sopstageOption {
  18756. return func(m *SopStageMutation) {
  18757. var (
  18758. err error
  18759. once sync.Once
  18760. value *SopStage
  18761. )
  18762. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  18763. once.Do(func() {
  18764. if m.done {
  18765. err = errors.New("querying old values post mutation is not allowed")
  18766. } else {
  18767. value, err = m.Client().SopStage.Get(ctx, id)
  18768. }
  18769. })
  18770. return value, err
  18771. }
  18772. m.id = &id
  18773. }
  18774. }
  18775. // withSopStage sets the old SopStage of the mutation.
  18776. func withSopStage(node *SopStage) sopstageOption {
  18777. return func(m *SopStageMutation) {
  18778. m.oldValue = func(context.Context) (*SopStage, error) {
  18779. return node, nil
  18780. }
  18781. m.id = &node.ID
  18782. }
  18783. }
  18784. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18785. // executed in a transaction (ent.Tx), a transactional client is returned.
  18786. func (m SopStageMutation) Client() *Client {
  18787. client := &Client{config: m.config}
  18788. client.init()
  18789. return client
  18790. }
  18791. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18792. // it returns an error otherwise.
  18793. func (m SopStageMutation) Tx() (*Tx, error) {
  18794. if _, ok := m.driver.(*txDriver); !ok {
  18795. return nil, errors.New("ent: mutation is not running in a transaction")
  18796. }
  18797. tx := &Tx{config: m.config}
  18798. tx.init()
  18799. return tx, nil
  18800. }
  18801. // SetID sets the value of the id field. Note that this
  18802. // operation is only accepted on creation of SopStage entities.
  18803. func (m *SopStageMutation) SetID(id uint64) {
  18804. m.id = &id
  18805. }
  18806. // ID returns the ID value in the mutation. Note that the ID is only available
  18807. // if it was provided to the builder or after it was returned from the database.
  18808. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  18809. if m.id == nil {
  18810. return
  18811. }
  18812. return *m.id, true
  18813. }
  18814. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18815. // That means, if the mutation is applied within a transaction with an isolation level such
  18816. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18817. // or updated by the mutation.
  18818. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  18819. switch {
  18820. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18821. id, exists := m.ID()
  18822. if exists {
  18823. return []uint64{id}, nil
  18824. }
  18825. fallthrough
  18826. case m.op.Is(OpUpdate | OpDelete):
  18827. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  18828. default:
  18829. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18830. }
  18831. }
  18832. // SetCreatedAt sets the "created_at" field.
  18833. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  18834. m.created_at = &t
  18835. }
  18836. // CreatedAt returns the value of the "created_at" field in the mutation.
  18837. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  18838. v := m.created_at
  18839. if v == nil {
  18840. return
  18841. }
  18842. return *v, true
  18843. }
  18844. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  18845. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18847. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18848. if !m.op.Is(OpUpdateOne) {
  18849. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18850. }
  18851. if m.id == nil || m.oldValue == nil {
  18852. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18853. }
  18854. oldValue, err := m.oldValue(ctx)
  18855. if err != nil {
  18856. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18857. }
  18858. return oldValue.CreatedAt, nil
  18859. }
  18860. // ResetCreatedAt resets all changes to the "created_at" field.
  18861. func (m *SopStageMutation) ResetCreatedAt() {
  18862. m.created_at = nil
  18863. }
  18864. // SetUpdatedAt sets the "updated_at" field.
  18865. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  18866. m.updated_at = &t
  18867. }
  18868. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18869. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  18870. v := m.updated_at
  18871. if v == nil {
  18872. return
  18873. }
  18874. return *v, true
  18875. }
  18876. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  18877. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18879. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18880. if !m.op.Is(OpUpdateOne) {
  18881. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18882. }
  18883. if m.id == nil || m.oldValue == nil {
  18884. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18885. }
  18886. oldValue, err := m.oldValue(ctx)
  18887. if err != nil {
  18888. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18889. }
  18890. return oldValue.UpdatedAt, nil
  18891. }
  18892. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18893. func (m *SopStageMutation) ResetUpdatedAt() {
  18894. m.updated_at = nil
  18895. }
  18896. // SetStatus sets the "status" field.
  18897. func (m *SopStageMutation) SetStatus(u uint8) {
  18898. m.status = &u
  18899. m.addstatus = nil
  18900. }
  18901. // Status returns the value of the "status" field in the mutation.
  18902. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18903. v := m.status
  18904. if v == nil {
  18905. return
  18906. }
  18907. return *v, true
  18908. }
  18909. // OldStatus returns the old "status" field's value of the SopStage entity.
  18910. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18912. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18913. if !m.op.Is(OpUpdateOne) {
  18914. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18915. }
  18916. if m.id == nil || m.oldValue == nil {
  18917. return v, errors.New("OldStatus requires an ID field in the mutation")
  18918. }
  18919. oldValue, err := m.oldValue(ctx)
  18920. if err != nil {
  18921. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18922. }
  18923. return oldValue.Status, nil
  18924. }
  18925. // AddStatus adds u to the "status" field.
  18926. func (m *SopStageMutation) AddStatus(u int8) {
  18927. if m.addstatus != nil {
  18928. *m.addstatus += u
  18929. } else {
  18930. m.addstatus = &u
  18931. }
  18932. }
  18933. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18934. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18935. v := m.addstatus
  18936. if v == nil {
  18937. return
  18938. }
  18939. return *v, true
  18940. }
  18941. // ClearStatus clears the value of the "status" field.
  18942. func (m *SopStageMutation) ClearStatus() {
  18943. m.status = nil
  18944. m.addstatus = nil
  18945. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18946. }
  18947. // StatusCleared returns if the "status" field was cleared in this mutation.
  18948. func (m *SopStageMutation) StatusCleared() bool {
  18949. _, ok := m.clearedFields[sopstage.FieldStatus]
  18950. return ok
  18951. }
  18952. // ResetStatus resets all changes to the "status" field.
  18953. func (m *SopStageMutation) ResetStatus() {
  18954. m.status = nil
  18955. m.addstatus = nil
  18956. delete(m.clearedFields, sopstage.FieldStatus)
  18957. }
  18958. // SetDeletedAt sets the "deleted_at" field.
  18959. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18960. m.deleted_at = &t
  18961. }
  18962. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18963. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18964. v := m.deleted_at
  18965. if v == nil {
  18966. return
  18967. }
  18968. return *v, true
  18969. }
  18970. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18971. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18973. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18974. if !m.op.Is(OpUpdateOne) {
  18975. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18976. }
  18977. if m.id == nil || m.oldValue == nil {
  18978. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18979. }
  18980. oldValue, err := m.oldValue(ctx)
  18981. if err != nil {
  18982. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18983. }
  18984. return oldValue.DeletedAt, nil
  18985. }
  18986. // ClearDeletedAt clears the value of the "deleted_at" field.
  18987. func (m *SopStageMutation) ClearDeletedAt() {
  18988. m.deleted_at = nil
  18989. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18990. }
  18991. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18992. func (m *SopStageMutation) DeletedAtCleared() bool {
  18993. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18994. return ok
  18995. }
  18996. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18997. func (m *SopStageMutation) ResetDeletedAt() {
  18998. m.deleted_at = nil
  18999. delete(m.clearedFields, sopstage.FieldDeletedAt)
  19000. }
  19001. // SetTaskID sets the "task_id" field.
  19002. func (m *SopStageMutation) SetTaskID(u uint64) {
  19003. m.sop_task = &u
  19004. }
  19005. // TaskID returns the value of the "task_id" field in the mutation.
  19006. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  19007. v := m.sop_task
  19008. if v == nil {
  19009. return
  19010. }
  19011. return *v, true
  19012. }
  19013. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  19014. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19016. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  19017. if !m.op.Is(OpUpdateOne) {
  19018. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  19019. }
  19020. if m.id == nil || m.oldValue == nil {
  19021. return v, errors.New("OldTaskID requires an ID field in the mutation")
  19022. }
  19023. oldValue, err := m.oldValue(ctx)
  19024. if err != nil {
  19025. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  19026. }
  19027. return oldValue.TaskID, nil
  19028. }
  19029. // ResetTaskID resets all changes to the "task_id" field.
  19030. func (m *SopStageMutation) ResetTaskID() {
  19031. m.sop_task = nil
  19032. }
  19033. // SetName sets the "name" field.
  19034. func (m *SopStageMutation) SetName(s string) {
  19035. m.name = &s
  19036. }
  19037. // Name returns the value of the "name" field in the mutation.
  19038. func (m *SopStageMutation) Name() (r string, exists bool) {
  19039. v := m.name
  19040. if v == nil {
  19041. return
  19042. }
  19043. return *v, true
  19044. }
  19045. // OldName returns the old "name" field's value of the SopStage entity.
  19046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19048. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  19049. if !m.op.Is(OpUpdateOne) {
  19050. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19051. }
  19052. if m.id == nil || m.oldValue == nil {
  19053. return v, errors.New("OldName requires an ID field in the mutation")
  19054. }
  19055. oldValue, err := m.oldValue(ctx)
  19056. if err != nil {
  19057. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19058. }
  19059. return oldValue.Name, nil
  19060. }
  19061. // ResetName resets all changes to the "name" field.
  19062. func (m *SopStageMutation) ResetName() {
  19063. m.name = nil
  19064. }
  19065. // SetConditionType sets the "condition_type" field.
  19066. func (m *SopStageMutation) SetConditionType(i int) {
  19067. m.condition_type = &i
  19068. m.addcondition_type = nil
  19069. }
  19070. // ConditionType returns the value of the "condition_type" field in the mutation.
  19071. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  19072. v := m.condition_type
  19073. if v == nil {
  19074. return
  19075. }
  19076. return *v, true
  19077. }
  19078. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  19079. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19081. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  19082. if !m.op.Is(OpUpdateOne) {
  19083. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  19084. }
  19085. if m.id == nil || m.oldValue == nil {
  19086. return v, errors.New("OldConditionType requires an ID field in the mutation")
  19087. }
  19088. oldValue, err := m.oldValue(ctx)
  19089. if err != nil {
  19090. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  19091. }
  19092. return oldValue.ConditionType, nil
  19093. }
  19094. // AddConditionType adds i to the "condition_type" field.
  19095. func (m *SopStageMutation) AddConditionType(i int) {
  19096. if m.addcondition_type != nil {
  19097. *m.addcondition_type += i
  19098. } else {
  19099. m.addcondition_type = &i
  19100. }
  19101. }
  19102. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  19103. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  19104. v := m.addcondition_type
  19105. if v == nil {
  19106. return
  19107. }
  19108. return *v, true
  19109. }
  19110. // ResetConditionType resets all changes to the "condition_type" field.
  19111. func (m *SopStageMutation) ResetConditionType() {
  19112. m.condition_type = nil
  19113. m.addcondition_type = nil
  19114. }
  19115. // SetConditionOperator sets the "condition_operator" field.
  19116. func (m *SopStageMutation) SetConditionOperator(i int) {
  19117. m.condition_operator = &i
  19118. m.addcondition_operator = nil
  19119. }
  19120. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  19121. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  19122. v := m.condition_operator
  19123. if v == nil {
  19124. return
  19125. }
  19126. return *v, true
  19127. }
  19128. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  19129. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19131. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  19132. if !m.op.Is(OpUpdateOne) {
  19133. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  19134. }
  19135. if m.id == nil || m.oldValue == nil {
  19136. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  19137. }
  19138. oldValue, err := m.oldValue(ctx)
  19139. if err != nil {
  19140. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  19141. }
  19142. return oldValue.ConditionOperator, nil
  19143. }
  19144. // AddConditionOperator adds i to the "condition_operator" field.
  19145. func (m *SopStageMutation) AddConditionOperator(i int) {
  19146. if m.addcondition_operator != nil {
  19147. *m.addcondition_operator += i
  19148. } else {
  19149. m.addcondition_operator = &i
  19150. }
  19151. }
  19152. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19153. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19154. v := m.addcondition_operator
  19155. if v == nil {
  19156. return
  19157. }
  19158. return *v, true
  19159. }
  19160. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19161. func (m *SopStageMutation) ResetConditionOperator() {
  19162. m.condition_operator = nil
  19163. m.addcondition_operator = nil
  19164. }
  19165. // SetConditionList sets the "condition_list" field.
  19166. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19167. m.condition_list = &ct
  19168. m.appendcondition_list = nil
  19169. }
  19170. // ConditionList returns the value of the "condition_list" field in the mutation.
  19171. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19172. v := m.condition_list
  19173. if v == nil {
  19174. return
  19175. }
  19176. return *v, true
  19177. }
  19178. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19179. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19181. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19182. if !m.op.Is(OpUpdateOne) {
  19183. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19184. }
  19185. if m.id == nil || m.oldValue == nil {
  19186. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19187. }
  19188. oldValue, err := m.oldValue(ctx)
  19189. if err != nil {
  19190. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19191. }
  19192. return oldValue.ConditionList, nil
  19193. }
  19194. // AppendConditionList adds ct to the "condition_list" field.
  19195. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19196. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19197. }
  19198. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19199. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19200. if len(m.appendcondition_list) == 0 {
  19201. return nil, false
  19202. }
  19203. return m.appendcondition_list, true
  19204. }
  19205. // ResetConditionList resets all changes to the "condition_list" field.
  19206. func (m *SopStageMutation) ResetConditionList() {
  19207. m.condition_list = nil
  19208. m.appendcondition_list = nil
  19209. }
  19210. // SetActionMessage sets the "action_message" field.
  19211. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19212. m.action_message = &ct
  19213. m.appendaction_message = nil
  19214. }
  19215. // ActionMessage returns the value of the "action_message" field in the mutation.
  19216. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19217. v := m.action_message
  19218. if v == nil {
  19219. return
  19220. }
  19221. return *v, true
  19222. }
  19223. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19224. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19226. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19227. if !m.op.Is(OpUpdateOne) {
  19228. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19229. }
  19230. if m.id == nil || m.oldValue == nil {
  19231. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19232. }
  19233. oldValue, err := m.oldValue(ctx)
  19234. if err != nil {
  19235. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19236. }
  19237. return oldValue.ActionMessage, nil
  19238. }
  19239. // AppendActionMessage adds ct to the "action_message" field.
  19240. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19241. m.appendaction_message = append(m.appendaction_message, ct...)
  19242. }
  19243. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19244. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19245. if len(m.appendaction_message) == 0 {
  19246. return nil, false
  19247. }
  19248. return m.appendaction_message, true
  19249. }
  19250. // ClearActionMessage clears the value of the "action_message" field.
  19251. func (m *SopStageMutation) ClearActionMessage() {
  19252. m.action_message = nil
  19253. m.appendaction_message = nil
  19254. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  19255. }
  19256. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  19257. func (m *SopStageMutation) ActionMessageCleared() bool {
  19258. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  19259. return ok
  19260. }
  19261. // ResetActionMessage resets all changes to the "action_message" field.
  19262. func (m *SopStageMutation) ResetActionMessage() {
  19263. m.action_message = nil
  19264. m.appendaction_message = nil
  19265. delete(m.clearedFields, sopstage.FieldActionMessage)
  19266. }
  19267. // SetActionLabelAdd sets the "action_label_add" field.
  19268. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  19269. m.action_label_add = &u
  19270. m.appendaction_label_add = nil
  19271. }
  19272. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19273. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19274. v := m.action_label_add
  19275. if v == nil {
  19276. return
  19277. }
  19278. return *v, true
  19279. }
  19280. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  19281. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19283. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19284. if !m.op.Is(OpUpdateOne) {
  19285. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19286. }
  19287. if m.id == nil || m.oldValue == nil {
  19288. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19289. }
  19290. oldValue, err := m.oldValue(ctx)
  19291. if err != nil {
  19292. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19293. }
  19294. return oldValue.ActionLabelAdd, nil
  19295. }
  19296. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19297. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  19298. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19299. }
  19300. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19301. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19302. if len(m.appendaction_label_add) == 0 {
  19303. return nil, false
  19304. }
  19305. return m.appendaction_label_add, true
  19306. }
  19307. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19308. func (m *SopStageMutation) ClearActionLabelAdd() {
  19309. m.action_label_add = nil
  19310. m.appendaction_label_add = nil
  19311. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  19312. }
  19313. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19314. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  19315. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  19316. return ok
  19317. }
  19318. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19319. func (m *SopStageMutation) ResetActionLabelAdd() {
  19320. m.action_label_add = nil
  19321. m.appendaction_label_add = nil
  19322. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  19323. }
  19324. // SetActionLabelDel sets the "action_label_del" field.
  19325. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  19326. m.action_label_del = &u
  19327. m.appendaction_label_del = nil
  19328. }
  19329. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19330. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  19331. v := m.action_label_del
  19332. if v == nil {
  19333. return
  19334. }
  19335. return *v, true
  19336. }
  19337. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  19338. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19340. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19341. if !m.op.Is(OpUpdateOne) {
  19342. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19343. }
  19344. if m.id == nil || m.oldValue == nil {
  19345. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19346. }
  19347. oldValue, err := m.oldValue(ctx)
  19348. if err != nil {
  19349. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19350. }
  19351. return oldValue.ActionLabelDel, nil
  19352. }
  19353. // AppendActionLabelDel adds u to the "action_label_del" field.
  19354. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  19355. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19356. }
  19357. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19358. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19359. if len(m.appendaction_label_del) == 0 {
  19360. return nil, false
  19361. }
  19362. return m.appendaction_label_del, true
  19363. }
  19364. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19365. func (m *SopStageMutation) ClearActionLabelDel() {
  19366. m.action_label_del = nil
  19367. m.appendaction_label_del = nil
  19368. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  19369. }
  19370. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19371. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  19372. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  19373. return ok
  19374. }
  19375. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19376. func (m *SopStageMutation) ResetActionLabelDel() {
  19377. m.action_label_del = nil
  19378. m.appendaction_label_del = nil
  19379. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  19380. }
  19381. // SetActionForward sets the "action_forward" field.
  19382. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  19383. m.action_forward = &ctf
  19384. }
  19385. // ActionForward returns the value of the "action_forward" field in the mutation.
  19386. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  19387. v := m.action_forward
  19388. if v == nil {
  19389. return
  19390. }
  19391. return *v, true
  19392. }
  19393. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  19394. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19396. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  19397. if !m.op.Is(OpUpdateOne) {
  19398. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  19399. }
  19400. if m.id == nil || m.oldValue == nil {
  19401. return v, errors.New("OldActionForward requires an ID field in the mutation")
  19402. }
  19403. oldValue, err := m.oldValue(ctx)
  19404. if err != nil {
  19405. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  19406. }
  19407. return oldValue.ActionForward, nil
  19408. }
  19409. // ClearActionForward clears the value of the "action_forward" field.
  19410. func (m *SopStageMutation) ClearActionForward() {
  19411. m.action_forward = nil
  19412. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  19413. }
  19414. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  19415. func (m *SopStageMutation) ActionForwardCleared() bool {
  19416. _, ok := m.clearedFields[sopstage.FieldActionForward]
  19417. return ok
  19418. }
  19419. // ResetActionForward resets all changes to the "action_forward" field.
  19420. func (m *SopStageMutation) ResetActionForward() {
  19421. m.action_forward = nil
  19422. delete(m.clearedFields, sopstage.FieldActionForward)
  19423. }
  19424. // SetIndexSort sets the "index_sort" field.
  19425. func (m *SopStageMutation) SetIndexSort(i int) {
  19426. m.index_sort = &i
  19427. m.addindex_sort = nil
  19428. }
  19429. // IndexSort returns the value of the "index_sort" field in the mutation.
  19430. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  19431. v := m.index_sort
  19432. if v == nil {
  19433. return
  19434. }
  19435. return *v, true
  19436. }
  19437. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  19438. // If the SopStage 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 *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  19441. if !m.op.Is(OpUpdateOne) {
  19442. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  19443. }
  19444. if m.id == nil || m.oldValue == nil {
  19445. return v, errors.New("OldIndexSort 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 OldIndexSort: %w", err)
  19450. }
  19451. return oldValue.IndexSort, nil
  19452. }
  19453. // AddIndexSort adds i to the "index_sort" field.
  19454. func (m *SopStageMutation) AddIndexSort(i int) {
  19455. if m.addindex_sort != nil {
  19456. *m.addindex_sort += i
  19457. } else {
  19458. m.addindex_sort = &i
  19459. }
  19460. }
  19461. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  19462. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  19463. v := m.addindex_sort
  19464. if v == nil {
  19465. return
  19466. }
  19467. return *v, true
  19468. }
  19469. // ClearIndexSort clears the value of the "index_sort" field.
  19470. func (m *SopStageMutation) ClearIndexSort() {
  19471. m.index_sort = nil
  19472. m.addindex_sort = nil
  19473. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  19474. }
  19475. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  19476. func (m *SopStageMutation) IndexSortCleared() bool {
  19477. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  19478. return ok
  19479. }
  19480. // ResetIndexSort resets all changes to the "index_sort" field.
  19481. func (m *SopStageMutation) ResetIndexSort() {
  19482. m.index_sort = nil
  19483. m.addindex_sort = nil
  19484. delete(m.clearedFields, sopstage.FieldIndexSort)
  19485. }
  19486. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  19487. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  19488. m.sop_task = &id
  19489. }
  19490. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  19491. func (m *SopStageMutation) ClearSopTask() {
  19492. m.clearedsop_task = true
  19493. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  19494. }
  19495. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  19496. func (m *SopStageMutation) SopTaskCleared() bool {
  19497. return m.clearedsop_task
  19498. }
  19499. // SopTaskID returns the "sop_task" edge ID in the mutation.
  19500. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  19501. if m.sop_task != nil {
  19502. return *m.sop_task, true
  19503. }
  19504. return
  19505. }
  19506. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  19507. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19508. // SopTaskID instead. It exists only for internal usage by the builders.
  19509. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  19510. if id := m.sop_task; id != nil {
  19511. ids = append(ids, *id)
  19512. }
  19513. return
  19514. }
  19515. // ResetSopTask resets all changes to the "sop_task" edge.
  19516. func (m *SopStageMutation) ResetSopTask() {
  19517. m.sop_task = nil
  19518. m.clearedsop_task = false
  19519. }
  19520. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  19521. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  19522. if m.stage_nodes == nil {
  19523. m.stage_nodes = make(map[uint64]struct{})
  19524. }
  19525. for i := range ids {
  19526. m.stage_nodes[ids[i]] = struct{}{}
  19527. }
  19528. }
  19529. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  19530. func (m *SopStageMutation) ClearStageNodes() {
  19531. m.clearedstage_nodes = true
  19532. }
  19533. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  19534. func (m *SopStageMutation) StageNodesCleared() bool {
  19535. return m.clearedstage_nodes
  19536. }
  19537. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  19538. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  19539. if m.removedstage_nodes == nil {
  19540. m.removedstage_nodes = make(map[uint64]struct{})
  19541. }
  19542. for i := range ids {
  19543. delete(m.stage_nodes, ids[i])
  19544. m.removedstage_nodes[ids[i]] = struct{}{}
  19545. }
  19546. }
  19547. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  19548. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  19549. for id := range m.removedstage_nodes {
  19550. ids = append(ids, id)
  19551. }
  19552. return
  19553. }
  19554. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  19555. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  19556. for id := range m.stage_nodes {
  19557. ids = append(ids, id)
  19558. }
  19559. return
  19560. }
  19561. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  19562. func (m *SopStageMutation) ResetStageNodes() {
  19563. m.stage_nodes = nil
  19564. m.clearedstage_nodes = false
  19565. m.removedstage_nodes = nil
  19566. }
  19567. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  19568. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  19569. if m.stage_messages == nil {
  19570. m.stage_messages = make(map[uint64]struct{})
  19571. }
  19572. for i := range ids {
  19573. m.stage_messages[ids[i]] = struct{}{}
  19574. }
  19575. }
  19576. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  19577. func (m *SopStageMutation) ClearStageMessages() {
  19578. m.clearedstage_messages = true
  19579. }
  19580. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  19581. func (m *SopStageMutation) StageMessagesCleared() bool {
  19582. return m.clearedstage_messages
  19583. }
  19584. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  19585. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  19586. if m.removedstage_messages == nil {
  19587. m.removedstage_messages = make(map[uint64]struct{})
  19588. }
  19589. for i := range ids {
  19590. delete(m.stage_messages, ids[i])
  19591. m.removedstage_messages[ids[i]] = struct{}{}
  19592. }
  19593. }
  19594. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  19595. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  19596. for id := range m.removedstage_messages {
  19597. ids = append(ids, id)
  19598. }
  19599. return
  19600. }
  19601. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  19602. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  19603. for id := range m.stage_messages {
  19604. ids = append(ids, id)
  19605. }
  19606. return
  19607. }
  19608. // ResetStageMessages resets all changes to the "stage_messages" edge.
  19609. func (m *SopStageMutation) ResetStageMessages() {
  19610. m.stage_messages = nil
  19611. m.clearedstage_messages = false
  19612. m.removedstage_messages = nil
  19613. }
  19614. // Where appends a list predicates to the SopStageMutation builder.
  19615. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  19616. m.predicates = append(m.predicates, ps...)
  19617. }
  19618. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  19619. // users can use type-assertion to append predicates that do not depend on any generated package.
  19620. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  19621. p := make([]predicate.SopStage, len(ps))
  19622. for i := range ps {
  19623. p[i] = ps[i]
  19624. }
  19625. m.Where(p...)
  19626. }
  19627. // Op returns the operation name.
  19628. func (m *SopStageMutation) Op() Op {
  19629. return m.op
  19630. }
  19631. // SetOp allows setting the mutation operation.
  19632. func (m *SopStageMutation) SetOp(op Op) {
  19633. m.op = op
  19634. }
  19635. // Type returns the node type of this mutation (SopStage).
  19636. func (m *SopStageMutation) Type() string {
  19637. return m.typ
  19638. }
  19639. // Fields returns all fields that were changed during this mutation. Note that in
  19640. // order to get all numeric fields that were incremented/decremented, call
  19641. // AddedFields().
  19642. func (m *SopStageMutation) Fields() []string {
  19643. fields := make([]string, 0, 14)
  19644. if m.created_at != nil {
  19645. fields = append(fields, sopstage.FieldCreatedAt)
  19646. }
  19647. if m.updated_at != nil {
  19648. fields = append(fields, sopstage.FieldUpdatedAt)
  19649. }
  19650. if m.status != nil {
  19651. fields = append(fields, sopstage.FieldStatus)
  19652. }
  19653. if m.deleted_at != nil {
  19654. fields = append(fields, sopstage.FieldDeletedAt)
  19655. }
  19656. if m.sop_task != nil {
  19657. fields = append(fields, sopstage.FieldTaskID)
  19658. }
  19659. if m.name != nil {
  19660. fields = append(fields, sopstage.FieldName)
  19661. }
  19662. if m.condition_type != nil {
  19663. fields = append(fields, sopstage.FieldConditionType)
  19664. }
  19665. if m.condition_operator != nil {
  19666. fields = append(fields, sopstage.FieldConditionOperator)
  19667. }
  19668. if m.condition_list != nil {
  19669. fields = append(fields, sopstage.FieldConditionList)
  19670. }
  19671. if m.action_message != nil {
  19672. fields = append(fields, sopstage.FieldActionMessage)
  19673. }
  19674. if m.action_label_add != nil {
  19675. fields = append(fields, sopstage.FieldActionLabelAdd)
  19676. }
  19677. if m.action_label_del != nil {
  19678. fields = append(fields, sopstage.FieldActionLabelDel)
  19679. }
  19680. if m.action_forward != nil {
  19681. fields = append(fields, sopstage.FieldActionForward)
  19682. }
  19683. if m.index_sort != nil {
  19684. fields = append(fields, sopstage.FieldIndexSort)
  19685. }
  19686. return fields
  19687. }
  19688. // Field returns the value of a field with the given name. The second boolean
  19689. // return value indicates that this field was not set, or was not defined in the
  19690. // schema.
  19691. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  19692. switch name {
  19693. case sopstage.FieldCreatedAt:
  19694. return m.CreatedAt()
  19695. case sopstage.FieldUpdatedAt:
  19696. return m.UpdatedAt()
  19697. case sopstage.FieldStatus:
  19698. return m.Status()
  19699. case sopstage.FieldDeletedAt:
  19700. return m.DeletedAt()
  19701. case sopstage.FieldTaskID:
  19702. return m.TaskID()
  19703. case sopstage.FieldName:
  19704. return m.Name()
  19705. case sopstage.FieldConditionType:
  19706. return m.ConditionType()
  19707. case sopstage.FieldConditionOperator:
  19708. return m.ConditionOperator()
  19709. case sopstage.FieldConditionList:
  19710. return m.ConditionList()
  19711. case sopstage.FieldActionMessage:
  19712. return m.ActionMessage()
  19713. case sopstage.FieldActionLabelAdd:
  19714. return m.ActionLabelAdd()
  19715. case sopstage.FieldActionLabelDel:
  19716. return m.ActionLabelDel()
  19717. case sopstage.FieldActionForward:
  19718. return m.ActionForward()
  19719. case sopstage.FieldIndexSort:
  19720. return m.IndexSort()
  19721. }
  19722. return nil, false
  19723. }
  19724. // OldField returns the old value of the field from the database. An error is
  19725. // returned if the mutation operation is not UpdateOne, or the query to the
  19726. // database failed.
  19727. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19728. switch name {
  19729. case sopstage.FieldCreatedAt:
  19730. return m.OldCreatedAt(ctx)
  19731. case sopstage.FieldUpdatedAt:
  19732. return m.OldUpdatedAt(ctx)
  19733. case sopstage.FieldStatus:
  19734. return m.OldStatus(ctx)
  19735. case sopstage.FieldDeletedAt:
  19736. return m.OldDeletedAt(ctx)
  19737. case sopstage.FieldTaskID:
  19738. return m.OldTaskID(ctx)
  19739. case sopstage.FieldName:
  19740. return m.OldName(ctx)
  19741. case sopstage.FieldConditionType:
  19742. return m.OldConditionType(ctx)
  19743. case sopstage.FieldConditionOperator:
  19744. return m.OldConditionOperator(ctx)
  19745. case sopstage.FieldConditionList:
  19746. return m.OldConditionList(ctx)
  19747. case sopstage.FieldActionMessage:
  19748. return m.OldActionMessage(ctx)
  19749. case sopstage.FieldActionLabelAdd:
  19750. return m.OldActionLabelAdd(ctx)
  19751. case sopstage.FieldActionLabelDel:
  19752. return m.OldActionLabelDel(ctx)
  19753. case sopstage.FieldActionForward:
  19754. return m.OldActionForward(ctx)
  19755. case sopstage.FieldIndexSort:
  19756. return m.OldIndexSort(ctx)
  19757. }
  19758. return nil, fmt.Errorf("unknown SopStage field %s", name)
  19759. }
  19760. // SetField sets the value of a field with the given name. It returns an error if
  19761. // the field is not defined in the schema, or if the type mismatched the field
  19762. // type.
  19763. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  19764. switch name {
  19765. case sopstage.FieldCreatedAt:
  19766. v, ok := value.(time.Time)
  19767. if !ok {
  19768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19769. }
  19770. m.SetCreatedAt(v)
  19771. return nil
  19772. case sopstage.FieldUpdatedAt:
  19773. v, ok := value.(time.Time)
  19774. if !ok {
  19775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19776. }
  19777. m.SetUpdatedAt(v)
  19778. return nil
  19779. case sopstage.FieldStatus:
  19780. v, ok := value.(uint8)
  19781. if !ok {
  19782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19783. }
  19784. m.SetStatus(v)
  19785. return nil
  19786. case sopstage.FieldDeletedAt:
  19787. v, ok := value.(time.Time)
  19788. if !ok {
  19789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19790. }
  19791. m.SetDeletedAt(v)
  19792. return nil
  19793. case sopstage.FieldTaskID:
  19794. v, ok := value.(uint64)
  19795. if !ok {
  19796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19797. }
  19798. m.SetTaskID(v)
  19799. return nil
  19800. case sopstage.FieldName:
  19801. v, ok := value.(string)
  19802. if !ok {
  19803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19804. }
  19805. m.SetName(v)
  19806. return nil
  19807. case sopstage.FieldConditionType:
  19808. v, ok := value.(int)
  19809. if !ok {
  19810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19811. }
  19812. m.SetConditionType(v)
  19813. return nil
  19814. case sopstage.FieldConditionOperator:
  19815. v, ok := value.(int)
  19816. if !ok {
  19817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19818. }
  19819. m.SetConditionOperator(v)
  19820. return nil
  19821. case sopstage.FieldConditionList:
  19822. v, ok := value.([]custom_types.Condition)
  19823. if !ok {
  19824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19825. }
  19826. m.SetConditionList(v)
  19827. return nil
  19828. case sopstage.FieldActionMessage:
  19829. v, ok := value.([]custom_types.Action)
  19830. if !ok {
  19831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19832. }
  19833. m.SetActionMessage(v)
  19834. return nil
  19835. case sopstage.FieldActionLabelAdd:
  19836. v, ok := value.([]uint64)
  19837. if !ok {
  19838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19839. }
  19840. m.SetActionLabelAdd(v)
  19841. return nil
  19842. case sopstage.FieldActionLabelDel:
  19843. v, ok := value.([]uint64)
  19844. if !ok {
  19845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19846. }
  19847. m.SetActionLabelDel(v)
  19848. return nil
  19849. case sopstage.FieldActionForward:
  19850. v, ok := value.(*custom_types.ActionForward)
  19851. if !ok {
  19852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19853. }
  19854. m.SetActionForward(v)
  19855. return nil
  19856. case sopstage.FieldIndexSort:
  19857. v, ok := value.(int)
  19858. if !ok {
  19859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19860. }
  19861. m.SetIndexSort(v)
  19862. return nil
  19863. }
  19864. return fmt.Errorf("unknown SopStage field %s", name)
  19865. }
  19866. // AddedFields returns all numeric fields that were incremented/decremented during
  19867. // this mutation.
  19868. func (m *SopStageMutation) AddedFields() []string {
  19869. var fields []string
  19870. if m.addstatus != nil {
  19871. fields = append(fields, sopstage.FieldStatus)
  19872. }
  19873. if m.addcondition_type != nil {
  19874. fields = append(fields, sopstage.FieldConditionType)
  19875. }
  19876. if m.addcondition_operator != nil {
  19877. fields = append(fields, sopstage.FieldConditionOperator)
  19878. }
  19879. if m.addindex_sort != nil {
  19880. fields = append(fields, sopstage.FieldIndexSort)
  19881. }
  19882. return fields
  19883. }
  19884. // AddedField returns the numeric value that was incremented/decremented on a field
  19885. // with the given name. The second boolean return value indicates that this field
  19886. // was not set, or was not defined in the schema.
  19887. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  19888. switch name {
  19889. case sopstage.FieldStatus:
  19890. return m.AddedStatus()
  19891. case sopstage.FieldConditionType:
  19892. return m.AddedConditionType()
  19893. case sopstage.FieldConditionOperator:
  19894. return m.AddedConditionOperator()
  19895. case sopstage.FieldIndexSort:
  19896. return m.AddedIndexSort()
  19897. }
  19898. return nil, false
  19899. }
  19900. // AddField adds the value to the field with the given name. It returns an error if
  19901. // the field is not defined in the schema, or if the type mismatched the field
  19902. // type.
  19903. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19904. switch name {
  19905. case sopstage.FieldStatus:
  19906. v, ok := value.(int8)
  19907. if !ok {
  19908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19909. }
  19910. m.AddStatus(v)
  19911. return nil
  19912. case sopstage.FieldConditionType:
  19913. v, ok := value.(int)
  19914. if !ok {
  19915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19916. }
  19917. m.AddConditionType(v)
  19918. return nil
  19919. case sopstage.FieldConditionOperator:
  19920. v, ok := value.(int)
  19921. if !ok {
  19922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19923. }
  19924. m.AddConditionOperator(v)
  19925. return nil
  19926. case sopstage.FieldIndexSort:
  19927. v, ok := value.(int)
  19928. if !ok {
  19929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19930. }
  19931. m.AddIndexSort(v)
  19932. return nil
  19933. }
  19934. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19935. }
  19936. // ClearedFields returns all nullable fields that were cleared during this
  19937. // mutation.
  19938. func (m *SopStageMutation) ClearedFields() []string {
  19939. var fields []string
  19940. if m.FieldCleared(sopstage.FieldStatus) {
  19941. fields = append(fields, sopstage.FieldStatus)
  19942. }
  19943. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19944. fields = append(fields, sopstage.FieldDeletedAt)
  19945. }
  19946. if m.FieldCleared(sopstage.FieldActionMessage) {
  19947. fields = append(fields, sopstage.FieldActionMessage)
  19948. }
  19949. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19950. fields = append(fields, sopstage.FieldActionLabelAdd)
  19951. }
  19952. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19953. fields = append(fields, sopstage.FieldActionLabelDel)
  19954. }
  19955. if m.FieldCleared(sopstage.FieldActionForward) {
  19956. fields = append(fields, sopstage.FieldActionForward)
  19957. }
  19958. if m.FieldCleared(sopstage.FieldIndexSort) {
  19959. fields = append(fields, sopstage.FieldIndexSort)
  19960. }
  19961. return fields
  19962. }
  19963. // FieldCleared returns a boolean indicating if a field with the given name was
  19964. // cleared in this mutation.
  19965. func (m *SopStageMutation) FieldCleared(name string) bool {
  19966. _, ok := m.clearedFields[name]
  19967. return ok
  19968. }
  19969. // ClearField clears the value of the field with the given name. It returns an
  19970. // error if the field is not defined in the schema.
  19971. func (m *SopStageMutation) ClearField(name string) error {
  19972. switch name {
  19973. case sopstage.FieldStatus:
  19974. m.ClearStatus()
  19975. return nil
  19976. case sopstage.FieldDeletedAt:
  19977. m.ClearDeletedAt()
  19978. return nil
  19979. case sopstage.FieldActionMessage:
  19980. m.ClearActionMessage()
  19981. return nil
  19982. case sopstage.FieldActionLabelAdd:
  19983. m.ClearActionLabelAdd()
  19984. return nil
  19985. case sopstage.FieldActionLabelDel:
  19986. m.ClearActionLabelDel()
  19987. return nil
  19988. case sopstage.FieldActionForward:
  19989. m.ClearActionForward()
  19990. return nil
  19991. case sopstage.FieldIndexSort:
  19992. m.ClearIndexSort()
  19993. return nil
  19994. }
  19995. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19996. }
  19997. // ResetField resets all changes in the mutation for the field with the given name.
  19998. // It returns an error if the field is not defined in the schema.
  19999. func (m *SopStageMutation) ResetField(name string) error {
  20000. switch name {
  20001. case sopstage.FieldCreatedAt:
  20002. m.ResetCreatedAt()
  20003. return nil
  20004. case sopstage.FieldUpdatedAt:
  20005. m.ResetUpdatedAt()
  20006. return nil
  20007. case sopstage.FieldStatus:
  20008. m.ResetStatus()
  20009. return nil
  20010. case sopstage.FieldDeletedAt:
  20011. m.ResetDeletedAt()
  20012. return nil
  20013. case sopstage.FieldTaskID:
  20014. m.ResetTaskID()
  20015. return nil
  20016. case sopstage.FieldName:
  20017. m.ResetName()
  20018. return nil
  20019. case sopstage.FieldConditionType:
  20020. m.ResetConditionType()
  20021. return nil
  20022. case sopstage.FieldConditionOperator:
  20023. m.ResetConditionOperator()
  20024. return nil
  20025. case sopstage.FieldConditionList:
  20026. m.ResetConditionList()
  20027. return nil
  20028. case sopstage.FieldActionMessage:
  20029. m.ResetActionMessage()
  20030. return nil
  20031. case sopstage.FieldActionLabelAdd:
  20032. m.ResetActionLabelAdd()
  20033. return nil
  20034. case sopstage.FieldActionLabelDel:
  20035. m.ResetActionLabelDel()
  20036. return nil
  20037. case sopstage.FieldActionForward:
  20038. m.ResetActionForward()
  20039. return nil
  20040. case sopstage.FieldIndexSort:
  20041. m.ResetIndexSort()
  20042. return nil
  20043. }
  20044. return fmt.Errorf("unknown SopStage field %s", name)
  20045. }
  20046. // AddedEdges returns all edge names that were set/added in this mutation.
  20047. func (m *SopStageMutation) AddedEdges() []string {
  20048. edges := make([]string, 0, 3)
  20049. if m.sop_task != nil {
  20050. edges = append(edges, sopstage.EdgeSopTask)
  20051. }
  20052. if m.stage_nodes != nil {
  20053. edges = append(edges, sopstage.EdgeStageNodes)
  20054. }
  20055. if m.stage_messages != nil {
  20056. edges = append(edges, sopstage.EdgeStageMessages)
  20057. }
  20058. return edges
  20059. }
  20060. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20061. // name in this mutation.
  20062. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  20063. switch name {
  20064. case sopstage.EdgeSopTask:
  20065. if id := m.sop_task; id != nil {
  20066. return []ent.Value{*id}
  20067. }
  20068. case sopstage.EdgeStageNodes:
  20069. ids := make([]ent.Value, 0, len(m.stage_nodes))
  20070. for id := range m.stage_nodes {
  20071. ids = append(ids, id)
  20072. }
  20073. return ids
  20074. case sopstage.EdgeStageMessages:
  20075. ids := make([]ent.Value, 0, len(m.stage_messages))
  20076. for id := range m.stage_messages {
  20077. ids = append(ids, id)
  20078. }
  20079. return ids
  20080. }
  20081. return nil
  20082. }
  20083. // RemovedEdges returns all edge names that were removed in this mutation.
  20084. func (m *SopStageMutation) RemovedEdges() []string {
  20085. edges := make([]string, 0, 3)
  20086. if m.removedstage_nodes != nil {
  20087. edges = append(edges, sopstage.EdgeStageNodes)
  20088. }
  20089. if m.removedstage_messages != nil {
  20090. edges = append(edges, sopstage.EdgeStageMessages)
  20091. }
  20092. return edges
  20093. }
  20094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20095. // the given name in this mutation.
  20096. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  20097. switch name {
  20098. case sopstage.EdgeStageNodes:
  20099. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  20100. for id := range m.removedstage_nodes {
  20101. ids = append(ids, id)
  20102. }
  20103. return ids
  20104. case sopstage.EdgeStageMessages:
  20105. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  20106. for id := range m.removedstage_messages {
  20107. ids = append(ids, id)
  20108. }
  20109. return ids
  20110. }
  20111. return nil
  20112. }
  20113. // ClearedEdges returns all edge names that were cleared in this mutation.
  20114. func (m *SopStageMutation) ClearedEdges() []string {
  20115. edges := make([]string, 0, 3)
  20116. if m.clearedsop_task {
  20117. edges = append(edges, sopstage.EdgeSopTask)
  20118. }
  20119. if m.clearedstage_nodes {
  20120. edges = append(edges, sopstage.EdgeStageNodes)
  20121. }
  20122. if m.clearedstage_messages {
  20123. edges = append(edges, sopstage.EdgeStageMessages)
  20124. }
  20125. return edges
  20126. }
  20127. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20128. // was cleared in this mutation.
  20129. func (m *SopStageMutation) EdgeCleared(name string) bool {
  20130. switch name {
  20131. case sopstage.EdgeSopTask:
  20132. return m.clearedsop_task
  20133. case sopstage.EdgeStageNodes:
  20134. return m.clearedstage_nodes
  20135. case sopstage.EdgeStageMessages:
  20136. return m.clearedstage_messages
  20137. }
  20138. return false
  20139. }
  20140. // ClearEdge clears the value of the edge with the given name. It returns an error
  20141. // if that edge is not defined in the schema.
  20142. func (m *SopStageMutation) ClearEdge(name string) error {
  20143. switch name {
  20144. case sopstage.EdgeSopTask:
  20145. m.ClearSopTask()
  20146. return nil
  20147. }
  20148. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20149. }
  20150. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20151. // It returns an error if the edge is not defined in the schema.
  20152. func (m *SopStageMutation) ResetEdge(name string) error {
  20153. switch name {
  20154. case sopstage.EdgeSopTask:
  20155. m.ResetSopTask()
  20156. return nil
  20157. case sopstage.EdgeStageNodes:
  20158. m.ResetStageNodes()
  20159. return nil
  20160. case sopstage.EdgeStageMessages:
  20161. m.ResetStageMessages()
  20162. return nil
  20163. }
  20164. return fmt.Errorf("unknown SopStage edge %s", name)
  20165. }
  20166. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20167. type SopTaskMutation struct {
  20168. config
  20169. op Op
  20170. typ string
  20171. id *uint64
  20172. created_at *time.Time
  20173. updated_at *time.Time
  20174. status *uint8
  20175. addstatus *int8
  20176. deleted_at *time.Time
  20177. name *string
  20178. bot_wxid_list *[]string
  20179. appendbot_wxid_list []string
  20180. _type *int
  20181. add_type *int
  20182. plan_start_time *time.Time
  20183. plan_end_time *time.Time
  20184. creator_id *string
  20185. organization_id *uint64
  20186. addorganization_id *int64
  20187. token *[]string
  20188. appendtoken []string
  20189. clearedFields map[string]struct{}
  20190. task_stages map[uint64]struct{}
  20191. removedtask_stages map[uint64]struct{}
  20192. clearedtask_stages bool
  20193. done bool
  20194. oldValue func(context.Context) (*SopTask, error)
  20195. predicates []predicate.SopTask
  20196. }
  20197. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20198. // soptaskOption allows management of the mutation configuration using functional options.
  20199. type soptaskOption func(*SopTaskMutation)
  20200. // newSopTaskMutation creates new mutation for the SopTask entity.
  20201. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20202. m := &SopTaskMutation{
  20203. config: c,
  20204. op: op,
  20205. typ: TypeSopTask,
  20206. clearedFields: make(map[string]struct{}),
  20207. }
  20208. for _, opt := range opts {
  20209. opt(m)
  20210. }
  20211. return m
  20212. }
  20213. // withSopTaskID sets the ID field of the mutation.
  20214. func withSopTaskID(id uint64) soptaskOption {
  20215. return func(m *SopTaskMutation) {
  20216. var (
  20217. err error
  20218. once sync.Once
  20219. value *SopTask
  20220. )
  20221. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20222. once.Do(func() {
  20223. if m.done {
  20224. err = errors.New("querying old values post mutation is not allowed")
  20225. } else {
  20226. value, err = m.Client().SopTask.Get(ctx, id)
  20227. }
  20228. })
  20229. return value, err
  20230. }
  20231. m.id = &id
  20232. }
  20233. }
  20234. // withSopTask sets the old SopTask of the mutation.
  20235. func withSopTask(node *SopTask) soptaskOption {
  20236. return func(m *SopTaskMutation) {
  20237. m.oldValue = func(context.Context) (*SopTask, error) {
  20238. return node, nil
  20239. }
  20240. m.id = &node.ID
  20241. }
  20242. }
  20243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20244. // executed in a transaction (ent.Tx), a transactional client is returned.
  20245. func (m SopTaskMutation) Client() *Client {
  20246. client := &Client{config: m.config}
  20247. client.init()
  20248. return client
  20249. }
  20250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20251. // it returns an error otherwise.
  20252. func (m SopTaskMutation) Tx() (*Tx, error) {
  20253. if _, ok := m.driver.(*txDriver); !ok {
  20254. return nil, errors.New("ent: mutation is not running in a transaction")
  20255. }
  20256. tx := &Tx{config: m.config}
  20257. tx.init()
  20258. return tx, nil
  20259. }
  20260. // SetID sets the value of the id field. Note that this
  20261. // operation is only accepted on creation of SopTask entities.
  20262. func (m *SopTaskMutation) SetID(id uint64) {
  20263. m.id = &id
  20264. }
  20265. // ID returns the ID value in the mutation. Note that the ID is only available
  20266. // if it was provided to the builder or after it was returned from the database.
  20267. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  20268. if m.id == nil {
  20269. return
  20270. }
  20271. return *m.id, true
  20272. }
  20273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20274. // That means, if the mutation is applied within a transaction with an isolation level such
  20275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20276. // or updated by the mutation.
  20277. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  20278. switch {
  20279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20280. id, exists := m.ID()
  20281. if exists {
  20282. return []uint64{id}, nil
  20283. }
  20284. fallthrough
  20285. case m.op.Is(OpUpdate | OpDelete):
  20286. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  20287. default:
  20288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20289. }
  20290. }
  20291. // SetCreatedAt sets the "created_at" field.
  20292. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  20293. m.created_at = &t
  20294. }
  20295. // CreatedAt returns the value of the "created_at" field in the mutation.
  20296. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  20297. v := m.created_at
  20298. if v == nil {
  20299. return
  20300. }
  20301. return *v, true
  20302. }
  20303. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  20304. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20306. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20307. if !m.op.Is(OpUpdateOne) {
  20308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20309. }
  20310. if m.id == nil || m.oldValue == nil {
  20311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20312. }
  20313. oldValue, err := m.oldValue(ctx)
  20314. if err != nil {
  20315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20316. }
  20317. return oldValue.CreatedAt, nil
  20318. }
  20319. // ResetCreatedAt resets all changes to the "created_at" field.
  20320. func (m *SopTaskMutation) ResetCreatedAt() {
  20321. m.created_at = nil
  20322. }
  20323. // SetUpdatedAt sets the "updated_at" field.
  20324. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  20325. m.updated_at = &t
  20326. }
  20327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20328. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  20329. v := m.updated_at
  20330. if v == nil {
  20331. return
  20332. }
  20333. return *v, true
  20334. }
  20335. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  20336. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20338. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20339. if !m.op.Is(OpUpdateOne) {
  20340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20341. }
  20342. if m.id == nil || m.oldValue == nil {
  20343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20344. }
  20345. oldValue, err := m.oldValue(ctx)
  20346. if err != nil {
  20347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20348. }
  20349. return oldValue.UpdatedAt, nil
  20350. }
  20351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20352. func (m *SopTaskMutation) ResetUpdatedAt() {
  20353. m.updated_at = nil
  20354. }
  20355. // SetStatus sets the "status" field.
  20356. func (m *SopTaskMutation) SetStatus(u uint8) {
  20357. m.status = &u
  20358. m.addstatus = nil
  20359. }
  20360. // Status returns the value of the "status" field in the mutation.
  20361. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  20362. v := m.status
  20363. if v == nil {
  20364. return
  20365. }
  20366. return *v, true
  20367. }
  20368. // OldStatus returns the old "status" field's value of the SopTask entity.
  20369. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20371. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20372. if !m.op.Is(OpUpdateOne) {
  20373. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20374. }
  20375. if m.id == nil || m.oldValue == nil {
  20376. return v, errors.New("OldStatus requires an ID field in the mutation")
  20377. }
  20378. oldValue, err := m.oldValue(ctx)
  20379. if err != nil {
  20380. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20381. }
  20382. return oldValue.Status, nil
  20383. }
  20384. // AddStatus adds u to the "status" field.
  20385. func (m *SopTaskMutation) AddStatus(u int8) {
  20386. if m.addstatus != nil {
  20387. *m.addstatus += u
  20388. } else {
  20389. m.addstatus = &u
  20390. }
  20391. }
  20392. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20393. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  20394. v := m.addstatus
  20395. if v == nil {
  20396. return
  20397. }
  20398. return *v, true
  20399. }
  20400. // ClearStatus clears the value of the "status" field.
  20401. func (m *SopTaskMutation) ClearStatus() {
  20402. m.status = nil
  20403. m.addstatus = nil
  20404. m.clearedFields[soptask.FieldStatus] = struct{}{}
  20405. }
  20406. // StatusCleared returns if the "status" field was cleared in this mutation.
  20407. func (m *SopTaskMutation) StatusCleared() bool {
  20408. _, ok := m.clearedFields[soptask.FieldStatus]
  20409. return ok
  20410. }
  20411. // ResetStatus resets all changes to the "status" field.
  20412. func (m *SopTaskMutation) ResetStatus() {
  20413. m.status = nil
  20414. m.addstatus = nil
  20415. delete(m.clearedFields, soptask.FieldStatus)
  20416. }
  20417. // SetDeletedAt sets the "deleted_at" field.
  20418. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  20419. m.deleted_at = &t
  20420. }
  20421. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20422. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  20423. v := m.deleted_at
  20424. if v == nil {
  20425. return
  20426. }
  20427. return *v, true
  20428. }
  20429. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  20430. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20432. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20433. if !m.op.Is(OpUpdateOne) {
  20434. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20435. }
  20436. if m.id == nil || m.oldValue == nil {
  20437. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20438. }
  20439. oldValue, err := m.oldValue(ctx)
  20440. if err != nil {
  20441. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20442. }
  20443. return oldValue.DeletedAt, nil
  20444. }
  20445. // ClearDeletedAt clears the value of the "deleted_at" field.
  20446. func (m *SopTaskMutation) ClearDeletedAt() {
  20447. m.deleted_at = nil
  20448. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  20449. }
  20450. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20451. func (m *SopTaskMutation) DeletedAtCleared() bool {
  20452. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  20453. return ok
  20454. }
  20455. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20456. func (m *SopTaskMutation) ResetDeletedAt() {
  20457. m.deleted_at = nil
  20458. delete(m.clearedFields, soptask.FieldDeletedAt)
  20459. }
  20460. // SetName sets the "name" field.
  20461. func (m *SopTaskMutation) SetName(s string) {
  20462. m.name = &s
  20463. }
  20464. // Name returns the value of the "name" field in the mutation.
  20465. func (m *SopTaskMutation) Name() (r string, exists bool) {
  20466. v := m.name
  20467. if v == nil {
  20468. return
  20469. }
  20470. return *v, true
  20471. }
  20472. // OldName returns the old "name" field's value of the SopTask entity.
  20473. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20475. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  20476. if !m.op.Is(OpUpdateOne) {
  20477. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20478. }
  20479. if m.id == nil || m.oldValue == nil {
  20480. return v, errors.New("OldName requires an ID field in the mutation")
  20481. }
  20482. oldValue, err := m.oldValue(ctx)
  20483. if err != nil {
  20484. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20485. }
  20486. return oldValue.Name, nil
  20487. }
  20488. // ResetName resets all changes to the "name" field.
  20489. func (m *SopTaskMutation) ResetName() {
  20490. m.name = nil
  20491. }
  20492. // SetBotWxidList sets the "bot_wxid_list" field.
  20493. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  20494. m.bot_wxid_list = &s
  20495. m.appendbot_wxid_list = nil
  20496. }
  20497. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  20498. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  20499. v := m.bot_wxid_list
  20500. if v == nil {
  20501. return
  20502. }
  20503. return *v, true
  20504. }
  20505. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  20506. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20508. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  20509. if !m.op.Is(OpUpdateOne) {
  20510. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  20511. }
  20512. if m.id == nil || m.oldValue == nil {
  20513. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  20514. }
  20515. oldValue, err := m.oldValue(ctx)
  20516. if err != nil {
  20517. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  20518. }
  20519. return oldValue.BotWxidList, nil
  20520. }
  20521. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  20522. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  20523. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  20524. }
  20525. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  20526. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  20527. if len(m.appendbot_wxid_list) == 0 {
  20528. return nil, false
  20529. }
  20530. return m.appendbot_wxid_list, true
  20531. }
  20532. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  20533. func (m *SopTaskMutation) ClearBotWxidList() {
  20534. m.bot_wxid_list = nil
  20535. m.appendbot_wxid_list = nil
  20536. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  20537. }
  20538. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  20539. func (m *SopTaskMutation) BotWxidListCleared() bool {
  20540. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  20541. return ok
  20542. }
  20543. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  20544. func (m *SopTaskMutation) ResetBotWxidList() {
  20545. m.bot_wxid_list = nil
  20546. m.appendbot_wxid_list = nil
  20547. delete(m.clearedFields, soptask.FieldBotWxidList)
  20548. }
  20549. // SetType sets the "type" field.
  20550. func (m *SopTaskMutation) SetType(i int) {
  20551. m._type = &i
  20552. m.add_type = nil
  20553. }
  20554. // GetType returns the value of the "type" field in the mutation.
  20555. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  20556. v := m._type
  20557. if v == nil {
  20558. return
  20559. }
  20560. return *v, true
  20561. }
  20562. // OldType returns the old "type" field's value of the SopTask entity.
  20563. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20565. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  20566. if !m.op.Is(OpUpdateOne) {
  20567. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20568. }
  20569. if m.id == nil || m.oldValue == nil {
  20570. return v, errors.New("OldType requires an ID field in the mutation")
  20571. }
  20572. oldValue, err := m.oldValue(ctx)
  20573. if err != nil {
  20574. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20575. }
  20576. return oldValue.Type, nil
  20577. }
  20578. // AddType adds i to the "type" field.
  20579. func (m *SopTaskMutation) AddType(i int) {
  20580. if m.add_type != nil {
  20581. *m.add_type += i
  20582. } else {
  20583. m.add_type = &i
  20584. }
  20585. }
  20586. // AddedType returns the value that was added to the "type" field in this mutation.
  20587. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  20588. v := m.add_type
  20589. if v == nil {
  20590. return
  20591. }
  20592. return *v, true
  20593. }
  20594. // ResetType resets all changes to the "type" field.
  20595. func (m *SopTaskMutation) ResetType() {
  20596. m._type = nil
  20597. m.add_type = nil
  20598. }
  20599. // SetPlanStartTime sets the "plan_start_time" field.
  20600. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  20601. m.plan_start_time = &t
  20602. }
  20603. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  20604. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  20605. v := m.plan_start_time
  20606. if v == nil {
  20607. return
  20608. }
  20609. return *v, true
  20610. }
  20611. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  20612. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20614. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  20615. if !m.op.Is(OpUpdateOne) {
  20616. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  20617. }
  20618. if m.id == nil || m.oldValue == nil {
  20619. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  20620. }
  20621. oldValue, err := m.oldValue(ctx)
  20622. if err != nil {
  20623. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  20624. }
  20625. return oldValue.PlanStartTime, nil
  20626. }
  20627. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  20628. func (m *SopTaskMutation) ClearPlanStartTime() {
  20629. m.plan_start_time = nil
  20630. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  20631. }
  20632. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  20633. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  20634. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  20635. return ok
  20636. }
  20637. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  20638. func (m *SopTaskMutation) ResetPlanStartTime() {
  20639. m.plan_start_time = nil
  20640. delete(m.clearedFields, soptask.FieldPlanStartTime)
  20641. }
  20642. // SetPlanEndTime sets the "plan_end_time" field.
  20643. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  20644. m.plan_end_time = &t
  20645. }
  20646. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  20647. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  20648. v := m.plan_end_time
  20649. if v == nil {
  20650. return
  20651. }
  20652. return *v, true
  20653. }
  20654. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  20655. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20657. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  20658. if !m.op.Is(OpUpdateOne) {
  20659. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  20660. }
  20661. if m.id == nil || m.oldValue == nil {
  20662. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  20663. }
  20664. oldValue, err := m.oldValue(ctx)
  20665. if err != nil {
  20666. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  20667. }
  20668. return oldValue.PlanEndTime, nil
  20669. }
  20670. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  20671. func (m *SopTaskMutation) ClearPlanEndTime() {
  20672. m.plan_end_time = nil
  20673. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  20674. }
  20675. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  20676. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  20677. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  20678. return ok
  20679. }
  20680. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  20681. func (m *SopTaskMutation) ResetPlanEndTime() {
  20682. m.plan_end_time = nil
  20683. delete(m.clearedFields, soptask.FieldPlanEndTime)
  20684. }
  20685. // SetCreatorID sets the "creator_id" field.
  20686. func (m *SopTaskMutation) SetCreatorID(s string) {
  20687. m.creator_id = &s
  20688. }
  20689. // CreatorID returns the value of the "creator_id" field in the mutation.
  20690. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  20691. v := m.creator_id
  20692. if v == nil {
  20693. return
  20694. }
  20695. return *v, true
  20696. }
  20697. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  20698. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20700. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  20701. if !m.op.Is(OpUpdateOne) {
  20702. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  20703. }
  20704. if m.id == nil || m.oldValue == nil {
  20705. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  20706. }
  20707. oldValue, err := m.oldValue(ctx)
  20708. if err != nil {
  20709. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  20710. }
  20711. return oldValue.CreatorID, nil
  20712. }
  20713. // ClearCreatorID clears the value of the "creator_id" field.
  20714. func (m *SopTaskMutation) ClearCreatorID() {
  20715. m.creator_id = nil
  20716. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  20717. }
  20718. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  20719. func (m *SopTaskMutation) CreatorIDCleared() bool {
  20720. _, ok := m.clearedFields[soptask.FieldCreatorID]
  20721. return ok
  20722. }
  20723. // ResetCreatorID resets all changes to the "creator_id" field.
  20724. func (m *SopTaskMutation) ResetCreatorID() {
  20725. m.creator_id = nil
  20726. delete(m.clearedFields, soptask.FieldCreatorID)
  20727. }
  20728. // SetOrganizationID sets the "organization_id" field.
  20729. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  20730. m.organization_id = &u
  20731. m.addorganization_id = nil
  20732. }
  20733. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20734. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  20735. v := m.organization_id
  20736. if v == nil {
  20737. return
  20738. }
  20739. return *v, true
  20740. }
  20741. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  20742. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20744. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20745. if !m.op.Is(OpUpdateOne) {
  20746. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20747. }
  20748. if m.id == nil || m.oldValue == nil {
  20749. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20750. }
  20751. oldValue, err := m.oldValue(ctx)
  20752. if err != nil {
  20753. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20754. }
  20755. return oldValue.OrganizationID, nil
  20756. }
  20757. // AddOrganizationID adds u to the "organization_id" field.
  20758. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  20759. if m.addorganization_id != nil {
  20760. *m.addorganization_id += u
  20761. } else {
  20762. m.addorganization_id = &u
  20763. }
  20764. }
  20765. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20766. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  20767. v := m.addorganization_id
  20768. if v == nil {
  20769. return
  20770. }
  20771. return *v, true
  20772. }
  20773. // ClearOrganizationID clears the value of the "organization_id" field.
  20774. func (m *SopTaskMutation) ClearOrganizationID() {
  20775. m.organization_id = nil
  20776. m.addorganization_id = nil
  20777. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  20778. }
  20779. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20780. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  20781. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  20782. return ok
  20783. }
  20784. // ResetOrganizationID resets all changes to the "organization_id" field.
  20785. func (m *SopTaskMutation) ResetOrganizationID() {
  20786. m.organization_id = nil
  20787. m.addorganization_id = nil
  20788. delete(m.clearedFields, soptask.FieldOrganizationID)
  20789. }
  20790. // SetToken sets the "token" field.
  20791. func (m *SopTaskMutation) SetToken(s []string) {
  20792. m.token = &s
  20793. m.appendtoken = nil
  20794. }
  20795. // Token returns the value of the "token" field in the mutation.
  20796. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  20797. v := m.token
  20798. if v == nil {
  20799. return
  20800. }
  20801. return *v, true
  20802. }
  20803. // OldToken returns the old "token" field's value of the SopTask entity.
  20804. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20806. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  20807. if !m.op.Is(OpUpdateOne) {
  20808. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20809. }
  20810. if m.id == nil || m.oldValue == nil {
  20811. return v, errors.New("OldToken requires an ID field in the mutation")
  20812. }
  20813. oldValue, err := m.oldValue(ctx)
  20814. if err != nil {
  20815. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20816. }
  20817. return oldValue.Token, nil
  20818. }
  20819. // AppendToken adds s to the "token" field.
  20820. func (m *SopTaskMutation) AppendToken(s []string) {
  20821. m.appendtoken = append(m.appendtoken, s...)
  20822. }
  20823. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  20824. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  20825. if len(m.appendtoken) == 0 {
  20826. return nil, false
  20827. }
  20828. return m.appendtoken, true
  20829. }
  20830. // ClearToken clears the value of the "token" field.
  20831. func (m *SopTaskMutation) ClearToken() {
  20832. m.token = nil
  20833. m.appendtoken = nil
  20834. m.clearedFields[soptask.FieldToken] = struct{}{}
  20835. }
  20836. // TokenCleared returns if the "token" field was cleared in this mutation.
  20837. func (m *SopTaskMutation) TokenCleared() bool {
  20838. _, ok := m.clearedFields[soptask.FieldToken]
  20839. return ok
  20840. }
  20841. // ResetToken resets all changes to the "token" field.
  20842. func (m *SopTaskMutation) ResetToken() {
  20843. m.token = nil
  20844. m.appendtoken = nil
  20845. delete(m.clearedFields, soptask.FieldToken)
  20846. }
  20847. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  20848. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  20849. if m.task_stages == nil {
  20850. m.task_stages = make(map[uint64]struct{})
  20851. }
  20852. for i := range ids {
  20853. m.task_stages[ids[i]] = struct{}{}
  20854. }
  20855. }
  20856. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  20857. func (m *SopTaskMutation) ClearTaskStages() {
  20858. m.clearedtask_stages = true
  20859. }
  20860. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  20861. func (m *SopTaskMutation) TaskStagesCleared() bool {
  20862. return m.clearedtask_stages
  20863. }
  20864. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  20865. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  20866. if m.removedtask_stages == nil {
  20867. m.removedtask_stages = make(map[uint64]struct{})
  20868. }
  20869. for i := range ids {
  20870. delete(m.task_stages, ids[i])
  20871. m.removedtask_stages[ids[i]] = struct{}{}
  20872. }
  20873. }
  20874. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  20875. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  20876. for id := range m.removedtask_stages {
  20877. ids = append(ids, id)
  20878. }
  20879. return
  20880. }
  20881. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  20882. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  20883. for id := range m.task_stages {
  20884. ids = append(ids, id)
  20885. }
  20886. return
  20887. }
  20888. // ResetTaskStages resets all changes to the "task_stages" edge.
  20889. func (m *SopTaskMutation) ResetTaskStages() {
  20890. m.task_stages = nil
  20891. m.clearedtask_stages = false
  20892. m.removedtask_stages = nil
  20893. }
  20894. // Where appends a list predicates to the SopTaskMutation builder.
  20895. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20896. m.predicates = append(m.predicates, ps...)
  20897. }
  20898. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20899. // users can use type-assertion to append predicates that do not depend on any generated package.
  20900. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20901. p := make([]predicate.SopTask, len(ps))
  20902. for i := range ps {
  20903. p[i] = ps[i]
  20904. }
  20905. m.Where(p...)
  20906. }
  20907. // Op returns the operation name.
  20908. func (m *SopTaskMutation) Op() Op {
  20909. return m.op
  20910. }
  20911. // SetOp allows setting the mutation operation.
  20912. func (m *SopTaskMutation) SetOp(op Op) {
  20913. m.op = op
  20914. }
  20915. // Type returns the node type of this mutation (SopTask).
  20916. func (m *SopTaskMutation) Type() string {
  20917. return m.typ
  20918. }
  20919. // Fields returns all fields that were changed during this mutation. Note that in
  20920. // order to get all numeric fields that were incremented/decremented, call
  20921. // AddedFields().
  20922. func (m *SopTaskMutation) Fields() []string {
  20923. fields := make([]string, 0, 12)
  20924. if m.created_at != nil {
  20925. fields = append(fields, soptask.FieldCreatedAt)
  20926. }
  20927. if m.updated_at != nil {
  20928. fields = append(fields, soptask.FieldUpdatedAt)
  20929. }
  20930. if m.status != nil {
  20931. fields = append(fields, soptask.FieldStatus)
  20932. }
  20933. if m.deleted_at != nil {
  20934. fields = append(fields, soptask.FieldDeletedAt)
  20935. }
  20936. if m.name != nil {
  20937. fields = append(fields, soptask.FieldName)
  20938. }
  20939. if m.bot_wxid_list != nil {
  20940. fields = append(fields, soptask.FieldBotWxidList)
  20941. }
  20942. if m._type != nil {
  20943. fields = append(fields, soptask.FieldType)
  20944. }
  20945. if m.plan_start_time != nil {
  20946. fields = append(fields, soptask.FieldPlanStartTime)
  20947. }
  20948. if m.plan_end_time != nil {
  20949. fields = append(fields, soptask.FieldPlanEndTime)
  20950. }
  20951. if m.creator_id != nil {
  20952. fields = append(fields, soptask.FieldCreatorID)
  20953. }
  20954. if m.organization_id != nil {
  20955. fields = append(fields, soptask.FieldOrganizationID)
  20956. }
  20957. if m.token != nil {
  20958. fields = append(fields, soptask.FieldToken)
  20959. }
  20960. return fields
  20961. }
  20962. // Field returns the value of a field with the given name. The second boolean
  20963. // return value indicates that this field was not set, or was not defined in the
  20964. // schema.
  20965. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20966. switch name {
  20967. case soptask.FieldCreatedAt:
  20968. return m.CreatedAt()
  20969. case soptask.FieldUpdatedAt:
  20970. return m.UpdatedAt()
  20971. case soptask.FieldStatus:
  20972. return m.Status()
  20973. case soptask.FieldDeletedAt:
  20974. return m.DeletedAt()
  20975. case soptask.FieldName:
  20976. return m.Name()
  20977. case soptask.FieldBotWxidList:
  20978. return m.BotWxidList()
  20979. case soptask.FieldType:
  20980. return m.GetType()
  20981. case soptask.FieldPlanStartTime:
  20982. return m.PlanStartTime()
  20983. case soptask.FieldPlanEndTime:
  20984. return m.PlanEndTime()
  20985. case soptask.FieldCreatorID:
  20986. return m.CreatorID()
  20987. case soptask.FieldOrganizationID:
  20988. return m.OrganizationID()
  20989. case soptask.FieldToken:
  20990. return m.Token()
  20991. }
  20992. return nil, false
  20993. }
  20994. // OldField returns the old value of the field from the database. An error is
  20995. // returned if the mutation operation is not UpdateOne, or the query to the
  20996. // database failed.
  20997. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20998. switch name {
  20999. case soptask.FieldCreatedAt:
  21000. return m.OldCreatedAt(ctx)
  21001. case soptask.FieldUpdatedAt:
  21002. return m.OldUpdatedAt(ctx)
  21003. case soptask.FieldStatus:
  21004. return m.OldStatus(ctx)
  21005. case soptask.FieldDeletedAt:
  21006. return m.OldDeletedAt(ctx)
  21007. case soptask.FieldName:
  21008. return m.OldName(ctx)
  21009. case soptask.FieldBotWxidList:
  21010. return m.OldBotWxidList(ctx)
  21011. case soptask.FieldType:
  21012. return m.OldType(ctx)
  21013. case soptask.FieldPlanStartTime:
  21014. return m.OldPlanStartTime(ctx)
  21015. case soptask.FieldPlanEndTime:
  21016. return m.OldPlanEndTime(ctx)
  21017. case soptask.FieldCreatorID:
  21018. return m.OldCreatorID(ctx)
  21019. case soptask.FieldOrganizationID:
  21020. return m.OldOrganizationID(ctx)
  21021. case soptask.FieldToken:
  21022. return m.OldToken(ctx)
  21023. }
  21024. return nil, fmt.Errorf("unknown SopTask field %s", name)
  21025. }
  21026. // SetField sets the value of a field with the given name. It returns an error if
  21027. // the field is not defined in the schema, or if the type mismatched the field
  21028. // type.
  21029. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  21030. switch name {
  21031. case soptask.FieldCreatedAt:
  21032. v, ok := value.(time.Time)
  21033. if !ok {
  21034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21035. }
  21036. m.SetCreatedAt(v)
  21037. return nil
  21038. case soptask.FieldUpdatedAt:
  21039. v, ok := value.(time.Time)
  21040. if !ok {
  21041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21042. }
  21043. m.SetUpdatedAt(v)
  21044. return nil
  21045. case soptask.FieldStatus:
  21046. v, ok := value.(uint8)
  21047. if !ok {
  21048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21049. }
  21050. m.SetStatus(v)
  21051. return nil
  21052. case soptask.FieldDeletedAt:
  21053. v, ok := value.(time.Time)
  21054. if !ok {
  21055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21056. }
  21057. m.SetDeletedAt(v)
  21058. return nil
  21059. case soptask.FieldName:
  21060. v, ok := value.(string)
  21061. if !ok {
  21062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21063. }
  21064. m.SetName(v)
  21065. return nil
  21066. case soptask.FieldBotWxidList:
  21067. v, ok := value.([]string)
  21068. if !ok {
  21069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21070. }
  21071. m.SetBotWxidList(v)
  21072. return nil
  21073. case soptask.FieldType:
  21074. v, ok := value.(int)
  21075. if !ok {
  21076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21077. }
  21078. m.SetType(v)
  21079. return nil
  21080. case soptask.FieldPlanStartTime:
  21081. v, ok := value.(time.Time)
  21082. if !ok {
  21083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21084. }
  21085. m.SetPlanStartTime(v)
  21086. return nil
  21087. case soptask.FieldPlanEndTime:
  21088. v, ok := value.(time.Time)
  21089. if !ok {
  21090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21091. }
  21092. m.SetPlanEndTime(v)
  21093. return nil
  21094. case soptask.FieldCreatorID:
  21095. v, ok := value.(string)
  21096. if !ok {
  21097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21098. }
  21099. m.SetCreatorID(v)
  21100. return nil
  21101. case soptask.FieldOrganizationID:
  21102. v, ok := value.(uint64)
  21103. if !ok {
  21104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21105. }
  21106. m.SetOrganizationID(v)
  21107. return nil
  21108. case soptask.FieldToken:
  21109. v, ok := value.([]string)
  21110. if !ok {
  21111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21112. }
  21113. m.SetToken(v)
  21114. return nil
  21115. }
  21116. return fmt.Errorf("unknown SopTask field %s", name)
  21117. }
  21118. // AddedFields returns all numeric fields that were incremented/decremented during
  21119. // this mutation.
  21120. func (m *SopTaskMutation) AddedFields() []string {
  21121. var fields []string
  21122. if m.addstatus != nil {
  21123. fields = append(fields, soptask.FieldStatus)
  21124. }
  21125. if m.add_type != nil {
  21126. fields = append(fields, soptask.FieldType)
  21127. }
  21128. if m.addorganization_id != nil {
  21129. fields = append(fields, soptask.FieldOrganizationID)
  21130. }
  21131. return fields
  21132. }
  21133. // AddedField returns the numeric value that was incremented/decremented on a field
  21134. // with the given name. The second boolean return value indicates that this field
  21135. // was not set, or was not defined in the schema.
  21136. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  21137. switch name {
  21138. case soptask.FieldStatus:
  21139. return m.AddedStatus()
  21140. case soptask.FieldType:
  21141. return m.AddedType()
  21142. case soptask.FieldOrganizationID:
  21143. return m.AddedOrganizationID()
  21144. }
  21145. return nil, false
  21146. }
  21147. // AddField adds the value to the field with the given name. It returns an error if
  21148. // the field is not defined in the schema, or if the type mismatched the field
  21149. // type.
  21150. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21151. switch name {
  21152. case soptask.FieldStatus:
  21153. v, ok := value.(int8)
  21154. if !ok {
  21155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21156. }
  21157. m.AddStatus(v)
  21158. return nil
  21159. case soptask.FieldType:
  21160. v, ok := value.(int)
  21161. if !ok {
  21162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21163. }
  21164. m.AddType(v)
  21165. return nil
  21166. case soptask.FieldOrganizationID:
  21167. v, ok := value.(int64)
  21168. if !ok {
  21169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21170. }
  21171. m.AddOrganizationID(v)
  21172. return nil
  21173. }
  21174. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21175. }
  21176. // ClearedFields returns all nullable fields that were cleared during this
  21177. // mutation.
  21178. func (m *SopTaskMutation) ClearedFields() []string {
  21179. var fields []string
  21180. if m.FieldCleared(soptask.FieldStatus) {
  21181. fields = append(fields, soptask.FieldStatus)
  21182. }
  21183. if m.FieldCleared(soptask.FieldDeletedAt) {
  21184. fields = append(fields, soptask.FieldDeletedAt)
  21185. }
  21186. if m.FieldCleared(soptask.FieldBotWxidList) {
  21187. fields = append(fields, soptask.FieldBotWxidList)
  21188. }
  21189. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21190. fields = append(fields, soptask.FieldPlanStartTime)
  21191. }
  21192. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21193. fields = append(fields, soptask.FieldPlanEndTime)
  21194. }
  21195. if m.FieldCleared(soptask.FieldCreatorID) {
  21196. fields = append(fields, soptask.FieldCreatorID)
  21197. }
  21198. if m.FieldCleared(soptask.FieldOrganizationID) {
  21199. fields = append(fields, soptask.FieldOrganizationID)
  21200. }
  21201. if m.FieldCleared(soptask.FieldToken) {
  21202. fields = append(fields, soptask.FieldToken)
  21203. }
  21204. return fields
  21205. }
  21206. // FieldCleared returns a boolean indicating if a field with the given name was
  21207. // cleared in this mutation.
  21208. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21209. _, ok := m.clearedFields[name]
  21210. return ok
  21211. }
  21212. // ClearField clears the value of the field with the given name. It returns an
  21213. // error if the field is not defined in the schema.
  21214. func (m *SopTaskMutation) ClearField(name string) error {
  21215. switch name {
  21216. case soptask.FieldStatus:
  21217. m.ClearStatus()
  21218. return nil
  21219. case soptask.FieldDeletedAt:
  21220. m.ClearDeletedAt()
  21221. return nil
  21222. case soptask.FieldBotWxidList:
  21223. m.ClearBotWxidList()
  21224. return nil
  21225. case soptask.FieldPlanStartTime:
  21226. m.ClearPlanStartTime()
  21227. return nil
  21228. case soptask.FieldPlanEndTime:
  21229. m.ClearPlanEndTime()
  21230. return nil
  21231. case soptask.FieldCreatorID:
  21232. m.ClearCreatorID()
  21233. return nil
  21234. case soptask.FieldOrganizationID:
  21235. m.ClearOrganizationID()
  21236. return nil
  21237. case soptask.FieldToken:
  21238. m.ClearToken()
  21239. return nil
  21240. }
  21241. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21242. }
  21243. // ResetField resets all changes in the mutation for the field with the given name.
  21244. // It returns an error if the field is not defined in the schema.
  21245. func (m *SopTaskMutation) ResetField(name string) error {
  21246. switch name {
  21247. case soptask.FieldCreatedAt:
  21248. m.ResetCreatedAt()
  21249. return nil
  21250. case soptask.FieldUpdatedAt:
  21251. m.ResetUpdatedAt()
  21252. return nil
  21253. case soptask.FieldStatus:
  21254. m.ResetStatus()
  21255. return nil
  21256. case soptask.FieldDeletedAt:
  21257. m.ResetDeletedAt()
  21258. return nil
  21259. case soptask.FieldName:
  21260. m.ResetName()
  21261. return nil
  21262. case soptask.FieldBotWxidList:
  21263. m.ResetBotWxidList()
  21264. return nil
  21265. case soptask.FieldType:
  21266. m.ResetType()
  21267. return nil
  21268. case soptask.FieldPlanStartTime:
  21269. m.ResetPlanStartTime()
  21270. return nil
  21271. case soptask.FieldPlanEndTime:
  21272. m.ResetPlanEndTime()
  21273. return nil
  21274. case soptask.FieldCreatorID:
  21275. m.ResetCreatorID()
  21276. return nil
  21277. case soptask.FieldOrganizationID:
  21278. m.ResetOrganizationID()
  21279. return nil
  21280. case soptask.FieldToken:
  21281. m.ResetToken()
  21282. return nil
  21283. }
  21284. return fmt.Errorf("unknown SopTask field %s", name)
  21285. }
  21286. // AddedEdges returns all edge names that were set/added in this mutation.
  21287. func (m *SopTaskMutation) AddedEdges() []string {
  21288. edges := make([]string, 0, 1)
  21289. if m.task_stages != nil {
  21290. edges = append(edges, soptask.EdgeTaskStages)
  21291. }
  21292. return edges
  21293. }
  21294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21295. // name in this mutation.
  21296. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  21297. switch name {
  21298. case soptask.EdgeTaskStages:
  21299. ids := make([]ent.Value, 0, len(m.task_stages))
  21300. for id := range m.task_stages {
  21301. ids = append(ids, id)
  21302. }
  21303. return ids
  21304. }
  21305. return nil
  21306. }
  21307. // RemovedEdges returns all edge names that were removed in this mutation.
  21308. func (m *SopTaskMutation) RemovedEdges() []string {
  21309. edges := make([]string, 0, 1)
  21310. if m.removedtask_stages != nil {
  21311. edges = append(edges, soptask.EdgeTaskStages)
  21312. }
  21313. return edges
  21314. }
  21315. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21316. // the given name in this mutation.
  21317. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  21318. switch name {
  21319. case soptask.EdgeTaskStages:
  21320. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  21321. for id := range m.removedtask_stages {
  21322. ids = append(ids, id)
  21323. }
  21324. return ids
  21325. }
  21326. return nil
  21327. }
  21328. // ClearedEdges returns all edge names that were cleared in this mutation.
  21329. func (m *SopTaskMutation) ClearedEdges() []string {
  21330. edges := make([]string, 0, 1)
  21331. if m.clearedtask_stages {
  21332. edges = append(edges, soptask.EdgeTaskStages)
  21333. }
  21334. return edges
  21335. }
  21336. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21337. // was cleared in this mutation.
  21338. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  21339. switch name {
  21340. case soptask.EdgeTaskStages:
  21341. return m.clearedtask_stages
  21342. }
  21343. return false
  21344. }
  21345. // ClearEdge clears the value of the edge with the given name. It returns an error
  21346. // if that edge is not defined in the schema.
  21347. func (m *SopTaskMutation) ClearEdge(name string) error {
  21348. switch name {
  21349. }
  21350. return fmt.Errorf("unknown SopTask unique edge %s", name)
  21351. }
  21352. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21353. // It returns an error if the edge is not defined in the schema.
  21354. func (m *SopTaskMutation) ResetEdge(name string) error {
  21355. switch name {
  21356. case soptask.EdgeTaskStages:
  21357. m.ResetTaskStages()
  21358. return nil
  21359. }
  21360. return fmt.Errorf("unknown SopTask edge %s", name)
  21361. }
  21362. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  21363. type TokenMutation struct {
  21364. config
  21365. op Op
  21366. typ string
  21367. id *uint64
  21368. created_at *time.Time
  21369. updated_at *time.Time
  21370. deleted_at *time.Time
  21371. expire_at *time.Time
  21372. token *string
  21373. mac *string
  21374. organization_id *uint64
  21375. addorganization_id *int64
  21376. custom_agent_base *string
  21377. custom_agent_key *string
  21378. openai_base *string
  21379. openai_key *string
  21380. clearedFields map[string]struct{}
  21381. agent *uint64
  21382. clearedagent bool
  21383. done bool
  21384. oldValue func(context.Context) (*Token, error)
  21385. predicates []predicate.Token
  21386. }
  21387. var _ ent.Mutation = (*TokenMutation)(nil)
  21388. // tokenOption allows management of the mutation configuration using functional options.
  21389. type tokenOption func(*TokenMutation)
  21390. // newTokenMutation creates new mutation for the Token entity.
  21391. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  21392. m := &TokenMutation{
  21393. config: c,
  21394. op: op,
  21395. typ: TypeToken,
  21396. clearedFields: make(map[string]struct{}),
  21397. }
  21398. for _, opt := range opts {
  21399. opt(m)
  21400. }
  21401. return m
  21402. }
  21403. // withTokenID sets the ID field of the mutation.
  21404. func withTokenID(id uint64) tokenOption {
  21405. return func(m *TokenMutation) {
  21406. var (
  21407. err error
  21408. once sync.Once
  21409. value *Token
  21410. )
  21411. m.oldValue = func(ctx context.Context) (*Token, error) {
  21412. once.Do(func() {
  21413. if m.done {
  21414. err = errors.New("querying old values post mutation is not allowed")
  21415. } else {
  21416. value, err = m.Client().Token.Get(ctx, id)
  21417. }
  21418. })
  21419. return value, err
  21420. }
  21421. m.id = &id
  21422. }
  21423. }
  21424. // withToken sets the old Token of the mutation.
  21425. func withToken(node *Token) tokenOption {
  21426. return func(m *TokenMutation) {
  21427. m.oldValue = func(context.Context) (*Token, error) {
  21428. return node, nil
  21429. }
  21430. m.id = &node.ID
  21431. }
  21432. }
  21433. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21434. // executed in a transaction (ent.Tx), a transactional client is returned.
  21435. func (m TokenMutation) Client() *Client {
  21436. client := &Client{config: m.config}
  21437. client.init()
  21438. return client
  21439. }
  21440. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21441. // it returns an error otherwise.
  21442. func (m TokenMutation) Tx() (*Tx, error) {
  21443. if _, ok := m.driver.(*txDriver); !ok {
  21444. return nil, errors.New("ent: mutation is not running in a transaction")
  21445. }
  21446. tx := &Tx{config: m.config}
  21447. tx.init()
  21448. return tx, nil
  21449. }
  21450. // SetID sets the value of the id field. Note that this
  21451. // operation is only accepted on creation of Token entities.
  21452. func (m *TokenMutation) SetID(id uint64) {
  21453. m.id = &id
  21454. }
  21455. // ID returns the ID value in the mutation. Note that the ID is only available
  21456. // if it was provided to the builder or after it was returned from the database.
  21457. func (m *TokenMutation) ID() (id uint64, exists bool) {
  21458. if m.id == nil {
  21459. return
  21460. }
  21461. return *m.id, true
  21462. }
  21463. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21464. // That means, if the mutation is applied within a transaction with an isolation level such
  21465. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21466. // or updated by the mutation.
  21467. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  21468. switch {
  21469. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21470. id, exists := m.ID()
  21471. if exists {
  21472. return []uint64{id}, nil
  21473. }
  21474. fallthrough
  21475. case m.op.Is(OpUpdate | OpDelete):
  21476. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  21477. default:
  21478. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21479. }
  21480. }
  21481. // SetCreatedAt sets the "created_at" field.
  21482. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  21483. m.created_at = &t
  21484. }
  21485. // CreatedAt returns the value of the "created_at" field in the mutation.
  21486. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  21487. v := m.created_at
  21488. if v == nil {
  21489. return
  21490. }
  21491. return *v, true
  21492. }
  21493. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  21494. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21496. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21497. if !m.op.Is(OpUpdateOne) {
  21498. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21499. }
  21500. if m.id == nil || m.oldValue == nil {
  21501. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21502. }
  21503. oldValue, err := m.oldValue(ctx)
  21504. if err != nil {
  21505. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21506. }
  21507. return oldValue.CreatedAt, nil
  21508. }
  21509. // ResetCreatedAt resets all changes to the "created_at" field.
  21510. func (m *TokenMutation) ResetCreatedAt() {
  21511. m.created_at = nil
  21512. }
  21513. // SetUpdatedAt sets the "updated_at" field.
  21514. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  21515. m.updated_at = &t
  21516. }
  21517. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21518. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  21519. v := m.updated_at
  21520. if v == nil {
  21521. return
  21522. }
  21523. return *v, true
  21524. }
  21525. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  21526. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21528. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21529. if !m.op.Is(OpUpdateOne) {
  21530. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21531. }
  21532. if m.id == nil || m.oldValue == nil {
  21533. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21534. }
  21535. oldValue, err := m.oldValue(ctx)
  21536. if err != nil {
  21537. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21538. }
  21539. return oldValue.UpdatedAt, nil
  21540. }
  21541. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21542. func (m *TokenMutation) ResetUpdatedAt() {
  21543. m.updated_at = nil
  21544. }
  21545. // SetDeletedAt sets the "deleted_at" field.
  21546. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  21547. m.deleted_at = &t
  21548. }
  21549. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21550. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  21551. v := m.deleted_at
  21552. if v == nil {
  21553. return
  21554. }
  21555. return *v, true
  21556. }
  21557. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  21558. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21560. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21561. if !m.op.Is(OpUpdateOne) {
  21562. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21563. }
  21564. if m.id == nil || m.oldValue == nil {
  21565. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21566. }
  21567. oldValue, err := m.oldValue(ctx)
  21568. if err != nil {
  21569. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21570. }
  21571. return oldValue.DeletedAt, nil
  21572. }
  21573. // ClearDeletedAt clears the value of the "deleted_at" field.
  21574. func (m *TokenMutation) ClearDeletedAt() {
  21575. m.deleted_at = nil
  21576. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  21577. }
  21578. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21579. func (m *TokenMutation) DeletedAtCleared() bool {
  21580. _, ok := m.clearedFields[token.FieldDeletedAt]
  21581. return ok
  21582. }
  21583. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21584. func (m *TokenMutation) ResetDeletedAt() {
  21585. m.deleted_at = nil
  21586. delete(m.clearedFields, token.FieldDeletedAt)
  21587. }
  21588. // SetExpireAt sets the "expire_at" field.
  21589. func (m *TokenMutation) SetExpireAt(t time.Time) {
  21590. m.expire_at = &t
  21591. }
  21592. // ExpireAt returns the value of the "expire_at" field in the mutation.
  21593. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  21594. v := m.expire_at
  21595. if v == nil {
  21596. return
  21597. }
  21598. return *v, true
  21599. }
  21600. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  21601. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21603. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  21604. if !m.op.Is(OpUpdateOne) {
  21605. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  21606. }
  21607. if m.id == nil || m.oldValue == nil {
  21608. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  21609. }
  21610. oldValue, err := m.oldValue(ctx)
  21611. if err != nil {
  21612. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  21613. }
  21614. return oldValue.ExpireAt, nil
  21615. }
  21616. // ClearExpireAt clears the value of the "expire_at" field.
  21617. func (m *TokenMutation) ClearExpireAt() {
  21618. m.expire_at = nil
  21619. m.clearedFields[token.FieldExpireAt] = struct{}{}
  21620. }
  21621. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  21622. func (m *TokenMutation) ExpireAtCleared() bool {
  21623. _, ok := m.clearedFields[token.FieldExpireAt]
  21624. return ok
  21625. }
  21626. // ResetExpireAt resets all changes to the "expire_at" field.
  21627. func (m *TokenMutation) ResetExpireAt() {
  21628. m.expire_at = nil
  21629. delete(m.clearedFields, token.FieldExpireAt)
  21630. }
  21631. // SetToken sets the "token" field.
  21632. func (m *TokenMutation) SetToken(s string) {
  21633. m.token = &s
  21634. }
  21635. // Token returns the value of the "token" field in the mutation.
  21636. func (m *TokenMutation) Token() (r string, exists bool) {
  21637. v := m.token
  21638. if v == nil {
  21639. return
  21640. }
  21641. return *v, true
  21642. }
  21643. // OldToken returns the old "token" field's value of the Token entity.
  21644. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21646. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  21647. if !m.op.Is(OpUpdateOne) {
  21648. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21649. }
  21650. if m.id == nil || m.oldValue == nil {
  21651. return v, errors.New("OldToken requires an ID field in the mutation")
  21652. }
  21653. oldValue, err := m.oldValue(ctx)
  21654. if err != nil {
  21655. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21656. }
  21657. return oldValue.Token, nil
  21658. }
  21659. // ClearToken clears the value of the "token" field.
  21660. func (m *TokenMutation) ClearToken() {
  21661. m.token = nil
  21662. m.clearedFields[token.FieldToken] = struct{}{}
  21663. }
  21664. // TokenCleared returns if the "token" field was cleared in this mutation.
  21665. func (m *TokenMutation) TokenCleared() bool {
  21666. _, ok := m.clearedFields[token.FieldToken]
  21667. return ok
  21668. }
  21669. // ResetToken resets all changes to the "token" field.
  21670. func (m *TokenMutation) ResetToken() {
  21671. m.token = nil
  21672. delete(m.clearedFields, token.FieldToken)
  21673. }
  21674. // SetMAC sets the "mac" field.
  21675. func (m *TokenMutation) SetMAC(s string) {
  21676. m.mac = &s
  21677. }
  21678. // MAC returns the value of the "mac" field in the mutation.
  21679. func (m *TokenMutation) MAC() (r string, exists bool) {
  21680. v := m.mac
  21681. if v == nil {
  21682. return
  21683. }
  21684. return *v, true
  21685. }
  21686. // OldMAC returns the old "mac" field's value of the Token entity.
  21687. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21689. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  21690. if !m.op.Is(OpUpdateOne) {
  21691. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  21692. }
  21693. if m.id == nil || m.oldValue == nil {
  21694. return v, errors.New("OldMAC requires an ID field in the mutation")
  21695. }
  21696. oldValue, err := m.oldValue(ctx)
  21697. if err != nil {
  21698. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  21699. }
  21700. return oldValue.MAC, nil
  21701. }
  21702. // ClearMAC clears the value of the "mac" field.
  21703. func (m *TokenMutation) ClearMAC() {
  21704. m.mac = nil
  21705. m.clearedFields[token.FieldMAC] = struct{}{}
  21706. }
  21707. // MACCleared returns if the "mac" field was cleared in this mutation.
  21708. func (m *TokenMutation) MACCleared() bool {
  21709. _, ok := m.clearedFields[token.FieldMAC]
  21710. return ok
  21711. }
  21712. // ResetMAC resets all changes to the "mac" field.
  21713. func (m *TokenMutation) ResetMAC() {
  21714. m.mac = nil
  21715. delete(m.clearedFields, token.FieldMAC)
  21716. }
  21717. // SetOrganizationID sets the "organization_id" field.
  21718. func (m *TokenMutation) SetOrganizationID(u uint64) {
  21719. m.organization_id = &u
  21720. m.addorganization_id = nil
  21721. }
  21722. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21723. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  21724. v := m.organization_id
  21725. if v == nil {
  21726. return
  21727. }
  21728. return *v, true
  21729. }
  21730. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  21731. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21733. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21734. if !m.op.Is(OpUpdateOne) {
  21735. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21736. }
  21737. if m.id == nil || m.oldValue == nil {
  21738. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21739. }
  21740. oldValue, err := m.oldValue(ctx)
  21741. if err != nil {
  21742. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21743. }
  21744. return oldValue.OrganizationID, nil
  21745. }
  21746. // AddOrganizationID adds u to the "organization_id" field.
  21747. func (m *TokenMutation) AddOrganizationID(u int64) {
  21748. if m.addorganization_id != nil {
  21749. *m.addorganization_id += u
  21750. } else {
  21751. m.addorganization_id = &u
  21752. }
  21753. }
  21754. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21755. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  21756. v := m.addorganization_id
  21757. if v == nil {
  21758. return
  21759. }
  21760. return *v, true
  21761. }
  21762. // ResetOrganizationID resets all changes to the "organization_id" field.
  21763. func (m *TokenMutation) ResetOrganizationID() {
  21764. m.organization_id = nil
  21765. m.addorganization_id = nil
  21766. }
  21767. // SetAgentID sets the "agent_id" field.
  21768. func (m *TokenMutation) SetAgentID(u uint64) {
  21769. m.agent = &u
  21770. }
  21771. // AgentID returns the value of the "agent_id" field in the mutation.
  21772. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  21773. v := m.agent
  21774. if v == nil {
  21775. return
  21776. }
  21777. return *v, true
  21778. }
  21779. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  21780. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21782. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  21783. if !m.op.Is(OpUpdateOne) {
  21784. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  21785. }
  21786. if m.id == nil || m.oldValue == nil {
  21787. return v, errors.New("OldAgentID requires an ID field in the mutation")
  21788. }
  21789. oldValue, err := m.oldValue(ctx)
  21790. if err != nil {
  21791. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  21792. }
  21793. return oldValue.AgentID, nil
  21794. }
  21795. // ResetAgentID resets all changes to the "agent_id" field.
  21796. func (m *TokenMutation) ResetAgentID() {
  21797. m.agent = nil
  21798. }
  21799. // SetCustomAgentBase sets the "custom_agent_base" field.
  21800. func (m *TokenMutation) SetCustomAgentBase(s string) {
  21801. m.custom_agent_base = &s
  21802. }
  21803. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  21804. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  21805. v := m.custom_agent_base
  21806. if v == nil {
  21807. return
  21808. }
  21809. return *v, true
  21810. }
  21811. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  21812. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21814. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  21815. if !m.op.Is(OpUpdateOne) {
  21816. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  21817. }
  21818. if m.id == nil || m.oldValue == nil {
  21819. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  21820. }
  21821. oldValue, err := m.oldValue(ctx)
  21822. if err != nil {
  21823. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  21824. }
  21825. return oldValue.CustomAgentBase, nil
  21826. }
  21827. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  21828. func (m *TokenMutation) ClearCustomAgentBase() {
  21829. m.custom_agent_base = nil
  21830. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  21831. }
  21832. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  21833. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  21834. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  21835. return ok
  21836. }
  21837. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  21838. func (m *TokenMutation) ResetCustomAgentBase() {
  21839. m.custom_agent_base = nil
  21840. delete(m.clearedFields, token.FieldCustomAgentBase)
  21841. }
  21842. // SetCustomAgentKey sets the "custom_agent_key" field.
  21843. func (m *TokenMutation) SetCustomAgentKey(s string) {
  21844. m.custom_agent_key = &s
  21845. }
  21846. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  21847. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  21848. v := m.custom_agent_key
  21849. if v == nil {
  21850. return
  21851. }
  21852. return *v, true
  21853. }
  21854. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  21855. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21857. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  21858. if !m.op.Is(OpUpdateOne) {
  21859. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  21860. }
  21861. if m.id == nil || m.oldValue == nil {
  21862. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  21863. }
  21864. oldValue, err := m.oldValue(ctx)
  21865. if err != nil {
  21866. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  21867. }
  21868. return oldValue.CustomAgentKey, nil
  21869. }
  21870. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  21871. func (m *TokenMutation) ClearCustomAgentKey() {
  21872. m.custom_agent_key = nil
  21873. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  21874. }
  21875. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  21876. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  21877. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  21878. return ok
  21879. }
  21880. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  21881. func (m *TokenMutation) ResetCustomAgentKey() {
  21882. m.custom_agent_key = nil
  21883. delete(m.clearedFields, token.FieldCustomAgentKey)
  21884. }
  21885. // SetOpenaiBase sets the "openai_base" field.
  21886. func (m *TokenMutation) SetOpenaiBase(s string) {
  21887. m.openai_base = &s
  21888. }
  21889. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  21890. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  21891. v := m.openai_base
  21892. if v == nil {
  21893. return
  21894. }
  21895. return *v, true
  21896. }
  21897. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21898. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21900. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21901. if !m.op.Is(OpUpdateOne) {
  21902. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21903. }
  21904. if m.id == nil || m.oldValue == nil {
  21905. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21906. }
  21907. oldValue, err := m.oldValue(ctx)
  21908. if err != nil {
  21909. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21910. }
  21911. return oldValue.OpenaiBase, nil
  21912. }
  21913. // ClearOpenaiBase clears the value of the "openai_base" field.
  21914. func (m *TokenMutation) ClearOpenaiBase() {
  21915. m.openai_base = nil
  21916. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21917. }
  21918. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21919. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21920. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21921. return ok
  21922. }
  21923. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21924. func (m *TokenMutation) ResetOpenaiBase() {
  21925. m.openai_base = nil
  21926. delete(m.clearedFields, token.FieldOpenaiBase)
  21927. }
  21928. // SetOpenaiKey sets the "openai_key" field.
  21929. func (m *TokenMutation) SetOpenaiKey(s string) {
  21930. m.openai_key = &s
  21931. }
  21932. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21933. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21934. v := m.openai_key
  21935. if v == nil {
  21936. return
  21937. }
  21938. return *v, true
  21939. }
  21940. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21941. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21943. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21944. if !m.op.Is(OpUpdateOne) {
  21945. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21946. }
  21947. if m.id == nil || m.oldValue == nil {
  21948. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21949. }
  21950. oldValue, err := m.oldValue(ctx)
  21951. if err != nil {
  21952. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21953. }
  21954. return oldValue.OpenaiKey, nil
  21955. }
  21956. // ClearOpenaiKey clears the value of the "openai_key" field.
  21957. func (m *TokenMutation) ClearOpenaiKey() {
  21958. m.openai_key = nil
  21959. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21960. }
  21961. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21962. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21963. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21964. return ok
  21965. }
  21966. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21967. func (m *TokenMutation) ResetOpenaiKey() {
  21968. m.openai_key = nil
  21969. delete(m.clearedFields, token.FieldOpenaiKey)
  21970. }
  21971. // ClearAgent clears the "agent" edge to the Agent entity.
  21972. func (m *TokenMutation) ClearAgent() {
  21973. m.clearedagent = true
  21974. m.clearedFields[token.FieldAgentID] = struct{}{}
  21975. }
  21976. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21977. func (m *TokenMutation) AgentCleared() bool {
  21978. return m.clearedagent
  21979. }
  21980. // AgentIDs returns the "agent" edge IDs in the mutation.
  21981. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21982. // AgentID instead. It exists only for internal usage by the builders.
  21983. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21984. if id := m.agent; id != nil {
  21985. ids = append(ids, *id)
  21986. }
  21987. return
  21988. }
  21989. // ResetAgent resets all changes to the "agent" edge.
  21990. func (m *TokenMutation) ResetAgent() {
  21991. m.agent = nil
  21992. m.clearedagent = false
  21993. }
  21994. // Where appends a list predicates to the TokenMutation builder.
  21995. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21996. m.predicates = append(m.predicates, ps...)
  21997. }
  21998. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21999. // users can use type-assertion to append predicates that do not depend on any generated package.
  22000. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  22001. p := make([]predicate.Token, len(ps))
  22002. for i := range ps {
  22003. p[i] = ps[i]
  22004. }
  22005. m.Where(p...)
  22006. }
  22007. // Op returns the operation name.
  22008. func (m *TokenMutation) Op() Op {
  22009. return m.op
  22010. }
  22011. // SetOp allows setting the mutation operation.
  22012. func (m *TokenMutation) SetOp(op Op) {
  22013. m.op = op
  22014. }
  22015. // Type returns the node type of this mutation (Token).
  22016. func (m *TokenMutation) Type() string {
  22017. return m.typ
  22018. }
  22019. // Fields returns all fields that were changed during this mutation. Note that in
  22020. // order to get all numeric fields that were incremented/decremented, call
  22021. // AddedFields().
  22022. func (m *TokenMutation) Fields() []string {
  22023. fields := make([]string, 0, 12)
  22024. if m.created_at != nil {
  22025. fields = append(fields, token.FieldCreatedAt)
  22026. }
  22027. if m.updated_at != nil {
  22028. fields = append(fields, token.FieldUpdatedAt)
  22029. }
  22030. if m.deleted_at != nil {
  22031. fields = append(fields, token.FieldDeletedAt)
  22032. }
  22033. if m.expire_at != nil {
  22034. fields = append(fields, token.FieldExpireAt)
  22035. }
  22036. if m.token != nil {
  22037. fields = append(fields, token.FieldToken)
  22038. }
  22039. if m.mac != nil {
  22040. fields = append(fields, token.FieldMAC)
  22041. }
  22042. if m.organization_id != nil {
  22043. fields = append(fields, token.FieldOrganizationID)
  22044. }
  22045. if m.agent != nil {
  22046. fields = append(fields, token.FieldAgentID)
  22047. }
  22048. if m.custom_agent_base != nil {
  22049. fields = append(fields, token.FieldCustomAgentBase)
  22050. }
  22051. if m.custom_agent_key != nil {
  22052. fields = append(fields, token.FieldCustomAgentKey)
  22053. }
  22054. if m.openai_base != nil {
  22055. fields = append(fields, token.FieldOpenaiBase)
  22056. }
  22057. if m.openai_key != nil {
  22058. fields = append(fields, token.FieldOpenaiKey)
  22059. }
  22060. return fields
  22061. }
  22062. // Field returns the value of a field with the given name. The second boolean
  22063. // return value indicates that this field was not set, or was not defined in the
  22064. // schema.
  22065. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  22066. switch name {
  22067. case token.FieldCreatedAt:
  22068. return m.CreatedAt()
  22069. case token.FieldUpdatedAt:
  22070. return m.UpdatedAt()
  22071. case token.FieldDeletedAt:
  22072. return m.DeletedAt()
  22073. case token.FieldExpireAt:
  22074. return m.ExpireAt()
  22075. case token.FieldToken:
  22076. return m.Token()
  22077. case token.FieldMAC:
  22078. return m.MAC()
  22079. case token.FieldOrganizationID:
  22080. return m.OrganizationID()
  22081. case token.FieldAgentID:
  22082. return m.AgentID()
  22083. case token.FieldCustomAgentBase:
  22084. return m.CustomAgentBase()
  22085. case token.FieldCustomAgentKey:
  22086. return m.CustomAgentKey()
  22087. case token.FieldOpenaiBase:
  22088. return m.OpenaiBase()
  22089. case token.FieldOpenaiKey:
  22090. return m.OpenaiKey()
  22091. }
  22092. return nil, false
  22093. }
  22094. // OldField returns the old value of the field from the database. An error is
  22095. // returned if the mutation operation is not UpdateOne, or the query to the
  22096. // database failed.
  22097. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22098. switch name {
  22099. case token.FieldCreatedAt:
  22100. return m.OldCreatedAt(ctx)
  22101. case token.FieldUpdatedAt:
  22102. return m.OldUpdatedAt(ctx)
  22103. case token.FieldDeletedAt:
  22104. return m.OldDeletedAt(ctx)
  22105. case token.FieldExpireAt:
  22106. return m.OldExpireAt(ctx)
  22107. case token.FieldToken:
  22108. return m.OldToken(ctx)
  22109. case token.FieldMAC:
  22110. return m.OldMAC(ctx)
  22111. case token.FieldOrganizationID:
  22112. return m.OldOrganizationID(ctx)
  22113. case token.FieldAgentID:
  22114. return m.OldAgentID(ctx)
  22115. case token.FieldCustomAgentBase:
  22116. return m.OldCustomAgentBase(ctx)
  22117. case token.FieldCustomAgentKey:
  22118. return m.OldCustomAgentKey(ctx)
  22119. case token.FieldOpenaiBase:
  22120. return m.OldOpenaiBase(ctx)
  22121. case token.FieldOpenaiKey:
  22122. return m.OldOpenaiKey(ctx)
  22123. }
  22124. return nil, fmt.Errorf("unknown Token field %s", name)
  22125. }
  22126. // SetField sets the value of a field with the given name. It returns an error if
  22127. // the field is not defined in the schema, or if the type mismatched the field
  22128. // type.
  22129. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  22130. switch name {
  22131. case token.FieldCreatedAt:
  22132. v, ok := value.(time.Time)
  22133. if !ok {
  22134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22135. }
  22136. m.SetCreatedAt(v)
  22137. return nil
  22138. case token.FieldUpdatedAt:
  22139. v, ok := value.(time.Time)
  22140. if !ok {
  22141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22142. }
  22143. m.SetUpdatedAt(v)
  22144. return nil
  22145. case token.FieldDeletedAt:
  22146. v, ok := value.(time.Time)
  22147. if !ok {
  22148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22149. }
  22150. m.SetDeletedAt(v)
  22151. return nil
  22152. case token.FieldExpireAt:
  22153. v, ok := value.(time.Time)
  22154. if !ok {
  22155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22156. }
  22157. m.SetExpireAt(v)
  22158. return nil
  22159. case token.FieldToken:
  22160. v, ok := value.(string)
  22161. if !ok {
  22162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22163. }
  22164. m.SetToken(v)
  22165. return nil
  22166. case token.FieldMAC:
  22167. v, ok := value.(string)
  22168. if !ok {
  22169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22170. }
  22171. m.SetMAC(v)
  22172. return nil
  22173. case token.FieldOrganizationID:
  22174. v, ok := value.(uint64)
  22175. if !ok {
  22176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22177. }
  22178. m.SetOrganizationID(v)
  22179. return nil
  22180. case token.FieldAgentID:
  22181. v, ok := value.(uint64)
  22182. if !ok {
  22183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22184. }
  22185. m.SetAgentID(v)
  22186. return nil
  22187. case token.FieldCustomAgentBase:
  22188. v, ok := value.(string)
  22189. if !ok {
  22190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22191. }
  22192. m.SetCustomAgentBase(v)
  22193. return nil
  22194. case token.FieldCustomAgentKey:
  22195. v, ok := value.(string)
  22196. if !ok {
  22197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22198. }
  22199. m.SetCustomAgentKey(v)
  22200. return nil
  22201. case token.FieldOpenaiBase:
  22202. v, ok := value.(string)
  22203. if !ok {
  22204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22205. }
  22206. m.SetOpenaiBase(v)
  22207. return nil
  22208. case token.FieldOpenaiKey:
  22209. v, ok := value.(string)
  22210. if !ok {
  22211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22212. }
  22213. m.SetOpenaiKey(v)
  22214. return nil
  22215. }
  22216. return fmt.Errorf("unknown Token field %s", name)
  22217. }
  22218. // AddedFields returns all numeric fields that were incremented/decremented during
  22219. // this mutation.
  22220. func (m *TokenMutation) AddedFields() []string {
  22221. var fields []string
  22222. if m.addorganization_id != nil {
  22223. fields = append(fields, token.FieldOrganizationID)
  22224. }
  22225. return fields
  22226. }
  22227. // AddedField returns the numeric value that was incremented/decremented on a field
  22228. // with the given name. The second boolean return value indicates that this field
  22229. // was not set, or was not defined in the schema.
  22230. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22231. switch name {
  22232. case token.FieldOrganizationID:
  22233. return m.AddedOrganizationID()
  22234. }
  22235. return nil, false
  22236. }
  22237. // AddField adds the value to the field with the given name. It returns an error if
  22238. // the field is not defined in the schema, or if the type mismatched the field
  22239. // type.
  22240. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22241. switch name {
  22242. case token.FieldOrganizationID:
  22243. v, ok := value.(int64)
  22244. if !ok {
  22245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22246. }
  22247. m.AddOrganizationID(v)
  22248. return nil
  22249. }
  22250. return fmt.Errorf("unknown Token numeric field %s", name)
  22251. }
  22252. // ClearedFields returns all nullable fields that were cleared during this
  22253. // mutation.
  22254. func (m *TokenMutation) ClearedFields() []string {
  22255. var fields []string
  22256. if m.FieldCleared(token.FieldDeletedAt) {
  22257. fields = append(fields, token.FieldDeletedAt)
  22258. }
  22259. if m.FieldCleared(token.FieldExpireAt) {
  22260. fields = append(fields, token.FieldExpireAt)
  22261. }
  22262. if m.FieldCleared(token.FieldToken) {
  22263. fields = append(fields, token.FieldToken)
  22264. }
  22265. if m.FieldCleared(token.FieldMAC) {
  22266. fields = append(fields, token.FieldMAC)
  22267. }
  22268. if m.FieldCleared(token.FieldCustomAgentBase) {
  22269. fields = append(fields, token.FieldCustomAgentBase)
  22270. }
  22271. if m.FieldCleared(token.FieldCustomAgentKey) {
  22272. fields = append(fields, token.FieldCustomAgentKey)
  22273. }
  22274. if m.FieldCleared(token.FieldOpenaiBase) {
  22275. fields = append(fields, token.FieldOpenaiBase)
  22276. }
  22277. if m.FieldCleared(token.FieldOpenaiKey) {
  22278. fields = append(fields, token.FieldOpenaiKey)
  22279. }
  22280. return fields
  22281. }
  22282. // FieldCleared returns a boolean indicating if a field with the given name was
  22283. // cleared in this mutation.
  22284. func (m *TokenMutation) FieldCleared(name string) bool {
  22285. _, ok := m.clearedFields[name]
  22286. return ok
  22287. }
  22288. // ClearField clears the value of the field with the given name. It returns an
  22289. // error if the field is not defined in the schema.
  22290. func (m *TokenMutation) ClearField(name string) error {
  22291. switch name {
  22292. case token.FieldDeletedAt:
  22293. m.ClearDeletedAt()
  22294. return nil
  22295. case token.FieldExpireAt:
  22296. m.ClearExpireAt()
  22297. return nil
  22298. case token.FieldToken:
  22299. m.ClearToken()
  22300. return nil
  22301. case token.FieldMAC:
  22302. m.ClearMAC()
  22303. return nil
  22304. case token.FieldCustomAgentBase:
  22305. m.ClearCustomAgentBase()
  22306. return nil
  22307. case token.FieldCustomAgentKey:
  22308. m.ClearCustomAgentKey()
  22309. return nil
  22310. case token.FieldOpenaiBase:
  22311. m.ClearOpenaiBase()
  22312. return nil
  22313. case token.FieldOpenaiKey:
  22314. m.ClearOpenaiKey()
  22315. return nil
  22316. }
  22317. return fmt.Errorf("unknown Token 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 *TokenMutation) ResetField(name string) error {
  22322. switch name {
  22323. case token.FieldCreatedAt:
  22324. m.ResetCreatedAt()
  22325. return nil
  22326. case token.FieldUpdatedAt:
  22327. m.ResetUpdatedAt()
  22328. return nil
  22329. case token.FieldDeletedAt:
  22330. m.ResetDeletedAt()
  22331. return nil
  22332. case token.FieldExpireAt:
  22333. m.ResetExpireAt()
  22334. return nil
  22335. case token.FieldToken:
  22336. m.ResetToken()
  22337. return nil
  22338. case token.FieldMAC:
  22339. m.ResetMAC()
  22340. return nil
  22341. case token.FieldOrganizationID:
  22342. m.ResetOrganizationID()
  22343. return nil
  22344. case token.FieldAgentID:
  22345. m.ResetAgentID()
  22346. return nil
  22347. case token.FieldCustomAgentBase:
  22348. m.ResetCustomAgentBase()
  22349. return nil
  22350. case token.FieldCustomAgentKey:
  22351. m.ResetCustomAgentKey()
  22352. return nil
  22353. case token.FieldOpenaiBase:
  22354. m.ResetOpenaiBase()
  22355. return nil
  22356. case token.FieldOpenaiKey:
  22357. m.ResetOpenaiKey()
  22358. return nil
  22359. }
  22360. return fmt.Errorf("unknown Token field %s", name)
  22361. }
  22362. // AddedEdges returns all edge names that were set/added in this mutation.
  22363. func (m *TokenMutation) AddedEdges() []string {
  22364. edges := make([]string, 0, 1)
  22365. if m.agent != nil {
  22366. edges = append(edges, token.EdgeAgent)
  22367. }
  22368. return edges
  22369. }
  22370. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22371. // name in this mutation.
  22372. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  22373. switch name {
  22374. case token.EdgeAgent:
  22375. if id := m.agent; id != nil {
  22376. return []ent.Value{*id}
  22377. }
  22378. }
  22379. return nil
  22380. }
  22381. // RemovedEdges returns all edge names that were removed in this mutation.
  22382. func (m *TokenMutation) RemovedEdges() []string {
  22383. edges := make([]string, 0, 1)
  22384. return edges
  22385. }
  22386. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22387. // the given name in this mutation.
  22388. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  22389. return nil
  22390. }
  22391. // ClearedEdges returns all edge names that were cleared in this mutation.
  22392. func (m *TokenMutation) ClearedEdges() []string {
  22393. edges := make([]string, 0, 1)
  22394. if m.clearedagent {
  22395. edges = append(edges, token.EdgeAgent)
  22396. }
  22397. return edges
  22398. }
  22399. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22400. // was cleared in this mutation.
  22401. func (m *TokenMutation) EdgeCleared(name string) bool {
  22402. switch name {
  22403. case token.EdgeAgent:
  22404. return m.clearedagent
  22405. }
  22406. return false
  22407. }
  22408. // ClearEdge clears the value of the edge with the given name. It returns an error
  22409. // if that edge is not defined in the schema.
  22410. func (m *TokenMutation) ClearEdge(name string) error {
  22411. switch name {
  22412. case token.EdgeAgent:
  22413. m.ClearAgent()
  22414. return nil
  22415. }
  22416. return fmt.Errorf("unknown Token unique edge %s", name)
  22417. }
  22418. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22419. // It returns an error if the edge is not defined in the schema.
  22420. func (m *TokenMutation) ResetEdge(name string) error {
  22421. switch name {
  22422. case token.EdgeAgent:
  22423. m.ResetAgent()
  22424. return nil
  22425. }
  22426. return fmt.Errorf("unknown Token edge %s", name)
  22427. }
  22428. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  22429. type TutorialMutation struct {
  22430. config
  22431. op Op
  22432. typ string
  22433. id *uint64
  22434. created_at *time.Time
  22435. updated_at *time.Time
  22436. deleted_at *time.Time
  22437. index *int
  22438. addindex *int
  22439. title *string
  22440. content *string
  22441. organization_id *uint64
  22442. addorganization_id *int64
  22443. clearedFields map[string]struct{}
  22444. employee *uint64
  22445. clearedemployee bool
  22446. done bool
  22447. oldValue func(context.Context) (*Tutorial, error)
  22448. predicates []predicate.Tutorial
  22449. }
  22450. var _ ent.Mutation = (*TutorialMutation)(nil)
  22451. // tutorialOption allows management of the mutation configuration using functional options.
  22452. type tutorialOption func(*TutorialMutation)
  22453. // newTutorialMutation creates new mutation for the Tutorial entity.
  22454. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  22455. m := &TutorialMutation{
  22456. config: c,
  22457. op: op,
  22458. typ: TypeTutorial,
  22459. clearedFields: make(map[string]struct{}),
  22460. }
  22461. for _, opt := range opts {
  22462. opt(m)
  22463. }
  22464. return m
  22465. }
  22466. // withTutorialID sets the ID field of the mutation.
  22467. func withTutorialID(id uint64) tutorialOption {
  22468. return func(m *TutorialMutation) {
  22469. var (
  22470. err error
  22471. once sync.Once
  22472. value *Tutorial
  22473. )
  22474. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  22475. once.Do(func() {
  22476. if m.done {
  22477. err = errors.New("querying old values post mutation is not allowed")
  22478. } else {
  22479. value, err = m.Client().Tutorial.Get(ctx, id)
  22480. }
  22481. })
  22482. return value, err
  22483. }
  22484. m.id = &id
  22485. }
  22486. }
  22487. // withTutorial sets the old Tutorial of the mutation.
  22488. func withTutorial(node *Tutorial) tutorialOption {
  22489. return func(m *TutorialMutation) {
  22490. m.oldValue = func(context.Context) (*Tutorial, error) {
  22491. return node, nil
  22492. }
  22493. m.id = &node.ID
  22494. }
  22495. }
  22496. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22497. // executed in a transaction (ent.Tx), a transactional client is returned.
  22498. func (m TutorialMutation) Client() *Client {
  22499. client := &Client{config: m.config}
  22500. client.init()
  22501. return client
  22502. }
  22503. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22504. // it returns an error otherwise.
  22505. func (m TutorialMutation) Tx() (*Tx, error) {
  22506. if _, ok := m.driver.(*txDriver); !ok {
  22507. return nil, errors.New("ent: mutation is not running in a transaction")
  22508. }
  22509. tx := &Tx{config: m.config}
  22510. tx.init()
  22511. return tx, nil
  22512. }
  22513. // SetID sets the value of the id field. Note that this
  22514. // operation is only accepted on creation of Tutorial entities.
  22515. func (m *TutorialMutation) SetID(id uint64) {
  22516. m.id = &id
  22517. }
  22518. // ID returns the ID value in the mutation. Note that the ID is only available
  22519. // if it was provided to the builder or after it was returned from the database.
  22520. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  22521. if m.id == nil {
  22522. return
  22523. }
  22524. return *m.id, true
  22525. }
  22526. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22527. // That means, if the mutation is applied within a transaction with an isolation level such
  22528. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22529. // or updated by the mutation.
  22530. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  22531. switch {
  22532. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22533. id, exists := m.ID()
  22534. if exists {
  22535. return []uint64{id}, nil
  22536. }
  22537. fallthrough
  22538. case m.op.Is(OpUpdate | OpDelete):
  22539. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  22540. default:
  22541. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22542. }
  22543. }
  22544. // SetCreatedAt sets the "created_at" field.
  22545. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  22546. m.created_at = &t
  22547. }
  22548. // CreatedAt returns the value of the "created_at" field in the mutation.
  22549. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  22550. v := m.created_at
  22551. if v == nil {
  22552. return
  22553. }
  22554. return *v, true
  22555. }
  22556. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  22557. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22559. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22560. if !m.op.Is(OpUpdateOne) {
  22561. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22562. }
  22563. if m.id == nil || m.oldValue == nil {
  22564. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22565. }
  22566. oldValue, err := m.oldValue(ctx)
  22567. if err != nil {
  22568. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22569. }
  22570. return oldValue.CreatedAt, nil
  22571. }
  22572. // ResetCreatedAt resets all changes to the "created_at" field.
  22573. func (m *TutorialMutation) ResetCreatedAt() {
  22574. m.created_at = nil
  22575. }
  22576. // SetUpdatedAt sets the "updated_at" field.
  22577. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  22578. m.updated_at = &t
  22579. }
  22580. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22581. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  22582. v := m.updated_at
  22583. if v == nil {
  22584. return
  22585. }
  22586. return *v, true
  22587. }
  22588. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  22589. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22591. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22592. if !m.op.Is(OpUpdateOne) {
  22593. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22594. }
  22595. if m.id == nil || m.oldValue == nil {
  22596. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22597. }
  22598. oldValue, err := m.oldValue(ctx)
  22599. if err != nil {
  22600. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22601. }
  22602. return oldValue.UpdatedAt, nil
  22603. }
  22604. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22605. func (m *TutorialMutation) ResetUpdatedAt() {
  22606. m.updated_at = nil
  22607. }
  22608. // SetDeletedAt sets the "deleted_at" field.
  22609. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  22610. m.deleted_at = &t
  22611. }
  22612. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22613. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  22614. v := m.deleted_at
  22615. if v == nil {
  22616. return
  22617. }
  22618. return *v, true
  22619. }
  22620. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  22621. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22623. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22624. if !m.op.Is(OpUpdateOne) {
  22625. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22626. }
  22627. if m.id == nil || m.oldValue == nil {
  22628. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22629. }
  22630. oldValue, err := m.oldValue(ctx)
  22631. if err != nil {
  22632. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22633. }
  22634. return oldValue.DeletedAt, nil
  22635. }
  22636. // ClearDeletedAt clears the value of the "deleted_at" field.
  22637. func (m *TutorialMutation) ClearDeletedAt() {
  22638. m.deleted_at = nil
  22639. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  22640. }
  22641. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22642. func (m *TutorialMutation) DeletedAtCleared() bool {
  22643. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  22644. return ok
  22645. }
  22646. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22647. func (m *TutorialMutation) ResetDeletedAt() {
  22648. m.deleted_at = nil
  22649. delete(m.clearedFields, tutorial.FieldDeletedAt)
  22650. }
  22651. // SetEmployeeID sets the "employee_id" field.
  22652. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  22653. m.employee = &u
  22654. }
  22655. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22656. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  22657. v := m.employee
  22658. if v == nil {
  22659. return
  22660. }
  22661. return *v, true
  22662. }
  22663. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  22664. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22666. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22667. if !m.op.Is(OpUpdateOne) {
  22668. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22669. }
  22670. if m.id == nil || m.oldValue == nil {
  22671. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22672. }
  22673. oldValue, err := m.oldValue(ctx)
  22674. if err != nil {
  22675. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22676. }
  22677. return oldValue.EmployeeID, nil
  22678. }
  22679. // ResetEmployeeID resets all changes to the "employee_id" field.
  22680. func (m *TutorialMutation) ResetEmployeeID() {
  22681. m.employee = nil
  22682. }
  22683. // SetIndex sets the "index" field.
  22684. func (m *TutorialMutation) SetIndex(i int) {
  22685. m.index = &i
  22686. m.addindex = nil
  22687. }
  22688. // Index returns the value of the "index" field in the mutation.
  22689. func (m *TutorialMutation) Index() (r int, exists bool) {
  22690. v := m.index
  22691. if v == nil {
  22692. return
  22693. }
  22694. return *v, true
  22695. }
  22696. // OldIndex returns the old "index" field's value of the Tutorial entity.
  22697. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22699. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  22700. if !m.op.Is(OpUpdateOne) {
  22701. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  22702. }
  22703. if m.id == nil || m.oldValue == nil {
  22704. return v, errors.New("OldIndex requires an ID field in the mutation")
  22705. }
  22706. oldValue, err := m.oldValue(ctx)
  22707. if err != nil {
  22708. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  22709. }
  22710. return oldValue.Index, nil
  22711. }
  22712. // AddIndex adds i to the "index" field.
  22713. func (m *TutorialMutation) AddIndex(i int) {
  22714. if m.addindex != nil {
  22715. *m.addindex += i
  22716. } else {
  22717. m.addindex = &i
  22718. }
  22719. }
  22720. // AddedIndex returns the value that was added to the "index" field in this mutation.
  22721. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  22722. v := m.addindex
  22723. if v == nil {
  22724. return
  22725. }
  22726. return *v, true
  22727. }
  22728. // ResetIndex resets all changes to the "index" field.
  22729. func (m *TutorialMutation) ResetIndex() {
  22730. m.index = nil
  22731. m.addindex = nil
  22732. }
  22733. // SetTitle sets the "title" field.
  22734. func (m *TutorialMutation) SetTitle(s string) {
  22735. m.title = &s
  22736. }
  22737. // Title returns the value of the "title" field in the mutation.
  22738. func (m *TutorialMutation) Title() (r string, exists bool) {
  22739. v := m.title
  22740. if v == nil {
  22741. return
  22742. }
  22743. return *v, true
  22744. }
  22745. // OldTitle returns the old "title" field's value of the Tutorial entity.
  22746. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22748. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  22749. if !m.op.Is(OpUpdateOne) {
  22750. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  22751. }
  22752. if m.id == nil || m.oldValue == nil {
  22753. return v, errors.New("OldTitle requires an ID field in the mutation")
  22754. }
  22755. oldValue, err := m.oldValue(ctx)
  22756. if err != nil {
  22757. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  22758. }
  22759. return oldValue.Title, nil
  22760. }
  22761. // ResetTitle resets all changes to the "title" field.
  22762. func (m *TutorialMutation) ResetTitle() {
  22763. m.title = nil
  22764. }
  22765. // SetContent sets the "content" field.
  22766. func (m *TutorialMutation) SetContent(s string) {
  22767. m.content = &s
  22768. }
  22769. // Content returns the value of the "content" field in the mutation.
  22770. func (m *TutorialMutation) Content() (r string, exists bool) {
  22771. v := m.content
  22772. if v == nil {
  22773. return
  22774. }
  22775. return *v, true
  22776. }
  22777. // OldContent returns the old "content" field's value of the Tutorial entity.
  22778. // If the Tutorial 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 *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  22781. if !m.op.Is(OpUpdateOne) {
  22782. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22783. }
  22784. if m.id == nil || m.oldValue == nil {
  22785. return v, errors.New("OldContent 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 OldContent: %w", err)
  22790. }
  22791. return oldValue.Content, nil
  22792. }
  22793. // ResetContent resets all changes to the "content" field.
  22794. func (m *TutorialMutation) ResetContent() {
  22795. m.content = nil
  22796. }
  22797. // SetOrganizationID sets the "organization_id" field.
  22798. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  22799. m.organization_id = &u
  22800. m.addorganization_id = nil
  22801. }
  22802. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22803. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  22804. v := m.organization_id
  22805. if v == nil {
  22806. return
  22807. }
  22808. return *v, true
  22809. }
  22810. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  22811. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22813. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22814. if !m.op.Is(OpUpdateOne) {
  22815. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22816. }
  22817. if m.id == nil || m.oldValue == nil {
  22818. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22819. }
  22820. oldValue, err := m.oldValue(ctx)
  22821. if err != nil {
  22822. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22823. }
  22824. return oldValue.OrganizationID, nil
  22825. }
  22826. // AddOrganizationID adds u to the "organization_id" field.
  22827. func (m *TutorialMutation) AddOrganizationID(u int64) {
  22828. if m.addorganization_id != nil {
  22829. *m.addorganization_id += u
  22830. } else {
  22831. m.addorganization_id = &u
  22832. }
  22833. }
  22834. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22835. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  22836. v := m.addorganization_id
  22837. if v == nil {
  22838. return
  22839. }
  22840. return *v, true
  22841. }
  22842. // ResetOrganizationID resets all changes to the "organization_id" field.
  22843. func (m *TutorialMutation) ResetOrganizationID() {
  22844. m.organization_id = nil
  22845. m.addorganization_id = nil
  22846. }
  22847. // ClearEmployee clears the "employee" edge to the Employee entity.
  22848. func (m *TutorialMutation) ClearEmployee() {
  22849. m.clearedemployee = true
  22850. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  22851. }
  22852. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22853. func (m *TutorialMutation) EmployeeCleared() bool {
  22854. return m.clearedemployee
  22855. }
  22856. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22857. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22858. // EmployeeID instead. It exists only for internal usage by the builders.
  22859. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  22860. if id := m.employee; id != nil {
  22861. ids = append(ids, *id)
  22862. }
  22863. return
  22864. }
  22865. // ResetEmployee resets all changes to the "employee" edge.
  22866. func (m *TutorialMutation) ResetEmployee() {
  22867. m.employee = nil
  22868. m.clearedemployee = false
  22869. }
  22870. // Where appends a list predicates to the TutorialMutation builder.
  22871. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  22872. m.predicates = append(m.predicates, ps...)
  22873. }
  22874. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  22875. // users can use type-assertion to append predicates that do not depend on any generated package.
  22876. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  22877. p := make([]predicate.Tutorial, len(ps))
  22878. for i := range ps {
  22879. p[i] = ps[i]
  22880. }
  22881. m.Where(p...)
  22882. }
  22883. // Op returns the operation name.
  22884. func (m *TutorialMutation) Op() Op {
  22885. return m.op
  22886. }
  22887. // SetOp allows setting the mutation operation.
  22888. func (m *TutorialMutation) SetOp(op Op) {
  22889. m.op = op
  22890. }
  22891. // Type returns the node type of this mutation (Tutorial).
  22892. func (m *TutorialMutation) Type() string {
  22893. return m.typ
  22894. }
  22895. // Fields returns all fields that were changed during this mutation. Note that in
  22896. // order to get all numeric fields that were incremented/decremented, call
  22897. // AddedFields().
  22898. func (m *TutorialMutation) Fields() []string {
  22899. fields := make([]string, 0, 8)
  22900. if m.created_at != nil {
  22901. fields = append(fields, tutorial.FieldCreatedAt)
  22902. }
  22903. if m.updated_at != nil {
  22904. fields = append(fields, tutorial.FieldUpdatedAt)
  22905. }
  22906. if m.deleted_at != nil {
  22907. fields = append(fields, tutorial.FieldDeletedAt)
  22908. }
  22909. if m.employee != nil {
  22910. fields = append(fields, tutorial.FieldEmployeeID)
  22911. }
  22912. if m.index != nil {
  22913. fields = append(fields, tutorial.FieldIndex)
  22914. }
  22915. if m.title != nil {
  22916. fields = append(fields, tutorial.FieldTitle)
  22917. }
  22918. if m.content != nil {
  22919. fields = append(fields, tutorial.FieldContent)
  22920. }
  22921. if m.organization_id != nil {
  22922. fields = append(fields, tutorial.FieldOrganizationID)
  22923. }
  22924. return fields
  22925. }
  22926. // Field returns the value of a field with the given name. The second boolean
  22927. // return value indicates that this field was not set, or was not defined in the
  22928. // schema.
  22929. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22930. switch name {
  22931. case tutorial.FieldCreatedAt:
  22932. return m.CreatedAt()
  22933. case tutorial.FieldUpdatedAt:
  22934. return m.UpdatedAt()
  22935. case tutorial.FieldDeletedAt:
  22936. return m.DeletedAt()
  22937. case tutorial.FieldEmployeeID:
  22938. return m.EmployeeID()
  22939. case tutorial.FieldIndex:
  22940. return m.Index()
  22941. case tutorial.FieldTitle:
  22942. return m.Title()
  22943. case tutorial.FieldContent:
  22944. return m.Content()
  22945. case tutorial.FieldOrganizationID:
  22946. return m.OrganizationID()
  22947. }
  22948. return nil, false
  22949. }
  22950. // OldField returns the old value of the field from the database. An error is
  22951. // returned if the mutation operation is not UpdateOne, or the query to the
  22952. // database failed.
  22953. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22954. switch name {
  22955. case tutorial.FieldCreatedAt:
  22956. return m.OldCreatedAt(ctx)
  22957. case tutorial.FieldUpdatedAt:
  22958. return m.OldUpdatedAt(ctx)
  22959. case tutorial.FieldDeletedAt:
  22960. return m.OldDeletedAt(ctx)
  22961. case tutorial.FieldEmployeeID:
  22962. return m.OldEmployeeID(ctx)
  22963. case tutorial.FieldIndex:
  22964. return m.OldIndex(ctx)
  22965. case tutorial.FieldTitle:
  22966. return m.OldTitle(ctx)
  22967. case tutorial.FieldContent:
  22968. return m.OldContent(ctx)
  22969. case tutorial.FieldOrganizationID:
  22970. return m.OldOrganizationID(ctx)
  22971. }
  22972. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22973. }
  22974. // SetField sets the value of a field with the given name. It returns an error if
  22975. // the field is not defined in the schema, or if the type mismatched the field
  22976. // type.
  22977. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22978. switch name {
  22979. case tutorial.FieldCreatedAt:
  22980. v, ok := value.(time.Time)
  22981. if !ok {
  22982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22983. }
  22984. m.SetCreatedAt(v)
  22985. return nil
  22986. case tutorial.FieldUpdatedAt:
  22987. v, ok := value.(time.Time)
  22988. if !ok {
  22989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22990. }
  22991. m.SetUpdatedAt(v)
  22992. return nil
  22993. case tutorial.FieldDeletedAt:
  22994. v, ok := value.(time.Time)
  22995. if !ok {
  22996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22997. }
  22998. m.SetDeletedAt(v)
  22999. return nil
  23000. case tutorial.FieldEmployeeID:
  23001. v, ok := value.(uint64)
  23002. if !ok {
  23003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23004. }
  23005. m.SetEmployeeID(v)
  23006. return nil
  23007. case tutorial.FieldIndex:
  23008. v, ok := value.(int)
  23009. if !ok {
  23010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23011. }
  23012. m.SetIndex(v)
  23013. return nil
  23014. case tutorial.FieldTitle:
  23015. v, ok := value.(string)
  23016. if !ok {
  23017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23018. }
  23019. m.SetTitle(v)
  23020. return nil
  23021. case tutorial.FieldContent:
  23022. v, ok := value.(string)
  23023. if !ok {
  23024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23025. }
  23026. m.SetContent(v)
  23027. return nil
  23028. case tutorial.FieldOrganizationID:
  23029. v, ok := value.(uint64)
  23030. if !ok {
  23031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23032. }
  23033. m.SetOrganizationID(v)
  23034. return nil
  23035. }
  23036. return fmt.Errorf("unknown Tutorial field %s", name)
  23037. }
  23038. // AddedFields returns all numeric fields that were incremented/decremented during
  23039. // this mutation.
  23040. func (m *TutorialMutation) AddedFields() []string {
  23041. var fields []string
  23042. if m.addindex != nil {
  23043. fields = append(fields, tutorial.FieldIndex)
  23044. }
  23045. if m.addorganization_id != nil {
  23046. fields = append(fields, tutorial.FieldOrganizationID)
  23047. }
  23048. return fields
  23049. }
  23050. // AddedField returns the numeric value that was incremented/decremented on a field
  23051. // with the given name. The second boolean return value indicates that this field
  23052. // was not set, or was not defined in the schema.
  23053. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  23054. switch name {
  23055. case tutorial.FieldIndex:
  23056. return m.AddedIndex()
  23057. case tutorial.FieldOrganizationID:
  23058. return m.AddedOrganizationID()
  23059. }
  23060. return nil, false
  23061. }
  23062. // AddField adds the value to the field with the given name. It returns an error if
  23063. // the field is not defined in the schema, or if the type mismatched the field
  23064. // type.
  23065. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  23066. switch name {
  23067. case tutorial.FieldIndex:
  23068. v, ok := value.(int)
  23069. if !ok {
  23070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23071. }
  23072. m.AddIndex(v)
  23073. return nil
  23074. case tutorial.FieldOrganizationID:
  23075. v, ok := value.(int64)
  23076. if !ok {
  23077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23078. }
  23079. m.AddOrganizationID(v)
  23080. return nil
  23081. }
  23082. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  23083. }
  23084. // ClearedFields returns all nullable fields that were cleared during this
  23085. // mutation.
  23086. func (m *TutorialMutation) ClearedFields() []string {
  23087. var fields []string
  23088. if m.FieldCleared(tutorial.FieldDeletedAt) {
  23089. fields = append(fields, tutorial.FieldDeletedAt)
  23090. }
  23091. return fields
  23092. }
  23093. // FieldCleared returns a boolean indicating if a field with the given name was
  23094. // cleared in this mutation.
  23095. func (m *TutorialMutation) FieldCleared(name string) bool {
  23096. _, ok := m.clearedFields[name]
  23097. return ok
  23098. }
  23099. // ClearField clears the value of the field with the given name. It returns an
  23100. // error if the field is not defined in the schema.
  23101. func (m *TutorialMutation) ClearField(name string) error {
  23102. switch name {
  23103. case tutorial.FieldDeletedAt:
  23104. m.ClearDeletedAt()
  23105. return nil
  23106. }
  23107. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  23108. }
  23109. // ResetField resets all changes in the mutation for the field with the given name.
  23110. // It returns an error if the field is not defined in the schema.
  23111. func (m *TutorialMutation) ResetField(name string) error {
  23112. switch name {
  23113. case tutorial.FieldCreatedAt:
  23114. m.ResetCreatedAt()
  23115. return nil
  23116. case tutorial.FieldUpdatedAt:
  23117. m.ResetUpdatedAt()
  23118. return nil
  23119. case tutorial.FieldDeletedAt:
  23120. m.ResetDeletedAt()
  23121. return nil
  23122. case tutorial.FieldEmployeeID:
  23123. m.ResetEmployeeID()
  23124. return nil
  23125. case tutorial.FieldIndex:
  23126. m.ResetIndex()
  23127. return nil
  23128. case tutorial.FieldTitle:
  23129. m.ResetTitle()
  23130. return nil
  23131. case tutorial.FieldContent:
  23132. m.ResetContent()
  23133. return nil
  23134. case tutorial.FieldOrganizationID:
  23135. m.ResetOrganizationID()
  23136. return nil
  23137. }
  23138. return fmt.Errorf("unknown Tutorial field %s", name)
  23139. }
  23140. // AddedEdges returns all edge names that were set/added in this mutation.
  23141. func (m *TutorialMutation) AddedEdges() []string {
  23142. edges := make([]string, 0, 1)
  23143. if m.employee != nil {
  23144. edges = append(edges, tutorial.EdgeEmployee)
  23145. }
  23146. return edges
  23147. }
  23148. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23149. // name in this mutation.
  23150. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23151. switch name {
  23152. case tutorial.EdgeEmployee:
  23153. if id := m.employee; id != nil {
  23154. return []ent.Value{*id}
  23155. }
  23156. }
  23157. return nil
  23158. }
  23159. // RemovedEdges returns all edge names that were removed in this mutation.
  23160. func (m *TutorialMutation) RemovedEdges() []string {
  23161. edges := make([]string, 0, 1)
  23162. return edges
  23163. }
  23164. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23165. // the given name in this mutation.
  23166. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23167. return nil
  23168. }
  23169. // ClearedEdges returns all edge names that were cleared in this mutation.
  23170. func (m *TutorialMutation) ClearedEdges() []string {
  23171. edges := make([]string, 0, 1)
  23172. if m.clearedemployee {
  23173. edges = append(edges, tutorial.EdgeEmployee)
  23174. }
  23175. return edges
  23176. }
  23177. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23178. // was cleared in this mutation.
  23179. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23180. switch name {
  23181. case tutorial.EdgeEmployee:
  23182. return m.clearedemployee
  23183. }
  23184. return false
  23185. }
  23186. // ClearEdge clears the value of the edge with the given name. It returns an error
  23187. // if that edge is not defined in the schema.
  23188. func (m *TutorialMutation) ClearEdge(name string) error {
  23189. switch name {
  23190. case tutorial.EdgeEmployee:
  23191. m.ClearEmployee()
  23192. return nil
  23193. }
  23194. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23195. }
  23196. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23197. // It returns an error if the edge is not defined in the schema.
  23198. func (m *TutorialMutation) ResetEdge(name string) error {
  23199. switch name {
  23200. case tutorial.EdgeEmployee:
  23201. m.ResetEmployee()
  23202. return nil
  23203. }
  23204. return fmt.Errorf("unknown Tutorial edge %s", name)
  23205. }
  23206. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23207. type UsageDetailMutation struct {
  23208. config
  23209. op Op
  23210. typ string
  23211. id *uint64
  23212. created_at *time.Time
  23213. updated_at *time.Time
  23214. status *uint8
  23215. addstatus *int8
  23216. _type *int
  23217. add_type *int
  23218. bot_id *string
  23219. receiver_id *string
  23220. app *int
  23221. addapp *int
  23222. session_id *uint64
  23223. addsession_id *int64
  23224. request *string
  23225. response *string
  23226. total_tokens *uint64
  23227. addtotal_tokens *int64
  23228. prompt_tokens *uint64
  23229. addprompt_tokens *int64
  23230. completion_tokens *uint64
  23231. addcompletion_tokens *int64
  23232. organization_id *uint64
  23233. addorganization_id *int64
  23234. clearedFields map[string]struct{}
  23235. done bool
  23236. oldValue func(context.Context) (*UsageDetail, error)
  23237. predicates []predicate.UsageDetail
  23238. }
  23239. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23240. // usagedetailOption allows management of the mutation configuration using functional options.
  23241. type usagedetailOption func(*UsageDetailMutation)
  23242. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23243. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23244. m := &UsageDetailMutation{
  23245. config: c,
  23246. op: op,
  23247. typ: TypeUsageDetail,
  23248. clearedFields: make(map[string]struct{}),
  23249. }
  23250. for _, opt := range opts {
  23251. opt(m)
  23252. }
  23253. return m
  23254. }
  23255. // withUsageDetailID sets the ID field of the mutation.
  23256. func withUsageDetailID(id uint64) usagedetailOption {
  23257. return func(m *UsageDetailMutation) {
  23258. var (
  23259. err error
  23260. once sync.Once
  23261. value *UsageDetail
  23262. )
  23263. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  23264. once.Do(func() {
  23265. if m.done {
  23266. err = errors.New("querying old values post mutation is not allowed")
  23267. } else {
  23268. value, err = m.Client().UsageDetail.Get(ctx, id)
  23269. }
  23270. })
  23271. return value, err
  23272. }
  23273. m.id = &id
  23274. }
  23275. }
  23276. // withUsageDetail sets the old UsageDetail of the mutation.
  23277. func withUsageDetail(node *UsageDetail) usagedetailOption {
  23278. return func(m *UsageDetailMutation) {
  23279. m.oldValue = func(context.Context) (*UsageDetail, error) {
  23280. return node, nil
  23281. }
  23282. m.id = &node.ID
  23283. }
  23284. }
  23285. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23286. // executed in a transaction (ent.Tx), a transactional client is returned.
  23287. func (m UsageDetailMutation) Client() *Client {
  23288. client := &Client{config: m.config}
  23289. client.init()
  23290. return client
  23291. }
  23292. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23293. // it returns an error otherwise.
  23294. func (m UsageDetailMutation) Tx() (*Tx, error) {
  23295. if _, ok := m.driver.(*txDriver); !ok {
  23296. return nil, errors.New("ent: mutation is not running in a transaction")
  23297. }
  23298. tx := &Tx{config: m.config}
  23299. tx.init()
  23300. return tx, nil
  23301. }
  23302. // SetID sets the value of the id field. Note that this
  23303. // operation is only accepted on creation of UsageDetail entities.
  23304. func (m *UsageDetailMutation) SetID(id uint64) {
  23305. m.id = &id
  23306. }
  23307. // ID returns the ID value in the mutation. Note that the ID is only available
  23308. // if it was provided to the builder or after it was returned from the database.
  23309. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  23310. if m.id == nil {
  23311. return
  23312. }
  23313. return *m.id, true
  23314. }
  23315. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23316. // That means, if the mutation is applied within a transaction with an isolation level such
  23317. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23318. // or updated by the mutation.
  23319. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  23320. switch {
  23321. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23322. id, exists := m.ID()
  23323. if exists {
  23324. return []uint64{id}, nil
  23325. }
  23326. fallthrough
  23327. case m.op.Is(OpUpdate | OpDelete):
  23328. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  23329. default:
  23330. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23331. }
  23332. }
  23333. // SetCreatedAt sets the "created_at" field.
  23334. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  23335. m.created_at = &t
  23336. }
  23337. // CreatedAt returns the value of the "created_at" field in the mutation.
  23338. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  23339. v := m.created_at
  23340. if v == nil {
  23341. return
  23342. }
  23343. return *v, true
  23344. }
  23345. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  23346. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23348. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23349. if !m.op.Is(OpUpdateOne) {
  23350. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23351. }
  23352. if m.id == nil || m.oldValue == nil {
  23353. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23354. }
  23355. oldValue, err := m.oldValue(ctx)
  23356. if err != nil {
  23357. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23358. }
  23359. return oldValue.CreatedAt, nil
  23360. }
  23361. // ResetCreatedAt resets all changes to the "created_at" field.
  23362. func (m *UsageDetailMutation) ResetCreatedAt() {
  23363. m.created_at = nil
  23364. }
  23365. // SetUpdatedAt sets the "updated_at" field.
  23366. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  23367. m.updated_at = &t
  23368. }
  23369. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23370. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  23371. v := m.updated_at
  23372. if v == nil {
  23373. return
  23374. }
  23375. return *v, true
  23376. }
  23377. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  23378. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23380. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23381. if !m.op.Is(OpUpdateOne) {
  23382. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23383. }
  23384. if m.id == nil || m.oldValue == nil {
  23385. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23386. }
  23387. oldValue, err := m.oldValue(ctx)
  23388. if err != nil {
  23389. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23390. }
  23391. return oldValue.UpdatedAt, nil
  23392. }
  23393. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23394. func (m *UsageDetailMutation) ResetUpdatedAt() {
  23395. m.updated_at = nil
  23396. }
  23397. // SetStatus sets the "status" field.
  23398. func (m *UsageDetailMutation) SetStatus(u uint8) {
  23399. m.status = &u
  23400. m.addstatus = nil
  23401. }
  23402. // Status returns the value of the "status" field in the mutation.
  23403. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  23404. v := m.status
  23405. if v == nil {
  23406. return
  23407. }
  23408. return *v, true
  23409. }
  23410. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  23411. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23413. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23414. if !m.op.Is(OpUpdateOne) {
  23415. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23416. }
  23417. if m.id == nil || m.oldValue == nil {
  23418. return v, errors.New("OldStatus requires an ID field in the mutation")
  23419. }
  23420. oldValue, err := m.oldValue(ctx)
  23421. if err != nil {
  23422. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23423. }
  23424. return oldValue.Status, nil
  23425. }
  23426. // AddStatus adds u to the "status" field.
  23427. func (m *UsageDetailMutation) AddStatus(u int8) {
  23428. if m.addstatus != nil {
  23429. *m.addstatus += u
  23430. } else {
  23431. m.addstatus = &u
  23432. }
  23433. }
  23434. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23435. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  23436. v := m.addstatus
  23437. if v == nil {
  23438. return
  23439. }
  23440. return *v, true
  23441. }
  23442. // ClearStatus clears the value of the "status" field.
  23443. func (m *UsageDetailMutation) ClearStatus() {
  23444. m.status = nil
  23445. m.addstatus = nil
  23446. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  23447. }
  23448. // StatusCleared returns if the "status" field was cleared in this mutation.
  23449. func (m *UsageDetailMutation) StatusCleared() bool {
  23450. _, ok := m.clearedFields[usagedetail.FieldStatus]
  23451. return ok
  23452. }
  23453. // ResetStatus resets all changes to the "status" field.
  23454. func (m *UsageDetailMutation) ResetStatus() {
  23455. m.status = nil
  23456. m.addstatus = nil
  23457. delete(m.clearedFields, usagedetail.FieldStatus)
  23458. }
  23459. // SetType sets the "type" field.
  23460. func (m *UsageDetailMutation) SetType(i int) {
  23461. m._type = &i
  23462. m.add_type = nil
  23463. }
  23464. // GetType returns the value of the "type" field in the mutation.
  23465. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  23466. v := m._type
  23467. if v == nil {
  23468. return
  23469. }
  23470. return *v, true
  23471. }
  23472. // OldType returns the old "type" field's value of the UsageDetail entity.
  23473. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23475. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  23476. if !m.op.Is(OpUpdateOne) {
  23477. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23478. }
  23479. if m.id == nil || m.oldValue == nil {
  23480. return v, errors.New("OldType requires an ID field in the mutation")
  23481. }
  23482. oldValue, err := m.oldValue(ctx)
  23483. if err != nil {
  23484. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23485. }
  23486. return oldValue.Type, nil
  23487. }
  23488. // AddType adds i to the "type" field.
  23489. func (m *UsageDetailMutation) AddType(i int) {
  23490. if m.add_type != nil {
  23491. *m.add_type += i
  23492. } else {
  23493. m.add_type = &i
  23494. }
  23495. }
  23496. // AddedType returns the value that was added to the "type" field in this mutation.
  23497. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  23498. v := m.add_type
  23499. if v == nil {
  23500. return
  23501. }
  23502. return *v, true
  23503. }
  23504. // ClearType clears the value of the "type" field.
  23505. func (m *UsageDetailMutation) ClearType() {
  23506. m._type = nil
  23507. m.add_type = nil
  23508. m.clearedFields[usagedetail.FieldType] = struct{}{}
  23509. }
  23510. // TypeCleared returns if the "type" field was cleared in this mutation.
  23511. func (m *UsageDetailMutation) TypeCleared() bool {
  23512. _, ok := m.clearedFields[usagedetail.FieldType]
  23513. return ok
  23514. }
  23515. // ResetType resets all changes to the "type" field.
  23516. func (m *UsageDetailMutation) ResetType() {
  23517. m._type = nil
  23518. m.add_type = nil
  23519. delete(m.clearedFields, usagedetail.FieldType)
  23520. }
  23521. // SetBotID sets the "bot_id" field.
  23522. func (m *UsageDetailMutation) SetBotID(s string) {
  23523. m.bot_id = &s
  23524. }
  23525. // BotID returns the value of the "bot_id" field in the mutation.
  23526. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  23527. v := m.bot_id
  23528. if v == nil {
  23529. return
  23530. }
  23531. return *v, true
  23532. }
  23533. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  23534. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23536. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  23537. if !m.op.Is(OpUpdateOne) {
  23538. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23539. }
  23540. if m.id == nil || m.oldValue == nil {
  23541. return v, errors.New("OldBotID requires an ID field in the mutation")
  23542. }
  23543. oldValue, err := m.oldValue(ctx)
  23544. if err != nil {
  23545. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23546. }
  23547. return oldValue.BotID, nil
  23548. }
  23549. // ResetBotID resets all changes to the "bot_id" field.
  23550. func (m *UsageDetailMutation) ResetBotID() {
  23551. m.bot_id = nil
  23552. }
  23553. // SetReceiverID sets the "receiver_id" field.
  23554. func (m *UsageDetailMutation) SetReceiverID(s string) {
  23555. m.receiver_id = &s
  23556. }
  23557. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  23558. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  23559. v := m.receiver_id
  23560. if v == nil {
  23561. return
  23562. }
  23563. return *v, true
  23564. }
  23565. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  23566. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23568. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  23569. if !m.op.Is(OpUpdateOne) {
  23570. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  23571. }
  23572. if m.id == nil || m.oldValue == nil {
  23573. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  23574. }
  23575. oldValue, err := m.oldValue(ctx)
  23576. if err != nil {
  23577. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  23578. }
  23579. return oldValue.ReceiverID, nil
  23580. }
  23581. // ResetReceiverID resets all changes to the "receiver_id" field.
  23582. func (m *UsageDetailMutation) ResetReceiverID() {
  23583. m.receiver_id = nil
  23584. }
  23585. // SetApp sets the "app" field.
  23586. func (m *UsageDetailMutation) SetApp(i int) {
  23587. m.app = &i
  23588. m.addapp = nil
  23589. }
  23590. // App returns the value of the "app" field in the mutation.
  23591. func (m *UsageDetailMutation) App() (r int, exists bool) {
  23592. v := m.app
  23593. if v == nil {
  23594. return
  23595. }
  23596. return *v, true
  23597. }
  23598. // OldApp returns the old "app" field's value of the UsageDetail entity.
  23599. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23601. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  23602. if !m.op.Is(OpUpdateOne) {
  23603. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  23604. }
  23605. if m.id == nil || m.oldValue == nil {
  23606. return v, errors.New("OldApp requires an ID field in the mutation")
  23607. }
  23608. oldValue, err := m.oldValue(ctx)
  23609. if err != nil {
  23610. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  23611. }
  23612. return oldValue.App, nil
  23613. }
  23614. // AddApp adds i to the "app" field.
  23615. func (m *UsageDetailMutation) AddApp(i int) {
  23616. if m.addapp != nil {
  23617. *m.addapp += i
  23618. } else {
  23619. m.addapp = &i
  23620. }
  23621. }
  23622. // AddedApp returns the value that was added to the "app" field in this mutation.
  23623. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  23624. v := m.addapp
  23625. if v == nil {
  23626. return
  23627. }
  23628. return *v, true
  23629. }
  23630. // ClearApp clears the value of the "app" field.
  23631. func (m *UsageDetailMutation) ClearApp() {
  23632. m.app = nil
  23633. m.addapp = nil
  23634. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  23635. }
  23636. // AppCleared returns if the "app" field was cleared in this mutation.
  23637. func (m *UsageDetailMutation) AppCleared() bool {
  23638. _, ok := m.clearedFields[usagedetail.FieldApp]
  23639. return ok
  23640. }
  23641. // ResetApp resets all changes to the "app" field.
  23642. func (m *UsageDetailMutation) ResetApp() {
  23643. m.app = nil
  23644. m.addapp = nil
  23645. delete(m.clearedFields, usagedetail.FieldApp)
  23646. }
  23647. // SetSessionID sets the "session_id" field.
  23648. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  23649. m.session_id = &u
  23650. m.addsession_id = nil
  23651. }
  23652. // SessionID returns the value of the "session_id" field in the mutation.
  23653. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  23654. v := m.session_id
  23655. if v == nil {
  23656. return
  23657. }
  23658. return *v, true
  23659. }
  23660. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  23661. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23663. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  23664. if !m.op.Is(OpUpdateOne) {
  23665. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  23666. }
  23667. if m.id == nil || m.oldValue == nil {
  23668. return v, errors.New("OldSessionID requires an ID field in the mutation")
  23669. }
  23670. oldValue, err := m.oldValue(ctx)
  23671. if err != nil {
  23672. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  23673. }
  23674. return oldValue.SessionID, nil
  23675. }
  23676. // AddSessionID adds u to the "session_id" field.
  23677. func (m *UsageDetailMutation) AddSessionID(u int64) {
  23678. if m.addsession_id != nil {
  23679. *m.addsession_id += u
  23680. } else {
  23681. m.addsession_id = &u
  23682. }
  23683. }
  23684. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  23685. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  23686. v := m.addsession_id
  23687. if v == nil {
  23688. return
  23689. }
  23690. return *v, true
  23691. }
  23692. // ClearSessionID clears the value of the "session_id" field.
  23693. func (m *UsageDetailMutation) ClearSessionID() {
  23694. m.session_id = nil
  23695. m.addsession_id = nil
  23696. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  23697. }
  23698. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  23699. func (m *UsageDetailMutation) SessionIDCleared() bool {
  23700. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  23701. return ok
  23702. }
  23703. // ResetSessionID resets all changes to the "session_id" field.
  23704. func (m *UsageDetailMutation) ResetSessionID() {
  23705. m.session_id = nil
  23706. m.addsession_id = nil
  23707. delete(m.clearedFields, usagedetail.FieldSessionID)
  23708. }
  23709. // SetRequest sets the "request" field.
  23710. func (m *UsageDetailMutation) SetRequest(s string) {
  23711. m.request = &s
  23712. }
  23713. // Request returns the value of the "request" field in the mutation.
  23714. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  23715. v := m.request
  23716. if v == nil {
  23717. return
  23718. }
  23719. return *v, true
  23720. }
  23721. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  23722. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23724. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  23725. if !m.op.Is(OpUpdateOne) {
  23726. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  23727. }
  23728. if m.id == nil || m.oldValue == nil {
  23729. return v, errors.New("OldRequest requires an ID field in the mutation")
  23730. }
  23731. oldValue, err := m.oldValue(ctx)
  23732. if err != nil {
  23733. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  23734. }
  23735. return oldValue.Request, nil
  23736. }
  23737. // ResetRequest resets all changes to the "request" field.
  23738. func (m *UsageDetailMutation) ResetRequest() {
  23739. m.request = nil
  23740. }
  23741. // SetResponse sets the "response" field.
  23742. func (m *UsageDetailMutation) SetResponse(s string) {
  23743. m.response = &s
  23744. }
  23745. // Response returns the value of the "response" field in the mutation.
  23746. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  23747. v := m.response
  23748. if v == nil {
  23749. return
  23750. }
  23751. return *v, true
  23752. }
  23753. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  23754. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23756. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  23757. if !m.op.Is(OpUpdateOne) {
  23758. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  23759. }
  23760. if m.id == nil || m.oldValue == nil {
  23761. return v, errors.New("OldResponse requires an ID field in the mutation")
  23762. }
  23763. oldValue, err := m.oldValue(ctx)
  23764. if err != nil {
  23765. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  23766. }
  23767. return oldValue.Response, nil
  23768. }
  23769. // ResetResponse resets all changes to the "response" field.
  23770. func (m *UsageDetailMutation) ResetResponse() {
  23771. m.response = nil
  23772. }
  23773. // SetTotalTokens sets the "total_tokens" field.
  23774. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  23775. m.total_tokens = &u
  23776. m.addtotal_tokens = nil
  23777. }
  23778. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23779. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  23780. v := m.total_tokens
  23781. if v == nil {
  23782. return
  23783. }
  23784. return *v, true
  23785. }
  23786. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  23787. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23789. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  23790. if !m.op.Is(OpUpdateOne) {
  23791. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  23792. }
  23793. if m.id == nil || m.oldValue == nil {
  23794. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  23795. }
  23796. oldValue, err := m.oldValue(ctx)
  23797. if err != nil {
  23798. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  23799. }
  23800. return oldValue.TotalTokens, nil
  23801. }
  23802. // AddTotalTokens adds u to the "total_tokens" field.
  23803. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  23804. if m.addtotal_tokens != nil {
  23805. *m.addtotal_tokens += u
  23806. } else {
  23807. m.addtotal_tokens = &u
  23808. }
  23809. }
  23810. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  23811. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  23812. v := m.addtotal_tokens
  23813. if v == nil {
  23814. return
  23815. }
  23816. return *v, true
  23817. }
  23818. // ClearTotalTokens clears the value of the "total_tokens" field.
  23819. func (m *UsageDetailMutation) ClearTotalTokens() {
  23820. m.total_tokens = nil
  23821. m.addtotal_tokens = nil
  23822. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  23823. }
  23824. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  23825. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  23826. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  23827. return ok
  23828. }
  23829. // ResetTotalTokens resets all changes to the "total_tokens" field.
  23830. func (m *UsageDetailMutation) ResetTotalTokens() {
  23831. m.total_tokens = nil
  23832. m.addtotal_tokens = nil
  23833. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  23834. }
  23835. // SetPromptTokens sets the "prompt_tokens" field.
  23836. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  23837. m.prompt_tokens = &u
  23838. m.addprompt_tokens = nil
  23839. }
  23840. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  23841. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  23842. v := m.prompt_tokens
  23843. if v == nil {
  23844. return
  23845. }
  23846. return *v, true
  23847. }
  23848. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  23849. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23851. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  23852. if !m.op.Is(OpUpdateOne) {
  23853. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  23854. }
  23855. if m.id == nil || m.oldValue == nil {
  23856. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  23857. }
  23858. oldValue, err := m.oldValue(ctx)
  23859. if err != nil {
  23860. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  23861. }
  23862. return oldValue.PromptTokens, nil
  23863. }
  23864. // AddPromptTokens adds u to the "prompt_tokens" field.
  23865. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  23866. if m.addprompt_tokens != nil {
  23867. *m.addprompt_tokens += u
  23868. } else {
  23869. m.addprompt_tokens = &u
  23870. }
  23871. }
  23872. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  23873. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  23874. v := m.addprompt_tokens
  23875. if v == nil {
  23876. return
  23877. }
  23878. return *v, true
  23879. }
  23880. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  23881. func (m *UsageDetailMutation) ClearPromptTokens() {
  23882. m.prompt_tokens = nil
  23883. m.addprompt_tokens = nil
  23884. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  23885. }
  23886. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  23887. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  23888. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  23889. return ok
  23890. }
  23891. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  23892. func (m *UsageDetailMutation) ResetPromptTokens() {
  23893. m.prompt_tokens = nil
  23894. m.addprompt_tokens = nil
  23895. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23896. }
  23897. // SetCompletionTokens sets the "completion_tokens" field.
  23898. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23899. m.completion_tokens = &u
  23900. m.addcompletion_tokens = nil
  23901. }
  23902. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23903. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23904. v := m.completion_tokens
  23905. if v == nil {
  23906. return
  23907. }
  23908. return *v, true
  23909. }
  23910. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23911. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23913. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23914. if !m.op.Is(OpUpdateOne) {
  23915. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23916. }
  23917. if m.id == nil || m.oldValue == nil {
  23918. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23919. }
  23920. oldValue, err := m.oldValue(ctx)
  23921. if err != nil {
  23922. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23923. }
  23924. return oldValue.CompletionTokens, nil
  23925. }
  23926. // AddCompletionTokens adds u to the "completion_tokens" field.
  23927. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23928. if m.addcompletion_tokens != nil {
  23929. *m.addcompletion_tokens += u
  23930. } else {
  23931. m.addcompletion_tokens = &u
  23932. }
  23933. }
  23934. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23935. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23936. v := m.addcompletion_tokens
  23937. if v == nil {
  23938. return
  23939. }
  23940. return *v, true
  23941. }
  23942. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23943. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23944. m.completion_tokens = nil
  23945. m.addcompletion_tokens = nil
  23946. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23947. }
  23948. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23949. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23950. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23951. return ok
  23952. }
  23953. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23954. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23955. m.completion_tokens = nil
  23956. m.addcompletion_tokens = nil
  23957. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23958. }
  23959. // SetOrganizationID sets the "organization_id" field.
  23960. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23961. m.organization_id = &u
  23962. m.addorganization_id = nil
  23963. }
  23964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23965. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23966. v := m.organization_id
  23967. if v == nil {
  23968. return
  23969. }
  23970. return *v, true
  23971. }
  23972. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23973. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23975. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23976. if !m.op.Is(OpUpdateOne) {
  23977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23978. }
  23979. if m.id == nil || m.oldValue == nil {
  23980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23981. }
  23982. oldValue, err := m.oldValue(ctx)
  23983. if err != nil {
  23984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23985. }
  23986. return oldValue.OrganizationID, nil
  23987. }
  23988. // AddOrganizationID adds u to the "organization_id" field.
  23989. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23990. if m.addorganization_id != nil {
  23991. *m.addorganization_id += u
  23992. } else {
  23993. m.addorganization_id = &u
  23994. }
  23995. }
  23996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23997. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23998. v := m.addorganization_id
  23999. if v == nil {
  24000. return
  24001. }
  24002. return *v, true
  24003. }
  24004. // ClearOrganizationID clears the value of the "organization_id" field.
  24005. func (m *UsageDetailMutation) ClearOrganizationID() {
  24006. m.organization_id = nil
  24007. m.addorganization_id = nil
  24008. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  24009. }
  24010. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24011. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  24012. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  24013. return ok
  24014. }
  24015. // ResetOrganizationID resets all changes to the "organization_id" field.
  24016. func (m *UsageDetailMutation) ResetOrganizationID() {
  24017. m.organization_id = nil
  24018. m.addorganization_id = nil
  24019. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  24020. }
  24021. // Where appends a list predicates to the UsageDetailMutation builder.
  24022. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  24023. m.predicates = append(m.predicates, ps...)
  24024. }
  24025. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  24026. // users can use type-assertion to append predicates that do not depend on any generated package.
  24027. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  24028. p := make([]predicate.UsageDetail, len(ps))
  24029. for i := range ps {
  24030. p[i] = ps[i]
  24031. }
  24032. m.Where(p...)
  24033. }
  24034. // Op returns the operation name.
  24035. func (m *UsageDetailMutation) Op() Op {
  24036. return m.op
  24037. }
  24038. // SetOp allows setting the mutation operation.
  24039. func (m *UsageDetailMutation) SetOp(op Op) {
  24040. m.op = op
  24041. }
  24042. // Type returns the node type of this mutation (UsageDetail).
  24043. func (m *UsageDetailMutation) Type() string {
  24044. return m.typ
  24045. }
  24046. // Fields returns all fields that were changed during this mutation. Note that in
  24047. // order to get all numeric fields that were incremented/decremented, call
  24048. // AddedFields().
  24049. func (m *UsageDetailMutation) Fields() []string {
  24050. fields := make([]string, 0, 14)
  24051. if m.created_at != nil {
  24052. fields = append(fields, usagedetail.FieldCreatedAt)
  24053. }
  24054. if m.updated_at != nil {
  24055. fields = append(fields, usagedetail.FieldUpdatedAt)
  24056. }
  24057. if m.status != nil {
  24058. fields = append(fields, usagedetail.FieldStatus)
  24059. }
  24060. if m._type != nil {
  24061. fields = append(fields, usagedetail.FieldType)
  24062. }
  24063. if m.bot_id != nil {
  24064. fields = append(fields, usagedetail.FieldBotID)
  24065. }
  24066. if m.receiver_id != nil {
  24067. fields = append(fields, usagedetail.FieldReceiverID)
  24068. }
  24069. if m.app != nil {
  24070. fields = append(fields, usagedetail.FieldApp)
  24071. }
  24072. if m.session_id != nil {
  24073. fields = append(fields, usagedetail.FieldSessionID)
  24074. }
  24075. if m.request != nil {
  24076. fields = append(fields, usagedetail.FieldRequest)
  24077. }
  24078. if m.response != nil {
  24079. fields = append(fields, usagedetail.FieldResponse)
  24080. }
  24081. if m.total_tokens != nil {
  24082. fields = append(fields, usagedetail.FieldTotalTokens)
  24083. }
  24084. if m.prompt_tokens != nil {
  24085. fields = append(fields, usagedetail.FieldPromptTokens)
  24086. }
  24087. if m.completion_tokens != nil {
  24088. fields = append(fields, usagedetail.FieldCompletionTokens)
  24089. }
  24090. if m.organization_id != nil {
  24091. fields = append(fields, usagedetail.FieldOrganizationID)
  24092. }
  24093. return fields
  24094. }
  24095. // Field returns the value of a field with the given name. The second boolean
  24096. // return value indicates that this field was not set, or was not defined in the
  24097. // schema.
  24098. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  24099. switch name {
  24100. case usagedetail.FieldCreatedAt:
  24101. return m.CreatedAt()
  24102. case usagedetail.FieldUpdatedAt:
  24103. return m.UpdatedAt()
  24104. case usagedetail.FieldStatus:
  24105. return m.Status()
  24106. case usagedetail.FieldType:
  24107. return m.GetType()
  24108. case usagedetail.FieldBotID:
  24109. return m.BotID()
  24110. case usagedetail.FieldReceiverID:
  24111. return m.ReceiverID()
  24112. case usagedetail.FieldApp:
  24113. return m.App()
  24114. case usagedetail.FieldSessionID:
  24115. return m.SessionID()
  24116. case usagedetail.FieldRequest:
  24117. return m.Request()
  24118. case usagedetail.FieldResponse:
  24119. return m.Response()
  24120. case usagedetail.FieldTotalTokens:
  24121. return m.TotalTokens()
  24122. case usagedetail.FieldPromptTokens:
  24123. return m.PromptTokens()
  24124. case usagedetail.FieldCompletionTokens:
  24125. return m.CompletionTokens()
  24126. case usagedetail.FieldOrganizationID:
  24127. return m.OrganizationID()
  24128. }
  24129. return nil, false
  24130. }
  24131. // OldField returns the old value of the field from the database. An error is
  24132. // returned if the mutation operation is not UpdateOne, or the query to the
  24133. // database failed.
  24134. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24135. switch name {
  24136. case usagedetail.FieldCreatedAt:
  24137. return m.OldCreatedAt(ctx)
  24138. case usagedetail.FieldUpdatedAt:
  24139. return m.OldUpdatedAt(ctx)
  24140. case usagedetail.FieldStatus:
  24141. return m.OldStatus(ctx)
  24142. case usagedetail.FieldType:
  24143. return m.OldType(ctx)
  24144. case usagedetail.FieldBotID:
  24145. return m.OldBotID(ctx)
  24146. case usagedetail.FieldReceiverID:
  24147. return m.OldReceiverID(ctx)
  24148. case usagedetail.FieldApp:
  24149. return m.OldApp(ctx)
  24150. case usagedetail.FieldSessionID:
  24151. return m.OldSessionID(ctx)
  24152. case usagedetail.FieldRequest:
  24153. return m.OldRequest(ctx)
  24154. case usagedetail.FieldResponse:
  24155. return m.OldResponse(ctx)
  24156. case usagedetail.FieldTotalTokens:
  24157. return m.OldTotalTokens(ctx)
  24158. case usagedetail.FieldPromptTokens:
  24159. return m.OldPromptTokens(ctx)
  24160. case usagedetail.FieldCompletionTokens:
  24161. return m.OldCompletionTokens(ctx)
  24162. case usagedetail.FieldOrganizationID:
  24163. return m.OldOrganizationID(ctx)
  24164. }
  24165. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24166. }
  24167. // SetField sets the value of a field with the given name. It returns an error if
  24168. // the field is not defined in the schema, or if the type mismatched the field
  24169. // type.
  24170. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24171. switch name {
  24172. case usagedetail.FieldCreatedAt:
  24173. v, ok := value.(time.Time)
  24174. if !ok {
  24175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24176. }
  24177. m.SetCreatedAt(v)
  24178. return nil
  24179. case usagedetail.FieldUpdatedAt:
  24180. v, ok := value.(time.Time)
  24181. if !ok {
  24182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24183. }
  24184. m.SetUpdatedAt(v)
  24185. return nil
  24186. case usagedetail.FieldStatus:
  24187. v, ok := value.(uint8)
  24188. if !ok {
  24189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24190. }
  24191. m.SetStatus(v)
  24192. return nil
  24193. case usagedetail.FieldType:
  24194. v, ok := value.(int)
  24195. if !ok {
  24196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24197. }
  24198. m.SetType(v)
  24199. return nil
  24200. case usagedetail.FieldBotID:
  24201. v, ok := value.(string)
  24202. if !ok {
  24203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24204. }
  24205. m.SetBotID(v)
  24206. return nil
  24207. case usagedetail.FieldReceiverID:
  24208. v, ok := value.(string)
  24209. if !ok {
  24210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24211. }
  24212. m.SetReceiverID(v)
  24213. return nil
  24214. case usagedetail.FieldApp:
  24215. v, ok := value.(int)
  24216. if !ok {
  24217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24218. }
  24219. m.SetApp(v)
  24220. return nil
  24221. case usagedetail.FieldSessionID:
  24222. v, ok := value.(uint64)
  24223. if !ok {
  24224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24225. }
  24226. m.SetSessionID(v)
  24227. return nil
  24228. case usagedetail.FieldRequest:
  24229. v, ok := value.(string)
  24230. if !ok {
  24231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24232. }
  24233. m.SetRequest(v)
  24234. return nil
  24235. case usagedetail.FieldResponse:
  24236. v, ok := value.(string)
  24237. if !ok {
  24238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24239. }
  24240. m.SetResponse(v)
  24241. return nil
  24242. case usagedetail.FieldTotalTokens:
  24243. v, ok := value.(uint64)
  24244. if !ok {
  24245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24246. }
  24247. m.SetTotalTokens(v)
  24248. return nil
  24249. case usagedetail.FieldPromptTokens:
  24250. v, ok := value.(uint64)
  24251. if !ok {
  24252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24253. }
  24254. m.SetPromptTokens(v)
  24255. return nil
  24256. case usagedetail.FieldCompletionTokens:
  24257. v, ok := value.(uint64)
  24258. if !ok {
  24259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24260. }
  24261. m.SetCompletionTokens(v)
  24262. return nil
  24263. case usagedetail.FieldOrganizationID:
  24264. v, ok := value.(uint64)
  24265. if !ok {
  24266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24267. }
  24268. m.SetOrganizationID(v)
  24269. return nil
  24270. }
  24271. return fmt.Errorf("unknown UsageDetail field %s", name)
  24272. }
  24273. // AddedFields returns all numeric fields that were incremented/decremented during
  24274. // this mutation.
  24275. func (m *UsageDetailMutation) AddedFields() []string {
  24276. var fields []string
  24277. if m.addstatus != nil {
  24278. fields = append(fields, usagedetail.FieldStatus)
  24279. }
  24280. if m.add_type != nil {
  24281. fields = append(fields, usagedetail.FieldType)
  24282. }
  24283. if m.addapp != nil {
  24284. fields = append(fields, usagedetail.FieldApp)
  24285. }
  24286. if m.addsession_id != nil {
  24287. fields = append(fields, usagedetail.FieldSessionID)
  24288. }
  24289. if m.addtotal_tokens != nil {
  24290. fields = append(fields, usagedetail.FieldTotalTokens)
  24291. }
  24292. if m.addprompt_tokens != nil {
  24293. fields = append(fields, usagedetail.FieldPromptTokens)
  24294. }
  24295. if m.addcompletion_tokens != nil {
  24296. fields = append(fields, usagedetail.FieldCompletionTokens)
  24297. }
  24298. if m.addorganization_id != nil {
  24299. fields = append(fields, usagedetail.FieldOrganizationID)
  24300. }
  24301. return fields
  24302. }
  24303. // AddedField returns the numeric value that was incremented/decremented on a field
  24304. // with the given name. The second boolean return value indicates that this field
  24305. // was not set, or was not defined in the schema.
  24306. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  24307. switch name {
  24308. case usagedetail.FieldStatus:
  24309. return m.AddedStatus()
  24310. case usagedetail.FieldType:
  24311. return m.AddedType()
  24312. case usagedetail.FieldApp:
  24313. return m.AddedApp()
  24314. case usagedetail.FieldSessionID:
  24315. return m.AddedSessionID()
  24316. case usagedetail.FieldTotalTokens:
  24317. return m.AddedTotalTokens()
  24318. case usagedetail.FieldPromptTokens:
  24319. return m.AddedPromptTokens()
  24320. case usagedetail.FieldCompletionTokens:
  24321. return m.AddedCompletionTokens()
  24322. case usagedetail.FieldOrganizationID:
  24323. return m.AddedOrganizationID()
  24324. }
  24325. return nil, false
  24326. }
  24327. // AddField adds the value to the field with the given name. It returns an error if
  24328. // the field is not defined in the schema, or if the type mismatched the field
  24329. // type.
  24330. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  24331. switch name {
  24332. case usagedetail.FieldStatus:
  24333. v, ok := value.(int8)
  24334. if !ok {
  24335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24336. }
  24337. m.AddStatus(v)
  24338. return nil
  24339. case usagedetail.FieldType:
  24340. v, ok := value.(int)
  24341. if !ok {
  24342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24343. }
  24344. m.AddType(v)
  24345. return nil
  24346. case usagedetail.FieldApp:
  24347. v, ok := value.(int)
  24348. if !ok {
  24349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24350. }
  24351. m.AddApp(v)
  24352. return nil
  24353. case usagedetail.FieldSessionID:
  24354. v, ok := value.(int64)
  24355. if !ok {
  24356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24357. }
  24358. m.AddSessionID(v)
  24359. return nil
  24360. case usagedetail.FieldTotalTokens:
  24361. v, ok := value.(int64)
  24362. if !ok {
  24363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24364. }
  24365. m.AddTotalTokens(v)
  24366. return nil
  24367. case usagedetail.FieldPromptTokens:
  24368. v, ok := value.(int64)
  24369. if !ok {
  24370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24371. }
  24372. m.AddPromptTokens(v)
  24373. return nil
  24374. case usagedetail.FieldCompletionTokens:
  24375. v, ok := value.(int64)
  24376. if !ok {
  24377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24378. }
  24379. m.AddCompletionTokens(v)
  24380. return nil
  24381. case usagedetail.FieldOrganizationID:
  24382. v, ok := value.(int64)
  24383. if !ok {
  24384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24385. }
  24386. m.AddOrganizationID(v)
  24387. return nil
  24388. }
  24389. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  24390. }
  24391. // ClearedFields returns all nullable fields that were cleared during this
  24392. // mutation.
  24393. func (m *UsageDetailMutation) ClearedFields() []string {
  24394. var fields []string
  24395. if m.FieldCleared(usagedetail.FieldStatus) {
  24396. fields = append(fields, usagedetail.FieldStatus)
  24397. }
  24398. if m.FieldCleared(usagedetail.FieldType) {
  24399. fields = append(fields, usagedetail.FieldType)
  24400. }
  24401. if m.FieldCleared(usagedetail.FieldApp) {
  24402. fields = append(fields, usagedetail.FieldApp)
  24403. }
  24404. if m.FieldCleared(usagedetail.FieldSessionID) {
  24405. fields = append(fields, usagedetail.FieldSessionID)
  24406. }
  24407. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  24408. fields = append(fields, usagedetail.FieldTotalTokens)
  24409. }
  24410. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  24411. fields = append(fields, usagedetail.FieldPromptTokens)
  24412. }
  24413. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  24414. fields = append(fields, usagedetail.FieldCompletionTokens)
  24415. }
  24416. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  24417. fields = append(fields, usagedetail.FieldOrganizationID)
  24418. }
  24419. return fields
  24420. }
  24421. // FieldCleared returns a boolean indicating if a field with the given name was
  24422. // cleared in this mutation.
  24423. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  24424. _, ok := m.clearedFields[name]
  24425. return ok
  24426. }
  24427. // ClearField clears the value of the field with the given name. It returns an
  24428. // error if the field is not defined in the schema.
  24429. func (m *UsageDetailMutation) ClearField(name string) error {
  24430. switch name {
  24431. case usagedetail.FieldStatus:
  24432. m.ClearStatus()
  24433. return nil
  24434. case usagedetail.FieldType:
  24435. m.ClearType()
  24436. return nil
  24437. case usagedetail.FieldApp:
  24438. m.ClearApp()
  24439. return nil
  24440. case usagedetail.FieldSessionID:
  24441. m.ClearSessionID()
  24442. return nil
  24443. case usagedetail.FieldTotalTokens:
  24444. m.ClearTotalTokens()
  24445. return nil
  24446. case usagedetail.FieldPromptTokens:
  24447. m.ClearPromptTokens()
  24448. return nil
  24449. case usagedetail.FieldCompletionTokens:
  24450. m.ClearCompletionTokens()
  24451. return nil
  24452. case usagedetail.FieldOrganizationID:
  24453. m.ClearOrganizationID()
  24454. return nil
  24455. }
  24456. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  24457. }
  24458. // ResetField resets all changes in the mutation for the field with the given name.
  24459. // It returns an error if the field is not defined in the schema.
  24460. func (m *UsageDetailMutation) ResetField(name string) error {
  24461. switch name {
  24462. case usagedetail.FieldCreatedAt:
  24463. m.ResetCreatedAt()
  24464. return nil
  24465. case usagedetail.FieldUpdatedAt:
  24466. m.ResetUpdatedAt()
  24467. return nil
  24468. case usagedetail.FieldStatus:
  24469. m.ResetStatus()
  24470. return nil
  24471. case usagedetail.FieldType:
  24472. m.ResetType()
  24473. return nil
  24474. case usagedetail.FieldBotID:
  24475. m.ResetBotID()
  24476. return nil
  24477. case usagedetail.FieldReceiverID:
  24478. m.ResetReceiverID()
  24479. return nil
  24480. case usagedetail.FieldApp:
  24481. m.ResetApp()
  24482. return nil
  24483. case usagedetail.FieldSessionID:
  24484. m.ResetSessionID()
  24485. return nil
  24486. case usagedetail.FieldRequest:
  24487. m.ResetRequest()
  24488. return nil
  24489. case usagedetail.FieldResponse:
  24490. m.ResetResponse()
  24491. return nil
  24492. case usagedetail.FieldTotalTokens:
  24493. m.ResetTotalTokens()
  24494. return nil
  24495. case usagedetail.FieldPromptTokens:
  24496. m.ResetPromptTokens()
  24497. return nil
  24498. case usagedetail.FieldCompletionTokens:
  24499. m.ResetCompletionTokens()
  24500. return nil
  24501. case usagedetail.FieldOrganizationID:
  24502. m.ResetOrganizationID()
  24503. return nil
  24504. }
  24505. return fmt.Errorf("unknown UsageDetail field %s", name)
  24506. }
  24507. // AddedEdges returns all edge names that were set/added in this mutation.
  24508. func (m *UsageDetailMutation) AddedEdges() []string {
  24509. edges := make([]string, 0, 0)
  24510. return edges
  24511. }
  24512. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24513. // name in this mutation.
  24514. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  24515. return nil
  24516. }
  24517. // RemovedEdges returns all edge names that were removed in this mutation.
  24518. func (m *UsageDetailMutation) RemovedEdges() []string {
  24519. edges := make([]string, 0, 0)
  24520. return edges
  24521. }
  24522. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24523. // the given name in this mutation.
  24524. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  24525. return nil
  24526. }
  24527. // ClearedEdges returns all edge names that were cleared in this mutation.
  24528. func (m *UsageDetailMutation) ClearedEdges() []string {
  24529. edges := make([]string, 0, 0)
  24530. return edges
  24531. }
  24532. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24533. // was cleared in this mutation.
  24534. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  24535. return false
  24536. }
  24537. // ClearEdge clears the value of the edge with the given name. It returns an error
  24538. // if that edge is not defined in the schema.
  24539. func (m *UsageDetailMutation) ClearEdge(name string) error {
  24540. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  24541. }
  24542. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24543. // It returns an error if the edge is not defined in the schema.
  24544. func (m *UsageDetailMutation) ResetEdge(name string) error {
  24545. return fmt.Errorf("unknown UsageDetail edge %s", name)
  24546. }
  24547. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  24548. type UsageStatisticDayMutation struct {
  24549. config
  24550. op Op
  24551. typ string
  24552. id *uint64
  24553. created_at *time.Time
  24554. updated_at *time.Time
  24555. status *uint8
  24556. addstatus *int8
  24557. deleted_at *time.Time
  24558. addtime *uint64
  24559. addaddtime *int64
  24560. _type *int
  24561. add_type *int
  24562. bot_id *string
  24563. organization_id *uint64
  24564. addorganization_id *int64
  24565. ai_response *uint64
  24566. addai_response *int64
  24567. sop_run *uint64
  24568. addsop_run *int64
  24569. total_friend *uint64
  24570. addtotal_friend *int64
  24571. total_group *uint64
  24572. addtotal_group *int64
  24573. account_balance *uint64
  24574. addaccount_balance *int64
  24575. consume_token *uint64
  24576. addconsume_token *int64
  24577. active_user *uint64
  24578. addactive_user *int64
  24579. new_user *int64
  24580. addnew_user *int64
  24581. label_dist *[]custom_types.LabelDist
  24582. appendlabel_dist []custom_types.LabelDist
  24583. clearedFields map[string]struct{}
  24584. done bool
  24585. oldValue func(context.Context) (*UsageStatisticDay, error)
  24586. predicates []predicate.UsageStatisticDay
  24587. }
  24588. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  24589. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  24590. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  24591. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  24592. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  24593. m := &UsageStatisticDayMutation{
  24594. config: c,
  24595. op: op,
  24596. typ: TypeUsageStatisticDay,
  24597. clearedFields: make(map[string]struct{}),
  24598. }
  24599. for _, opt := range opts {
  24600. opt(m)
  24601. }
  24602. return m
  24603. }
  24604. // withUsageStatisticDayID sets the ID field of the mutation.
  24605. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  24606. return func(m *UsageStatisticDayMutation) {
  24607. var (
  24608. err error
  24609. once sync.Once
  24610. value *UsageStatisticDay
  24611. )
  24612. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  24613. once.Do(func() {
  24614. if m.done {
  24615. err = errors.New("querying old values post mutation is not allowed")
  24616. } else {
  24617. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  24618. }
  24619. })
  24620. return value, err
  24621. }
  24622. m.id = &id
  24623. }
  24624. }
  24625. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  24626. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  24627. return func(m *UsageStatisticDayMutation) {
  24628. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  24629. return node, nil
  24630. }
  24631. m.id = &node.ID
  24632. }
  24633. }
  24634. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24635. // executed in a transaction (ent.Tx), a transactional client is returned.
  24636. func (m UsageStatisticDayMutation) Client() *Client {
  24637. client := &Client{config: m.config}
  24638. client.init()
  24639. return client
  24640. }
  24641. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24642. // it returns an error otherwise.
  24643. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  24644. if _, ok := m.driver.(*txDriver); !ok {
  24645. return nil, errors.New("ent: mutation is not running in a transaction")
  24646. }
  24647. tx := &Tx{config: m.config}
  24648. tx.init()
  24649. return tx, nil
  24650. }
  24651. // SetID sets the value of the id field. Note that this
  24652. // operation is only accepted on creation of UsageStatisticDay entities.
  24653. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  24654. m.id = &id
  24655. }
  24656. // ID returns the ID value in the mutation. Note that the ID is only available
  24657. // if it was provided to the builder or after it was returned from the database.
  24658. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  24659. if m.id == nil {
  24660. return
  24661. }
  24662. return *m.id, true
  24663. }
  24664. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24665. // That means, if the mutation is applied within a transaction with an isolation level such
  24666. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24667. // or updated by the mutation.
  24668. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  24669. switch {
  24670. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24671. id, exists := m.ID()
  24672. if exists {
  24673. return []uint64{id}, nil
  24674. }
  24675. fallthrough
  24676. case m.op.Is(OpUpdate | OpDelete):
  24677. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  24678. default:
  24679. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24680. }
  24681. }
  24682. // SetCreatedAt sets the "created_at" field.
  24683. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  24684. m.created_at = &t
  24685. }
  24686. // CreatedAt returns the value of the "created_at" field in the mutation.
  24687. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  24688. v := m.created_at
  24689. if v == nil {
  24690. return
  24691. }
  24692. return *v, true
  24693. }
  24694. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  24695. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24697. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24698. if !m.op.Is(OpUpdateOne) {
  24699. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24700. }
  24701. if m.id == nil || m.oldValue == nil {
  24702. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24703. }
  24704. oldValue, err := m.oldValue(ctx)
  24705. if err != nil {
  24706. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24707. }
  24708. return oldValue.CreatedAt, nil
  24709. }
  24710. // ResetCreatedAt resets all changes to the "created_at" field.
  24711. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  24712. m.created_at = nil
  24713. }
  24714. // SetUpdatedAt sets the "updated_at" field.
  24715. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  24716. m.updated_at = &t
  24717. }
  24718. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24719. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  24720. v := m.updated_at
  24721. if v == nil {
  24722. return
  24723. }
  24724. return *v, true
  24725. }
  24726. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  24727. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24729. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24730. if !m.op.Is(OpUpdateOne) {
  24731. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24732. }
  24733. if m.id == nil || m.oldValue == nil {
  24734. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24735. }
  24736. oldValue, err := m.oldValue(ctx)
  24737. if err != nil {
  24738. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24739. }
  24740. return oldValue.UpdatedAt, nil
  24741. }
  24742. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24743. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  24744. m.updated_at = nil
  24745. }
  24746. // SetStatus sets the "status" field.
  24747. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  24748. m.status = &u
  24749. m.addstatus = nil
  24750. }
  24751. // Status returns the value of the "status" field in the mutation.
  24752. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  24753. v := m.status
  24754. if v == nil {
  24755. return
  24756. }
  24757. return *v, true
  24758. }
  24759. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  24760. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24762. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24763. if !m.op.Is(OpUpdateOne) {
  24764. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24765. }
  24766. if m.id == nil || m.oldValue == nil {
  24767. return v, errors.New("OldStatus requires an ID field in the mutation")
  24768. }
  24769. oldValue, err := m.oldValue(ctx)
  24770. if err != nil {
  24771. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24772. }
  24773. return oldValue.Status, nil
  24774. }
  24775. // AddStatus adds u to the "status" field.
  24776. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  24777. if m.addstatus != nil {
  24778. *m.addstatus += u
  24779. } else {
  24780. m.addstatus = &u
  24781. }
  24782. }
  24783. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24784. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  24785. v := m.addstatus
  24786. if v == nil {
  24787. return
  24788. }
  24789. return *v, true
  24790. }
  24791. // ClearStatus clears the value of the "status" field.
  24792. func (m *UsageStatisticDayMutation) ClearStatus() {
  24793. m.status = nil
  24794. m.addstatus = nil
  24795. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  24796. }
  24797. // StatusCleared returns if the "status" field was cleared in this mutation.
  24798. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  24799. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  24800. return ok
  24801. }
  24802. // ResetStatus resets all changes to the "status" field.
  24803. func (m *UsageStatisticDayMutation) ResetStatus() {
  24804. m.status = nil
  24805. m.addstatus = nil
  24806. delete(m.clearedFields, usagestatisticday.FieldStatus)
  24807. }
  24808. // SetDeletedAt sets the "deleted_at" field.
  24809. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  24810. m.deleted_at = &t
  24811. }
  24812. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24813. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  24814. v := m.deleted_at
  24815. if v == nil {
  24816. return
  24817. }
  24818. return *v, true
  24819. }
  24820. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  24821. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24823. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24824. if !m.op.Is(OpUpdateOne) {
  24825. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24826. }
  24827. if m.id == nil || m.oldValue == nil {
  24828. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24829. }
  24830. oldValue, err := m.oldValue(ctx)
  24831. if err != nil {
  24832. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24833. }
  24834. return oldValue.DeletedAt, nil
  24835. }
  24836. // ClearDeletedAt clears the value of the "deleted_at" field.
  24837. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  24838. m.deleted_at = nil
  24839. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  24840. }
  24841. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24842. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  24843. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  24844. return ok
  24845. }
  24846. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24847. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  24848. m.deleted_at = nil
  24849. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  24850. }
  24851. // SetAddtime sets the "addtime" field.
  24852. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  24853. m.addtime = &u
  24854. m.addaddtime = nil
  24855. }
  24856. // Addtime returns the value of the "addtime" field in the mutation.
  24857. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  24858. v := m.addtime
  24859. if v == nil {
  24860. return
  24861. }
  24862. return *v, true
  24863. }
  24864. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  24865. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24867. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  24868. if !m.op.Is(OpUpdateOne) {
  24869. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  24870. }
  24871. if m.id == nil || m.oldValue == nil {
  24872. return v, errors.New("OldAddtime requires an ID field in the mutation")
  24873. }
  24874. oldValue, err := m.oldValue(ctx)
  24875. if err != nil {
  24876. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  24877. }
  24878. return oldValue.Addtime, nil
  24879. }
  24880. // AddAddtime adds u to the "addtime" field.
  24881. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  24882. if m.addaddtime != nil {
  24883. *m.addaddtime += u
  24884. } else {
  24885. m.addaddtime = &u
  24886. }
  24887. }
  24888. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  24889. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  24890. v := m.addaddtime
  24891. if v == nil {
  24892. return
  24893. }
  24894. return *v, true
  24895. }
  24896. // ResetAddtime resets all changes to the "addtime" field.
  24897. func (m *UsageStatisticDayMutation) ResetAddtime() {
  24898. m.addtime = nil
  24899. m.addaddtime = nil
  24900. }
  24901. // SetType sets the "type" field.
  24902. func (m *UsageStatisticDayMutation) SetType(i int) {
  24903. m._type = &i
  24904. m.add_type = nil
  24905. }
  24906. // GetType returns the value of the "type" field in the mutation.
  24907. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  24908. v := m._type
  24909. if v == nil {
  24910. return
  24911. }
  24912. return *v, true
  24913. }
  24914. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  24915. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24917. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  24918. if !m.op.Is(OpUpdateOne) {
  24919. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24920. }
  24921. if m.id == nil || m.oldValue == nil {
  24922. return v, errors.New("OldType requires an ID field in the mutation")
  24923. }
  24924. oldValue, err := m.oldValue(ctx)
  24925. if err != nil {
  24926. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24927. }
  24928. return oldValue.Type, nil
  24929. }
  24930. // AddType adds i to the "type" field.
  24931. func (m *UsageStatisticDayMutation) AddType(i int) {
  24932. if m.add_type != nil {
  24933. *m.add_type += i
  24934. } else {
  24935. m.add_type = &i
  24936. }
  24937. }
  24938. // AddedType returns the value that was added to the "type" field in this mutation.
  24939. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  24940. v := m.add_type
  24941. if v == nil {
  24942. return
  24943. }
  24944. return *v, true
  24945. }
  24946. // ResetType resets all changes to the "type" field.
  24947. func (m *UsageStatisticDayMutation) ResetType() {
  24948. m._type = nil
  24949. m.add_type = nil
  24950. }
  24951. // SetBotID sets the "bot_id" field.
  24952. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  24953. m.bot_id = &s
  24954. }
  24955. // BotID returns the value of the "bot_id" field in the mutation.
  24956. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  24957. v := m.bot_id
  24958. if v == nil {
  24959. return
  24960. }
  24961. return *v, true
  24962. }
  24963. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  24964. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24966. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  24967. if !m.op.Is(OpUpdateOne) {
  24968. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24969. }
  24970. if m.id == nil || m.oldValue == nil {
  24971. return v, errors.New("OldBotID requires an ID field in the mutation")
  24972. }
  24973. oldValue, err := m.oldValue(ctx)
  24974. if err != nil {
  24975. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24976. }
  24977. return oldValue.BotID, nil
  24978. }
  24979. // ClearBotID clears the value of the "bot_id" field.
  24980. func (m *UsageStatisticDayMutation) ClearBotID() {
  24981. m.bot_id = nil
  24982. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  24983. }
  24984. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  24985. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  24986. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  24987. return ok
  24988. }
  24989. // ResetBotID resets all changes to the "bot_id" field.
  24990. func (m *UsageStatisticDayMutation) ResetBotID() {
  24991. m.bot_id = nil
  24992. delete(m.clearedFields, usagestatisticday.FieldBotID)
  24993. }
  24994. // SetOrganizationID sets the "organization_id" field.
  24995. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  24996. m.organization_id = &u
  24997. m.addorganization_id = nil
  24998. }
  24999. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25000. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  25001. v := m.organization_id
  25002. if v == nil {
  25003. return
  25004. }
  25005. return *v, true
  25006. }
  25007. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  25008. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25010. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25011. if !m.op.Is(OpUpdateOne) {
  25012. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25013. }
  25014. if m.id == nil || m.oldValue == nil {
  25015. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25016. }
  25017. oldValue, err := m.oldValue(ctx)
  25018. if err != nil {
  25019. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25020. }
  25021. return oldValue.OrganizationID, nil
  25022. }
  25023. // AddOrganizationID adds u to the "organization_id" field.
  25024. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  25025. if m.addorganization_id != nil {
  25026. *m.addorganization_id += u
  25027. } else {
  25028. m.addorganization_id = &u
  25029. }
  25030. }
  25031. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25032. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  25033. v := m.addorganization_id
  25034. if v == nil {
  25035. return
  25036. }
  25037. return *v, true
  25038. }
  25039. // ClearOrganizationID clears the value of the "organization_id" field.
  25040. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  25041. m.organization_id = nil
  25042. m.addorganization_id = nil
  25043. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  25044. }
  25045. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25046. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  25047. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  25048. return ok
  25049. }
  25050. // ResetOrganizationID resets all changes to the "organization_id" field.
  25051. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  25052. m.organization_id = nil
  25053. m.addorganization_id = nil
  25054. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  25055. }
  25056. // SetAiResponse sets the "ai_response" field.
  25057. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  25058. m.ai_response = &u
  25059. m.addai_response = nil
  25060. }
  25061. // AiResponse returns the value of the "ai_response" field in the mutation.
  25062. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  25063. v := m.ai_response
  25064. if v == nil {
  25065. return
  25066. }
  25067. return *v, true
  25068. }
  25069. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  25070. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25072. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  25073. if !m.op.Is(OpUpdateOne) {
  25074. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  25075. }
  25076. if m.id == nil || m.oldValue == nil {
  25077. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  25078. }
  25079. oldValue, err := m.oldValue(ctx)
  25080. if err != nil {
  25081. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  25082. }
  25083. return oldValue.AiResponse, nil
  25084. }
  25085. // AddAiResponse adds u to the "ai_response" field.
  25086. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  25087. if m.addai_response != nil {
  25088. *m.addai_response += u
  25089. } else {
  25090. m.addai_response = &u
  25091. }
  25092. }
  25093. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  25094. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  25095. v := m.addai_response
  25096. if v == nil {
  25097. return
  25098. }
  25099. return *v, true
  25100. }
  25101. // ResetAiResponse resets all changes to the "ai_response" field.
  25102. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  25103. m.ai_response = nil
  25104. m.addai_response = nil
  25105. }
  25106. // SetSopRun sets the "sop_run" field.
  25107. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  25108. m.sop_run = &u
  25109. m.addsop_run = nil
  25110. }
  25111. // SopRun returns the value of the "sop_run" field in the mutation.
  25112. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  25113. v := m.sop_run
  25114. if v == nil {
  25115. return
  25116. }
  25117. return *v, true
  25118. }
  25119. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  25120. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25122. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  25123. if !m.op.Is(OpUpdateOne) {
  25124. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  25125. }
  25126. if m.id == nil || m.oldValue == nil {
  25127. return v, errors.New("OldSopRun requires an ID field in the mutation")
  25128. }
  25129. oldValue, err := m.oldValue(ctx)
  25130. if err != nil {
  25131. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  25132. }
  25133. return oldValue.SopRun, nil
  25134. }
  25135. // AddSopRun adds u to the "sop_run" field.
  25136. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  25137. if m.addsop_run != nil {
  25138. *m.addsop_run += u
  25139. } else {
  25140. m.addsop_run = &u
  25141. }
  25142. }
  25143. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  25144. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  25145. v := m.addsop_run
  25146. if v == nil {
  25147. return
  25148. }
  25149. return *v, true
  25150. }
  25151. // ResetSopRun resets all changes to the "sop_run" field.
  25152. func (m *UsageStatisticDayMutation) ResetSopRun() {
  25153. m.sop_run = nil
  25154. m.addsop_run = nil
  25155. }
  25156. // SetTotalFriend sets the "total_friend" field.
  25157. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  25158. m.total_friend = &u
  25159. m.addtotal_friend = nil
  25160. }
  25161. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25162. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  25163. v := m.total_friend
  25164. if v == nil {
  25165. return
  25166. }
  25167. return *v, true
  25168. }
  25169. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  25170. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25172. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25173. if !m.op.Is(OpUpdateOne) {
  25174. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25175. }
  25176. if m.id == nil || m.oldValue == nil {
  25177. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25178. }
  25179. oldValue, err := m.oldValue(ctx)
  25180. if err != nil {
  25181. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25182. }
  25183. return oldValue.TotalFriend, nil
  25184. }
  25185. // AddTotalFriend adds u to the "total_friend" field.
  25186. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  25187. if m.addtotal_friend != nil {
  25188. *m.addtotal_friend += u
  25189. } else {
  25190. m.addtotal_friend = &u
  25191. }
  25192. }
  25193. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25194. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  25195. v := m.addtotal_friend
  25196. if v == nil {
  25197. return
  25198. }
  25199. return *v, true
  25200. }
  25201. // ResetTotalFriend resets all changes to the "total_friend" field.
  25202. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  25203. m.total_friend = nil
  25204. m.addtotal_friend = nil
  25205. }
  25206. // SetTotalGroup sets the "total_group" field.
  25207. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  25208. m.total_group = &u
  25209. m.addtotal_group = nil
  25210. }
  25211. // TotalGroup returns the value of the "total_group" field in the mutation.
  25212. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  25213. v := m.total_group
  25214. if v == nil {
  25215. return
  25216. }
  25217. return *v, true
  25218. }
  25219. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  25220. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25222. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  25223. if !m.op.Is(OpUpdateOne) {
  25224. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  25225. }
  25226. if m.id == nil || m.oldValue == nil {
  25227. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  25228. }
  25229. oldValue, err := m.oldValue(ctx)
  25230. if err != nil {
  25231. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  25232. }
  25233. return oldValue.TotalGroup, nil
  25234. }
  25235. // AddTotalGroup adds u to the "total_group" field.
  25236. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  25237. if m.addtotal_group != nil {
  25238. *m.addtotal_group += u
  25239. } else {
  25240. m.addtotal_group = &u
  25241. }
  25242. }
  25243. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  25244. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  25245. v := m.addtotal_group
  25246. if v == nil {
  25247. return
  25248. }
  25249. return *v, true
  25250. }
  25251. // ResetTotalGroup resets all changes to the "total_group" field.
  25252. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  25253. m.total_group = nil
  25254. m.addtotal_group = nil
  25255. }
  25256. // SetAccountBalance sets the "account_balance" field.
  25257. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  25258. m.account_balance = &u
  25259. m.addaccount_balance = nil
  25260. }
  25261. // AccountBalance returns the value of the "account_balance" field in the mutation.
  25262. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  25263. v := m.account_balance
  25264. if v == nil {
  25265. return
  25266. }
  25267. return *v, true
  25268. }
  25269. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  25270. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25272. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  25273. if !m.op.Is(OpUpdateOne) {
  25274. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  25275. }
  25276. if m.id == nil || m.oldValue == nil {
  25277. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  25278. }
  25279. oldValue, err := m.oldValue(ctx)
  25280. if err != nil {
  25281. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  25282. }
  25283. return oldValue.AccountBalance, nil
  25284. }
  25285. // AddAccountBalance adds u to the "account_balance" field.
  25286. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  25287. if m.addaccount_balance != nil {
  25288. *m.addaccount_balance += u
  25289. } else {
  25290. m.addaccount_balance = &u
  25291. }
  25292. }
  25293. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  25294. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  25295. v := m.addaccount_balance
  25296. if v == nil {
  25297. return
  25298. }
  25299. return *v, true
  25300. }
  25301. // ResetAccountBalance resets all changes to the "account_balance" field.
  25302. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  25303. m.account_balance = nil
  25304. m.addaccount_balance = nil
  25305. }
  25306. // SetConsumeToken sets the "consume_token" field.
  25307. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  25308. m.consume_token = &u
  25309. m.addconsume_token = nil
  25310. }
  25311. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  25312. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  25313. v := m.consume_token
  25314. if v == nil {
  25315. return
  25316. }
  25317. return *v, true
  25318. }
  25319. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  25320. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25322. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  25323. if !m.op.Is(OpUpdateOne) {
  25324. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  25325. }
  25326. if m.id == nil || m.oldValue == nil {
  25327. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  25328. }
  25329. oldValue, err := m.oldValue(ctx)
  25330. if err != nil {
  25331. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  25332. }
  25333. return oldValue.ConsumeToken, nil
  25334. }
  25335. // AddConsumeToken adds u to the "consume_token" field.
  25336. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  25337. if m.addconsume_token != nil {
  25338. *m.addconsume_token += u
  25339. } else {
  25340. m.addconsume_token = &u
  25341. }
  25342. }
  25343. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  25344. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  25345. v := m.addconsume_token
  25346. if v == nil {
  25347. return
  25348. }
  25349. return *v, true
  25350. }
  25351. // ResetConsumeToken resets all changes to the "consume_token" field.
  25352. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  25353. m.consume_token = nil
  25354. m.addconsume_token = nil
  25355. }
  25356. // SetActiveUser sets the "active_user" field.
  25357. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  25358. m.active_user = &u
  25359. m.addactive_user = nil
  25360. }
  25361. // ActiveUser returns the value of the "active_user" field in the mutation.
  25362. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  25363. v := m.active_user
  25364. if v == nil {
  25365. return
  25366. }
  25367. return *v, true
  25368. }
  25369. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  25370. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25372. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  25373. if !m.op.Is(OpUpdateOne) {
  25374. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  25375. }
  25376. if m.id == nil || m.oldValue == nil {
  25377. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  25378. }
  25379. oldValue, err := m.oldValue(ctx)
  25380. if err != nil {
  25381. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  25382. }
  25383. return oldValue.ActiveUser, nil
  25384. }
  25385. // AddActiveUser adds u to the "active_user" field.
  25386. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  25387. if m.addactive_user != nil {
  25388. *m.addactive_user += u
  25389. } else {
  25390. m.addactive_user = &u
  25391. }
  25392. }
  25393. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  25394. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  25395. v := m.addactive_user
  25396. if v == nil {
  25397. return
  25398. }
  25399. return *v, true
  25400. }
  25401. // ResetActiveUser resets all changes to the "active_user" field.
  25402. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  25403. m.active_user = nil
  25404. m.addactive_user = nil
  25405. }
  25406. // SetNewUser sets the "new_user" field.
  25407. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  25408. m.new_user = &i
  25409. m.addnew_user = nil
  25410. }
  25411. // NewUser returns the value of the "new_user" field in the mutation.
  25412. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  25413. v := m.new_user
  25414. if v == nil {
  25415. return
  25416. }
  25417. return *v, true
  25418. }
  25419. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  25420. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25422. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  25423. if !m.op.Is(OpUpdateOne) {
  25424. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  25425. }
  25426. if m.id == nil || m.oldValue == nil {
  25427. return v, errors.New("OldNewUser requires an ID field in the mutation")
  25428. }
  25429. oldValue, err := m.oldValue(ctx)
  25430. if err != nil {
  25431. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  25432. }
  25433. return oldValue.NewUser, nil
  25434. }
  25435. // AddNewUser adds i to the "new_user" field.
  25436. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  25437. if m.addnew_user != nil {
  25438. *m.addnew_user += i
  25439. } else {
  25440. m.addnew_user = &i
  25441. }
  25442. }
  25443. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  25444. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  25445. v := m.addnew_user
  25446. if v == nil {
  25447. return
  25448. }
  25449. return *v, true
  25450. }
  25451. // ResetNewUser resets all changes to the "new_user" field.
  25452. func (m *UsageStatisticDayMutation) ResetNewUser() {
  25453. m.new_user = nil
  25454. m.addnew_user = nil
  25455. }
  25456. // SetLabelDist sets the "label_dist" field.
  25457. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  25458. m.label_dist = &ctd
  25459. m.appendlabel_dist = nil
  25460. }
  25461. // LabelDist returns the value of the "label_dist" field in the mutation.
  25462. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  25463. v := m.label_dist
  25464. if v == nil {
  25465. return
  25466. }
  25467. return *v, true
  25468. }
  25469. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  25470. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25472. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  25473. if !m.op.Is(OpUpdateOne) {
  25474. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  25475. }
  25476. if m.id == nil || m.oldValue == nil {
  25477. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  25478. }
  25479. oldValue, err := m.oldValue(ctx)
  25480. if err != nil {
  25481. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  25482. }
  25483. return oldValue.LabelDist, nil
  25484. }
  25485. // AppendLabelDist adds ctd to the "label_dist" field.
  25486. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  25487. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  25488. }
  25489. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  25490. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  25491. if len(m.appendlabel_dist) == 0 {
  25492. return nil, false
  25493. }
  25494. return m.appendlabel_dist, true
  25495. }
  25496. // ResetLabelDist resets all changes to the "label_dist" field.
  25497. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  25498. m.label_dist = nil
  25499. m.appendlabel_dist = nil
  25500. }
  25501. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  25502. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  25503. m.predicates = append(m.predicates, ps...)
  25504. }
  25505. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  25506. // users can use type-assertion to append predicates that do not depend on any generated package.
  25507. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  25508. p := make([]predicate.UsageStatisticDay, len(ps))
  25509. for i := range ps {
  25510. p[i] = ps[i]
  25511. }
  25512. m.Where(p...)
  25513. }
  25514. // Op returns the operation name.
  25515. func (m *UsageStatisticDayMutation) Op() Op {
  25516. return m.op
  25517. }
  25518. // SetOp allows setting the mutation operation.
  25519. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  25520. m.op = op
  25521. }
  25522. // Type returns the node type of this mutation (UsageStatisticDay).
  25523. func (m *UsageStatisticDayMutation) Type() string {
  25524. return m.typ
  25525. }
  25526. // Fields returns all fields that were changed during this mutation. Note that in
  25527. // order to get all numeric fields that were incremented/decremented, call
  25528. // AddedFields().
  25529. func (m *UsageStatisticDayMutation) Fields() []string {
  25530. fields := make([]string, 0, 17)
  25531. if m.created_at != nil {
  25532. fields = append(fields, usagestatisticday.FieldCreatedAt)
  25533. }
  25534. if m.updated_at != nil {
  25535. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  25536. }
  25537. if m.status != nil {
  25538. fields = append(fields, usagestatisticday.FieldStatus)
  25539. }
  25540. if m.deleted_at != nil {
  25541. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25542. }
  25543. if m.addtime != nil {
  25544. fields = append(fields, usagestatisticday.FieldAddtime)
  25545. }
  25546. if m._type != nil {
  25547. fields = append(fields, usagestatisticday.FieldType)
  25548. }
  25549. if m.bot_id != nil {
  25550. fields = append(fields, usagestatisticday.FieldBotID)
  25551. }
  25552. if m.organization_id != nil {
  25553. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25554. }
  25555. if m.ai_response != nil {
  25556. fields = append(fields, usagestatisticday.FieldAiResponse)
  25557. }
  25558. if m.sop_run != nil {
  25559. fields = append(fields, usagestatisticday.FieldSopRun)
  25560. }
  25561. if m.total_friend != nil {
  25562. fields = append(fields, usagestatisticday.FieldTotalFriend)
  25563. }
  25564. if m.total_group != nil {
  25565. fields = append(fields, usagestatisticday.FieldTotalGroup)
  25566. }
  25567. if m.account_balance != nil {
  25568. fields = append(fields, usagestatisticday.FieldAccountBalance)
  25569. }
  25570. if m.consume_token != nil {
  25571. fields = append(fields, usagestatisticday.FieldConsumeToken)
  25572. }
  25573. if m.active_user != nil {
  25574. fields = append(fields, usagestatisticday.FieldActiveUser)
  25575. }
  25576. if m.new_user != nil {
  25577. fields = append(fields, usagestatisticday.FieldNewUser)
  25578. }
  25579. if m.label_dist != nil {
  25580. fields = append(fields, usagestatisticday.FieldLabelDist)
  25581. }
  25582. return fields
  25583. }
  25584. // Field returns the value of a field with the given name. The second boolean
  25585. // return value indicates that this field was not set, or was not defined in the
  25586. // schema.
  25587. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  25588. switch name {
  25589. case usagestatisticday.FieldCreatedAt:
  25590. return m.CreatedAt()
  25591. case usagestatisticday.FieldUpdatedAt:
  25592. return m.UpdatedAt()
  25593. case usagestatisticday.FieldStatus:
  25594. return m.Status()
  25595. case usagestatisticday.FieldDeletedAt:
  25596. return m.DeletedAt()
  25597. case usagestatisticday.FieldAddtime:
  25598. return m.Addtime()
  25599. case usagestatisticday.FieldType:
  25600. return m.GetType()
  25601. case usagestatisticday.FieldBotID:
  25602. return m.BotID()
  25603. case usagestatisticday.FieldOrganizationID:
  25604. return m.OrganizationID()
  25605. case usagestatisticday.FieldAiResponse:
  25606. return m.AiResponse()
  25607. case usagestatisticday.FieldSopRun:
  25608. return m.SopRun()
  25609. case usagestatisticday.FieldTotalFriend:
  25610. return m.TotalFriend()
  25611. case usagestatisticday.FieldTotalGroup:
  25612. return m.TotalGroup()
  25613. case usagestatisticday.FieldAccountBalance:
  25614. return m.AccountBalance()
  25615. case usagestatisticday.FieldConsumeToken:
  25616. return m.ConsumeToken()
  25617. case usagestatisticday.FieldActiveUser:
  25618. return m.ActiveUser()
  25619. case usagestatisticday.FieldNewUser:
  25620. return m.NewUser()
  25621. case usagestatisticday.FieldLabelDist:
  25622. return m.LabelDist()
  25623. }
  25624. return nil, false
  25625. }
  25626. // OldField returns the old value of the field from the database. An error is
  25627. // returned if the mutation operation is not UpdateOne, or the query to the
  25628. // database failed.
  25629. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25630. switch name {
  25631. case usagestatisticday.FieldCreatedAt:
  25632. return m.OldCreatedAt(ctx)
  25633. case usagestatisticday.FieldUpdatedAt:
  25634. return m.OldUpdatedAt(ctx)
  25635. case usagestatisticday.FieldStatus:
  25636. return m.OldStatus(ctx)
  25637. case usagestatisticday.FieldDeletedAt:
  25638. return m.OldDeletedAt(ctx)
  25639. case usagestatisticday.FieldAddtime:
  25640. return m.OldAddtime(ctx)
  25641. case usagestatisticday.FieldType:
  25642. return m.OldType(ctx)
  25643. case usagestatisticday.FieldBotID:
  25644. return m.OldBotID(ctx)
  25645. case usagestatisticday.FieldOrganizationID:
  25646. return m.OldOrganizationID(ctx)
  25647. case usagestatisticday.FieldAiResponse:
  25648. return m.OldAiResponse(ctx)
  25649. case usagestatisticday.FieldSopRun:
  25650. return m.OldSopRun(ctx)
  25651. case usagestatisticday.FieldTotalFriend:
  25652. return m.OldTotalFriend(ctx)
  25653. case usagestatisticday.FieldTotalGroup:
  25654. return m.OldTotalGroup(ctx)
  25655. case usagestatisticday.FieldAccountBalance:
  25656. return m.OldAccountBalance(ctx)
  25657. case usagestatisticday.FieldConsumeToken:
  25658. return m.OldConsumeToken(ctx)
  25659. case usagestatisticday.FieldActiveUser:
  25660. return m.OldActiveUser(ctx)
  25661. case usagestatisticday.FieldNewUser:
  25662. return m.OldNewUser(ctx)
  25663. case usagestatisticday.FieldLabelDist:
  25664. return m.OldLabelDist(ctx)
  25665. }
  25666. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25667. }
  25668. // SetField sets the value of a field with the given name. It returns an error if
  25669. // the field is not defined in the schema, or if the type mismatched the field
  25670. // type.
  25671. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  25672. switch name {
  25673. case usagestatisticday.FieldCreatedAt:
  25674. v, ok := value.(time.Time)
  25675. if !ok {
  25676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25677. }
  25678. m.SetCreatedAt(v)
  25679. return nil
  25680. case usagestatisticday.FieldUpdatedAt:
  25681. v, ok := value.(time.Time)
  25682. if !ok {
  25683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25684. }
  25685. m.SetUpdatedAt(v)
  25686. return nil
  25687. case usagestatisticday.FieldStatus:
  25688. v, ok := value.(uint8)
  25689. if !ok {
  25690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25691. }
  25692. m.SetStatus(v)
  25693. return nil
  25694. case usagestatisticday.FieldDeletedAt:
  25695. v, ok := value.(time.Time)
  25696. if !ok {
  25697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25698. }
  25699. m.SetDeletedAt(v)
  25700. return nil
  25701. case usagestatisticday.FieldAddtime:
  25702. v, ok := value.(uint64)
  25703. if !ok {
  25704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25705. }
  25706. m.SetAddtime(v)
  25707. return nil
  25708. case usagestatisticday.FieldType:
  25709. v, ok := value.(int)
  25710. if !ok {
  25711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25712. }
  25713. m.SetType(v)
  25714. return nil
  25715. case usagestatisticday.FieldBotID:
  25716. v, ok := value.(string)
  25717. if !ok {
  25718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25719. }
  25720. m.SetBotID(v)
  25721. return nil
  25722. case usagestatisticday.FieldOrganizationID:
  25723. v, ok := value.(uint64)
  25724. if !ok {
  25725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25726. }
  25727. m.SetOrganizationID(v)
  25728. return nil
  25729. case usagestatisticday.FieldAiResponse:
  25730. v, ok := value.(uint64)
  25731. if !ok {
  25732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25733. }
  25734. m.SetAiResponse(v)
  25735. return nil
  25736. case usagestatisticday.FieldSopRun:
  25737. v, ok := value.(uint64)
  25738. if !ok {
  25739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25740. }
  25741. m.SetSopRun(v)
  25742. return nil
  25743. case usagestatisticday.FieldTotalFriend:
  25744. v, ok := value.(uint64)
  25745. if !ok {
  25746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25747. }
  25748. m.SetTotalFriend(v)
  25749. return nil
  25750. case usagestatisticday.FieldTotalGroup:
  25751. v, ok := value.(uint64)
  25752. if !ok {
  25753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25754. }
  25755. m.SetTotalGroup(v)
  25756. return nil
  25757. case usagestatisticday.FieldAccountBalance:
  25758. v, ok := value.(uint64)
  25759. if !ok {
  25760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25761. }
  25762. m.SetAccountBalance(v)
  25763. return nil
  25764. case usagestatisticday.FieldConsumeToken:
  25765. v, ok := value.(uint64)
  25766. if !ok {
  25767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25768. }
  25769. m.SetConsumeToken(v)
  25770. return nil
  25771. case usagestatisticday.FieldActiveUser:
  25772. v, ok := value.(uint64)
  25773. if !ok {
  25774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25775. }
  25776. m.SetActiveUser(v)
  25777. return nil
  25778. case usagestatisticday.FieldNewUser:
  25779. v, ok := value.(int64)
  25780. if !ok {
  25781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25782. }
  25783. m.SetNewUser(v)
  25784. return nil
  25785. case usagestatisticday.FieldLabelDist:
  25786. v, ok := value.([]custom_types.LabelDist)
  25787. if !ok {
  25788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25789. }
  25790. m.SetLabelDist(v)
  25791. return nil
  25792. }
  25793. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25794. }
  25795. // AddedFields returns all numeric fields that were incremented/decremented during
  25796. // this mutation.
  25797. func (m *UsageStatisticDayMutation) AddedFields() []string {
  25798. var fields []string
  25799. if m.addstatus != nil {
  25800. fields = append(fields, usagestatisticday.FieldStatus)
  25801. }
  25802. if m.addaddtime != nil {
  25803. fields = append(fields, usagestatisticday.FieldAddtime)
  25804. }
  25805. if m.add_type != nil {
  25806. fields = append(fields, usagestatisticday.FieldType)
  25807. }
  25808. if m.addorganization_id != nil {
  25809. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25810. }
  25811. if m.addai_response != nil {
  25812. fields = append(fields, usagestatisticday.FieldAiResponse)
  25813. }
  25814. if m.addsop_run != nil {
  25815. fields = append(fields, usagestatisticday.FieldSopRun)
  25816. }
  25817. if m.addtotal_friend != nil {
  25818. fields = append(fields, usagestatisticday.FieldTotalFriend)
  25819. }
  25820. if m.addtotal_group != nil {
  25821. fields = append(fields, usagestatisticday.FieldTotalGroup)
  25822. }
  25823. if m.addaccount_balance != nil {
  25824. fields = append(fields, usagestatisticday.FieldAccountBalance)
  25825. }
  25826. if m.addconsume_token != nil {
  25827. fields = append(fields, usagestatisticday.FieldConsumeToken)
  25828. }
  25829. if m.addactive_user != nil {
  25830. fields = append(fields, usagestatisticday.FieldActiveUser)
  25831. }
  25832. if m.addnew_user != nil {
  25833. fields = append(fields, usagestatisticday.FieldNewUser)
  25834. }
  25835. return fields
  25836. }
  25837. // AddedField returns the numeric value that was incremented/decremented on a field
  25838. // with the given name. The second boolean return value indicates that this field
  25839. // was not set, or was not defined in the schema.
  25840. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  25841. switch name {
  25842. case usagestatisticday.FieldStatus:
  25843. return m.AddedStatus()
  25844. case usagestatisticday.FieldAddtime:
  25845. return m.AddedAddtime()
  25846. case usagestatisticday.FieldType:
  25847. return m.AddedType()
  25848. case usagestatisticday.FieldOrganizationID:
  25849. return m.AddedOrganizationID()
  25850. case usagestatisticday.FieldAiResponse:
  25851. return m.AddedAiResponse()
  25852. case usagestatisticday.FieldSopRun:
  25853. return m.AddedSopRun()
  25854. case usagestatisticday.FieldTotalFriend:
  25855. return m.AddedTotalFriend()
  25856. case usagestatisticday.FieldTotalGroup:
  25857. return m.AddedTotalGroup()
  25858. case usagestatisticday.FieldAccountBalance:
  25859. return m.AddedAccountBalance()
  25860. case usagestatisticday.FieldConsumeToken:
  25861. return m.AddedConsumeToken()
  25862. case usagestatisticday.FieldActiveUser:
  25863. return m.AddedActiveUser()
  25864. case usagestatisticday.FieldNewUser:
  25865. return m.AddedNewUser()
  25866. }
  25867. return nil, false
  25868. }
  25869. // AddField adds the value to the field with the given name. It returns an error if
  25870. // the field is not defined in the schema, or if the type mismatched the field
  25871. // type.
  25872. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  25873. switch name {
  25874. case usagestatisticday.FieldStatus:
  25875. v, ok := value.(int8)
  25876. if !ok {
  25877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25878. }
  25879. m.AddStatus(v)
  25880. return nil
  25881. case usagestatisticday.FieldAddtime:
  25882. v, ok := value.(int64)
  25883. if !ok {
  25884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25885. }
  25886. m.AddAddtime(v)
  25887. return nil
  25888. case usagestatisticday.FieldType:
  25889. v, ok := value.(int)
  25890. if !ok {
  25891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25892. }
  25893. m.AddType(v)
  25894. return nil
  25895. case usagestatisticday.FieldOrganizationID:
  25896. v, ok := value.(int64)
  25897. if !ok {
  25898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25899. }
  25900. m.AddOrganizationID(v)
  25901. return nil
  25902. case usagestatisticday.FieldAiResponse:
  25903. v, ok := value.(int64)
  25904. if !ok {
  25905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25906. }
  25907. m.AddAiResponse(v)
  25908. return nil
  25909. case usagestatisticday.FieldSopRun:
  25910. v, ok := value.(int64)
  25911. if !ok {
  25912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25913. }
  25914. m.AddSopRun(v)
  25915. return nil
  25916. case usagestatisticday.FieldTotalFriend:
  25917. v, ok := value.(int64)
  25918. if !ok {
  25919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25920. }
  25921. m.AddTotalFriend(v)
  25922. return nil
  25923. case usagestatisticday.FieldTotalGroup:
  25924. v, ok := value.(int64)
  25925. if !ok {
  25926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25927. }
  25928. m.AddTotalGroup(v)
  25929. return nil
  25930. case usagestatisticday.FieldAccountBalance:
  25931. v, ok := value.(int64)
  25932. if !ok {
  25933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25934. }
  25935. m.AddAccountBalance(v)
  25936. return nil
  25937. case usagestatisticday.FieldConsumeToken:
  25938. v, ok := value.(int64)
  25939. if !ok {
  25940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25941. }
  25942. m.AddConsumeToken(v)
  25943. return nil
  25944. case usagestatisticday.FieldActiveUser:
  25945. v, ok := value.(int64)
  25946. if !ok {
  25947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25948. }
  25949. m.AddActiveUser(v)
  25950. return nil
  25951. case usagestatisticday.FieldNewUser:
  25952. v, ok := value.(int64)
  25953. if !ok {
  25954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25955. }
  25956. m.AddNewUser(v)
  25957. return nil
  25958. }
  25959. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  25960. }
  25961. // ClearedFields returns all nullable fields that were cleared during this
  25962. // mutation.
  25963. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  25964. var fields []string
  25965. if m.FieldCleared(usagestatisticday.FieldStatus) {
  25966. fields = append(fields, usagestatisticday.FieldStatus)
  25967. }
  25968. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  25969. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25970. }
  25971. if m.FieldCleared(usagestatisticday.FieldBotID) {
  25972. fields = append(fields, usagestatisticday.FieldBotID)
  25973. }
  25974. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  25975. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25976. }
  25977. return fields
  25978. }
  25979. // FieldCleared returns a boolean indicating if a field with the given name was
  25980. // cleared in this mutation.
  25981. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  25982. _, ok := m.clearedFields[name]
  25983. return ok
  25984. }
  25985. // ClearField clears the value of the field with the given name. It returns an
  25986. // error if the field is not defined in the schema.
  25987. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  25988. switch name {
  25989. case usagestatisticday.FieldStatus:
  25990. m.ClearStatus()
  25991. return nil
  25992. case usagestatisticday.FieldDeletedAt:
  25993. m.ClearDeletedAt()
  25994. return nil
  25995. case usagestatisticday.FieldBotID:
  25996. m.ClearBotID()
  25997. return nil
  25998. case usagestatisticday.FieldOrganizationID:
  25999. m.ClearOrganizationID()
  26000. return nil
  26001. }
  26002. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  26003. }
  26004. // ResetField resets all changes in the mutation for the field with the given name.
  26005. // It returns an error if the field is not defined in the schema.
  26006. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  26007. switch name {
  26008. case usagestatisticday.FieldCreatedAt:
  26009. m.ResetCreatedAt()
  26010. return nil
  26011. case usagestatisticday.FieldUpdatedAt:
  26012. m.ResetUpdatedAt()
  26013. return nil
  26014. case usagestatisticday.FieldStatus:
  26015. m.ResetStatus()
  26016. return nil
  26017. case usagestatisticday.FieldDeletedAt:
  26018. m.ResetDeletedAt()
  26019. return nil
  26020. case usagestatisticday.FieldAddtime:
  26021. m.ResetAddtime()
  26022. return nil
  26023. case usagestatisticday.FieldType:
  26024. m.ResetType()
  26025. return nil
  26026. case usagestatisticday.FieldBotID:
  26027. m.ResetBotID()
  26028. return nil
  26029. case usagestatisticday.FieldOrganizationID:
  26030. m.ResetOrganizationID()
  26031. return nil
  26032. case usagestatisticday.FieldAiResponse:
  26033. m.ResetAiResponse()
  26034. return nil
  26035. case usagestatisticday.FieldSopRun:
  26036. m.ResetSopRun()
  26037. return nil
  26038. case usagestatisticday.FieldTotalFriend:
  26039. m.ResetTotalFriend()
  26040. return nil
  26041. case usagestatisticday.FieldTotalGroup:
  26042. m.ResetTotalGroup()
  26043. return nil
  26044. case usagestatisticday.FieldAccountBalance:
  26045. m.ResetAccountBalance()
  26046. return nil
  26047. case usagestatisticday.FieldConsumeToken:
  26048. m.ResetConsumeToken()
  26049. return nil
  26050. case usagestatisticday.FieldActiveUser:
  26051. m.ResetActiveUser()
  26052. return nil
  26053. case usagestatisticday.FieldNewUser:
  26054. m.ResetNewUser()
  26055. return nil
  26056. case usagestatisticday.FieldLabelDist:
  26057. m.ResetLabelDist()
  26058. return nil
  26059. }
  26060. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26061. }
  26062. // AddedEdges returns all edge names that were set/added in this mutation.
  26063. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  26064. edges := make([]string, 0, 0)
  26065. return edges
  26066. }
  26067. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26068. // name in this mutation.
  26069. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  26070. return nil
  26071. }
  26072. // RemovedEdges returns all edge names that were removed in this mutation.
  26073. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  26074. edges := make([]string, 0, 0)
  26075. return edges
  26076. }
  26077. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26078. // the given name in this mutation.
  26079. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  26080. return nil
  26081. }
  26082. // ClearedEdges returns all edge names that were cleared in this mutation.
  26083. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  26084. edges := make([]string, 0, 0)
  26085. return edges
  26086. }
  26087. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26088. // was cleared in this mutation.
  26089. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  26090. return false
  26091. }
  26092. // ClearEdge clears the value of the edge with the given name. It returns an error
  26093. // if that edge is not defined in the schema.
  26094. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  26095. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  26096. }
  26097. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26098. // It returns an error if the edge is not defined in the schema.
  26099. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  26100. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  26101. }
  26102. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  26103. type UsageStatisticHourMutation struct {
  26104. config
  26105. op Op
  26106. typ string
  26107. id *uint64
  26108. created_at *time.Time
  26109. updated_at *time.Time
  26110. status *uint8
  26111. addstatus *int8
  26112. deleted_at *time.Time
  26113. addtime *uint64
  26114. addaddtime *int64
  26115. _type *int
  26116. add_type *int
  26117. bot_id *string
  26118. organization_id *uint64
  26119. addorganization_id *int64
  26120. ai_response *uint64
  26121. addai_response *int64
  26122. sop_run *uint64
  26123. addsop_run *int64
  26124. total_friend *uint64
  26125. addtotal_friend *int64
  26126. total_group *uint64
  26127. addtotal_group *int64
  26128. account_balance *uint64
  26129. addaccount_balance *int64
  26130. consume_token *uint64
  26131. addconsume_token *int64
  26132. active_user *uint64
  26133. addactive_user *int64
  26134. new_user *int64
  26135. addnew_user *int64
  26136. label_dist *[]custom_types.LabelDist
  26137. appendlabel_dist []custom_types.LabelDist
  26138. clearedFields map[string]struct{}
  26139. done bool
  26140. oldValue func(context.Context) (*UsageStatisticHour, error)
  26141. predicates []predicate.UsageStatisticHour
  26142. }
  26143. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  26144. // usagestatistichourOption allows management of the mutation configuration using functional options.
  26145. type usagestatistichourOption func(*UsageStatisticHourMutation)
  26146. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  26147. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  26148. m := &UsageStatisticHourMutation{
  26149. config: c,
  26150. op: op,
  26151. typ: TypeUsageStatisticHour,
  26152. clearedFields: make(map[string]struct{}),
  26153. }
  26154. for _, opt := range opts {
  26155. opt(m)
  26156. }
  26157. return m
  26158. }
  26159. // withUsageStatisticHourID sets the ID field of the mutation.
  26160. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  26161. return func(m *UsageStatisticHourMutation) {
  26162. var (
  26163. err error
  26164. once sync.Once
  26165. value *UsageStatisticHour
  26166. )
  26167. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  26168. once.Do(func() {
  26169. if m.done {
  26170. err = errors.New("querying old values post mutation is not allowed")
  26171. } else {
  26172. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  26173. }
  26174. })
  26175. return value, err
  26176. }
  26177. m.id = &id
  26178. }
  26179. }
  26180. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  26181. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  26182. return func(m *UsageStatisticHourMutation) {
  26183. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  26184. return node, nil
  26185. }
  26186. m.id = &node.ID
  26187. }
  26188. }
  26189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26190. // executed in a transaction (ent.Tx), a transactional client is returned.
  26191. func (m UsageStatisticHourMutation) Client() *Client {
  26192. client := &Client{config: m.config}
  26193. client.init()
  26194. return client
  26195. }
  26196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26197. // it returns an error otherwise.
  26198. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  26199. if _, ok := m.driver.(*txDriver); !ok {
  26200. return nil, errors.New("ent: mutation is not running in a transaction")
  26201. }
  26202. tx := &Tx{config: m.config}
  26203. tx.init()
  26204. return tx, nil
  26205. }
  26206. // SetID sets the value of the id field. Note that this
  26207. // operation is only accepted on creation of UsageStatisticHour entities.
  26208. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  26209. m.id = &id
  26210. }
  26211. // ID returns the ID value in the mutation. Note that the ID is only available
  26212. // if it was provided to the builder or after it was returned from the database.
  26213. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  26214. if m.id == nil {
  26215. return
  26216. }
  26217. return *m.id, true
  26218. }
  26219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26220. // That means, if the mutation is applied within a transaction with an isolation level such
  26221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26222. // or updated by the mutation.
  26223. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  26224. switch {
  26225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26226. id, exists := m.ID()
  26227. if exists {
  26228. return []uint64{id}, nil
  26229. }
  26230. fallthrough
  26231. case m.op.Is(OpUpdate | OpDelete):
  26232. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  26233. default:
  26234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26235. }
  26236. }
  26237. // SetCreatedAt sets the "created_at" field.
  26238. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  26239. m.created_at = &t
  26240. }
  26241. // CreatedAt returns the value of the "created_at" field in the mutation.
  26242. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  26243. v := m.created_at
  26244. if v == nil {
  26245. return
  26246. }
  26247. return *v, true
  26248. }
  26249. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  26250. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26252. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26253. if !m.op.Is(OpUpdateOne) {
  26254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26255. }
  26256. if m.id == nil || m.oldValue == nil {
  26257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26258. }
  26259. oldValue, err := m.oldValue(ctx)
  26260. if err != nil {
  26261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26262. }
  26263. return oldValue.CreatedAt, nil
  26264. }
  26265. // ResetCreatedAt resets all changes to the "created_at" field.
  26266. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  26267. m.created_at = nil
  26268. }
  26269. // SetUpdatedAt sets the "updated_at" field.
  26270. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  26271. m.updated_at = &t
  26272. }
  26273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26274. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  26275. v := m.updated_at
  26276. if v == nil {
  26277. return
  26278. }
  26279. return *v, true
  26280. }
  26281. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  26282. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26284. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26285. if !m.op.Is(OpUpdateOne) {
  26286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26287. }
  26288. if m.id == nil || m.oldValue == nil {
  26289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26290. }
  26291. oldValue, err := m.oldValue(ctx)
  26292. if err != nil {
  26293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26294. }
  26295. return oldValue.UpdatedAt, nil
  26296. }
  26297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26298. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  26299. m.updated_at = nil
  26300. }
  26301. // SetStatus sets the "status" field.
  26302. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  26303. m.status = &u
  26304. m.addstatus = nil
  26305. }
  26306. // Status returns the value of the "status" field in the mutation.
  26307. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  26308. v := m.status
  26309. if v == nil {
  26310. return
  26311. }
  26312. return *v, true
  26313. }
  26314. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  26315. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26317. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26318. if !m.op.Is(OpUpdateOne) {
  26319. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26320. }
  26321. if m.id == nil || m.oldValue == nil {
  26322. return v, errors.New("OldStatus requires an ID field in the mutation")
  26323. }
  26324. oldValue, err := m.oldValue(ctx)
  26325. if err != nil {
  26326. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26327. }
  26328. return oldValue.Status, nil
  26329. }
  26330. // AddStatus adds u to the "status" field.
  26331. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  26332. if m.addstatus != nil {
  26333. *m.addstatus += u
  26334. } else {
  26335. m.addstatus = &u
  26336. }
  26337. }
  26338. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26339. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  26340. v := m.addstatus
  26341. if v == nil {
  26342. return
  26343. }
  26344. return *v, true
  26345. }
  26346. // ClearStatus clears the value of the "status" field.
  26347. func (m *UsageStatisticHourMutation) ClearStatus() {
  26348. m.status = nil
  26349. m.addstatus = nil
  26350. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  26351. }
  26352. // StatusCleared returns if the "status" field was cleared in this mutation.
  26353. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  26354. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  26355. return ok
  26356. }
  26357. // ResetStatus resets all changes to the "status" field.
  26358. func (m *UsageStatisticHourMutation) ResetStatus() {
  26359. m.status = nil
  26360. m.addstatus = nil
  26361. delete(m.clearedFields, usagestatistichour.FieldStatus)
  26362. }
  26363. // SetDeletedAt sets the "deleted_at" field.
  26364. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  26365. m.deleted_at = &t
  26366. }
  26367. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26368. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  26369. v := m.deleted_at
  26370. if v == nil {
  26371. return
  26372. }
  26373. return *v, true
  26374. }
  26375. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  26376. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26378. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26379. if !m.op.Is(OpUpdateOne) {
  26380. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26381. }
  26382. if m.id == nil || m.oldValue == nil {
  26383. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26384. }
  26385. oldValue, err := m.oldValue(ctx)
  26386. if err != nil {
  26387. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26388. }
  26389. return oldValue.DeletedAt, nil
  26390. }
  26391. // ClearDeletedAt clears the value of the "deleted_at" field.
  26392. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  26393. m.deleted_at = nil
  26394. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  26395. }
  26396. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26397. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  26398. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  26399. return ok
  26400. }
  26401. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26402. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  26403. m.deleted_at = nil
  26404. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  26405. }
  26406. // SetAddtime sets the "addtime" field.
  26407. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  26408. m.addtime = &u
  26409. m.addaddtime = nil
  26410. }
  26411. // Addtime returns the value of the "addtime" field in the mutation.
  26412. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  26413. v := m.addtime
  26414. if v == nil {
  26415. return
  26416. }
  26417. return *v, true
  26418. }
  26419. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  26420. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26422. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  26423. if !m.op.Is(OpUpdateOne) {
  26424. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  26425. }
  26426. if m.id == nil || m.oldValue == nil {
  26427. return v, errors.New("OldAddtime requires an ID field in the mutation")
  26428. }
  26429. oldValue, err := m.oldValue(ctx)
  26430. if err != nil {
  26431. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  26432. }
  26433. return oldValue.Addtime, nil
  26434. }
  26435. // AddAddtime adds u to the "addtime" field.
  26436. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  26437. if m.addaddtime != nil {
  26438. *m.addaddtime += u
  26439. } else {
  26440. m.addaddtime = &u
  26441. }
  26442. }
  26443. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  26444. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  26445. v := m.addaddtime
  26446. if v == nil {
  26447. return
  26448. }
  26449. return *v, true
  26450. }
  26451. // ResetAddtime resets all changes to the "addtime" field.
  26452. func (m *UsageStatisticHourMutation) ResetAddtime() {
  26453. m.addtime = nil
  26454. m.addaddtime = nil
  26455. }
  26456. // SetType sets the "type" field.
  26457. func (m *UsageStatisticHourMutation) SetType(i int) {
  26458. m._type = &i
  26459. m.add_type = nil
  26460. }
  26461. // GetType returns the value of the "type" field in the mutation.
  26462. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  26463. v := m._type
  26464. if v == nil {
  26465. return
  26466. }
  26467. return *v, true
  26468. }
  26469. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  26470. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26472. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  26473. if !m.op.Is(OpUpdateOne) {
  26474. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26475. }
  26476. if m.id == nil || m.oldValue == nil {
  26477. return v, errors.New("OldType requires an ID field in the mutation")
  26478. }
  26479. oldValue, err := m.oldValue(ctx)
  26480. if err != nil {
  26481. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26482. }
  26483. return oldValue.Type, nil
  26484. }
  26485. // AddType adds i to the "type" field.
  26486. func (m *UsageStatisticHourMutation) AddType(i int) {
  26487. if m.add_type != nil {
  26488. *m.add_type += i
  26489. } else {
  26490. m.add_type = &i
  26491. }
  26492. }
  26493. // AddedType returns the value that was added to the "type" field in this mutation.
  26494. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  26495. v := m.add_type
  26496. if v == nil {
  26497. return
  26498. }
  26499. return *v, true
  26500. }
  26501. // ResetType resets all changes to the "type" field.
  26502. func (m *UsageStatisticHourMutation) ResetType() {
  26503. m._type = nil
  26504. m.add_type = nil
  26505. }
  26506. // SetBotID sets the "bot_id" field.
  26507. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  26508. m.bot_id = &s
  26509. }
  26510. // BotID returns the value of the "bot_id" field in the mutation.
  26511. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  26512. v := m.bot_id
  26513. if v == nil {
  26514. return
  26515. }
  26516. return *v, true
  26517. }
  26518. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  26519. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  26522. if !m.op.Is(OpUpdateOne) {
  26523. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26524. }
  26525. if m.id == nil || m.oldValue == nil {
  26526. return v, errors.New("OldBotID 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 OldBotID: %w", err)
  26531. }
  26532. return oldValue.BotID, nil
  26533. }
  26534. // ClearBotID clears the value of the "bot_id" field.
  26535. func (m *UsageStatisticHourMutation) ClearBotID() {
  26536. m.bot_id = nil
  26537. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  26538. }
  26539. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  26540. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  26541. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  26542. return ok
  26543. }
  26544. // ResetBotID resets all changes to the "bot_id" field.
  26545. func (m *UsageStatisticHourMutation) ResetBotID() {
  26546. m.bot_id = nil
  26547. delete(m.clearedFields, usagestatistichour.FieldBotID)
  26548. }
  26549. // SetOrganizationID sets the "organization_id" field.
  26550. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  26551. m.organization_id = &u
  26552. m.addorganization_id = nil
  26553. }
  26554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26555. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  26556. v := m.organization_id
  26557. if v == nil {
  26558. return
  26559. }
  26560. return *v, true
  26561. }
  26562. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  26563. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26566. if !m.op.Is(OpUpdateOne) {
  26567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26568. }
  26569. if m.id == nil || m.oldValue == nil {
  26570. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  26575. }
  26576. return oldValue.OrganizationID, nil
  26577. }
  26578. // AddOrganizationID adds u to the "organization_id" field.
  26579. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  26580. if m.addorganization_id != nil {
  26581. *m.addorganization_id += u
  26582. } else {
  26583. m.addorganization_id = &u
  26584. }
  26585. }
  26586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26587. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  26588. v := m.addorganization_id
  26589. if v == nil {
  26590. return
  26591. }
  26592. return *v, true
  26593. }
  26594. // ClearOrganizationID clears the value of the "organization_id" field.
  26595. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  26596. m.organization_id = nil
  26597. m.addorganization_id = nil
  26598. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  26599. }
  26600. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26601. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  26602. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  26603. return ok
  26604. }
  26605. // ResetOrganizationID resets all changes to the "organization_id" field.
  26606. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  26607. m.organization_id = nil
  26608. m.addorganization_id = nil
  26609. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  26610. }
  26611. // SetAiResponse sets the "ai_response" field.
  26612. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  26613. m.ai_response = &u
  26614. m.addai_response = nil
  26615. }
  26616. // AiResponse returns the value of the "ai_response" field in the mutation.
  26617. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  26618. v := m.ai_response
  26619. if v == nil {
  26620. return
  26621. }
  26622. return *v, true
  26623. }
  26624. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  26625. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  26628. if !m.op.Is(OpUpdateOne) {
  26629. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  26630. }
  26631. if m.id == nil || m.oldValue == nil {
  26632. return v, errors.New("OldAiResponse 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 OldAiResponse: %w", err)
  26637. }
  26638. return oldValue.AiResponse, nil
  26639. }
  26640. // AddAiResponse adds u to the "ai_response" field.
  26641. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  26642. if m.addai_response != nil {
  26643. *m.addai_response += u
  26644. } else {
  26645. m.addai_response = &u
  26646. }
  26647. }
  26648. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  26649. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  26650. v := m.addai_response
  26651. if v == nil {
  26652. return
  26653. }
  26654. return *v, true
  26655. }
  26656. // ResetAiResponse resets all changes to the "ai_response" field.
  26657. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  26658. m.ai_response = nil
  26659. m.addai_response = nil
  26660. }
  26661. // SetSopRun sets the "sop_run" field.
  26662. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  26663. m.sop_run = &u
  26664. m.addsop_run = nil
  26665. }
  26666. // SopRun returns the value of the "sop_run" field in the mutation.
  26667. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  26668. v := m.sop_run
  26669. if v == nil {
  26670. return
  26671. }
  26672. return *v, true
  26673. }
  26674. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  26675. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  26678. if !m.op.Is(OpUpdateOne) {
  26679. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  26680. }
  26681. if m.id == nil || m.oldValue == nil {
  26682. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  26687. }
  26688. return oldValue.SopRun, nil
  26689. }
  26690. // AddSopRun adds u to the "sop_run" field.
  26691. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  26692. if m.addsop_run != nil {
  26693. *m.addsop_run += u
  26694. } else {
  26695. m.addsop_run = &u
  26696. }
  26697. }
  26698. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  26699. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  26700. v := m.addsop_run
  26701. if v == nil {
  26702. return
  26703. }
  26704. return *v, true
  26705. }
  26706. // ResetSopRun resets all changes to the "sop_run" field.
  26707. func (m *UsageStatisticHourMutation) ResetSopRun() {
  26708. m.sop_run = nil
  26709. m.addsop_run = nil
  26710. }
  26711. // SetTotalFriend sets the "total_friend" field.
  26712. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  26713. m.total_friend = &u
  26714. m.addtotal_friend = nil
  26715. }
  26716. // TotalFriend returns the value of the "total_friend" field in the mutation.
  26717. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  26718. v := m.total_friend
  26719. if v == nil {
  26720. return
  26721. }
  26722. return *v, true
  26723. }
  26724. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  26725. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26727. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  26728. if !m.op.Is(OpUpdateOne) {
  26729. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  26730. }
  26731. if m.id == nil || m.oldValue == nil {
  26732. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  26733. }
  26734. oldValue, err := m.oldValue(ctx)
  26735. if err != nil {
  26736. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  26737. }
  26738. return oldValue.TotalFriend, nil
  26739. }
  26740. // AddTotalFriend adds u to the "total_friend" field.
  26741. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  26742. if m.addtotal_friend != nil {
  26743. *m.addtotal_friend += u
  26744. } else {
  26745. m.addtotal_friend = &u
  26746. }
  26747. }
  26748. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  26749. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  26750. v := m.addtotal_friend
  26751. if v == nil {
  26752. return
  26753. }
  26754. return *v, true
  26755. }
  26756. // ResetTotalFriend resets all changes to the "total_friend" field.
  26757. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  26758. m.total_friend = nil
  26759. m.addtotal_friend = nil
  26760. }
  26761. // SetTotalGroup sets the "total_group" field.
  26762. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  26763. m.total_group = &u
  26764. m.addtotal_group = nil
  26765. }
  26766. // TotalGroup returns the value of the "total_group" field in the mutation.
  26767. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  26768. v := m.total_group
  26769. if v == nil {
  26770. return
  26771. }
  26772. return *v, true
  26773. }
  26774. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  26775. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26777. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  26778. if !m.op.Is(OpUpdateOne) {
  26779. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  26780. }
  26781. if m.id == nil || m.oldValue == nil {
  26782. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  26783. }
  26784. oldValue, err := m.oldValue(ctx)
  26785. if err != nil {
  26786. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  26787. }
  26788. return oldValue.TotalGroup, nil
  26789. }
  26790. // AddTotalGroup adds u to the "total_group" field.
  26791. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  26792. if m.addtotal_group != nil {
  26793. *m.addtotal_group += u
  26794. } else {
  26795. m.addtotal_group = &u
  26796. }
  26797. }
  26798. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  26799. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  26800. v := m.addtotal_group
  26801. if v == nil {
  26802. return
  26803. }
  26804. return *v, true
  26805. }
  26806. // ResetTotalGroup resets all changes to the "total_group" field.
  26807. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  26808. m.total_group = nil
  26809. m.addtotal_group = nil
  26810. }
  26811. // SetAccountBalance sets the "account_balance" field.
  26812. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  26813. m.account_balance = &u
  26814. m.addaccount_balance = nil
  26815. }
  26816. // AccountBalance returns the value of the "account_balance" field in the mutation.
  26817. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  26818. v := m.account_balance
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  26825. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26827. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  26828. if !m.op.Is(OpUpdateOne) {
  26829. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  26830. }
  26831. if m.id == nil || m.oldValue == nil {
  26832. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  26833. }
  26834. oldValue, err := m.oldValue(ctx)
  26835. if err != nil {
  26836. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  26837. }
  26838. return oldValue.AccountBalance, nil
  26839. }
  26840. // AddAccountBalance adds u to the "account_balance" field.
  26841. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  26842. if m.addaccount_balance != nil {
  26843. *m.addaccount_balance += u
  26844. } else {
  26845. m.addaccount_balance = &u
  26846. }
  26847. }
  26848. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  26849. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  26850. v := m.addaccount_balance
  26851. if v == nil {
  26852. return
  26853. }
  26854. return *v, true
  26855. }
  26856. // ResetAccountBalance resets all changes to the "account_balance" field.
  26857. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  26858. m.account_balance = nil
  26859. m.addaccount_balance = nil
  26860. }
  26861. // SetConsumeToken sets the "consume_token" field.
  26862. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  26863. m.consume_token = &u
  26864. m.addconsume_token = nil
  26865. }
  26866. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  26867. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  26868. v := m.consume_token
  26869. if v == nil {
  26870. return
  26871. }
  26872. return *v, true
  26873. }
  26874. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  26875. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26877. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  26878. if !m.op.Is(OpUpdateOne) {
  26879. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  26880. }
  26881. if m.id == nil || m.oldValue == nil {
  26882. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  26883. }
  26884. oldValue, err := m.oldValue(ctx)
  26885. if err != nil {
  26886. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  26887. }
  26888. return oldValue.ConsumeToken, nil
  26889. }
  26890. // AddConsumeToken adds u to the "consume_token" field.
  26891. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  26892. if m.addconsume_token != nil {
  26893. *m.addconsume_token += u
  26894. } else {
  26895. m.addconsume_token = &u
  26896. }
  26897. }
  26898. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  26899. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  26900. v := m.addconsume_token
  26901. if v == nil {
  26902. return
  26903. }
  26904. return *v, true
  26905. }
  26906. // ResetConsumeToken resets all changes to the "consume_token" field.
  26907. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  26908. m.consume_token = nil
  26909. m.addconsume_token = nil
  26910. }
  26911. // SetActiveUser sets the "active_user" field.
  26912. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  26913. m.active_user = &u
  26914. m.addactive_user = nil
  26915. }
  26916. // ActiveUser returns the value of the "active_user" field in the mutation.
  26917. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  26918. v := m.active_user
  26919. if v == nil {
  26920. return
  26921. }
  26922. return *v, true
  26923. }
  26924. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  26925. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26927. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  26928. if !m.op.Is(OpUpdateOne) {
  26929. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  26930. }
  26931. if m.id == nil || m.oldValue == nil {
  26932. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  26933. }
  26934. oldValue, err := m.oldValue(ctx)
  26935. if err != nil {
  26936. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  26937. }
  26938. return oldValue.ActiveUser, nil
  26939. }
  26940. // AddActiveUser adds u to the "active_user" field.
  26941. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  26942. if m.addactive_user != nil {
  26943. *m.addactive_user += u
  26944. } else {
  26945. m.addactive_user = &u
  26946. }
  26947. }
  26948. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  26949. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  26950. v := m.addactive_user
  26951. if v == nil {
  26952. return
  26953. }
  26954. return *v, true
  26955. }
  26956. // ResetActiveUser resets all changes to the "active_user" field.
  26957. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  26958. m.active_user = nil
  26959. m.addactive_user = nil
  26960. }
  26961. // SetNewUser sets the "new_user" field.
  26962. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  26963. m.new_user = &i
  26964. m.addnew_user = nil
  26965. }
  26966. // NewUser returns the value of the "new_user" field in the mutation.
  26967. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  26968. v := m.new_user
  26969. if v == nil {
  26970. return
  26971. }
  26972. return *v, true
  26973. }
  26974. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  26975. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26977. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26978. if !m.op.Is(OpUpdateOne) {
  26979. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26980. }
  26981. if m.id == nil || m.oldValue == nil {
  26982. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26983. }
  26984. oldValue, err := m.oldValue(ctx)
  26985. if err != nil {
  26986. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26987. }
  26988. return oldValue.NewUser, nil
  26989. }
  26990. // AddNewUser adds i to the "new_user" field.
  26991. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  26992. if m.addnew_user != nil {
  26993. *m.addnew_user += i
  26994. } else {
  26995. m.addnew_user = &i
  26996. }
  26997. }
  26998. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26999. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  27000. v := m.addnew_user
  27001. if v == nil {
  27002. return
  27003. }
  27004. return *v, true
  27005. }
  27006. // ResetNewUser resets all changes to the "new_user" field.
  27007. func (m *UsageStatisticHourMutation) ResetNewUser() {
  27008. m.new_user = nil
  27009. m.addnew_user = nil
  27010. }
  27011. // SetLabelDist sets the "label_dist" field.
  27012. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  27013. m.label_dist = &ctd
  27014. m.appendlabel_dist = nil
  27015. }
  27016. // LabelDist returns the value of the "label_dist" field in the mutation.
  27017. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  27018. v := m.label_dist
  27019. if v == nil {
  27020. return
  27021. }
  27022. return *v, true
  27023. }
  27024. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  27025. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27027. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  27028. if !m.op.Is(OpUpdateOne) {
  27029. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  27030. }
  27031. if m.id == nil || m.oldValue == nil {
  27032. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  27033. }
  27034. oldValue, err := m.oldValue(ctx)
  27035. if err != nil {
  27036. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  27037. }
  27038. return oldValue.LabelDist, nil
  27039. }
  27040. // AppendLabelDist adds ctd to the "label_dist" field.
  27041. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  27042. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  27043. }
  27044. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  27045. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  27046. if len(m.appendlabel_dist) == 0 {
  27047. return nil, false
  27048. }
  27049. return m.appendlabel_dist, true
  27050. }
  27051. // ResetLabelDist resets all changes to the "label_dist" field.
  27052. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  27053. m.label_dist = nil
  27054. m.appendlabel_dist = nil
  27055. }
  27056. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  27057. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  27058. m.predicates = append(m.predicates, ps...)
  27059. }
  27060. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  27061. // users can use type-assertion to append predicates that do not depend on any generated package.
  27062. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  27063. p := make([]predicate.UsageStatisticHour, len(ps))
  27064. for i := range ps {
  27065. p[i] = ps[i]
  27066. }
  27067. m.Where(p...)
  27068. }
  27069. // Op returns the operation name.
  27070. func (m *UsageStatisticHourMutation) Op() Op {
  27071. return m.op
  27072. }
  27073. // SetOp allows setting the mutation operation.
  27074. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  27075. m.op = op
  27076. }
  27077. // Type returns the node type of this mutation (UsageStatisticHour).
  27078. func (m *UsageStatisticHourMutation) Type() string {
  27079. return m.typ
  27080. }
  27081. // Fields returns all fields that were changed during this mutation. Note that in
  27082. // order to get all numeric fields that were incremented/decremented, call
  27083. // AddedFields().
  27084. func (m *UsageStatisticHourMutation) Fields() []string {
  27085. fields := make([]string, 0, 17)
  27086. if m.created_at != nil {
  27087. fields = append(fields, usagestatistichour.FieldCreatedAt)
  27088. }
  27089. if m.updated_at != nil {
  27090. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  27091. }
  27092. if m.status != nil {
  27093. fields = append(fields, usagestatistichour.FieldStatus)
  27094. }
  27095. if m.deleted_at != nil {
  27096. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27097. }
  27098. if m.addtime != nil {
  27099. fields = append(fields, usagestatistichour.FieldAddtime)
  27100. }
  27101. if m._type != nil {
  27102. fields = append(fields, usagestatistichour.FieldType)
  27103. }
  27104. if m.bot_id != nil {
  27105. fields = append(fields, usagestatistichour.FieldBotID)
  27106. }
  27107. if m.organization_id != nil {
  27108. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27109. }
  27110. if m.ai_response != nil {
  27111. fields = append(fields, usagestatistichour.FieldAiResponse)
  27112. }
  27113. if m.sop_run != nil {
  27114. fields = append(fields, usagestatistichour.FieldSopRun)
  27115. }
  27116. if m.total_friend != nil {
  27117. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27118. }
  27119. if m.total_group != nil {
  27120. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27121. }
  27122. if m.account_balance != nil {
  27123. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27124. }
  27125. if m.consume_token != nil {
  27126. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27127. }
  27128. if m.active_user != nil {
  27129. fields = append(fields, usagestatistichour.FieldActiveUser)
  27130. }
  27131. if m.new_user != nil {
  27132. fields = append(fields, usagestatistichour.FieldNewUser)
  27133. }
  27134. if m.label_dist != nil {
  27135. fields = append(fields, usagestatistichour.FieldLabelDist)
  27136. }
  27137. return fields
  27138. }
  27139. // Field returns the value of a field with the given name. The second boolean
  27140. // return value indicates that this field was not set, or was not defined in the
  27141. // schema.
  27142. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  27143. switch name {
  27144. case usagestatistichour.FieldCreatedAt:
  27145. return m.CreatedAt()
  27146. case usagestatistichour.FieldUpdatedAt:
  27147. return m.UpdatedAt()
  27148. case usagestatistichour.FieldStatus:
  27149. return m.Status()
  27150. case usagestatistichour.FieldDeletedAt:
  27151. return m.DeletedAt()
  27152. case usagestatistichour.FieldAddtime:
  27153. return m.Addtime()
  27154. case usagestatistichour.FieldType:
  27155. return m.GetType()
  27156. case usagestatistichour.FieldBotID:
  27157. return m.BotID()
  27158. case usagestatistichour.FieldOrganizationID:
  27159. return m.OrganizationID()
  27160. case usagestatistichour.FieldAiResponse:
  27161. return m.AiResponse()
  27162. case usagestatistichour.FieldSopRun:
  27163. return m.SopRun()
  27164. case usagestatistichour.FieldTotalFriend:
  27165. return m.TotalFriend()
  27166. case usagestatistichour.FieldTotalGroup:
  27167. return m.TotalGroup()
  27168. case usagestatistichour.FieldAccountBalance:
  27169. return m.AccountBalance()
  27170. case usagestatistichour.FieldConsumeToken:
  27171. return m.ConsumeToken()
  27172. case usagestatistichour.FieldActiveUser:
  27173. return m.ActiveUser()
  27174. case usagestatistichour.FieldNewUser:
  27175. return m.NewUser()
  27176. case usagestatistichour.FieldLabelDist:
  27177. return m.LabelDist()
  27178. }
  27179. return nil, false
  27180. }
  27181. // OldField returns the old value of the field from the database. An error is
  27182. // returned if the mutation operation is not UpdateOne, or the query to the
  27183. // database failed.
  27184. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27185. switch name {
  27186. case usagestatistichour.FieldCreatedAt:
  27187. return m.OldCreatedAt(ctx)
  27188. case usagestatistichour.FieldUpdatedAt:
  27189. return m.OldUpdatedAt(ctx)
  27190. case usagestatistichour.FieldStatus:
  27191. return m.OldStatus(ctx)
  27192. case usagestatistichour.FieldDeletedAt:
  27193. return m.OldDeletedAt(ctx)
  27194. case usagestatistichour.FieldAddtime:
  27195. return m.OldAddtime(ctx)
  27196. case usagestatistichour.FieldType:
  27197. return m.OldType(ctx)
  27198. case usagestatistichour.FieldBotID:
  27199. return m.OldBotID(ctx)
  27200. case usagestatistichour.FieldOrganizationID:
  27201. return m.OldOrganizationID(ctx)
  27202. case usagestatistichour.FieldAiResponse:
  27203. return m.OldAiResponse(ctx)
  27204. case usagestatistichour.FieldSopRun:
  27205. return m.OldSopRun(ctx)
  27206. case usagestatistichour.FieldTotalFriend:
  27207. return m.OldTotalFriend(ctx)
  27208. case usagestatistichour.FieldTotalGroup:
  27209. return m.OldTotalGroup(ctx)
  27210. case usagestatistichour.FieldAccountBalance:
  27211. return m.OldAccountBalance(ctx)
  27212. case usagestatistichour.FieldConsumeToken:
  27213. return m.OldConsumeToken(ctx)
  27214. case usagestatistichour.FieldActiveUser:
  27215. return m.OldActiveUser(ctx)
  27216. case usagestatistichour.FieldNewUser:
  27217. return m.OldNewUser(ctx)
  27218. case usagestatistichour.FieldLabelDist:
  27219. return m.OldLabelDist(ctx)
  27220. }
  27221. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27222. }
  27223. // SetField sets the value of a field with the given name. It returns an error if
  27224. // the field is not defined in the schema, or if the type mismatched the field
  27225. // type.
  27226. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  27227. switch name {
  27228. case usagestatistichour.FieldCreatedAt:
  27229. v, ok := value.(time.Time)
  27230. if !ok {
  27231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27232. }
  27233. m.SetCreatedAt(v)
  27234. return nil
  27235. case usagestatistichour.FieldUpdatedAt:
  27236. v, ok := value.(time.Time)
  27237. if !ok {
  27238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27239. }
  27240. m.SetUpdatedAt(v)
  27241. return nil
  27242. case usagestatistichour.FieldStatus:
  27243. v, ok := value.(uint8)
  27244. if !ok {
  27245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27246. }
  27247. m.SetStatus(v)
  27248. return nil
  27249. case usagestatistichour.FieldDeletedAt:
  27250. v, ok := value.(time.Time)
  27251. if !ok {
  27252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27253. }
  27254. m.SetDeletedAt(v)
  27255. return nil
  27256. case usagestatistichour.FieldAddtime:
  27257. v, ok := value.(uint64)
  27258. if !ok {
  27259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27260. }
  27261. m.SetAddtime(v)
  27262. return nil
  27263. case usagestatistichour.FieldType:
  27264. v, ok := value.(int)
  27265. if !ok {
  27266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27267. }
  27268. m.SetType(v)
  27269. return nil
  27270. case usagestatistichour.FieldBotID:
  27271. v, ok := value.(string)
  27272. if !ok {
  27273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27274. }
  27275. m.SetBotID(v)
  27276. return nil
  27277. case usagestatistichour.FieldOrganizationID:
  27278. v, ok := value.(uint64)
  27279. if !ok {
  27280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27281. }
  27282. m.SetOrganizationID(v)
  27283. return nil
  27284. case usagestatistichour.FieldAiResponse:
  27285. v, ok := value.(uint64)
  27286. if !ok {
  27287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27288. }
  27289. m.SetAiResponse(v)
  27290. return nil
  27291. case usagestatistichour.FieldSopRun:
  27292. v, ok := value.(uint64)
  27293. if !ok {
  27294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27295. }
  27296. m.SetSopRun(v)
  27297. return nil
  27298. case usagestatistichour.FieldTotalFriend:
  27299. v, ok := value.(uint64)
  27300. if !ok {
  27301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27302. }
  27303. m.SetTotalFriend(v)
  27304. return nil
  27305. case usagestatistichour.FieldTotalGroup:
  27306. v, ok := value.(uint64)
  27307. if !ok {
  27308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27309. }
  27310. m.SetTotalGroup(v)
  27311. return nil
  27312. case usagestatistichour.FieldAccountBalance:
  27313. v, ok := value.(uint64)
  27314. if !ok {
  27315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27316. }
  27317. m.SetAccountBalance(v)
  27318. return nil
  27319. case usagestatistichour.FieldConsumeToken:
  27320. v, ok := value.(uint64)
  27321. if !ok {
  27322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27323. }
  27324. m.SetConsumeToken(v)
  27325. return nil
  27326. case usagestatistichour.FieldActiveUser:
  27327. v, ok := value.(uint64)
  27328. if !ok {
  27329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27330. }
  27331. m.SetActiveUser(v)
  27332. return nil
  27333. case usagestatistichour.FieldNewUser:
  27334. v, ok := value.(int64)
  27335. if !ok {
  27336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27337. }
  27338. m.SetNewUser(v)
  27339. return nil
  27340. case usagestatistichour.FieldLabelDist:
  27341. v, ok := value.([]custom_types.LabelDist)
  27342. if !ok {
  27343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27344. }
  27345. m.SetLabelDist(v)
  27346. return nil
  27347. }
  27348. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27349. }
  27350. // AddedFields returns all numeric fields that were incremented/decremented during
  27351. // this mutation.
  27352. func (m *UsageStatisticHourMutation) AddedFields() []string {
  27353. var fields []string
  27354. if m.addstatus != nil {
  27355. fields = append(fields, usagestatistichour.FieldStatus)
  27356. }
  27357. if m.addaddtime != nil {
  27358. fields = append(fields, usagestatistichour.FieldAddtime)
  27359. }
  27360. if m.add_type != nil {
  27361. fields = append(fields, usagestatistichour.FieldType)
  27362. }
  27363. if m.addorganization_id != nil {
  27364. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27365. }
  27366. if m.addai_response != nil {
  27367. fields = append(fields, usagestatistichour.FieldAiResponse)
  27368. }
  27369. if m.addsop_run != nil {
  27370. fields = append(fields, usagestatistichour.FieldSopRun)
  27371. }
  27372. if m.addtotal_friend != nil {
  27373. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27374. }
  27375. if m.addtotal_group != nil {
  27376. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27377. }
  27378. if m.addaccount_balance != nil {
  27379. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27380. }
  27381. if m.addconsume_token != nil {
  27382. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27383. }
  27384. if m.addactive_user != nil {
  27385. fields = append(fields, usagestatistichour.FieldActiveUser)
  27386. }
  27387. if m.addnew_user != nil {
  27388. fields = append(fields, usagestatistichour.FieldNewUser)
  27389. }
  27390. return fields
  27391. }
  27392. // AddedField returns the numeric value that was incremented/decremented on a field
  27393. // with the given name. The second boolean return value indicates that this field
  27394. // was not set, or was not defined in the schema.
  27395. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  27396. switch name {
  27397. case usagestatistichour.FieldStatus:
  27398. return m.AddedStatus()
  27399. case usagestatistichour.FieldAddtime:
  27400. return m.AddedAddtime()
  27401. case usagestatistichour.FieldType:
  27402. return m.AddedType()
  27403. case usagestatistichour.FieldOrganizationID:
  27404. return m.AddedOrganizationID()
  27405. case usagestatistichour.FieldAiResponse:
  27406. return m.AddedAiResponse()
  27407. case usagestatistichour.FieldSopRun:
  27408. return m.AddedSopRun()
  27409. case usagestatistichour.FieldTotalFriend:
  27410. return m.AddedTotalFriend()
  27411. case usagestatistichour.FieldTotalGroup:
  27412. return m.AddedTotalGroup()
  27413. case usagestatistichour.FieldAccountBalance:
  27414. return m.AddedAccountBalance()
  27415. case usagestatistichour.FieldConsumeToken:
  27416. return m.AddedConsumeToken()
  27417. case usagestatistichour.FieldActiveUser:
  27418. return m.AddedActiveUser()
  27419. case usagestatistichour.FieldNewUser:
  27420. return m.AddedNewUser()
  27421. }
  27422. return nil, false
  27423. }
  27424. // AddField adds the value to the field with the given name. It returns an error if
  27425. // the field is not defined in the schema, or if the type mismatched the field
  27426. // type.
  27427. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  27428. switch name {
  27429. case usagestatistichour.FieldStatus:
  27430. v, ok := value.(int8)
  27431. if !ok {
  27432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27433. }
  27434. m.AddStatus(v)
  27435. return nil
  27436. case usagestatistichour.FieldAddtime:
  27437. v, ok := value.(int64)
  27438. if !ok {
  27439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27440. }
  27441. m.AddAddtime(v)
  27442. return nil
  27443. case usagestatistichour.FieldType:
  27444. v, ok := value.(int)
  27445. if !ok {
  27446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27447. }
  27448. m.AddType(v)
  27449. return nil
  27450. case usagestatistichour.FieldOrganizationID:
  27451. v, ok := value.(int64)
  27452. if !ok {
  27453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27454. }
  27455. m.AddOrganizationID(v)
  27456. return nil
  27457. case usagestatistichour.FieldAiResponse:
  27458. v, ok := value.(int64)
  27459. if !ok {
  27460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27461. }
  27462. m.AddAiResponse(v)
  27463. return nil
  27464. case usagestatistichour.FieldSopRun:
  27465. v, ok := value.(int64)
  27466. if !ok {
  27467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27468. }
  27469. m.AddSopRun(v)
  27470. return nil
  27471. case usagestatistichour.FieldTotalFriend:
  27472. v, ok := value.(int64)
  27473. if !ok {
  27474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27475. }
  27476. m.AddTotalFriend(v)
  27477. return nil
  27478. case usagestatistichour.FieldTotalGroup:
  27479. v, ok := value.(int64)
  27480. if !ok {
  27481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27482. }
  27483. m.AddTotalGroup(v)
  27484. return nil
  27485. case usagestatistichour.FieldAccountBalance:
  27486. v, ok := value.(int64)
  27487. if !ok {
  27488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27489. }
  27490. m.AddAccountBalance(v)
  27491. return nil
  27492. case usagestatistichour.FieldConsumeToken:
  27493. v, ok := value.(int64)
  27494. if !ok {
  27495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27496. }
  27497. m.AddConsumeToken(v)
  27498. return nil
  27499. case usagestatistichour.FieldActiveUser:
  27500. v, ok := value.(int64)
  27501. if !ok {
  27502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27503. }
  27504. m.AddActiveUser(v)
  27505. return nil
  27506. case usagestatistichour.FieldNewUser:
  27507. v, ok := value.(int64)
  27508. if !ok {
  27509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27510. }
  27511. m.AddNewUser(v)
  27512. return nil
  27513. }
  27514. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  27515. }
  27516. // ClearedFields returns all nullable fields that were cleared during this
  27517. // mutation.
  27518. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  27519. var fields []string
  27520. if m.FieldCleared(usagestatistichour.FieldStatus) {
  27521. fields = append(fields, usagestatistichour.FieldStatus)
  27522. }
  27523. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  27524. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27525. }
  27526. if m.FieldCleared(usagestatistichour.FieldBotID) {
  27527. fields = append(fields, usagestatistichour.FieldBotID)
  27528. }
  27529. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  27530. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27531. }
  27532. return fields
  27533. }
  27534. // FieldCleared returns a boolean indicating if a field with the given name was
  27535. // cleared in this mutation.
  27536. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  27537. _, ok := m.clearedFields[name]
  27538. return ok
  27539. }
  27540. // ClearField clears the value of the field with the given name. It returns an
  27541. // error if the field is not defined in the schema.
  27542. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  27543. switch name {
  27544. case usagestatistichour.FieldStatus:
  27545. m.ClearStatus()
  27546. return nil
  27547. case usagestatistichour.FieldDeletedAt:
  27548. m.ClearDeletedAt()
  27549. return nil
  27550. case usagestatistichour.FieldBotID:
  27551. m.ClearBotID()
  27552. return nil
  27553. case usagestatistichour.FieldOrganizationID:
  27554. m.ClearOrganizationID()
  27555. return nil
  27556. }
  27557. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  27558. }
  27559. // ResetField resets all changes in the mutation for the field with the given name.
  27560. // It returns an error if the field is not defined in the schema.
  27561. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  27562. switch name {
  27563. case usagestatistichour.FieldCreatedAt:
  27564. m.ResetCreatedAt()
  27565. return nil
  27566. case usagestatistichour.FieldUpdatedAt:
  27567. m.ResetUpdatedAt()
  27568. return nil
  27569. case usagestatistichour.FieldStatus:
  27570. m.ResetStatus()
  27571. return nil
  27572. case usagestatistichour.FieldDeletedAt:
  27573. m.ResetDeletedAt()
  27574. return nil
  27575. case usagestatistichour.FieldAddtime:
  27576. m.ResetAddtime()
  27577. return nil
  27578. case usagestatistichour.FieldType:
  27579. m.ResetType()
  27580. return nil
  27581. case usagestatistichour.FieldBotID:
  27582. m.ResetBotID()
  27583. return nil
  27584. case usagestatistichour.FieldOrganizationID:
  27585. m.ResetOrganizationID()
  27586. return nil
  27587. case usagestatistichour.FieldAiResponse:
  27588. m.ResetAiResponse()
  27589. return nil
  27590. case usagestatistichour.FieldSopRun:
  27591. m.ResetSopRun()
  27592. return nil
  27593. case usagestatistichour.FieldTotalFriend:
  27594. m.ResetTotalFriend()
  27595. return nil
  27596. case usagestatistichour.FieldTotalGroup:
  27597. m.ResetTotalGroup()
  27598. return nil
  27599. case usagestatistichour.FieldAccountBalance:
  27600. m.ResetAccountBalance()
  27601. return nil
  27602. case usagestatistichour.FieldConsumeToken:
  27603. m.ResetConsumeToken()
  27604. return nil
  27605. case usagestatistichour.FieldActiveUser:
  27606. m.ResetActiveUser()
  27607. return nil
  27608. case usagestatistichour.FieldNewUser:
  27609. m.ResetNewUser()
  27610. return nil
  27611. case usagestatistichour.FieldLabelDist:
  27612. m.ResetLabelDist()
  27613. return nil
  27614. }
  27615. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27616. }
  27617. // AddedEdges returns all edge names that were set/added in this mutation.
  27618. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  27619. edges := make([]string, 0, 0)
  27620. return edges
  27621. }
  27622. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27623. // name in this mutation.
  27624. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  27625. return nil
  27626. }
  27627. // RemovedEdges returns all edge names that were removed in this mutation.
  27628. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  27629. edges := make([]string, 0, 0)
  27630. return edges
  27631. }
  27632. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27633. // the given name in this mutation.
  27634. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  27635. return nil
  27636. }
  27637. // ClearedEdges returns all edge names that were cleared in this mutation.
  27638. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  27639. edges := make([]string, 0, 0)
  27640. return edges
  27641. }
  27642. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27643. // was cleared in this mutation.
  27644. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  27645. return false
  27646. }
  27647. // ClearEdge clears the value of the edge with the given name. It returns an error
  27648. // if that edge is not defined in the schema.
  27649. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  27650. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  27651. }
  27652. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27653. // It returns an error if the edge is not defined in the schema.
  27654. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  27655. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  27656. }
  27657. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  27658. type UsageStatisticMonthMutation struct {
  27659. config
  27660. op Op
  27661. typ string
  27662. id *uint64
  27663. created_at *time.Time
  27664. updated_at *time.Time
  27665. status *uint8
  27666. addstatus *int8
  27667. deleted_at *time.Time
  27668. addtime *uint64
  27669. addaddtime *int64
  27670. _type *int
  27671. add_type *int
  27672. bot_id *string
  27673. organization_id *uint64
  27674. addorganization_id *int64
  27675. ai_response *uint64
  27676. addai_response *int64
  27677. sop_run *uint64
  27678. addsop_run *int64
  27679. total_friend *uint64
  27680. addtotal_friend *int64
  27681. total_group *uint64
  27682. addtotal_group *int64
  27683. account_balance *uint64
  27684. addaccount_balance *int64
  27685. consume_token *uint64
  27686. addconsume_token *int64
  27687. active_user *uint64
  27688. addactive_user *int64
  27689. new_user *int64
  27690. addnew_user *int64
  27691. label_dist *[]custom_types.LabelDist
  27692. appendlabel_dist []custom_types.LabelDist
  27693. clearedFields map[string]struct{}
  27694. done bool
  27695. oldValue func(context.Context) (*UsageStatisticMonth, error)
  27696. predicates []predicate.UsageStatisticMonth
  27697. }
  27698. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  27699. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  27700. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  27701. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  27702. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  27703. m := &UsageStatisticMonthMutation{
  27704. config: c,
  27705. op: op,
  27706. typ: TypeUsageStatisticMonth,
  27707. clearedFields: make(map[string]struct{}),
  27708. }
  27709. for _, opt := range opts {
  27710. opt(m)
  27711. }
  27712. return m
  27713. }
  27714. // withUsageStatisticMonthID sets the ID field of the mutation.
  27715. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  27716. return func(m *UsageStatisticMonthMutation) {
  27717. var (
  27718. err error
  27719. once sync.Once
  27720. value *UsageStatisticMonth
  27721. )
  27722. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  27723. once.Do(func() {
  27724. if m.done {
  27725. err = errors.New("querying old values post mutation is not allowed")
  27726. } else {
  27727. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  27728. }
  27729. })
  27730. return value, err
  27731. }
  27732. m.id = &id
  27733. }
  27734. }
  27735. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  27736. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  27737. return func(m *UsageStatisticMonthMutation) {
  27738. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  27739. return node, nil
  27740. }
  27741. m.id = &node.ID
  27742. }
  27743. }
  27744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27745. // executed in a transaction (ent.Tx), a transactional client is returned.
  27746. func (m UsageStatisticMonthMutation) Client() *Client {
  27747. client := &Client{config: m.config}
  27748. client.init()
  27749. return client
  27750. }
  27751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27752. // it returns an error otherwise.
  27753. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  27754. if _, ok := m.driver.(*txDriver); !ok {
  27755. return nil, errors.New("ent: mutation is not running in a transaction")
  27756. }
  27757. tx := &Tx{config: m.config}
  27758. tx.init()
  27759. return tx, nil
  27760. }
  27761. // SetID sets the value of the id field. Note that this
  27762. // operation is only accepted on creation of UsageStatisticMonth entities.
  27763. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  27764. m.id = &id
  27765. }
  27766. // ID returns the ID value in the mutation. Note that the ID is only available
  27767. // if it was provided to the builder or after it was returned from the database.
  27768. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  27769. if m.id == nil {
  27770. return
  27771. }
  27772. return *m.id, true
  27773. }
  27774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27775. // That means, if the mutation is applied within a transaction with an isolation level such
  27776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27777. // or updated by the mutation.
  27778. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  27779. switch {
  27780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27781. id, exists := m.ID()
  27782. if exists {
  27783. return []uint64{id}, nil
  27784. }
  27785. fallthrough
  27786. case m.op.Is(OpUpdate | OpDelete):
  27787. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  27788. default:
  27789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27790. }
  27791. }
  27792. // SetCreatedAt sets the "created_at" field.
  27793. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  27794. m.created_at = &t
  27795. }
  27796. // CreatedAt returns the value of the "created_at" field in the mutation.
  27797. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  27798. v := m.created_at
  27799. if v == nil {
  27800. return
  27801. }
  27802. return *v, true
  27803. }
  27804. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  27805. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27807. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27808. if !m.op.Is(OpUpdateOne) {
  27809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27810. }
  27811. if m.id == nil || m.oldValue == nil {
  27812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27813. }
  27814. oldValue, err := m.oldValue(ctx)
  27815. if err != nil {
  27816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27817. }
  27818. return oldValue.CreatedAt, nil
  27819. }
  27820. // ResetCreatedAt resets all changes to the "created_at" field.
  27821. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  27822. m.created_at = nil
  27823. }
  27824. // SetUpdatedAt sets the "updated_at" field.
  27825. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  27826. m.updated_at = &t
  27827. }
  27828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27829. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  27830. v := m.updated_at
  27831. if v == nil {
  27832. return
  27833. }
  27834. return *v, true
  27835. }
  27836. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  27837. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27839. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27840. if !m.op.Is(OpUpdateOne) {
  27841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27842. }
  27843. if m.id == nil || m.oldValue == nil {
  27844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27845. }
  27846. oldValue, err := m.oldValue(ctx)
  27847. if err != nil {
  27848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27849. }
  27850. return oldValue.UpdatedAt, nil
  27851. }
  27852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27853. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  27854. m.updated_at = nil
  27855. }
  27856. // SetStatus sets the "status" field.
  27857. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  27858. m.status = &u
  27859. m.addstatus = nil
  27860. }
  27861. // Status returns the value of the "status" field in the mutation.
  27862. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  27863. v := m.status
  27864. if v == nil {
  27865. return
  27866. }
  27867. return *v, true
  27868. }
  27869. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  27870. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27872. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27873. if !m.op.Is(OpUpdateOne) {
  27874. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27875. }
  27876. if m.id == nil || m.oldValue == nil {
  27877. return v, errors.New("OldStatus requires an ID field in the mutation")
  27878. }
  27879. oldValue, err := m.oldValue(ctx)
  27880. if err != nil {
  27881. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27882. }
  27883. return oldValue.Status, nil
  27884. }
  27885. // AddStatus adds u to the "status" field.
  27886. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  27887. if m.addstatus != nil {
  27888. *m.addstatus += u
  27889. } else {
  27890. m.addstatus = &u
  27891. }
  27892. }
  27893. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27894. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  27895. v := m.addstatus
  27896. if v == nil {
  27897. return
  27898. }
  27899. return *v, true
  27900. }
  27901. // ClearStatus clears the value of the "status" field.
  27902. func (m *UsageStatisticMonthMutation) ClearStatus() {
  27903. m.status = nil
  27904. m.addstatus = nil
  27905. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  27906. }
  27907. // StatusCleared returns if the "status" field was cleared in this mutation.
  27908. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  27909. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  27910. return ok
  27911. }
  27912. // ResetStatus resets all changes to the "status" field.
  27913. func (m *UsageStatisticMonthMutation) ResetStatus() {
  27914. m.status = nil
  27915. m.addstatus = nil
  27916. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  27917. }
  27918. // SetDeletedAt sets the "deleted_at" field.
  27919. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  27920. m.deleted_at = &t
  27921. }
  27922. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27923. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  27924. v := m.deleted_at
  27925. if v == nil {
  27926. return
  27927. }
  27928. return *v, true
  27929. }
  27930. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  27931. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27933. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27934. if !m.op.Is(OpUpdateOne) {
  27935. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27936. }
  27937. if m.id == nil || m.oldValue == nil {
  27938. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27939. }
  27940. oldValue, err := m.oldValue(ctx)
  27941. if err != nil {
  27942. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27943. }
  27944. return oldValue.DeletedAt, nil
  27945. }
  27946. // ClearDeletedAt clears the value of the "deleted_at" field.
  27947. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  27948. m.deleted_at = nil
  27949. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  27950. }
  27951. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27952. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  27953. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  27954. return ok
  27955. }
  27956. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27957. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  27958. m.deleted_at = nil
  27959. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  27960. }
  27961. // SetAddtime sets the "addtime" field.
  27962. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  27963. m.addtime = &u
  27964. m.addaddtime = nil
  27965. }
  27966. // Addtime returns the value of the "addtime" field in the mutation.
  27967. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  27968. v := m.addtime
  27969. if v == nil {
  27970. return
  27971. }
  27972. return *v, true
  27973. }
  27974. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  27975. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27977. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27978. if !m.op.Is(OpUpdateOne) {
  27979. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27980. }
  27981. if m.id == nil || m.oldValue == nil {
  27982. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27983. }
  27984. oldValue, err := m.oldValue(ctx)
  27985. if err != nil {
  27986. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27987. }
  27988. return oldValue.Addtime, nil
  27989. }
  27990. // AddAddtime adds u to the "addtime" field.
  27991. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  27992. if m.addaddtime != nil {
  27993. *m.addaddtime += u
  27994. } else {
  27995. m.addaddtime = &u
  27996. }
  27997. }
  27998. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27999. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  28000. v := m.addaddtime
  28001. if v == nil {
  28002. return
  28003. }
  28004. return *v, true
  28005. }
  28006. // ResetAddtime resets all changes to the "addtime" field.
  28007. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  28008. m.addtime = nil
  28009. m.addaddtime = nil
  28010. }
  28011. // SetType sets the "type" field.
  28012. func (m *UsageStatisticMonthMutation) SetType(i int) {
  28013. m._type = &i
  28014. m.add_type = nil
  28015. }
  28016. // GetType returns the value of the "type" field in the mutation.
  28017. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  28018. v := m._type
  28019. if v == nil {
  28020. return
  28021. }
  28022. return *v, true
  28023. }
  28024. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  28025. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28027. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  28028. if !m.op.Is(OpUpdateOne) {
  28029. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28030. }
  28031. if m.id == nil || m.oldValue == nil {
  28032. return v, errors.New("OldType requires an ID field in the mutation")
  28033. }
  28034. oldValue, err := m.oldValue(ctx)
  28035. if err != nil {
  28036. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28037. }
  28038. return oldValue.Type, nil
  28039. }
  28040. // AddType adds i to the "type" field.
  28041. func (m *UsageStatisticMonthMutation) AddType(i int) {
  28042. if m.add_type != nil {
  28043. *m.add_type += i
  28044. } else {
  28045. m.add_type = &i
  28046. }
  28047. }
  28048. // AddedType returns the value that was added to the "type" field in this mutation.
  28049. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  28050. v := m.add_type
  28051. if v == nil {
  28052. return
  28053. }
  28054. return *v, true
  28055. }
  28056. // ResetType resets all changes to the "type" field.
  28057. func (m *UsageStatisticMonthMutation) ResetType() {
  28058. m._type = nil
  28059. m.add_type = nil
  28060. }
  28061. // SetBotID sets the "bot_id" field.
  28062. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  28063. m.bot_id = &s
  28064. }
  28065. // BotID returns the value of the "bot_id" field in the mutation.
  28066. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  28067. v := m.bot_id
  28068. if v == nil {
  28069. return
  28070. }
  28071. return *v, true
  28072. }
  28073. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  28074. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28076. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  28077. if !m.op.Is(OpUpdateOne) {
  28078. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28079. }
  28080. if m.id == nil || m.oldValue == nil {
  28081. return v, errors.New("OldBotID requires an ID field in the mutation")
  28082. }
  28083. oldValue, err := m.oldValue(ctx)
  28084. if err != nil {
  28085. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28086. }
  28087. return oldValue.BotID, nil
  28088. }
  28089. // ClearBotID clears the value of the "bot_id" field.
  28090. func (m *UsageStatisticMonthMutation) ClearBotID() {
  28091. m.bot_id = nil
  28092. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  28093. }
  28094. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28095. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  28096. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  28097. return ok
  28098. }
  28099. // ResetBotID resets all changes to the "bot_id" field.
  28100. func (m *UsageStatisticMonthMutation) ResetBotID() {
  28101. m.bot_id = nil
  28102. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  28103. }
  28104. // SetOrganizationID sets the "organization_id" field.
  28105. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  28106. m.organization_id = &u
  28107. m.addorganization_id = nil
  28108. }
  28109. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28110. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  28111. v := m.organization_id
  28112. if v == nil {
  28113. return
  28114. }
  28115. return *v, true
  28116. }
  28117. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  28118. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28120. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28121. if !m.op.Is(OpUpdateOne) {
  28122. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28123. }
  28124. if m.id == nil || m.oldValue == nil {
  28125. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28126. }
  28127. oldValue, err := m.oldValue(ctx)
  28128. if err != nil {
  28129. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28130. }
  28131. return oldValue.OrganizationID, nil
  28132. }
  28133. // AddOrganizationID adds u to the "organization_id" field.
  28134. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  28135. if m.addorganization_id != nil {
  28136. *m.addorganization_id += u
  28137. } else {
  28138. m.addorganization_id = &u
  28139. }
  28140. }
  28141. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28142. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  28143. v := m.addorganization_id
  28144. if v == nil {
  28145. return
  28146. }
  28147. return *v, true
  28148. }
  28149. // ClearOrganizationID clears the value of the "organization_id" field.
  28150. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  28151. m.organization_id = nil
  28152. m.addorganization_id = nil
  28153. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  28154. }
  28155. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28156. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  28157. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  28158. return ok
  28159. }
  28160. // ResetOrganizationID resets all changes to the "organization_id" field.
  28161. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  28162. m.organization_id = nil
  28163. m.addorganization_id = nil
  28164. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  28165. }
  28166. // SetAiResponse sets the "ai_response" field.
  28167. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  28168. m.ai_response = &u
  28169. m.addai_response = nil
  28170. }
  28171. // AiResponse returns the value of the "ai_response" field in the mutation.
  28172. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  28173. v := m.ai_response
  28174. if v == nil {
  28175. return
  28176. }
  28177. return *v, true
  28178. }
  28179. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  28180. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28182. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28183. if !m.op.Is(OpUpdateOne) {
  28184. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28185. }
  28186. if m.id == nil || m.oldValue == nil {
  28187. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28188. }
  28189. oldValue, err := m.oldValue(ctx)
  28190. if err != nil {
  28191. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28192. }
  28193. return oldValue.AiResponse, nil
  28194. }
  28195. // AddAiResponse adds u to the "ai_response" field.
  28196. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  28197. if m.addai_response != nil {
  28198. *m.addai_response += u
  28199. } else {
  28200. m.addai_response = &u
  28201. }
  28202. }
  28203. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28204. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  28205. v := m.addai_response
  28206. if v == nil {
  28207. return
  28208. }
  28209. return *v, true
  28210. }
  28211. // ResetAiResponse resets all changes to the "ai_response" field.
  28212. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  28213. m.ai_response = nil
  28214. m.addai_response = nil
  28215. }
  28216. // SetSopRun sets the "sop_run" field.
  28217. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  28218. m.sop_run = &u
  28219. m.addsop_run = nil
  28220. }
  28221. // SopRun returns the value of the "sop_run" field in the mutation.
  28222. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  28223. v := m.sop_run
  28224. if v == nil {
  28225. return
  28226. }
  28227. return *v, true
  28228. }
  28229. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  28230. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28232. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28233. if !m.op.Is(OpUpdateOne) {
  28234. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28235. }
  28236. if m.id == nil || m.oldValue == nil {
  28237. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28238. }
  28239. oldValue, err := m.oldValue(ctx)
  28240. if err != nil {
  28241. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28242. }
  28243. return oldValue.SopRun, nil
  28244. }
  28245. // AddSopRun adds u to the "sop_run" field.
  28246. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  28247. if m.addsop_run != nil {
  28248. *m.addsop_run += u
  28249. } else {
  28250. m.addsop_run = &u
  28251. }
  28252. }
  28253. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28254. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  28255. v := m.addsop_run
  28256. if v == nil {
  28257. return
  28258. }
  28259. return *v, true
  28260. }
  28261. // ResetSopRun resets all changes to the "sop_run" field.
  28262. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  28263. m.sop_run = nil
  28264. m.addsop_run = nil
  28265. }
  28266. // SetTotalFriend sets the "total_friend" field.
  28267. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  28268. m.total_friend = &u
  28269. m.addtotal_friend = nil
  28270. }
  28271. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28272. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  28273. v := m.total_friend
  28274. if v == nil {
  28275. return
  28276. }
  28277. return *v, true
  28278. }
  28279. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  28280. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28282. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28283. if !m.op.Is(OpUpdateOne) {
  28284. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28285. }
  28286. if m.id == nil || m.oldValue == nil {
  28287. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28288. }
  28289. oldValue, err := m.oldValue(ctx)
  28290. if err != nil {
  28291. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28292. }
  28293. return oldValue.TotalFriend, nil
  28294. }
  28295. // AddTotalFriend adds u to the "total_friend" field.
  28296. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  28297. if m.addtotal_friend != nil {
  28298. *m.addtotal_friend += u
  28299. } else {
  28300. m.addtotal_friend = &u
  28301. }
  28302. }
  28303. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28304. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  28305. v := m.addtotal_friend
  28306. if v == nil {
  28307. return
  28308. }
  28309. return *v, true
  28310. }
  28311. // ResetTotalFriend resets all changes to the "total_friend" field.
  28312. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  28313. m.total_friend = nil
  28314. m.addtotal_friend = nil
  28315. }
  28316. // SetTotalGroup sets the "total_group" field.
  28317. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  28318. m.total_group = &u
  28319. m.addtotal_group = nil
  28320. }
  28321. // TotalGroup returns the value of the "total_group" field in the mutation.
  28322. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  28323. v := m.total_group
  28324. if v == nil {
  28325. return
  28326. }
  28327. return *v, true
  28328. }
  28329. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  28330. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28332. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28333. if !m.op.Is(OpUpdateOne) {
  28334. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28335. }
  28336. if m.id == nil || m.oldValue == nil {
  28337. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28338. }
  28339. oldValue, err := m.oldValue(ctx)
  28340. if err != nil {
  28341. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28342. }
  28343. return oldValue.TotalGroup, nil
  28344. }
  28345. // AddTotalGroup adds u to the "total_group" field.
  28346. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  28347. if m.addtotal_group != nil {
  28348. *m.addtotal_group += u
  28349. } else {
  28350. m.addtotal_group = &u
  28351. }
  28352. }
  28353. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28354. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  28355. v := m.addtotal_group
  28356. if v == nil {
  28357. return
  28358. }
  28359. return *v, true
  28360. }
  28361. // ResetTotalGroup resets all changes to the "total_group" field.
  28362. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  28363. m.total_group = nil
  28364. m.addtotal_group = nil
  28365. }
  28366. // SetAccountBalance sets the "account_balance" field.
  28367. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  28368. m.account_balance = &u
  28369. m.addaccount_balance = nil
  28370. }
  28371. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28372. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  28373. v := m.account_balance
  28374. if v == nil {
  28375. return
  28376. }
  28377. return *v, true
  28378. }
  28379. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  28380. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28382. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28383. if !m.op.Is(OpUpdateOne) {
  28384. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28385. }
  28386. if m.id == nil || m.oldValue == nil {
  28387. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28388. }
  28389. oldValue, err := m.oldValue(ctx)
  28390. if err != nil {
  28391. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28392. }
  28393. return oldValue.AccountBalance, nil
  28394. }
  28395. // AddAccountBalance adds u to the "account_balance" field.
  28396. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  28397. if m.addaccount_balance != nil {
  28398. *m.addaccount_balance += u
  28399. } else {
  28400. m.addaccount_balance = &u
  28401. }
  28402. }
  28403. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28404. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  28405. v := m.addaccount_balance
  28406. if v == nil {
  28407. return
  28408. }
  28409. return *v, true
  28410. }
  28411. // ResetAccountBalance resets all changes to the "account_balance" field.
  28412. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  28413. m.account_balance = nil
  28414. m.addaccount_balance = nil
  28415. }
  28416. // SetConsumeToken sets the "consume_token" field.
  28417. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  28418. m.consume_token = &u
  28419. m.addconsume_token = nil
  28420. }
  28421. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28422. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  28423. v := m.consume_token
  28424. if v == nil {
  28425. return
  28426. }
  28427. return *v, true
  28428. }
  28429. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  28430. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28432. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28433. if !m.op.Is(OpUpdateOne) {
  28434. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28435. }
  28436. if m.id == nil || m.oldValue == nil {
  28437. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28438. }
  28439. oldValue, err := m.oldValue(ctx)
  28440. if err != nil {
  28441. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28442. }
  28443. return oldValue.ConsumeToken, nil
  28444. }
  28445. // AddConsumeToken adds u to the "consume_token" field.
  28446. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  28447. if m.addconsume_token != nil {
  28448. *m.addconsume_token += u
  28449. } else {
  28450. m.addconsume_token = &u
  28451. }
  28452. }
  28453. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28454. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  28455. v := m.addconsume_token
  28456. if v == nil {
  28457. return
  28458. }
  28459. return *v, true
  28460. }
  28461. // ResetConsumeToken resets all changes to the "consume_token" field.
  28462. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  28463. m.consume_token = nil
  28464. m.addconsume_token = nil
  28465. }
  28466. // SetActiveUser sets the "active_user" field.
  28467. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  28468. m.active_user = &u
  28469. m.addactive_user = nil
  28470. }
  28471. // ActiveUser returns the value of the "active_user" field in the mutation.
  28472. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  28473. v := m.active_user
  28474. if v == nil {
  28475. return
  28476. }
  28477. return *v, true
  28478. }
  28479. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  28480. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28482. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28483. if !m.op.Is(OpUpdateOne) {
  28484. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28485. }
  28486. if m.id == nil || m.oldValue == nil {
  28487. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28488. }
  28489. oldValue, err := m.oldValue(ctx)
  28490. if err != nil {
  28491. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28492. }
  28493. return oldValue.ActiveUser, nil
  28494. }
  28495. // AddActiveUser adds u to the "active_user" field.
  28496. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  28497. if m.addactive_user != nil {
  28498. *m.addactive_user += u
  28499. } else {
  28500. m.addactive_user = &u
  28501. }
  28502. }
  28503. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28504. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  28505. v := m.addactive_user
  28506. if v == nil {
  28507. return
  28508. }
  28509. return *v, true
  28510. }
  28511. // ResetActiveUser resets all changes to the "active_user" field.
  28512. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  28513. m.active_user = nil
  28514. m.addactive_user = nil
  28515. }
  28516. // SetNewUser sets the "new_user" field.
  28517. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  28518. m.new_user = &i
  28519. m.addnew_user = nil
  28520. }
  28521. // NewUser returns the value of the "new_user" field in the mutation.
  28522. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  28523. v := m.new_user
  28524. if v == nil {
  28525. return
  28526. }
  28527. return *v, true
  28528. }
  28529. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  28530. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28532. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28533. if !m.op.Is(OpUpdateOne) {
  28534. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28535. }
  28536. if m.id == nil || m.oldValue == nil {
  28537. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28538. }
  28539. oldValue, err := m.oldValue(ctx)
  28540. if err != nil {
  28541. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28542. }
  28543. return oldValue.NewUser, nil
  28544. }
  28545. // AddNewUser adds i to the "new_user" field.
  28546. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  28547. if m.addnew_user != nil {
  28548. *m.addnew_user += i
  28549. } else {
  28550. m.addnew_user = &i
  28551. }
  28552. }
  28553. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28554. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  28555. v := m.addnew_user
  28556. if v == nil {
  28557. return
  28558. }
  28559. return *v, true
  28560. }
  28561. // ResetNewUser resets all changes to the "new_user" field.
  28562. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  28563. m.new_user = nil
  28564. m.addnew_user = nil
  28565. }
  28566. // SetLabelDist sets the "label_dist" field.
  28567. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28568. m.label_dist = &ctd
  28569. m.appendlabel_dist = nil
  28570. }
  28571. // LabelDist returns the value of the "label_dist" field in the mutation.
  28572. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28573. v := m.label_dist
  28574. if v == nil {
  28575. return
  28576. }
  28577. return *v, true
  28578. }
  28579. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  28580. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28582. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28583. if !m.op.Is(OpUpdateOne) {
  28584. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28585. }
  28586. if m.id == nil || m.oldValue == nil {
  28587. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28588. }
  28589. oldValue, err := m.oldValue(ctx)
  28590. if err != nil {
  28591. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28592. }
  28593. return oldValue.LabelDist, nil
  28594. }
  28595. // AppendLabelDist adds ctd to the "label_dist" field.
  28596. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28597. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28598. }
  28599. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28600. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28601. if len(m.appendlabel_dist) == 0 {
  28602. return nil, false
  28603. }
  28604. return m.appendlabel_dist, true
  28605. }
  28606. // ResetLabelDist resets all changes to the "label_dist" field.
  28607. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  28608. m.label_dist = nil
  28609. m.appendlabel_dist = nil
  28610. }
  28611. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  28612. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  28613. m.predicates = append(m.predicates, ps...)
  28614. }
  28615. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  28616. // users can use type-assertion to append predicates that do not depend on any generated package.
  28617. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  28618. p := make([]predicate.UsageStatisticMonth, len(ps))
  28619. for i := range ps {
  28620. p[i] = ps[i]
  28621. }
  28622. m.Where(p...)
  28623. }
  28624. // Op returns the operation name.
  28625. func (m *UsageStatisticMonthMutation) Op() Op {
  28626. return m.op
  28627. }
  28628. // SetOp allows setting the mutation operation.
  28629. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  28630. m.op = op
  28631. }
  28632. // Type returns the node type of this mutation (UsageStatisticMonth).
  28633. func (m *UsageStatisticMonthMutation) Type() string {
  28634. return m.typ
  28635. }
  28636. // Fields returns all fields that were changed during this mutation. Note that in
  28637. // order to get all numeric fields that were incremented/decremented, call
  28638. // AddedFields().
  28639. func (m *UsageStatisticMonthMutation) Fields() []string {
  28640. fields := make([]string, 0, 17)
  28641. if m.created_at != nil {
  28642. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  28643. }
  28644. if m.updated_at != nil {
  28645. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  28646. }
  28647. if m.status != nil {
  28648. fields = append(fields, usagestatisticmonth.FieldStatus)
  28649. }
  28650. if m.deleted_at != nil {
  28651. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  28652. }
  28653. if m.addtime != nil {
  28654. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28655. }
  28656. if m._type != nil {
  28657. fields = append(fields, usagestatisticmonth.FieldType)
  28658. }
  28659. if m.bot_id != nil {
  28660. fields = append(fields, usagestatisticmonth.FieldBotID)
  28661. }
  28662. if m.organization_id != nil {
  28663. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28664. }
  28665. if m.ai_response != nil {
  28666. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28667. }
  28668. if m.sop_run != nil {
  28669. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28670. }
  28671. if m.total_friend != nil {
  28672. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28673. }
  28674. if m.total_group != nil {
  28675. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28676. }
  28677. if m.account_balance != nil {
  28678. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28679. }
  28680. if m.consume_token != nil {
  28681. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28682. }
  28683. if m.active_user != nil {
  28684. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28685. }
  28686. if m.new_user != nil {
  28687. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28688. }
  28689. if m.label_dist != nil {
  28690. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  28691. }
  28692. return fields
  28693. }
  28694. // Field returns the value of a field with the given name. The second boolean
  28695. // return value indicates that this field was not set, or was not defined in the
  28696. // schema.
  28697. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  28698. switch name {
  28699. case usagestatisticmonth.FieldCreatedAt:
  28700. return m.CreatedAt()
  28701. case usagestatisticmonth.FieldUpdatedAt:
  28702. return m.UpdatedAt()
  28703. case usagestatisticmonth.FieldStatus:
  28704. return m.Status()
  28705. case usagestatisticmonth.FieldDeletedAt:
  28706. return m.DeletedAt()
  28707. case usagestatisticmonth.FieldAddtime:
  28708. return m.Addtime()
  28709. case usagestatisticmonth.FieldType:
  28710. return m.GetType()
  28711. case usagestatisticmonth.FieldBotID:
  28712. return m.BotID()
  28713. case usagestatisticmonth.FieldOrganizationID:
  28714. return m.OrganizationID()
  28715. case usagestatisticmonth.FieldAiResponse:
  28716. return m.AiResponse()
  28717. case usagestatisticmonth.FieldSopRun:
  28718. return m.SopRun()
  28719. case usagestatisticmonth.FieldTotalFriend:
  28720. return m.TotalFriend()
  28721. case usagestatisticmonth.FieldTotalGroup:
  28722. return m.TotalGroup()
  28723. case usagestatisticmonth.FieldAccountBalance:
  28724. return m.AccountBalance()
  28725. case usagestatisticmonth.FieldConsumeToken:
  28726. return m.ConsumeToken()
  28727. case usagestatisticmonth.FieldActiveUser:
  28728. return m.ActiveUser()
  28729. case usagestatisticmonth.FieldNewUser:
  28730. return m.NewUser()
  28731. case usagestatisticmonth.FieldLabelDist:
  28732. return m.LabelDist()
  28733. }
  28734. return nil, false
  28735. }
  28736. // OldField returns the old value of the field from the database. An error is
  28737. // returned if the mutation operation is not UpdateOne, or the query to the
  28738. // database failed.
  28739. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28740. switch name {
  28741. case usagestatisticmonth.FieldCreatedAt:
  28742. return m.OldCreatedAt(ctx)
  28743. case usagestatisticmonth.FieldUpdatedAt:
  28744. return m.OldUpdatedAt(ctx)
  28745. case usagestatisticmonth.FieldStatus:
  28746. return m.OldStatus(ctx)
  28747. case usagestatisticmonth.FieldDeletedAt:
  28748. return m.OldDeletedAt(ctx)
  28749. case usagestatisticmonth.FieldAddtime:
  28750. return m.OldAddtime(ctx)
  28751. case usagestatisticmonth.FieldType:
  28752. return m.OldType(ctx)
  28753. case usagestatisticmonth.FieldBotID:
  28754. return m.OldBotID(ctx)
  28755. case usagestatisticmonth.FieldOrganizationID:
  28756. return m.OldOrganizationID(ctx)
  28757. case usagestatisticmonth.FieldAiResponse:
  28758. return m.OldAiResponse(ctx)
  28759. case usagestatisticmonth.FieldSopRun:
  28760. return m.OldSopRun(ctx)
  28761. case usagestatisticmonth.FieldTotalFriend:
  28762. return m.OldTotalFriend(ctx)
  28763. case usagestatisticmonth.FieldTotalGroup:
  28764. return m.OldTotalGroup(ctx)
  28765. case usagestatisticmonth.FieldAccountBalance:
  28766. return m.OldAccountBalance(ctx)
  28767. case usagestatisticmonth.FieldConsumeToken:
  28768. return m.OldConsumeToken(ctx)
  28769. case usagestatisticmonth.FieldActiveUser:
  28770. return m.OldActiveUser(ctx)
  28771. case usagestatisticmonth.FieldNewUser:
  28772. return m.OldNewUser(ctx)
  28773. case usagestatisticmonth.FieldLabelDist:
  28774. return m.OldLabelDist(ctx)
  28775. }
  28776. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28777. }
  28778. // SetField sets the value of a field with the given name. It returns an error if
  28779. // the field is not defined in the schema, or if the type mismatched the field
  28780. // type.
  28781. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  28782. switch name {
  28783. case usagestatisticmonth.FieldCreatedAt:
  28784. v, ok := value.(time.Time)
  28785. if !ok {
  28786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28787. }
  28788. m.SetCreatedAt(v)
  28789. return nil
  28790. case usagestatisticmonth.FieldUpdatedAt:
  28791. v, ok := value.(time.Time)
  28792. if !ok {
  28793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28794. }
  28795. m.SetUpdatedAt(v)
  28796. return nil
  28797. case usagestatisticmonth.FieldStatus:
  28798. v, ok := value.(uint8)
  28799. if !ok {
  28800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28801. }
  28802. m.SetStatus(v)
  28803. return nil
  28804. case usagestatisticmonth.FieldDeletedAt:
  28805. v, ok := value.(time.Time)
  28806. if !ok {
  28807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28808. }
  28809. m.SetDeletedAt(v)
  28810. return nil
  28811. case usagestatisticmonth.FieldAddtime:
  28812. v, ok := value.(uint64)
  28813. if !ok {
  28814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28815. }
  28816. m.SetAddtime(v)
  28817. return nil
  28818. case usagestatisticmonth.FieldType:
  28819. v, ok := value.(int)
  28820. if !ok {
  28821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28822. }
  28823. m.SetType(v)
  28824. return nil
  28825. case usagestatisticmonth.FieldBotID:
  28826. v, ok := value.(string)
  28827. if !ok {
  28828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28829. }
  28830. m.SetBotID(v)
  28831. return nil
  28832. case usagestatisticmonth.FieldOrganizationID:
  28833. v, ok := value.(uint64)
  28834. if !ok {
  28835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28836. }
  28837. m.SetOrganizationID(v)
  28838. return nil
  28839. case usagestatisticmonth.FieldAiResponse:
  28840. v, ok := value.(uint64)
  28841. if !ok {
  28842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28843. }
  28844. m.SetAiResponse(v)
  28845. return nil
  28846. case usagestatisticmonth.FieldSopRun:
  28847. v, ok := value.(uint64)
  28848. if !ok {
  28849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28850. }
  28851. m.SetSopRun(v)
  28852. return nil
  28853. case usagestatisticmonth.FieldTotalFriend:
  28854. v, ok := value.(uint64)
  28855. if !ok {
  28856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28857. }
  28858. m.SetTotalFriend(v)
  28859. return nil
  28860. case usagestatisticmonth.FieldTotalGroup:
  28861. v, ok := value.(uint64)
  28862. if !ok {
  28863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28864. }
  28865. m.SetTotalGroup(v)
  28866. return nil
  28867. case usagestatisticmonth.FieldAccountBalance:
  28868. v, ok := value.(uint64)
  28869. if !ok {
  28870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28871. }
  28872. m.SetAccountBalance(v)
  28873. return nil
  28874. case usagestatisticmonth.FieldConsumeToken:
  28875. v, ok := value.(uint64)
  28876. if !ok {
  28877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28878. }
  28879. m.SetConsumeToken(v)
  28880. return nil
  28881. case usagestatisticmonth.FieldActiveUser:
  28882. v, ok := value.(uint64)
  28883. if !ok {
  28884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28885. }
  28886. m.SetActiveUser(v)
  28887. return nil
  28888. case usagestatisticmonth.FieldNewUser:
  28889. v, ok := value.(int64)
  28890. if !ok {
  28891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28892. }
  28893. m.SetNewUser(v)
  28894. return nil
  28895. case usagestatisticmonth.FieldLabelDist:
  28896. v, ok := value.([]custom_types.LabelDist)
  28897. if !ok {
  28898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28899. }
  28900. m.SetLabelDist(v)
  28901. return nil
  28902. }
  28903. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28904. }
  28905. // AddedFields returns all numeric fields that were incremented/decremented during
  28906. // this mutation.
  28907. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  28908. var fields []string
  28909. if m.addstatus != nil {
  28910. fields = append(fields, usagestatisticmonth.FieldStatus)
  28911. }
  28912. if m.addaddtime != nil {
  28913. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28914. }
  28915. if m.add_type != nil {
  28916. fields = append(fields, usagestatisticmonth.FieldType)
  28917. }
  28918. if m.addorganization_id != nil {
  28919. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28920. }
  28921. if m.addai_response != nil {
  28922. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28923. }
  28924. if m.addsop_run != nil {
  28925. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28926. }
  28927. if m.addtotal_friend != nil {
  28928. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28929. }
  28930. if m.addtotal_group != nil {
  28931. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28932. }
  28933. if m.addaccount_balance != nil {
  28934. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28935. }
  28936. if m.addconsume_token != nil {
  28937. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28938. }
  28939. if m.addactive_user != nil {
  28940. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28941. }
  28942. if m.addnew_user != nil {
  28943. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28944. }
  28945. return fields
  28946. }
  28947. // AddedField returns the numeric value that was incremented/decremented on a field
  28948. // with the given name. The second boolean return value indicates that this field
  28949. // was not set, or was not defined in the schema.
  28950. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  28951. switch name {
  28952. case usagestatisticmonth.FieldStatus:
  28953. return m.AddedStatus()
  28954. case usagestatisticmonth.FieldAddtime:
  28955. return m.AddedAddtime()
  28956. case usagestatisticmonth.FieldType:
  28957. return m.AddedType()
  28958. case usagestatisticmonth.FieldOrganizationID:
  28959. return m.AddedOrganizationID()
  28960. case usagestatisticmonth.FieldAiResponse:
  28961. return m.AddedAiResponse()
  28962. case usagestatisticmonth.FieldSopRun:
  28963. return m.AddedSopRun()
  28964. case usagestatisticmonth.FieldTotalFriend:
  28965. return m.AddedTotalFriend()
  28966. case usagestatisticmonth.FieldTotalGroup:
  28967. return m.AddedTotalGroup()
  28968. case usagestatisticmonth.FieldAccountBalance:
  28969. return m.AddedAccountBalance()
  28970. case usagestatisticmonth.FieldConsumeToken:
  28971. return m.AddedConsumeToken()
  28972. case usagestatisticmonth.FieldActiveUser:
  28973. return m.AddedActiveUser()
  28974. case usagestatisticmonth.FieldNewUser:
  28975. return m.AddedNewUser()
  28976. }
  28977. return nil, false
  28978. }
  28979. // AddField adds the value to the field with the given name. It returns an error if
  28980. // the field is not defined in the schema, or if the type mismatched the field
  28981. // type.
  28982. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  28983. switch name {
  28984. case usagestatisticmonth.FieldStatus:
  28985. v, ok := value.(int8)
  28986. if !ok {
  28987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28988. }
  28989. m.AddStatus(v)
  28990. return nil
  28991. case usagestatisticmonth.FieldAddtime:
  28992. v, ok := value.(int64)
  28993. if !ok {
  28994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28995. }
  28996. m.AddAddtime(v)
  28997. return nil
  28998. case usagestatisticmonth.FieldType:
  28999. v, ok := value.(int)
  29000. if !ok {
  29001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29002. }
  29003. m.AddType(v)
  29004. return nil
  29005. case usagestatisticmonth.FieldOrganizationID:
  29006. v, ok := value.(int64)
  29007. if !ok {
  29008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29009. }
  29010. m.AddOrganizationID(v)
  29011. return nil
  29012. case usagestatisticmonth.FieldAiResponse:
  29013. v, ok := value.(int64)
  29014. if !ok {
  29015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29016. }
  29017. m.AddAiResponse(v)
  29018. return nil
  29019. case usagestatisticmonth.FieldSopRun:
  29020. v, ok := value.(int64)
  29021. if !ok {
  29022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29023. }
  29024. m.AddSopRun(v)
  29025. return nil
  29026. case usagestatisticmonth.FieldTotalFriend:
  29027. v, ok := value.(int64)
  29028. if !ok {
  29029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29030. }
  29031. m.AddTotalFriend(v)
  29032. return nil
  29033. case usagestatisticmonth.FieldTotalGroup:
  29034. v, ok := value.(int64)
  29035. if !ok {
  29036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29037. }
  29038. m.AddTotalGroup(v)
  29039. return nil
  29040. case usagestatisticmonth.FieldAccountBalance:
  29041. v, ok := value.(int64)
  29042. if !ok {
  29043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29044. }
  29045. m.AddAccountBalance(v)
  29046. return nil
  29047. case usagestatisticmonth.FieldConsumeToken:
  29048. v, ok := value.(int64)
  29049. if !ok {
  29050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29051. }
  29052. m.AddConsumeToken(v)
  29053. return nil
  29054. case usagestatisticmonth.FieldActiveUser:
  29055. v, ok := value.(int64)
  29056. if !ok {
  29057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29058. }
  29059. m.AddActiveUser(v)
  29060. return nil
  29061. case usagestatisticmonth.FieldNewUser:
  29062. v, ok := value.(int64)
  29063. if !ok {
  29064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29065. }
  29066. m.AddNewUser(v)
  29067. return nil
  29068. }
  29069. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  29070. }
  29071. // ClearedFields returns all nullable fields that were cleared during this
  29072. // mutation.
  29073. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  29074. var fields []string
  29075. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  29076. fields = append(fields, usagestatisticmonth.FieldStatus)
  29077. }
  29078. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  29079. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  29080. }
  29081. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  29082. fields = append(fields, usagestatisticmonth.FieldBotID)
  29083. }
  29084. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  29085. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29086. }
  29087. return fields
  29088. }
  29089. // FieldCleared returns a boolean indicating if a field with the given name was
  29090. // cleared in this mutation.
  29091. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  29092. _, ok := m.clearedFields[name]
  29093. return ok
  29094. }
  29095. // ClearField clears the value of the field with the given name. It returns an
  29096. // error if the field is not defined in the schema.
  29097. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  29098. switch name {
  29099. case usagestatisticmonth.FieldStatus:
  29100. m.ClearStatus()
  29101. return nil
  29102. case usagestatisticmonth.FieldDeletedAt:
  29103. m.ClearDeletedAt()
  29104. return nil
  29105. case usagestatisticmonth.FieldBotID:
  29106. m.ClearBotID()
  29107. return nil
  29108. case usagestatisticmonth.FieldOrganizationID:
  29109. m.ClearOrganizationID()
  29110. return nil
  29111. }
  29112. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  29113. }
  29114. // ResetField resets all changes in the mutation for the field with the given name.
  29115. // It returns an error if the field is not defined in the schema.
  29116. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  29117. switch name {
  29118. case usagestatisticmonth.FieldCreatedAt:
  29119. m.ResetCreatedAt()
  29120. return nil
  29121. case usagestatisticmonth.FieldUpdatedAt:
  29122. m.ResetUpdatedAt()
  29123. return nil
  29124. case usagestatisticmonth.FieldStatus:
  29125. m.ResetStatus()
  29126. return nil
  29127. case usagestatisticmonth.FieldDeletedAt:
  29128. m.ResetDeletedAt()
  29129. return nil
  29130. case usagestatisticmonth.FieldAddtime:
  29131. m.ResetAddtime()
  29132. return nil
  29133. case usagestatisticmonth.FieldType:
  29134. m.ResetType()
  29135. return nil
  29136. case usagestatisticmonth.FieldBotID:
  29137. m.ResetBotID()
  29138. return nil
  29139. case usagestatisticmonth.FieldOrganizationID:
  29140. m.ResetOrganizationID()
  29141. return nil
  29142. case usagestatisticmonth.FieldAiResponse:
  29143. m.ResetAiResponse()
  29144. return nil
  29145. case usagestatisticmonth.FieldSopRun:
  29146. m.ResetSopRun()
  29147. return nil
  29148. case usagestatisticmonth.FieldTotalFriend:
  29149. m.ResetTotalFriend()
  29150. return nil
  29151. case usagestatisticmonth.FieldTotalGroup:
  29152. m.ResetTotalGroup()
  29153. return nil
  29154. case usagestatisticmonth.FieldAccountBalance:
  29155. m.ResetAccountBalance()
  29156. return nil
  29157. case usagestatisticmonth.FieldConsumeToken:
  29158. m.ResetConsumeToken()
  29159. return nil
  29160. case usagestatisticmonth.FieldActiveUser:
  29161. m.ResetActiveUser()
  29162. return nil
  29163. case usagestatisticmonth.FieldNewUser:
  29164. m.ResetNewUser()
  29165. return nil
  29166. case usagestatisticmonth.FieldLabelDist:
  29167. m.ResetLabelDist()
  29168. return nil
  29169. }
  29170. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29171. }
  29172. // AddedEdges returns all edge names that were set/added in this mutation.
  29173. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  29174. edges := make([]string, 0, 0)
  29175. return edges
  29176. }
  29177. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29178. // name in this mutation.
  29179. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  29180. return nil
  29181. }
  29182. // RemovedEdges returns all edge names that were removed in this mutation.
  29183. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  29184. edges := make([]string, 0, 0)
  29185. return edges
  29186. }
  29187. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29188. // the given name in this mutation.
  29189. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  29190. return nil
  29191. }
  29192. // ClearedEdges returns all edge names that were cleared in this mutation.
  29193. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  29194. edges := make([]string, 0, 0)
  29195. return edges
  29196. }
  29197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29198. // was cleared in this mutation.
  29199. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  29200. return false
  29201. }
  29202. // ClearEdge clears the value of the edge with the given name. It returns an error
  29203. // if that edge is not defined in the schema.
  29204. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  29205. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  29206. }
  29207. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29208. // It returns an error if the edge is not defined in the schema.
  29209. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  29210. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  29211. }
  29212. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  29213. type UsageTotalMutation struct {
  29214. config
  29215. op Op
  29216. typ string
  29217. id *uint64
  29218. created_at *time.Time
  29219. updated_at *time.Time
  29220. status *uint8
  29221. addstatus *int8
  29222. _type *int
  29223. add_type *int
  29224. bot_id *string
  29225. total_tokens *uint64
  29226. addtotal_tokens *int64
  29227. start_index *uint64
  29228. addstart_index *int64
  29229. end_index *uint64
  29230. addend_index *int64
  29231. organization_id *uint64
  29232. addorganization_id *int64
  29233. clearedFields map[string]struct{}
  29234. done bool
  29235. oldValue func(context.Context) (*UsageTotal, error)
  29236. predicates []predicate.UsageTotal
  29237. }
  29238. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  29239. // usagetotalOption allows management of the mutation configuration using functional options.
  29240. type usagetotalOption func(*UsageTotalMutation)
  29241. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  29242. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  29243. m := &UsageTotalMutation{
  29244. config: c,
  29245. op: op,
  29246. typ: TypeUsageTotal,
  29247. clearedFields: make(map[string]struct{}),
  29248. }
  29249. for _, opt := range opts {
  29250. opt(m)
  29251. }
  29252. return m
  29253. }
  29254. // withUsageTotalID sets the ID field of the mutation.
  29255. func withUsageTotalID(id uint64) usagetotalOption {
  29256. return func(m *UsageTotalMutation) {
  29257. var (
  29258. err error
  29259. once sync.Once
  29260. value *UsageTotal
  29261. )
  29262. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  29263. once.Do(func() {
  29264. if m.done {
  29265. err = errors.New("querying old values post mutation is not allowed")
  29266. } else {
  29267. value, err = m.Client().UsageTotal.Get(ctx, id)
  29268. }
  29269. })
  29270. return value, err
  29271. }
  29272. m.id = &id
  29273. }
  29274. }
  29275. // withUsageTotal sets the old UsageTotal of the mutation.
  29276. func withUsageTotal(node *UsageTotal) usagetotalOption {
  29277. return func(m *UsageTotalMutation) {
  29278. m.oldValue = func(context.Context) (*UsageTotal, error) {
  29279. return node, nil
  29280. }
  29281. m.id = &node.ID
  29282. }
  29283. }
  29284. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29285. // executed in a transaction (ent.Tx), a transactional client is returned.
  29286. func (m UsageTotalMutation) Client() *Client {
  29287. client := &Client{config: m.config}
  29288. client.init()
  29289. return client
  29290. }
  29291. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29292. // it returns an error otherwise.
  29293. func (m UsageTotalMutation) Tx() (*Tx, error) {
  29294. if _, ok := m.driver.(*txDriver); !ok {
  29295. return nil, errors.New("ent: mutation is not running in a transaction")
  29296. }
  29297. tx := &Tx{config: m.config}
  29298. tx.init()
  29299. return tx, nil
  29300. }
  29301. // SetID sets the value of the id field. Note that this
  29302. // operation is only accepted on creation of UsageTotal entities.
  29303. func (m *UsageTotalMutation) SetID(id uint64) {
  29304. m.id = &id
  29305. }
  29306. // ID returns the ID value in the mutation. Note that the ID is only available
  29307. // if it was provided to the builder or after it was returned from the database.
  29308. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  29309. if m.id == nil {
  29310. return
  29311. }
  29312. return *m.id, true
  29313. }
  29314. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29315. // That means, if the mutation is applied within a transaction with an isolation level such
  29316. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29317. // or updated by the mutation.
  29318. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  29319. switch {
  29320. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29321. id, exists := m.ID()
  29322. if exists {
  29323. return []uint64{id}, nil
  29324. }
  29325. fallthrough
  29326. case m.op.Is(OpUpdate | OpDelete):
  29327. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  29328. default:
  29329. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29330. }
  29331. }
  29332. // SetCreatedAt sets the "created_at" field.
  29333. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  29334. m.created_at = &t
  29335. }
  29336. // CreatedAt returns the value of the "created_at" field in the mutation.
  29337. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  29338. v := m.created_at
  29339. if v == nil {
  29340. return
  29341. }
  29342. return *v, true
  29343. }
  29344. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  29345. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29347. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29348. if !m.op.Is(OpUpdateOne) {
  29349. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29350. }
  29351. if m.id == nil || m.oldValue == nil {
  29352. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29353. }
  29354. oldValue, err := m.oldValue(ctx)
  29355. if err != nil {
  29356. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29357. }
  29358. return oldValue.CreatedAt, nil
  29359. }
  29360. // ResetCreatedAt resets all changes to the "created_at" field.
  29361. func (m *UsageTotalMutation) ResetCreatedAt() {
  29362. m.created_at = nil
  29363. }
  29364. // SetUpdatedAt sets the "updated_at" field.
  29365. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  29366. m.updated_at = &t
  29367. }
  29368. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29369. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  29370. v := m.updated_at
  29371. if v == nil {
  29372. return
  29373. }
  29374. return *v, true
  29375. }
  29376. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  29377. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29379. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29380. if !m.op.Is(OpUpdateOne) {
  29381. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29382. }
  29383. if m.id == nil || m.oldValue == nil {
  29384. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29385. }
  29386. oldValue, err := m.oldValue(ctx)
  29387. if err != nil {
  29388. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29389. }
  29390. return oldValue.UpdatedAt, nil
  29391. }
  29392. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29393. func (m *UsageTotalMutation) ResetUpdatedAt() {
  29394. m.updated_at = nil
  29395. }
  29396. // SetStatus sets the "status" field.
  29397. func (m *UsageTotalMutation) SetStatus(u uint8) {
  29398. m.status = &u
  29399. m.addstatus = nil
  29400. }
  29401. // Status returns the value of the "status" field in the mutation.
  29402. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  29403. v := m.status
  29404. if v == nil {
  29405. return
  29406. }
  29407. return *v, true
  29408. }
  29409. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  29410. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29412. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29413. if !m.op.Is(OpUpdateOne) {
  29414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29415. }
  29416. if m.id == nil || m.oldValue == nil {
  29417. return v, errors.New("OldStatus requires an ID field in the mutation")
  29418. }
  29419. oldValue, err := m.oldValue(ctx)
  29420. if err != nil {
  29421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29422. }
  29423. return oldValue.Status, nil
  29424. }
  29425. // AddStatus adds u to the "status" field.
  29426. func (m *UsageTotalMutation) AddStatus(u int8) {
  29427. if m.addstatus != nil {
  29428. *m.addstatus += u
  29429. } else {
  29430. m.addstatus = &u
  29431. }
  29432. }
  29433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29434. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  29435. v := m.addstatus
  29436. if v == nil {
  29437. return
  29438. }
  29439. return *v, true
  29440. }
  29441. // ClearStatus clears the value of the "status" field.
  29442. func (m *UsageTotalMutation) ClearStatus() {
  29443. m.status = nil
  29444. m.addstatus = nil
  29445. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  29446. }
  29447. // StatusCleared returns if the "status" field was cleared in this mutation.
  29448. func (m *UsageTotalMutation) StatusCleared() bool {
  29449. _, ok := m.clearedFields[usagetotal.FieldStatus]
  29450. return ok
  29451. }
  29452. // ResetStatus resets all changes to the "status" field.
  29453. func (m *UsageTotalMutation) ResetStatus() {
  29454. m.status = nil
  29455. m.addstatus = nil
  29456. delete(m.clearedFields, usagetotal.FieldStatus)
  29457. }
  29458. // SetType sets the "type" field.
  29459. func (m *UsageTotalMutation) SetType(i int) {
  29460. m._type = &i
  29461. m.add_type = nil
  29462. }
  29463. // GetType returns the value of the "type" field in the mutation.
  29464. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  29465. v := m._type
  29466. if v == nil {
  29467. return
  29468. }
  29469. return *v, true
  29470. }
  29471. // OldType returns the old "type" field's value of the UsageTotal entity.
  29472. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29474. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  29475. if !m.op.Is(OpUpdateOne) {
  29476. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29477. }
  29478. if m.id == nil || m.oldValue == nil {
  29479. return v, errors.New("OldType requires an ID field in the mutation")
  29480. }
  29481. oldValue, err := m.oldValue(ctx)
  29482. if err != nil {
  29483. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29484. }
  29485. return oldValue.Type, nil
  29486. }
  29487. // AddType adds i to the "type" field.
  29488. func (m *UsageTotalMutation) AddType(i int) {
  29489. if m.add_type != nil {
  29490. *m.add_type += i
  29491. } else {
  29492. m.add_type = &i
  29493. }
  29494. }
  29495. // AddedType returns the value that was added to the "type" field in this mutation.
  29496. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  29497. v := m.add_type
  29498. if v == nil {
  29499. return
  29500. }
  29501. return *v, true
  29502. }
  29503. // ClearType clears the value of the "type" field.
  29504. func (m *UsageTotalMutation) ClearType() {
  29505. m._type = nil
  29506. m.add_type = nil
  29507. m.clearedFields[usagetotal.FieldType] = struct{}{}
  29508. }
  29509. // TypeCleared returns if the "type" field was cleared in this mutation.
  29510. func (m *UsageTotalMutation) TypeCleared() bool {
  29511. _, ok := m.clearedFields[usagetotal.FieldType]
  29512. return ok
  29513. }
  29514. // ResetType resets all changes to the "type" field.
  29515. func (m *UsageTotalMutation) ResetType() {
  29516. m._type = nil
  29517. m.add_type = nil
  29518. delete(m.clearedFields, usagetotal.FieldType)
  29519. }
  29520. // SetBotID sets the "bot_id" field.
  29521. func (m *UsageTotalMutation) SetBotID(s string) {
  29522. m.bot_id = &s
  29523. }
  29524. // BotID returns the value of the "bot_id" field in the mutation.
  29525. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  29526. v := m.bot_id
  29527. if v == nil {
  29528. return
  29529. }
  29530. return *v, true
  29531. }
  29532. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  29533. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29535. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  29536. if !m.op.Is(OpUpdateOne) {
  29537. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29538. }
  29539. if m.id == nil || m.oldValue == nil {
  29540. return v, errors.New("OldBotID requires an ID field in the mutation")
  29541. }
  29542. oldValue, err := m.oldValue(ctx)
  29543. if err != nil {
  29544. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29545. }
  29546. return oldValue.BotID, nil
  29547. }
  29548. // ResetBotID resets all changes to the "bot_id" field.
  29549. func (m *UsageTotalMutation) ResetBotID() {
  29550. m.bot_id = nil
  29551. }
  29552. // SetTotalTokens sets the "total_tokens" field.
  29553. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  29554. m.total_tokens = &u
  29555. m.addtotal_tokens = nil
  29556. }
  29557. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29558. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  29559. v := m.total_tokens
  29560. if v == nil {
  29561. return
  29562. }
  29563. return *v, true
  29564. }
  29565. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  29566. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29568. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29569. if !m.op.Is(OpUpdateOne) {
  29570. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29571. }
  29572. if m.id == nil || m.oldValue == nil {
  29573. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29574. }
  29575. oldValue, err := m.oldValue(ctx)
  29576. if err != nil {
  29577. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29578. }
  29579. return oldValue.TotalTokens, nil
  29580. }
  29581. // AddTotalTokens adds u to the "total_tokens" field.
  29582. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  29583. if m.addtotal_tokens != nil {
  29584. *m.addtotal_tokens += u
  29585. } else {
  29586. m.addtotal_tokens = &u
  29587. }
  29588. }
  29589. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29590. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  29591. v := m.addtotal_tokens
  29592. if v == nil {
  29593. return
  29594. }
  29595. return *v, true
  29596. }
  29597. // ClearTotalTokens clears the value of the "total_tokens" field.
  29598. func (m *UsageTotalMutation) ClearTotalTokens() {
  29599. m.total_tokens = nil
  29600. m.addtotal_tokens = nil
  29601. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  29602. }
  29603. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29604. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  29605. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  29606. return ok
  29607. }
  29608. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29609. func (m *UsageTotalMutation) ResetTotalTokens() {
  29610. m.total_tokens = nil
  29611. m.addtotal_tokens = nil
  29612. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  29613. }
  29614. // SetStartIndex sets the "start_index" field.
  29615. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  29616. m.start_index = &u
  29617. m.addstart_index = nil
  29618. }
  29619. // StartIndex returns the value of the "start_index" field in the mutation.
  29620. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  29621. v := m.start_index
  29622. if v == nil {
  29623. return
  29624. }
  29625. return *v, true
  29626. }
  29627. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  29628. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29630. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  29631. if !m.op.Is(OpUpdateOne) {
  29632. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  29633. }
  29634. if m.id == nil || m.oldValue == nil {
  29635. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  29636. }
  29637. oldValue, err := m.oldValue(ctx)
  29638. if err != nil {
  29639. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  29640. }
  29641. return oldValue.StartIndex, nil
  29642. }
  29643. // AddStartIndex adds u to the "start_index" field.
  29644. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  29645. if m.addstart_index != nil {
  29646. *m.addstart_index += u
  29647. } else {
  29648. m.addstart_index = &u
  29649. }
  29650. }
  29651. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  29652. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  29653. v := m.addstart_index
  29654. if v == nil {
  29655. return
  29656. }
  29657. return *v, true
  29658. }
  29659. // ClearStartIndex clears the value of the "start_index" field.
  29660. func (m *UsageTotalMutation) ClearStartIndex() {
  29661. m.start_index = nil
  29662. m.addstart_index = nil
  29663. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  29664. }
  29665. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  29666. func (m *UsageTotalMutation) StartIndexCleared() bool {
  29667. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  29668. return ok
  29669. }
  29670. // ResetStartIndex resets all changes to the "start_index" field.
  29671. func (m *UsageTotalMutation) ResetStartIndex() {
  29672. m.start_index = nil
  29673. m.addstart_index = nil
  29674. delete(m.clearedFields, usagetotal.FieldStartIndex)
  29675. }
  29676. // SetEndIndex sets the "end_index" field.
  29677. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  29678. m.end_index = &u
  29679. m.addend_index = nil
  29680. }
  29681. // EndIndex returns the value of the "end_index" field in the mutation.
  29682. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  29683. v := m.end_index
  29684. if v == nil {
  29685. return
  29686. }
  29687. return *v, true
  29688. }
  29689. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  29690. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29692. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  29693. if !m.op.Is(OpUpdateOne) {
  29694. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  29695. }
  29696. if m.id == nil || m.oldValue == nil {
  29697. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  29698. }
  29699. oldValue, err := m.oldValue(ctx)
  29700. if err != nil {
  29701. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  29702. }
  29703. return oldValue.EndIndex, nil
  29704. }
  29705. // AddEndIndex adds u to the "end_index" field.
  29706. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  29707. if m.addend_index != nil {
  29708. *m.addend_index += u
  29709. } else {
  29710. m.addend_index = &u
  29711. }
  29712. }
  29713. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  29714. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  29715. v := m.addend_index
  29716. if v == nil {
  29717. return
  29718. }
  29719. return *v, true
  29720. }
  29721. // ClearEndIndex clears the value of the "end_index" field.
  29722. func (m *UsageTotalMutation) ClearEndIndex() {
  29723. m.end_index = nil
  29724. m.addend_index = nil
  29725. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  29726. }
  29727. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  29728. func (m *UsageTotalMutation) EndIndexCleared() bool {
  29729. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  29730. return ok
  29731. }
  29732. // ResetEndIndex resets all changes to the "end_index" field.
  29733. func (m *UsageTotalMutation) ResetEndIndex() {
  29734. m.end_index = nil
  29735. m.addend_index = nil
  29736. delete(m.clearedFields, usagetotal.FieldEndIndex)
  29737. }
  29738. // SetOrganizationID sets the "organization_id" field.
  29739. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  29740. m.organization_id = &u
  29741. m.addorganization_id = nil
  29742. }
  29743. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29744. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  29745. v := m.organization_id
  29746. if v == nil {
  29747. return
  29748. }
  29749. return *v, true
  29750. }
  29751. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  29752. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29754. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29755. if !m.op.Is(OpUpdateOne) {
  29756. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29757. }
  29758. if m.id == nil || m.oldValue == nil {
  29759. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29760. }
  29761. oldValue, err := m.oldValue(ctx)
  29762. if err != nil {
  29763. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29764. }
  29765. return oldValue.OrganizationID, nil
  29766. }
  29767. // AddOrganizationID adds u to the "organization_id" field.
  29768. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  29769. if m.addorganization_id != nil {
  29770. *m.addorganization_id += u
  29771. } else {
  29772. m.addorganization_id = &u
  29773. }
  29774. }
  29775. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29776. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  29777. v := m.addorganization_id
  29778. if v == nil {
  29779. return
  29780. }
  29781. return *v, true
  29782. }
  29783. // ClearOrganizationID clears the value of the "organization_id" field.
  29784. func (m *UsageTotalMutation) ClearOrganizationID() {
  29785. m.organization_id = nil
  29786. m.addorganization_id = nil
  29787. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  29788. }
  29789. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29790. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  29791. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  29792. return ok
  29793. }
  29794. // ResetOrganizationID resets all changes to the "organization_id" field.
  29795. func (m *UsageTotalMutation) ResetOrganizationID() {
  29796. m.organization_id = nil
  29797. m.addorganization_id = nil
  29798. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  29799. }
  29800. // Where appends a list predicates to the UsageTotalMutation builder.
  29801. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  29802. m.predicates = append(m.predicates, ps...)
  29803. }
  29804. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  29805. // users can use type-assertion to append predicates that do not depend on any generated package.
  29806. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  29807. p := make([]predicate.UsageTotal, len(ps))
  29808. for i := range ps {
  29809. p[i] = ps[i]
  29810. }
  29811. m.Where(p...)
  29812. }
  29813. // Op returns the operation name.
  29814. func (m *UsageTotalMutation) Op() Op {
  29815. return m.op
  29816. }
  29817. // SetOp allows setting the mutation operation.
  29818. func (m *UsageTotalMutation) SetOp(op Op) {
  29819. m.op = op
  29820. }
  29821. // Type returns the node type of this mutation (UsageTotal).
  29822. func (m *UsageTotalMutation) Type() string {
  29823. return m.typ
  29824. }
  29825. // Fields returns all fields that were changed during this mutation. Note that in
  29826. // order to get all numeric fields that were incremented/decremented, call
  29827. // AddedFields().
  29828. func (m *UsageTotalMutation) Fields() []string {
  29829. fields := make([]string, 0, 9)
  29830. if m.created_at != nil {
  29831. fields = append(fields, usagetotal.FieldCreatedAt)
  29832. }
  29833. if m.updated_at != nil {
  29834. fields = append(fields, usagetotal.FieldUpdatedAt)
  29835. }
  29836. if m.status != nil {
  29837. fields = append(fields, usagetotal.FieldStatus)
  29838. }
  29839. if m._type != nil {
  29840. fields = append(fields, usagetotal.FieldType)
  29841. }
  29842. if m.bot_id != nil {
  29843. fields = append(fields, usagetotal.FieldBotID)
  29844. }
  29845. if m.total_tokens != nil {
  29846. fields = append(fields, usagetotal.FieldTotalTokens)
  29847. }
  29848. if m.start_index != nil {
  29849. fields = append(fields, usagetotal.FieldStartIndex)
  29850. }
  29851. if m.end_index != nil {
  29852. fields = append(fields, usagetotal.FieldEndIndex)
  29853. }
  29854. if m.organization_id != nil {
  29855. fields = append(fields, usagetotal.FieldOrganizationID)
  29856. }
  29857. return fields
  29858. }
  29859. // Field returns the value of a field with the given name. The second boolean
  29860. // return value indicates that this field was not set, or was not defined in the
  29861. // schema.
  29862. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  29863. switch name {
  29864. case usagetotal.FieldCreatedAt:
  29865. return m.CreatedAt()
  29866. case usagetotal.FieldUpdatedAt:
  29867. return m.UpdatedAt()
  29868. case usagetotal.FieldStatus:
  29869. return m.Status()
  29870. case usagetotal.FieldType:
  29871. return m.GetType()
  29872. case usagetotal.FieldBotID:
  29873. return m.BotID()
  29874. case usagetotal.FieldTotalTokens:
  29875. return m.TotalTokens()
  29876. case usagetotal.FieldStartIndex:
  29877. return m.StartIndex()
  29878. case usagetotal.FieldEndIndex:
  29879. return m.EndIndex()
  29880. case usagetotal.FieldOrganizationID:
  29881. return m.OrganizationID()
  29882. }
  29883. return nil, false
  29884. }
  29885. // OldField returns the old value of the field from the database. An error is
  29886. // returned if the mutation operation is not UpdateOne, or the query to the
  29887. // database failed.
  29888. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29889. switch name {
  29890. case usagetotal.FieldCreatedAt:
  29891. return m.OldCreatedAt(ctx)
  29892. case usagetotal.FieldUpdatedAt:
  29893. return m.OldUpdatedAt(ctx)
  29894. case usagetotal.FieldStatus:
  29895. return m.OldStatus(ctx)
  29896. case usagetotal.FieldType:
  29897. return m.OldType(ctx)
  29898. case usagetotal.FieldBotID:
  29899. return m.OldBotID(ctx)
  29900. case usagetotal.FieldTotalTokens:
  29901. return m.OldTotalTokens(ctx)
  29902. case usagetotal.FieldStartIndex:
  29903. return m.OldStartIndex(ctx)
  29904. case usagetotal.FieldEndIndex:
  29905. return m.OldEndIndex(ctx)
  29906. case usagetotal.FieldOrganizationID:
  29907. return m.OldOrganizationID(ctx)
  29908. }
  29909. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  29910. }
  29911. // SetField sets the value of a field with the given name. It returns an error if
  29912. // the field is not defined in the schema, or if the type mismatched the field
  29913. // type.
  29914. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  29915. switch name {
  29916. case usagetotal.FieldCreatedAt:
  29917. v, ok := value.(time.Time)
  29918. if !ok {
  29919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29920. }
  29921. m.SetCreatedAt(v)
  29922. return nil
  29923. case usagetotal.FieldUpdatedAt:
  29924. v, ok := value.(time.Time)
  29925. if !ok {
  29926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29927. }
  29928. m.SetUpdatedAt(v)
  29929. return nil
  29930. case usagetotal.FieldStatus:
  29931. v, ok := value.(uint8)
  29932. if !ok {
  29933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29934. }
  29935. m.SetStatus(v)
  29936. return nil
  29937. case usagetotal.FieldType:
  29938. v, ok := value.(int)
  29939. if !ok {
  29940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29941. }
  29942. m.SetType(v)
  29943. return nil
  29944. case usagetotal.FieldBotID:
  29945. v, ok := value.(string)
  29946. if !ok {
  29947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29948. }
  29949. m.SetBotID(v)
  29950. return nil
  29951. case usagetotal.FieldTotalTokens:
  29952. v, ok := value.(uint64)
  29953. if !ok {
  29954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29955. }
  29956. m.SetTotalTokens(v)
  29957. return nil
  29958. case usagetotal.FieldStartIndex:
  29959. v, ok := value.(uint64)
  29960. if !ok {
  29961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29962. }
  29963. m.SetStartIndex(v)
  29964. return nil
  29965. case usagetotal.FieldEndIndex:
  29966. v, ok := value.(uint64)
  29967. if !ok {
  29968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29969. }
  29970. m.SetEndIndex(v)
  29971. return nil
  29972. case usagetotal.FieldOrganizationID:
  29973. v, ok := value.(uint64)
  29974. if !ok {
  29975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29976. }
  29977. m.SetOrganizationID(v)
  29978. return nil
  29979. }
  29980. return fmt.Errorf("unknown UsageTotal field %s", name)
  29981. }
  29982. // AddedFields returns all numeric fields that were incremented/decremented during
  29983. // this mutation.
  29984. func (m *UsageTotalMutation) AddedFields() []string {
  29985. var fields []string
  29986. if m.addstatus != nil {
  29987. fields = append(fields, usagetotal.FieldStatus)
  29988. }
  29989. if m.add_type != nil {
  29990. fields = append(fields, usagetotal.FieldType)
  29991. }
  29992. if m.addtotal_tokens != nil {
  29993. fields = append(fields, usagetotal.FieldTotalTokens)
  29994. }
  29995. if m.addstart_index != nil {
  29996. fields = append(fields, usagetotal.FieldStartIndex)
  29997. }
  29998. if m.addend_index != nil {
  29999. fields = append(fields, usagetotal.FieldEndIndex)
  30000. }
  30001. if m.addorganization_id != nil {
  30002. fields = append(fields, usagetotal.FieldOrganizationID)
  30003. }
  30004. return fields
  30005. }
  30006. // AddedField returns the numeric value that was incremented/decremented on a field
  30007. // with the given name. The second boolean return value indicates that this field
  30008. // was not set, or was not defined in the schema.
  30009. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  30010. switch name {
  30011. case usagetotal.FieldStatus:
  30012. return m.AddedStatus()
  30013. case usagetotal.FieldType:
  30014. return m.AddedType()
  30015. case usagetotal.FieldTotalTokens:
  30016. return m.AddedTotalTokens()
  30017. case usagetotal.FieldStartIndex:
  30018. return m.AddedStartIndex()
  30019. case usagetotal.FieldEndIndex:
  30020. return m.AddedEndIndex()
  30021. case usagetotal.FieldOrganizationID:
  30022. return m.AddedOrganizationID()
  30023. }
  30024. return nil, false
  30025. }
  30026. // AddField adds the value to the field with the given name. It returns an error if
  30027. // the field is not defined in the schema, or if the type mismatched the field
  30028. // type.
  30029. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  30030. switch name {
  30031. case usagetotal.FieldStatus:
  30032. v, ok := value.(int8)
  30033. if !ok {
  30034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30035. }
  30036. m.AddStatus(v)
  30037. return nil
  30038. case usagetotal.FieldType:
  30039. v, ok := value.(int)
  30040. if !ok {
  30041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30042. }
  30043. m.AddType(v)
  30044. return nil
  30045. case usagetotal.FieldTotalTokens:
  30046. v, ok := value.(int64)
  30047. if !ok {
  30048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30049. }
  30050. m.AddTotalTokens(v)
  30051. return nil
  30052. case usagetotal.FieldStartIndex:
  30053. v, ok := value.(int64)
  30054. if !ok {
  30055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30056. }
  30057. m.AddStartIndex(v)
  30058. return nil
  30059. case usagetotal.FieldEndIndex:
  30060. v, ok := value.(int64)
  30061. if !ok {
  30062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30063. }
  30064. m.AddEndIndex(v)
  30065. return nil
  30066. case usagetotal.FieldOrganizationID:
  30067. v, ok := value.(int64)
  30068. if !ok {
  30069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30070. }
  30071. m.AddOrganizationID(v)
  30072. return nil
  30073. }
  30074. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  30075. }
  30076. // ClearedFields returns all nullable fields that were cleared during this
  30077. // mutation.
  30078. func (m *UsageTotalMutation) ClearedFields() []string {
  30079. var fields []string
  30080. if m.FieldCleared(usagetotal.FieldStatus) {
  30081. fields = append(fields, usagetotal.FieldStatus)
  30082. }
  30083. if m.FieldCleared(usagetotal.FieldType) {
  30084. fields = append(fields, usagetotal.FieldType)
  30085. }
  30086. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  30087. fields = append(fields, usagetotal.FieldTotalTokens)
  30088. }
  30089. if m.FieldCleared(usagetotal.FieldStartIndex) {
  30090. fields = append(fields, usagetotal.FieldStartIndex)
  30091. }
  30092. if m.FieldCleared(usagetotal.FieldEndIndex) {
  30093. fields = append(fields, usagetotal.FieldEndIndex)
  30094. }
  30095. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  30096. fields = append(fields, usagetotal.FieldOrganizationID)
  30097. }
  30098. return fields
  30099. }
  30100. // FieldCleared returns a boolean indicating if a field with the given name was
  30101. // cleared in this mutation.
  30102. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  30103. _, ok := m.clearedFields[name]
  30104. return ok
  30105. }
  30106. // ClearField clears the value of the field with the given name. It returns an
  30107. // error if the field is not defined in the schema.
  30108. func (m *UsageTotalMutation) ClearField(name string) error {
  30109. switch name {
  30110. case usagetotal.FieldStatus:
  30111. m.ClearStatus()
  30112. return nil
  30113. case usagetotal.FieldType:
  30114. m.ClearType()
  30115. return nil
  30116. case usagetotal.FieldTotalTokens:
  30117. m.ClearTotalTokens()
  30118. return nil
  30119. case usagetotal.FieldStartIndex:
  30120. m.ClearStartIndex()
  30121. return nil
  30122. case usagetotal.FieldEndIndex:
  30123. m.ClearEndIndex()
  30124. return nil
  30125. case usagetotal.FieldOrganizationID:
  30126. m.ClearOrganizationID()
  30127. return nil
  30128. }
  30129. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  30130. }
  30131. // ResetField resets all changes in the mutation for the field with the given name.
  30132. // It returns an error if the field is not defined in the schema.
  30133. func (m *UsageTotalMutation) ResetField(name string) error {
  30134. switch name {
  30135. case usagetotal.FieldCreatedAt:
  30136. m.ResetCreatedAt()
  30137. return nil
  30138. case usagetotal.FieldUpdatedAt:
  30139. m.ResetUpdatedAt()
  30140. return nil
  30141. case usagetotal.FieldStatus:
  30142. m.ResetStatus()
  30143. return nil
  30144. case usagetotal.FieldType:
  30145. m.ResetType()
  30146. return nil
  30147. case usagetotal.FieldBotID:
  30148. m.ResetBotID()
  30149. return nil
  30150. case usagetotal.FieldTotalTokens:
  30151. m.ResetTotalTokens()
  30152. return nil
  30153. case usagetotal.FieldStartIndex:
  30154. m.ResetStartIndex()
  30155. return nil
  30156. case usagetotal.FieldEndIndex:
  30157. m.ResetEndIndex()
  30158. return nil
  30159. case usagetotal.FieldOrganizationID:
  30160. m.ResetOrganizationID()
  30161. return nil
  30162. }
  30163. return fmt.Errorf("unknown UsageTotal field %s", name)
  30164. }
  30165. // AddedEdges returns all edge names that were set/added in this mutation.
  30166. func (m *UsageTotalMutation) AddedEdges() []string {
  30167. edges := make([]string, 0, 0)
  30168. return edges
  30169. }
  30170. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30171. // name in this mutation.
  30172. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  30173. return nil
  30174. }
  30175. // RemovedEdges returns all edge names that were removed in this mutation.
  30176. func (m *UsageTotalMutation) RemovedEdges() []string {
  30177. edges := make([]string, 0, 0)
  30178. return edges
  30179. }
  30180. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30181. // the given name in this mutation.
  30182. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  30183. return nil
  30184. }
  30185. // ClearedEdges returns all edge names that were cleared in this mutation.
  30186. func (m *UsageTotalMutation) ClearedEdges() []string {
  30187. edges := make([]string, 0, 0)
  30188. return edges
  30189. }
  30190. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30191. // was cleared in this mutation.
  30192. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  30193. return false
  30194. }
  30195. // ClearEdge clears the value of the edge with the given name. It returns an error
  30196. // if that edge is not defined in the schema.
  30197. func (m *UsageTotalMutation) ClearEdge(name string) error {
  30198. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  30199. }
  30200. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30201. // It returns an error if the edge is not defined in the schema.
  30202. func (m *UsageTotalMutation) ResetEdge(name string) error {
  30203. return fmt.Errorf("unknown UsageTotal edge %s", name)
  30204. }
  30205. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  30206. type WorkExperienceMutation struct {
  30207. config
  30208. op Op
  30209. typ string
  30210. id *uint64
  30211. created_at *time.Time
  30212. updated_at *time.Time
  30213. deleted_at *time.Time
  30214. start_date *time.Time
  30215. end_date *time.Time
  30216. company *string
  30217. experience *string
  30218. organization_id *uint64
  30219. addorganization_id *int64
  30220. clearedFields map[string]struct{}
  30221. employee *uint64
  30222. clearedemployee bool
  30223. done bool
  30224. oldValue func(context.Context) (*WorkExperience, error)
  30225. predicates []predicate.WorkExperience
  30226. }
  30227. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  30228. // workexperienceOption allows management of the mutation configuration using functional options.
  30229. type workexperienceOption func(*WorkExperienceMutation)
  30230. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  30231. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  30232. m := &WorkExperienceMutation{
  30233. config: c,
  30234. op: op,
  30235. typ: TypeWorkExperience,
  30236. clearedFields: make(map[string]struct{}),
  30237. }
  30238. for _, opt := range opts {
  30239. opt(m)
  30240. }
  30241. return m
  30242. }
  30243. // withWorkExperienceID sets the ID field of the mutation.
  30244. func withWorkExperienceID(id uint64) workexperienceOption {
  30245. return func(m *WorkExperienceMutation) {
  30246. var (
  30247. err error
  30248. once sync.Once
  30249. value *WorkExperience
  30250. )
  30251. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  30252. once.Do(func() {
  30253. if m.done {
  30254. err = errors.New("querying old values post mutation is not allowed")
  30255. } else {
  30256. value, err = m.Client().WorkExperience.Get(ctx, id)
  30257. }
  30258. })
  30259. return value, err
  30260. }
  30261. m.id = &id
  30262. }
  30263. }
  30264. // withWorkExperience sets the old WorkExperience of the mutation.
  30265. func withWorkExperience(node *WorkExperience) workexperienceOption {
  30266. return func(m *WorkExperienceMutation) {
  30267. m.oldValue = func(context.Context) (*WorkExperience, error) {
  30268. return node, nil
  30269. }
  30270. m.id = &node.ID
  30271. }
  30272. }
  30273. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30274. // executed in a transaction (ent.Tx), a transactional client is returned.
  30275. func (m WorkExperienceMutation) Client() *Client {
  30276. client := &Client{config: m.config}
  30277. client.init()
  30278. return client
  30279. }
  30280. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30281. // it returns an error otherwise.
  30282. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  30283. if _, ok := m.driver.(*txDriver); !ok {
  30284. return nil, errors.New("ent: mutation is not running in a transaction")
  30285. }
  30286. tx := &Tx{config: m.config}
  30287. tx.init()
  30288. return tx, nil
  30289. }
  30290. // SetID sets the value of the id field. Note that this
  30291. // operation is only accepted on creation of WorkExperience entities.
  30292. func (m *WorkExperienceMutation) SetID(id uint64) {
  30293. m.id = &id
  30294. }
  30295. // ID returns the ID value in the mutation. Note that the ID is only available
  30296. // if it was provided to the builder or after it was returned from the database.
  30297. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  30298. if m.id == nil {
  30299. return
  30300. }
  30301. return *m.id, true
  30302. }
  30303. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30304. // That means, if the mutation is applied within a transaction with an isolation level such
  30305. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30306. // or updated by the mutation.
  30307. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  30308. switch {
  30309. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30310. id, exists := m.ID()
  30311. if exists {
  30312. return []uint64{id}, nil
  30313. }
  30314. fallthrough
  30315. case m.op.Is(OpUpdate | OpDelete):
  30316. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  30317. default:
  30318. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30319. }
  30320. }
  30321. // SetCreatedAt sets the "created_at" field.
  30322. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  30323. m.created_at = &t
  30324. }
  30325. // CreatedAt returns the value of the "created_at" field in the mutation.
  30326. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  30327. v := m.created_at
  30328. if v == nil {
  30329. return
  30330. }
  30331. return *v, true
  30332. }
  30333. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  30334. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30336. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30337. if !m.op.Is(OpUpdateOne) {
  30338. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30339. }
  30340. if m.id == nil || m.oldValue == nil {
  30341. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30342. }
  30343. oldValue, err := m.oldValue(ctx)
  30344. if err != nil {
  30345. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30346. }
  30347. return oldValue.CreatedAt, nil
  30348. }
  30349. // ResetCreatedAt resets all changes to the "created_at" field.
  30350. func (m *WorkExperienceMutation) ResetCreatedAt() {
  30351. m.created_at = nil
  30352. }
  30353. // SetUpdatedAt sets the "updated_at" field.
  30354. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  30355. m.updated_at = &t
  30356. }
  30357. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30358. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  30359. v := m.updated_at
  30360. if v == nil {
  30361. return
  30362. }
  30363. return *v, true
  30364. }
  30365. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  30366. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30368. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30369. if !m.op.Is(OpUpdateOne) {
  30370. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30371. }
  30372. if m.id == nil || m.oldValue == nil {
  30373. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30374. }
  30375. oldValue, err := m.oldValue(ctx)
  30376. if err != nil {
  30377. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30378. }
  30379. return oldValue.UpdatedAt, nil
  30380. }
  30381. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30382. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  30383. m.updated_at = nil
  30384. }
  30385. // SetDeletedAt sets the "deleted_at" field.
  30386. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  30387. m.deleted_at = &t
  30388. }
  30389. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30390. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  30391. v := m.deleted_at
  30392. if v == nil {
  30393. return
  30394. }
  30395. return *v, true
  30396. }
  30397. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  30398. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30400. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30401. if !m.op.Is(OpUpdateOne) {
  30402. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30403. }
  30404. if m.id == nil || m.oldValue == nil {
  30405. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30406. }
  30407. oldValue, err := m.oldValue(ctx)
  30408. if err != nil {
  30409. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30410. }
  30411. return oldValue.DeletedAt, nil
  30412. }
  30413. // ClearDeletedAt clears the value of the "deleted_at" field.
  30414. func (m *WorkExperienceMutation) ClearDeletedAt() {
  30415. m.deleted_at = nil
  30416. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  30417. }
  30418. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30419. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  30420. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  30421. return ok
  30422. }
  30423. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30424. func (m *WorkExperienceMutation) ResetDeletedAt() {
  30425. m.deleted_at = nil
  30426. delete(m.clearedFields, workexperience.FieldDeletedAt)
  30427. }
  30428. // SetEmployeeID sets the "employee_id" field.
  30429. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  30430. m.employee = &u
  30431. }
  30432. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30433. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  30434. v := m.employee
  30435. if v == nil {
  30436. return
  30437. }
  30438. return *v, true
  30439. }
  30440. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  30441. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30443. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30444. if !m.op.Is(OpUpdateOne) {
  30445. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30446. }
  30447. if m.id == nil || m.oldValue == nil {
  30448. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30449. }
  30450. oldValue, err := m.oldValue(ctx)
  30451. if err != nil {
  30452. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30453. }
  30454. return oldValue.EmployeeID, nil
  30455. }
  30456. // ResetEmployeeID resets all changes to the "employee_id" field.
  30457. func (m *WorkExperienceMutation) ResetEmployeeID() {
  30458. m.employee = nil
  30459. }
  30460. // SetStartDate sets the "start_date" field.
  30461. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  30462. m.start_date = &t
  30463. }
  30464. // StartDate returns the value of the "start_date" field in the mutation.
  30465. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  30466. v := m.start_date
  30467. if v == nil {
  30468. return
  30469. }
  30470. return *v, true
  30471. }
  30472. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  30473. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30475. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  30476. if !m.op.Is(OpUpdateOne) {
  30477. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  30478. }
  30479. if m.id == nil || m.oldValue == nil {
  30480. return v, errors.New("OldStartDate requires an ID field in the mutation")
  30481. }
  30482. oldValue, err := m.oldValue(ctx)
  30483. if err != nil {
  30484. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  30485. }
  30486. return oldValue.StartDate, nil
  30487. }
  30488. // ResetStartDate resets all changes to the "start_date" field.
  30489. func (m *WorkExperienceMutation) ResetStartDate() {
  30490. m.start_date = nil
  30491. }
  30492. // SetEndDate sets the "end_date" field.
  30493. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  30494. m.end_date = &t
  30495. }
  30496. // EndDate returns the value of the "end_date" field in the mutation.
  30497. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  30498. v := m.end_date
  30499. if v == nil {
  30500. return
  30501. }
  30502. return *v, true
  30503. }
  30504. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  30505. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30507. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  30508. if !m.op.Is(OpUpdateOne) {
  30509. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  30510. }
  30511. if m.id == nil || m.oldValue == nil {
  30512. return v, errors.New("OldEndDate requires an ID field in the mutation")
  30513. }
  30514. oldValue, err := m.oldValue(ctx)
  30515. if err != nil {
  30516. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  30517. }
  30518. return oldValue.EndDate, nil
  30519. }
  30520. // ResetEndDate resets all changes to the "end_date" field.
  30521. func (m *WorkExperienceMutation) ResetEndDate() {
  30522. m.end_date = nil
  30523. }
  30524. // SetCompany sets the "company" field.
  30525. func (m *WorkExperienceMutation) SetCompany(s string) {
  30526. m.company = &s
  30527. }
  30528. // Company returns the value of the "company" field in the mutation.
  30529. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  30530. v := m.company
  30531. if v == nil {
  30532. return
  30533. }
  30534. return *v, true
  30535. }
  30536. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  30537. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30539. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  30540. if !m.op.Is(OpUpdateOne) {
  30541. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  30542. }
  30543. if m.id == nil || m.oldValue == nil {
  30544. return v, errors.New("OldCompany requires an ID field in the mutation")
  30545. }
  30546. oldValue, err := m.oldValue(ctx)
  30547. if err != nil {
  30548. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  30549. }
  30550. return oldValue.Company, nil
  30551. }
  30552. // ResetCompany resets all changes to the "company" field.
  30553. func (m *WorkExperienceMutation) ResetCompany() {
  30554. m.company = nil
  30555. }
  30556. // SetExperience sets the "experience" field.
  30557. func (m *WorkExperienceMutation) SetExperience(s string) {
  30558. m.experience = &s
  30559. }
  30560. // Experience returns the value of the "experience" field in the mutation.
  30561. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  30562. v := m.experience
  30563. if v == nil {
  30564. return
  30565. }
  30566. return *v, true
  30567. }
  30568. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  30569. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30571. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  30572. if !m.op.Is(OpUpdateOne) {
  30573. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  30574. }
  30575. if m.id == nil || m.oldValue == nil {
  30576. return v, errors.New("OldExperience requires an ID field in the mutation")
  30577. }
  30578. oldValue, err := m.oldValue(ctx)
  30579. if err != nil {
  30580. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  30581. }
  30582. return oldValue.Experience, nil
  30583. }
  30584. // ResetExperience resets all changes to the "experience" field.
  30585. func (m *WorkExperienceMutation) ResetExperience() {
  30586. m.experience = nil
  30587. }
  30588. // SetOrganizationID sets the "organization_id" field.
  30589. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  30590. m.organization_id = &u
  30591. m.addorganization_id = nil
  30592. }
  30593. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30594. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  30595. v := m.organization_id
  30596. if v == nil {
  30597. return
  30598. }
  30599. return *v, true
  30600. }
  30601. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  30602. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30604. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30605. if !m.op.Is(OpUpdateOne) {
  30606. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30607. }
  30608. if m.id == nil || m.oldValue == nil {
  30609. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30610. }
  30611. oldValue, err := m.oldValue(ctx)
  30612. if err != nil {
  30613. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30614. }
  30615. return oldValue.OrganizationID, nil
  30616. }
  30617. // AddOrganizationID adds u to the "organization_id" field.
  30618. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  30619. if m.addorganization_id != nil {
  30620. *m.addorganization_id += u
  30621. } else {
  30622. m.addorganization_id = &u
  30623. }
  30624. }
  30625. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30626. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  30627. v := m.addorganization_id
  30628. if v == nil {
  30629. return
  30630. }
  30631. return *v, true
  30632. }
  30633. // ResetOrganizationID resets all changes to the "organization_id" field.
  30634. func (m *WorkExperienceMutation) ResetOrganizationID() {
  30635. m.organization_id = nil
  30636. m.addorganization_id = nil
  30637. }
  30638. // ClearEmployee clears the "employee" edge to the Employee entity.
  30639. func (m *WorkExperienceMutation) ClearEmployee() {
  30640. m.clearedemployee = true
  30641. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  30642. }
  30643. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30644. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  30645. return m.clearedemployee
  30646. }
  30647. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30648. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30649. // EmployeeID instead. It exists only for internal usage by the builders.
  30650. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  30651. if id := m.employee; id != nil {
  30652. ids = append(ids, *id)
  30653. }
  30654. return
  30655. }
  30656. // ResetEmployee resets all changes to the "employee" edge.
  30657. func (m *WorkExperienceMutation) ResetEmployee() {
  30658. m.employee = nil
  30659. m.clearedemployee = false
  30660. }
  30661. // Where appends a list predicates to the WorkExperienceMutation builder.
  30662. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  30663. m.predicates = append(m.predicates, ps...)
  30664. }
  30665. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  30666. // users can use type-assertion to append predicates that do not depend on any generated package.
  30667. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  30668. p := make([]predicate.WorkExperience, len(ps))
  30669. for i := range ps {
  30670. p[i] = ps[i]
  30671. }
  30672. m.Where(p...)
  30673. }
  30674. // Op returns the operation name.
  30675. func (m *WorkExperienceMutation) Op() Op {
  30676. return m.op
  30677. }
  30678. // SetOp allows setting the mutation operation.
  30679. func (m *WorkExperienceMutation) SetOp(op Op) {
  30680. m.op = op
  30681. }
  30682. // Type returns the node type of this mutation (WorkExperience).
  30683. func (m *WorkExperienceMutation) Type() string {
  30684. return m.typ
  30685. }
  30686. // Fields returns all fields that were changed during this mutation. Note that in
  30687. // order to get all numeric fields that were incremented/decremented, call
  30688. // AddedFields().
  30689. func (m *WorkExperienceMutation) Fields() []string {
  30690. fields := make([]string, 0, 9)
  30691. if m.created_at != nil {
  30692. fields = append(fields, workexperience.FieldCreatedAt)
  30693. }
  30694. if m.updated_at != nil {
  30695. fields = append(fields, workexperience.FieldUpdatedAt)
  30696. }
  30697. if m.deleted_at != nil {
  30698. fields = append(fields, workexperience.FieldDeletedAt)
  30699. }
  30700. if m.employee != nil {
  30701. fields = append(fields, workexperience.FieldEmployeeID)
  30702. }
  30703. if m.start_date != nil {
  30704. fields = append(fields, workexperience.FieldStartDate)
  30705. }
  30706. if m.end_date != nil {
  30707. fields = append(fields, workexperience.FieldEndDate)
  30708. }
  30709. if m.company != nil {
  30710. fields = append(fields, workexperience.FieldCompany)
  30711. }
  30712. if m.experience != nil {
  30713. fields = append(fields, workexperience.FieldExperience)
  30714. }
  30715. if m.organization_id != nil {
  30716. fields = append(fields, workexperience.FieldOrganizationID)
  30717. }
  30718. return fields
  30719. }
  30720. // Field returns the value of a field with the given name. The second boolean
  30721. // return value indicates that this field was not set, or was not defined in the
  30722. // schema.
  30723. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  30724. switch name {
  30725. case workexperience.FieldCreatedAt:
  30726. return m.CreatedAt()
  30727. case workexperience.FieldUpdatedAt:
  30728. return m.UpdatedAt()
  30729. case workexperience.FieldDeletedAt:
  30730. return m.DeletedAt()
  30731. case workexperience.FieldEmployeeID:
  30732. return m.EmployeeID()
  30733. case workexperience.FieldStartDate:
  30734. return m.StartDate()
  30735. case workexperience.FieldEndDate:
  30736. return m.EndDate()
  30737. case workexperience.FieldCompany:
  30738. return m.Company()
  30739. case workexperience.FieldExperience:
  30740. return m.Experience()
  30741. case workexperience.FieldOrganizationID:
  30742. return m.OrganizationID()
  30743. }
  30744. return nil, false
  30745. }
  30746. // OldField returns the old value of the field from the database. An error is
  30747. // returned if the mutation operation is not UpdateOne, or the query to the
  30748. // database failed.
  30749. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30750. switch name {
  30751. case workexperience.FieldCreatedAt:
  30752. return m.OldCreatedAt(ctx)
  30753. case workexperience.FieldUpdatedAt:
  30754. return m.OldUpdatedAt(ctx)
  30755. case workexperience.FieldDeletedAt:
  30756. return m.OldDeletedAt(ctx)
  30757. case workexperience.FieldEmployeeID:
  30758. return m.OldEmployeeID(ctx)
  30759. case workexperience.FieldStartDate:
  30760. return m.OldStartDate(ctx)
  30761. case workexperience.FieldEndDate:
  30762. return m.OldEndDate(ctx)
  30763. case workexperience.FieldCompany:
  30764. return m.OldCompany(ctx)
  30765. case workexperience.FieldExperience:
  30766. return m.OldExperience(ctx)
  30767. case workexperience.FieldOrganizationID:
  30768. return m.OldOrganizationID(ctx)
  30769. }
  30770. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  30771. }
  30772. // SetField sets the value of a field with the given name. It returns an error if
  30773. // the field is not defined in the schema, or if the type mismatched the field
  30774. // type.
  30775. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  30776. switch name {
  30777. case workexperience.FieldCreatedAt:
  30778. v, ok := value.(time.Time)
  30779. if !ok {
  30780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30781. }
  30782. m.SetCreatedAt(v)
  30783. return nil
  30784. case workexperience.FieldUpdatedAt:
  30785. v, ok := value.(time.Time)
  30786. if !ok {
  30787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30788. }
  30789. m.SetUpdatedAt(v)
  30790. return nil
  30791. case workexperience.FieldDeletedAt:
  30792. v, ok := value.(time.Time)
  30793. if !ok {
  30794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30795. }
  30796. m.SetDeletedAt(v)
  30797. return nil
  30798. case workexperience.FieldEmployeeID:
  30799. v, ok := value.(uint64)
  30800. if !ok {
  30801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30802. }
  30803. m.SetEmployeeID(v)
  30804. return nil
  30805. case workexperience.FieldStartDate:
  30806. v, ok := value.(time.Time)
  30807. if !ok {
  30808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30809. }
  30810. m.SetStartDate(v)
  30811. return nil
  30812. case workexperience.FieldEndDate:
  30813. v, ok := value.(time.Time)
  30814. if !ok {
  30815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30816. }
  30817. m.SetEndDate(v)
  30818. return nil
  30819. case workexperience.FieldCompany:
  30820. v, ok := value.(string)
  30821. if !ok {
  30822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30823. }
  30824. m.SetCompany(v)
  30825. return nil
  30826. case workexperience.FieldExperience:
  30827. v, ok := value.(string)
  30828. if !ok {
  30829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30830. }
  30831. m.SetExperience(v)
  30832. return nil
  30833. case workexperience.FieldOrganizationID:
  30834. v, ok := value.(uint64)
  30835. if !ok {
  30836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30837. }
  30838. m.SetOrganizationID(v)
  30839. return nil
  30840. }
  30841. return fmt.Errorf("unknown WorkExperience field %s", name)
  30842. }
  30843. // AddedFields returns all numeric fields that were incremented/decremented during
  30844. // this mutation.
  30845. func (m *WorkExperienceMutation) AddedFields() []string {
  30846. var fields []string
  30847. if m.addorganization_id != nil {
  30848. fields = append(fields, workexperience.FieldOrganizationID)
  30849. }
  30850. return fields
  30851. }
  30852. // AddedField returns the numeric value that was incremented/decremented on a field
  30853. // with the given name. The second boolean return value indicates that this field
  30854. // was not set, or was not defined in the schema.
  30855. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  30856. switch name {
  30857. case workexperience.FieldOrganizationID:
  30858. return m.AddedOrganizationID()
  30859. }
  30860. return nil, false
  30861. }
  30862. // AddField adds the value to the field with the given name. It returns an error if
  30863. // the field is not defined in the schema, or if the type mismatched the field
  30864. // type.
  30865. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  30866. switch name {
  30867. case workexperience.FieldOrganizationID:
  30868. v, ok := value.(int64)
  30869. if !ok {
  30870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30871. }
  30872. m.AddOrganizationID(v)
  30873. return nil
  30874. }
  30875. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  30876. }
  30877. // ClearedFields returns all nullable fields that were cleared during this
  30878. // mutation.
  30879. func (m *WorkExperienceMutation) ClearedFields() []string {
  30880. var fields []string
  30881. if m.FieldCleared(workexperience.FieldDeletedAt) {
  30882. fields = append(fields, workexperience.FieldDeletedAt)
  30883. }
  30884. return fields
  30885. }
  30886. // FieldCleared returns a boolean indicating if a field with the given name was
  30887. // cleared in this mutation.
  30888. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  30889. _, ok := m.clearedFields[name]
  30890. return ok
  30891. }
  30892. // ClearField clears the value of the field with the given name. It returns an
  30893. // error if the field is not defined in the schema.
  30894. func (m *WorkExperienceMutation) ClearField(name string) error {
  30895. switch name {
  30896. case workexperience.FieldDeletedAt:
  30897. m.ClearDeletedAt()
  30898. return nil
  30899. }
  30900. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  30901. }
  30902. // ResetField resets all changes in the mutation for the field with the given name.
  30903. // It returns an error if the field is not defined in the schema.
  30904. func (m *WorkExperienceMutation) ResetField(name string) error {
  30905. switch name {
  30906. case workexperience.FieldCreatedAt:
  30907. m.ResetCreatedAt()
  30908. return nil
  30909. case workexperience.FieldUpdatedAt:
  30910. m.ResetUpdatedAt()
  30911. return nil
  30912. case workexperience.FieldDeletedAt:
  30913. m.ResetDeletedAt()
  30914. return nil
  30915. case workexperience.FieldEmployeeID:
  30916. m.ResetEmployeeID()
  30917. return nil
  30918. case workexperience.FieldStartDate:
  30919. m.ResetStartDate()
  30920. return nil
  30921. case workexperience.FieldEndDate:
  30922. m.ResetEndDate()
  30923. return nil
  30924. case workexperience.FieldCompany:
  30925. m.ResetCompany()
  30926. return nil
  30927. case workexperience.FieldExperience:
  30928. m.ResetExperience()
  30929. return nil
  30930. case workexperience.FieldOrganizationID:
  30931. m.ResetOrganizationID()
  30932. return nil
  30933. }
  30934. return fmt.Errorf("unknown WorkExperience field %s", name)
  30935. }
  30936. // AddedEdges returns all edge names that were set/added in this mutation.
  30937. func (m *WorkExperienceMutation) AddedEdges() []string {
  30938. edges := make([]string, 0, 1)
  30939. if m.employee != nil {
  30940. edges = append(edges, workexperience.EdgeEmployee)
  30941. }
  30942. return edges
  30943. }
  30944. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30945. // name in this mutation.
  30946. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  30947. switch name {
  30948. case workexperience.EdgeEmployee:
  30949. if id := m.employee; id != nil {
  30950. return []ent.Value{*id}
  30951. }
  30952. }
  30953. return nil
  30954. }
  30955. // RemovedEdges returns all edge names that were removed in this mutation.
  30956. func (m *WorkExperienceMutation) RemovedEdges() []string {
  30957. edges := make([]string, 0, 1)
  30958. return edges
  30959. }
  30960. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30961. // the given name in this mutation.
  30962. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  30963. return nil
  30964. }
  30965. // ClearedEdges returns all edge names that were cleared in this mutation.
  30966. func (m *WorkExperienceMutation) ClearedEdges() []string {
  30967. edges := make([]string, 0, 1)
  30968. if m.clearedemployee {
  30969. edges = append(edges, workexperience.EdgeEmployee)
  30970. }
  30971. return edges
  30972. }
  30973. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30974. // was cleared in this mutation.
  30975. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  30976. switch name {
  30977. case workexperience.EdgeEmployee:
  30978. return m.clearedemployee
  30979. }
  30980. return false
  30981. }
  30982. // ClearEdge clears the value of the edge with the given name. It returns an error
  30983. // if that edge is not defined in the schema.
  30984. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  30985. switch name {
  30986. case workexperience.EdgeEmployee:
  30987. m.ClearEmployee()
  30988. return nil
  30989. }
  30990. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  30991. }
  30992. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30993. // It returns an error if the edge is not defined in the schema.
  30994. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  30995. switch name {
  30996. case workexperience.EdgeEmployee:
  30997. m.ResetEmployee()
  30998. return nil
  30999. }
  31000. return fmt.Errorf("unknown WorkExperience edge %s", name)
  31001. }
  31002. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  31003. type WpChatroomMutation struct {
  31004. config
  31005. op Op
  31006. typ string
  31007. id *uint64
  31008. created_at *time.Time
  31009. updated_at *time.Time
  31010. status *uint8
  31011. addstatus *int8
  31012. wx_wxid *string
  31013. chatroom_id *string
  31014. nickname *string
  31015. owner *string
  31016. avatar *string
  31017. member_list *[]string
  31018. appendmember_list []string
  31019. clearedFields map[string]struct{}
  31020. done bool
  31021. oldValue func(context.Context) (*WpChatroom, error)
  31022. predicates []predicate.WpChatroom
  31023. }
  31024. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  31025. // wpchatroomOption allows management of the mutation configuration using functional options.
  31026. type wpchatroomOption func(*WpChatroomMutation)
  31027. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  31028. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  31029. m := &WpChatroomMutation{
  31030. config: c,
  31031. op: op,
  31032. typ: TypeWpChatroom,
  31033. clearedFields: make(map[string]struct{}),
  31034. }
  31035. for _, opt := range opts {
  31036. opt(m)
  31037. }
  31038. return m
  31039. }
  31040. // withWpChatroomID sets the ID field of the mutation.
  31041. func withWpChatroomID(id uint64) wpchatroomOption {
  31042. return func(m *WpChatroomMutation) {
  31043. var (
  31044. err error
  31045. once sync.Once
  31046. value *WpChatroom
  31047. )
  31048. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  31049. once.Do(func() {
  31050. if m.done {
  31051. err = errors.New("querying old values post mutation is not allowed")
  31052. } else {
  31053. value, err = m.Client().WpChatroom.Get(ctx, id)
  31054. }
  31055. })
  31056. return value, err
  31057. }
  31058. m.id = &id
  31059. }
  31060. }
  31061. // withWpChatroom sets the old WpChatroom of the mutation.
  31062. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  31063. return func(m *WpChatroomMutation) {
  31064. m.oldValue = func(context.Context) (*WpChatroom, error) {
  31065. return node, nil
  31066. }
  31067. m.id = &node.ID
  31068. }
  31069. }
  31070. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31071. // executed in a transaction (ent.Tx), a transactional client is returned.
  31072. func (m WpChatroomMutation) Client() *Client {
  31073. client := &Client{config: m.config}
  31074. client.init()
  31075. return client
  31076. }
  31077. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31078. // it returns an error otherwise.
  31079. func (m WpChatroomMutation) Tx() (*Tx, error) {
  31080. if _, ok := m.driver.(*txDriver); !ok {
  31081. return nil, errors.New("ent: mutation is not running in a transaction")
  31082. }
  31083. tx := &Tx{config: m.config}
  31084. tx.init()
  31085. return tx, nil
  31086. }
  31087. // SetID sets the value of the id field. Note that this
  31088. // operation is only accepted on creation of WpChatroom entities.
  31089. func (m *WpChatroomMutation) SetID(id uint64) {
  31090. m.id = &id
  31091. }
  31092. // ID returns the ID value in the mutation. Note that the ID is only available
  31093. // if it was provided to the builder or after it was returned from the database.
  31094. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  31095. if m.id == nil {
  31096. return
  31097. }
  31098. return *m.id, true
  31099. }
  31100. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31101. // That means, if the mutation is applied within a transaction with an isolation level such
  31102. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31103. // or updated by the mutation.
  31104. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  31105. switch {
  31106. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31107. id, exists := m.ID()
  31108. if exists {
  31109. return []uint64{id}, nil
  31110. }
  31111. fallthrough
  31112. case m.op.Is(OpUpdate | OpDelete):
  31113. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  31114. default:
  31115. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31116. }
  31117. }
  31118. // SetCreatedAt sets the "created_at" field.
  31119. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  31120. m.created_at = &t
  31121. }
  31122. // CreatedAt returns the value of the "created_at" field in the mutation.
  31123. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  31124. v := m.created_at
  31125. if v == nil {
  31126. return
  31127. }
  31128. return *v, true
  31129. }
  31130. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  31131. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31133. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31134. if !m.op.Is(OpUpdateOne) {
  31135. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31136. }
  31137. if m.id == nil || m.oldValue == nil {
  31138. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31139. }
  31140. oldValue, err := m.oldValue(ctx)
  31141. if err != nil {
  31142. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31143. }
  31144. return oldValue.CreatedAt, nil
  31145. }
  31146. // ResetCreatedAt resets all changes to the "created_at" field.
  31147. func (m *WpChatroomMutation) ResetCreatedAt() {
  31148. m.created_at = nil
  31149. }
  31150. // SetUpdatedAt sets the "updated_at" field.
  31151. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  31152. m.updated_at = &t
  31153. }
  31154. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31155. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  31156. v := m.updated_at
  31157. if v == nil {
  31158. return
  31159. }
  31160. return *v, true
  31161. }
  31162. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  31163. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31165. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31166. if !m.op.Is(OpUpdateOne) {
  31167. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31168. }
  31169. if m.id == nil || m.oldValue == nil {
  31170. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31171. }
  31172. oldValue, err := m.oldValue(ctx)
  31173. if err != nil {
  31174. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31175. }
  31176. return oldValue.UpdatedAt, nil
  31177. }
  31178. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31179. func (m *WpChatroomMutation) ResetUpdatedAt() {
  31180. m.updated_at = nil
  31181. }
  31182. // SetStatus sets the "status" field.
  31183. func (m *WpChatroomMutation) SetStatus(u uint8) {
  31184. m.status = &u
  31185. m.addstatus = nil
  31186. }
  31187. // Status returns the value of the "status" field in the mutation.
  31188. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  31189. v := m.status
  31190. if v == nil {
  31191. return
  31192. }
  31193. return *v, true
  31194. }
  31195. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  31196. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31198. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31199. if !m.op.Is(OpUpdateOne) {
  31200. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31201. }
  31202. if m.id == nil || m.oldValue == nil {
  31203. return v, errors.New("OldStatus requires an ID field in the mutation")
  31204. }
  31205. oldValue, err := m.oldValue(ctx)
  31206. if err != nil {
  31207. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31208. }
  31209. return oldValue.Status, nil
  31210. }
  31211. // AddStatus adds u to the "status" field.
  31212. func (m *WpChatroomMutation) AddStatus(u int8) {
  31213. if m.addstatus != nil {
  31214. *m.addstatus += u
  31215. } else {
  31216. m.addstatus = &u
  31217. }
  31218. }
  31219. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31220. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  31221. v := m.addstatus
  31222. if v == nil {
  31223. return
  31224. }
  31225. return *v, true
  31226. }
  31227. // ClearStatus clears the value of the "status" field.
  31228. func (m *WpChatroomMutation) ClearStatus() {
  31229. m.status = nil
  31230. m.addstatus = nil
  31231. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  31232. }
  31233. // StatusCleared returns if the "status" field was cleared in this mutation.
  31234. func (m *WpChatroomMutation) StatusCleared() bool {
  31235. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  31236. return ok
  31237. }
  31238. // ResetStatus resets all changes to the "status" field.
  31239. func (m *WpChatroomMutation) ResetStatus() {
  31240. m.status = nil
  31241. m.addstatus = nil
  31242. delete(m.clearedFields, wpchatroom.FieldStatus)
  31243. }
  31244. // SetWxWxid sets the "wx_wxid" field.
  31245. func (m *WpChatroomMutation) SetWxWxid(s string) {
  31246. m.wx_wxid = &s
  31247. }
  31248. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31249. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  31250. v := m.wx_wxid
  31251. if v == nil {
  31252. return
  31253. }
  31254. return *v, true
  31255. }
  31256. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  31257. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31259. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31260. if !m.op.Is(OpUpdateOne) {
  31261. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31262. }
  31263. if m.id == nil || m.oldValue == nil {
  31264. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31265. }
  31266. oldValue, err := m.oldValue(ctx)
  31267. if err != nil {
  31268. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31269. }
  31270. return oldValue.WxWxid, nil
  31271. }
  31272. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31273. func (m *WpChatroomMutation) ResetWxWxid() {
  31274. m.wx_wxid = nil
  31275. }
  31276. // SetChatroomID sets the "chatroom_id" field.
  31277. func (m *WpChatroomMutation) SetChatroomID(s string) {
  31278. m.chatroom_id = &s
  31279. }
  31280. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  31281. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  31282. v := m.chatroom_id
  31283. if v == nil {
  31284. return
  31285. }
  31286. return *v, true
  31287. }
  31288. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  31289. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31291. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  31292. if !m.op.Is(OpUpdateOne) {
  31293. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  31294. }
  31295. if m.id == nil || m.oldValue == nil {
  31296. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  31297. }
  31298. oldValue, err := m.oldValue(ctx)
  31299. if err != nil {
  31300. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  31301. }
  31302. return oldValue.ChatroomID, nil
  31303. }
  31304. // ResetChatroomID resets all changes to the "chatroom_id" field.
  31305. func (m *WpChatroomMutation) ResetChatroomID() {
  31306. m.chatroom_id = nil
  31307. }
  31308. // SetNickname sets the "nickname" field.
  31309. func (m *WpChatroomMutation) SetNickname(s string) {
  31310. m.nickname = &s
  31311. }
  31312. // Nickname returns the value of the "nickname" field in the mutation.
  31313. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  31314. v := m.nickname
  31315. if v == nil {
  31316. return
  31317. }
  31318. return *v, true
  31319. }
  31320. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  31321. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31323. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  31324. if !m.op.Is(OpUpdateOne) {
  31325. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31326. }
  31327. if m.id == nil || m.oldValue == nil {
  31328. return v, errors.New("OldNickname requires an ID field in the mutation")
  31329. }
  31330. oldValue, err := m.oldValue(ctx)
  31331. if err != nil {
  31332. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31333. }
  31334. return oldValue.Nickname, nil
  31335. }
  31336. // ResetNickname resets all changes to the "nickname" field.
  31337. func (m *WpChatroomMutation) ResetNickname() {
  31338. m.nickname = nil
  31339. }
  31340. // SetOwner sets the "owner" field.
  31341. func (m *WpChatroomMutation) SetOwner(s string) {
  31342. m.owner = &s
  31343. }
  31344. // Owner returns the value of the "owner" field in the mutation.
  31345. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  31346. v := m.owner
  31347. if v == nil {
  31348. return
  31349. }
  31350. return *v, true
  31351. }
  31352. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  31353. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31355. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  31356. if !m.op.Is(OpUpdateOne) {
  31357. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  31358. }
  31359. if m.id == nil || m.oldValue == nil {
  31360. return v, errors.New("OldOwner requires an ID field in the mutation")
  31361. }
  31362. oldValue, err := m.oldValue(ctx)
  31363. if err != nil {
  31364. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  31365. }
  31366. return oldValue.Owner, nil
  31367. }
  31368. // ResetOwner resets all changes to the "owner" field.
  31369. func (m *WpChatroomMutation) ResetOwner() {
  31370. m.owner = nil
  31371. }
  31372. // SetAvatar sets the "avatar" field.
  31373. func (m *WpChatroomMutation) SetAvatar(s string) {
  31374. m.avatar = &s
  31375. }
  31376. // Avatar returns the value of the "avatar" field in the mutation.
  31377. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  31378. v := m.avatar
  31379. if v == nil {
  31380. return
  31381. }
  31382. return *v, true
  31383. }
  31384. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  31385. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31387. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31388. if !m.op.Is(OpUpdateOne) {
  31389. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31390. }
  31391. if m.id == nil || m.oldValue == nil {
  31392. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31393. }
  31394. oldValue, err := m.oldValue(ctx)
  31395. if err != nil {
  31396. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31397. }
  31398. return oldValue.Avatar, nil
  31399. }
  31400. // ResetAvatar resets all changes to the "avatar" field.
  31401. func (m *WpChatroomMutation) ResetAvatar() {
  31402. m.avatar = nil
  31403. }
  31404. // SetMemberList sets the "member_list" field.
  31405. func (m *WpChatroomMutation) SetMemberList(s []string) {
  31406. m.member_list = &s
  31407. m.appendmember_list = nil
  31408. }
  31409. // MemberList returns the value of the "member_list" field in the mutation.
  31410. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  31411. v := m.member_list
  31412. if v == nil {
  31413. return
  31414. }
  31415. return *v, true
  31416. }
  31417. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  31418. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31420. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  31421. if !m.op.Is(OpUpdateOne) {
  31422. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  31423. }
  31424. if m.id == nil || m.oldValue == nil {
  31425. return v, errors.New("OldMemberList requires an ID field in the mutation")
  31426. }
  31427. oldValue, err := m.oldValue(ctx)
  31428. if err != nil {
  31429. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  31430. }
  31431. return oldValue.MemberList, nil
  31432. }
  31433. // AppendMemberList adds s to the "member_list" field.
  31434. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  31435. m.appendmember_list = append(m.appendmember_list, s...)
  31436. }
  31437. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  31438. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  31439. if len(m.appendmember_list) == 0 {
  31440. return nil, false
  31441. }
  31442. return m.appendmember_list, true
  31443. }
  31444. // ResetMemberList resets all changes to the "member_list" field.
  31445. func (m *WpChatroomMutation) ResetMemberList() {
  31446. m.member_list = nil
  31447. m.appendmember_list = nil
  31448. }
  31449. // Where appends a list predicates to the WpChatroomMutation builder.
  31450. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  31451. m.predicates = append(m.predicates, ps...)
  31452. }
  31453. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  31454. // users can use type-assertion to append predicates that do not depend on any generated package.
  31455. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  31456. p := make([]predicate.WpChatroom, len(ps))
  31457. for i := range ps {
  31458. p[i] = ps[i]
  31459. }
  31460. m.Where(p...)
  31461. }
  31462. // Op returns the operation name.
  31463. func (m *WpChatroomMutation) Op() Op {
  31464. return m.op
  31465. }
  31466. // SetOp allows setting the mutation operation.
  31467. func (m *WpChatroomMutation) SetOp(op Op) {
  31468. m.op = op
  31469. }
  31470. // Type returns the node type of this mutation (WpChatroom).
  31471. func (m *WpChatroomMutation) Type() string {
  31472. return m.typ
  31473. }
  31474. // Fields returns all fields that were changed during this mutation. Note that in
  31475. // order to get all numeric fields that were incremented/decremented, call
  31476. // AddedFields().
  31477. func (m *WpChatroomMutation) Fields() []string {
  31478. fields := make([]string, 0, 9)
  31479. if m.created_at != nil {
  31480. fields = append(fields, wpchatroom.FieldCreatedAt)
  31481. }
  31482. if m.updated_at != nil {
  31483. fields = append(fields, wpchatroom.FieldUpdatedAt)
  31484. }
  31485. if m.status != nil {
  31486. fields = append(fields, wpchatroom.FieldStatus)
  31487. }
  31488. if m.wx_wxid != nil {
  31489. fields = append(fields, wpchatroom.FieldWxWxid)
  31490. }
  31491. if m.chatroom_id != nil {
  31492. fields = append(fields, wpchatroom.FieldChatroomID)
  31493. }
  31494. if m.nickname != nil {
  31495. fields = append(fields, wpchatroom.FieldNickname)
  31496. }
  31497. if m.owner != nil {
  31498. fields = append(fields, wpchatroom.FieldOwner)
  31499. }
  31500. if m.avatar != nil {
  31501. fields = append(fields, wpchatroom.FieldAvatar)
  31502. }
  31503. if m.member_list != nil {
  31504. fields = append(fields, wpchatroom.FieldMemberList)
  31505. }
  31506. return fields
  31507. }
  31508. // Field returns the value of a field with the given name. The second boolean
  31509. // return value indicates that this field was not set, or was not defined in the
  31510. // schema.
  31511. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  31512. switch name {
  31513. case wpchatroom.FieldCreatedAt:
  31514. return m.CreatedAt()
  31515. case wpchatroom.FieldUpdatedAt:
  31516. return m.UpdatedAt()
  31517. case wpchatroom.FieldStatus:
  31518. return m.Status()
  31519. case wpchatroom.FieldWxWxid:
  31520. return m.WxWxid()
  31521. case wpchatroom.FieldChatroomID:
  31522. return m.ChatroomID()
  31523. case wpchatroom.FieldNickname:
  31524. return m.Nickname()
  31525. case wpchatroom.FieldOwner:
  31526. return m.Owner()
  31527. case wpchatroom.FieldAvatar:
  31528. return m.Avatar()
  31529. case wpchatroom.FieldMemberList:
  31530. return m.MemberList()
  31531. }
  31532. return nil, false
  31533. }
  31534. // OldField returns the old value of the field from the database. An error is
  31535. // returned if the mutation operation is not UpdateOne, or the query to the
  31536. // database failed.
  31537. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31538. switch name {
  31539. case wpchatroom.FieldCreatedAt:
  31540. return m.OldCreatedAt(ctx)
  31541. case wpchatroom.FieldUpdatedAt:
  31542. return m.OldUpdatedAt(ctx)
  31543. case wpchatroom.FieldStatus:
  31544. return m.OldStatus(ctx)
  31545. case wpchatroom.FieldWxWxid:
  31546. return m.OldWxWxid(ctx)
  31547. case wpchatroom.FieldChatroomID:
  31548. return m.OldChatroomID(ctx)
  31549. case wpchatroom.FieldNickname:
  31550. return m.OldNickname(ctx)
  31551. case wpchatroom.FieldOwner:
  31552. return m.OldOwner(ctx)
  31553. case wpchatroom.FieldAvatar:
  31554. return m.OldAvatar(ctx)
  31555. case wpchatroom.FieldMemberList:
  31556. return m.OldMemberList(ctx)
  31557. }
  31558. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  31559. }
  31560. // SetField sets the value of a field with the given name. It returns an error if
  31561. // the field is not defined in the schema, or if the type mismatched the field
  31562. // type.
  31563. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  31564. switch name {
  31565. case wpchatroom.FieldCreatedAt:
  31566. v, ok := value.(time.Time)
  31567. if !ok {
  31568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31569. }
  31570. m.SetCreatedAt(v)
  31571. return nil
  31572. case wpchatroom.FieldUpdatedAt:
  31573. v, ok := value.(time.Time)
  31574. if !ok {
  31575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31576. }
  31577. m.SetUpdatedAt(v)
  31578. return nil
  31579. case wpchatroom.FieldStatus:
  31580. v, ok := value.(uint8)
  31581. if !ok {
  31582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31583. }
  31584. m.SetStatus(v)
  31585. return nil
  31586. case wpchatroom.FieldWxWxid:
  31587. v, ok := value.(string)
  31588. if !ok {
  31589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31590. }
  31591. m.SetWxWxid(v)
  31592. return nil
  31593. case wpchatroom.FieldChatroomID:
  31594. v, ok := value.(string)
  31595. if !ok {
  31596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31597. }
  31598. m.SetChatroomID(v)
  31599. return nil
  31600. case wpchatroom.FieldNickname:
  31601. v, ok := value.(string)
  31602. if !ok {
  31603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31604. }
  31605. m.SetNickname(v)
  31606. return nil
  31607. case wpchatroom.FieldOwner:
  31608. v, ok := value.(string)
  31609. if !ok {
  31610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31611. }
  31612. m.SetOwner(v)
  31613. return nil
  31614. case wpchatroom.FieldAvatar:
  31615. v, ok := value.(string)
  31616. if !ok {
  31617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31618. }
  31619. m.SetAvatar(v)
  31620. return nil
  31621. case wpchatroom.FieldMemberList:
  31622. v, ok := value.([]string)
  31623. if !ok {
  31624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31625. }
  31626. m.SetMemberList(v)
  31627. return nil
  31628. }
  31629. return fmt.Errorf("unknown WpChatroom field %s", name)
  31630. }
  31631. // AddedFields returns all numeric fields that were incremented/decremented during
  31632. // this mutation.
  31633. func (m *WpChatroomMutation) AddedFields() []string {
  31634. var fields []string
  31635. if m.addstatus != nil {
  31636. fields = append(fields, wpchatroom.FieldStatus)
  31637. }
  31638. return fields
  31639. }
  31640. // AddedField returns the numeric value that was incremented/decremented on a field
  31641. // with the given name. The second boolean return value indicates that this field
  31642. // was not set, or was not defined in the schema.
  31643. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  31644. switch name {
  31645. case wpchatroom.FieldStatus:
  31646. return m.AddedStatus()
  31647. }
  31648. return nil, false
  31649. }
  31650. // AddField adds the value to the field with the given name. It returns an error if
  31651. // the field is not defined in the schema, or if the type mismatched the field
  31652. // type.
  31653. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  31654. switch name {
  31655. case wpchatroom.FieldStatus:
  31656. v, ok := value.(int8)
  31657. if !ok {
  31658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31659. }
  31660. m.AddStatus(v)
  31661. return nil
  31662. }
  31663. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  31664. }
  31665. // ClearedFields returns all nullable fields that were cleared during this
  31666. // mutation.
  31667. func (m *WpChatroomMutation) ClearedFields() []string {
  31668. var fields []string
  31669. if m.FieldCleared(wpchatroom.FieldStatus) {
  31670. fields = append(fields, wpchatroom.FieldStatus)
  31671. }
  31672. return fields
  31673. }
  31674. // FieldCleared returns a boolean indicating if a field with the given name was
  31675. // cleared in this mutation.
  31676. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  31677. _, ok := m.clearedFields[name]
  31678. return ok
  31679. }
  31680. // ClearField clears the value of the field with the given name. It returns an
  31681. // error if the field is not defined in the schema.
  31682. func (m *WpChatroomMutation) ClearField(name string) error {
  31683. switch name {
  31684. case wpchatroom.FieldStatus:
  31685. m.ClearStatus()
  31686. return nil
  31687. }
  31688. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  31689. }
  31690. // ResetField resets all changes in the mutation for the field with the given name.
  31691. // It returns an error if the field is not defined in the schema.
  31692. func (m *WpChatroomMutation) ResetField(name string) error {
  31693. switch name {
  31694. case wpchatroom.FieldCreatedAt:
  31695. m.ResetCreatedAt()
  31696. return nil
  31697. case wpchatroom.FieldUpdatedAt:
  31698. m.ResetUpdatedAt()
  31699. return nil
  31700. case wpchatroom.FieldStatus:
  31701. m.ResetStatus()
  31702. return nil
  31703. case wpchatroom.FieldWxWxid:
  31704. m.ResetWxWxid()
  31705. return nil
  31706. case wpchatroom.FieldChatroomID:
  31707. m.ResetChatroomID()
  31708. return nil
  31709. case wpchatroom.FieldNickname:
  31710. m.ResetNickname()
  31711. return nil
  31712. case wpchatroom.FieldOwner:
  31713. m.ResetOwner()
  31714. return nil
  31715. case wpchatroom.FieldAvatar:
  31716. m.ResetAvatar()
  31717. return nil
  31718. case wpchatroom.FieldMemberList:
  31719. m.ResetMemberList()
  31720. return nil
  31721. }
  31722. return fmt.Errorf("unknown WpChatroom field %s", name)
  31723. }
  31724. // AddedEdges returns all edge names that were set/added in this mutation.
  31725. func (m *WpChatroomMutation) AddedEdges() []string {
  31726. edges := make([]string, 0, 0)
  31727. return edges
  31728. }
  31729. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31730. // name in this mutation.
  31731. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  31732. return nil
  31733. }
  31734. // RemovedEdges returns all edge names that were removed in this mutation.
  31735. func (m *WpChatroomMutation) RemovedEdges() []string {
  31736. edges := make([]string, 0, 0)
  31737. return edges
  31738. }
  31739. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31740. // the given name in this mutation.
  31741. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  31742. return nil
  31743. }
  31744. // ClearedEdges returns all edge names that were cleared in this mutation.
  31745. func (m *WpChatroomMutation) ClearedEdges() []string {
  31746. edges := make([]string, 0, 0)
  31747. return edges
  31748. }
  31749. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31750. // was cleared in this mutation.
  31751. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  31752. return false
  31753. }
  31754. // ClearEdge clears the value of the edge with the given name. It returns an error
  31755. // if that edge is not defined in the schema.
  31756. func (m *WpChatroomMutation) ClearEdge(name string) error {
  31757. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  31758. }
  31759. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31760. // It returns an error if the edge is not defined in the schema.
  31761. func (m *WpChatroomMutation) ResetEdge(name string) error {
  31762. return fmt.Errorf("unknown WpChatroom edge %s", name)
  31763. }
  31764. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  31765. type WpChatroomMemberMutation struct {
  31766. config
  31767. op Op
  31768. typ string
  31769. id *uint64
  31770. created_at *time.Time
  31771. updated_at *time.Time
  31772. status *uint8
  31773. addstatus *int8
  31774. wx_wxid *string
  31775. wxid *string
  31776. nickname *string
  31777. avatar *string
  31778. clearedFields map[string]struct{}
  31779. done bool
  31780. oldValue func(context.Context) (*WpChatroomMember, error)
  31781. predicates []predicate.WpChatroomMember
  31782. }
  31783. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  31784. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  31785. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  31786. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  31787. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  31788. m := &WpChatroomMemberMutation{
  31789. config: c,
  31790. op: op,
  31791. typ: TypeWpChatroomMember,
  31792. clearedFields: make(map[string]struct{}),
  31793. }
  31794. for _, opt := range opts {
  31795. opt(m)
  31796. }
  31797. return m
  31798. }
  31799. // withWpChatroomMemberID sets the ID field of the mutation.
  31800. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  31801. return func(m *WpChatroomMemberMutation) {
  31802. var (
  31803. err error
  31804. once sync.Once
  31805. value *WpChatroomMember
  31806. )
  31807. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  31808. once.Do(func() {
  31809. if m.done {
  31810. err = errors.New("querying old values post mutation is not allowed")
  31811. } else {
  31812. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  31813. }
  31814. })
  31815. return value, err
  31816. }
  31817. m.id = &id
  31818. }
  31819. }
  31820. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  31821. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  31822. return func(m *WpChatroomMemberMutation) {
  31823. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  31824. return node, nil
  31825. }
  31826. m.id = &node.ID
  31827. }
  31828. }
  31829. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31830. // executed in a transaction (ent.Tx), a transactional client is returned.
  31831. func (m WpChatroomMemberMutation) Client() *Client {
  31832. client := &Client{config: m.config}
  31833. client.init()
  31834. return client
  31835. }
  31836. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31837. // it returns an error otherwise.
  31838. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  31839. if _, ok := m.driver.(*txDriver); !ok {
  31840. return nil, errors.New("ent: mutation is not running in a transaction")
  31841. }
  31842. tx := &Tx{config: m.config}
  31843. tx.init()
  31844. return tx, nil
  31845. }
  31846. // SetID sets the value of the id field. Note that this
  31847. // operation is only accepted on creation of WpChatroomMember entities.
  31848. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  31849. m.id = &id
  31850. }
  31851. // ID returns the ID value in the mutation. Note that the ID is only available
  31852. // if it was provided to the builder or after it was returned from the database.
  31853. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  31854. if m.id == nil {
  31855. return
  31856. }
  31857. return *m.id, true
  31858. }
  31859. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31860. // That means, if the mutation is applied within a transaction with an isolation level such
  31861. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31862. // or updated by the mutation.
  31863. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  31864. switch {
  31865. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31866. id, exists := m.ID()
  31867. if exists {
  31868. return []uint64{id}, nil
  31869. }
  31870. fallthrough
  31871. case m.op.Is(OpUpdate | OpDelete):
  31872. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  31873. default:
  31874. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31875. }
  31876. }
  31877. // SetCreatedAt sets the "created_at" field.
  31878. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  31879. m.created_at = &t
  31880. }
  31881. // CreatedAt returns the value of the "created_at" field in the mutation.
  31882. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  31883. v := m.created_at
  31884. if v == nil {
  31885. return
  31886. }
  31887. return *v, true
  31888. }
  31889. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  31890. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31892. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31893. if !m.op.Is(OpUpdateOne) {
  31894. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31895. }
  31896. if m.id == nil || m.oldValue == nil {
  31897. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31898. }
  31899. oldValue, err := m.oldValue(ctx)
  31900. if err != nil {
  31901. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31902. }
  31903. return oldValue.CreatedAt, nil
  31904. }
  31905. // ResetCreatedAt resets all changes to the "created_at" field.
  31906. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  31907. m.created_at = nil
  31908. }
  31909. // SetUpdatedAt sets the "updated_at" field.
  31910. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  31911. m.updated_at = &t
  31912. }
  31913. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31914. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  31915. v := m.updated_at
  31916. if v == nil {
  31917. return
  31918. }
  31919. return *v, true
  31920. }
  31921. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  31922. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31924. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31925. if !m.op.Is(OpUpdateOne) {
  31926. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31927. }
  31928. if m.id == nil || m.oldValue == nil {
  31929. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31930. }
  31931. oldValue, err := m.oldValue(ctx)
  31932. if err != nil {
  31933. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31934. }
  31935. return oldValue.UpdatedAt, nil
  31936. }
  31937. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31938. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  31939. m.updated_at = nil
  31940. }
  31941. // SetStatus sets the "status" field.
  31942. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  31943. m.status = &u
  31944. m.addstatus = nil
  31945. }
  31946. // Status returns the value of the "status" field in the mutation.
  31947. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  31948. v := m.status
  31949. if v == nil {
  31950. return
  31951. }
  31952. return *v, true
  31953. }
  31954. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  31955. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31957. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31958. if !m.op.Is(OpUpdateOne) {
  31959. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31960. }
  31961. if m.id == nil || m.oldValue == nil {
  31962. return v, errors.New("OldStatus requires an ID field in the mutation")
  31963. }
  31964. oldValue, err := m.oldValue(ctx)
  31965. if err != nil {
  31966. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31967. }
  31968. return oldValue.Status, nil
  31969. }
  31970. // AddStatus adds u to the "status" field.
  31971. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  31972. if m.addstatus != nil {
  31973. *m.addstatus += u
  31974. } else {
  31975. m.addstatus = &u
  31976. }
  31977. }
  31978. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31979. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  31980. v := m.addstatus
  31981. if v == nil {
  31982. return
  31983. }
  31984. return *v, true
  31985. }
  31986. // ClearStatus clears the value of the "status" field.
  31987. func (m *WpChatroomMemberMutation) ClearStatus() {
  31988. m.status = nil
  31989. m.addstatus = nil
  31990. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  31991. }
  31992. // StatusCleared returns if the "status" field was cleared in this mutation.
  31993. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  31994. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  31995. return ok
  31996. }
  31997. // ResetStatus resets all changes to the "status" field.
  31998. func (m *WpChatroomMemberMutation) ResetStatus() {
  31999. m.status = nil
  32000. m.addstatus = nil
  32001. delete(m.clearedFields, wpchatroommember.FieldStatus)
  32002. }
  32003. // SetWxWxid sets the "wx_wxid" field.
  32004. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  32005. m.wx_wxid = &s
  32006. }
  32007. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  32008. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  32009. v := m.wx_wxid
  32010. if v == nil {
  32011. return
  32012. }
  32013. return *v, true
  32014. }
  32015. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  32016. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32018. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  32019. if !m.op.Is(OpUpdateOne) {
  32020. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  32021. }
  32022. if m.id == nil || m.oldValue == nil {
  32023. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  32024. }
  32025. oldValue, err := m.oldValue(ctx)
  32026. if err != nil {
  32027. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  32028. }
  32029. return oldValue.WxWxid, nil
  32030. }
  32031. // ResetWxWxid resets all changes to the "wx_wxid" field.
  32032. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  32033. m.wx_wxid = nil
  32034. }
  32035. // SetWxid sets the "wxid" field.
  32036. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  32037. m.wxid = &s
  32038. }
  32039. // Wxid returns the value of the "wxid" field in the mutation.
  32040. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  32041. v := m.wxid
  32042. if v == nil {
  32043. return
  32044. }
  32045. return *v, true
  32046. }
  32047. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  32048. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32050. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  32051. if !m.op.Is(OpUpdateOne) {
  32052. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  32053. }
  32054. if m.id == nil || m.oldValue == nil {
  32055. return v, errors.New("OldWxid requires an ID field in the mutation")
  32056. }
  32057. oldValue, err := m.oldValue(ctx)
  32058. if err != nil {
  32059. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  32060. }
  32061. return oldValue.Wxid, nil
  32062. }
  32063. // ResetWxid resets all changes to the "wxid" field.
  32064. func (m *WpChatroomMemberMutation) ResetWxid() {
  32065. m.wxid = nil
  32066. }
  32067. // SetNickname sets the "nickname" field.
  32068. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  32069. m.nickname = &s
  32070. }
  32071. // Nickname returns the value of the "nickname" field in the mutation.
  32072. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  32073. v := m.nickname
  32074. if v == nil {
  32075. return
  32076. }
  32077. return *v, true
  32078. }
  32079. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  32080. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32082. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  32083. if !m.op.Is(OpUpdateOne) {
  32084. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32085. }
  32086. if m.id == nil || m.oldValue == nil {
  32087. return v, errors.New("OldNickname requires an ID field in the mutation")
  32088. }
  32089. oldValue, err := m.oldValue(ctx)
  32090. if err != nil {
  32091. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32092. }
  32093. return oldValue.Nickname, nil
  32094. }
  32095. // ResetNickname resets all changes to the "nickname" field.
  32096. func (m *WpChatroomMemberMutation) ResetNickname() {
  32097. m.nickname = nil
  32098. }
  32099. // SetAvatar sets the "avatar" field.
  32100. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  32101. m.avatar = &s
  32102. }
  32103. // Avatar returns the value of the "avatar" field in the mutation.
  32104. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  32105. v := m.avatar
  32106. if v == nil {
  32107. return
  32108. }
  32109. return *v, true
  32110. }
  32111. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  32112. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32114. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  32115. if !m.op.Is(OpUpdateOne) {
  32116. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  32117. }
  32118. if m.id == nil || m.oldValue == nil {
  32119. return v, errors.New("OldAvatar requires an ID field in the mutation")
  32120. }
  32121. oldValue, err := m.oldValue(ctx)
  32122. if err != nil {
  32123. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  32124. }
  32125. return oldValue.Avatar, nil
  32126. }
  32127. // ResetAvatar resets all changes to the "avatar" field.
  32128. func (m *WpChatroomMemberMutation) ResetAvatar() {
  32129. m.avatar = nil
  32130. }
  32131. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  32132. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  32133. m.predicates = append(m.predicates, ps...)
  32134. }
  32135. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  32136. // users can use type-assertion to append predicates that do not depend on any generated package.
  32137. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  32138. p := make([]predicate.WpChatroomMember, len(ps))
  32139. for i := range ps {
  32140. p[i] = ps[i]
  32141. }
  32142. m.Where(p...)
  32143. }
  32144. // Op returns the operation name.
  32145. func (m *WpChatroomMemberMutation) Op() Op {
  32146. return m.op
  32147. }
  32148. // SetOp allows setting the mutation operation.
  32149. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  32150. m.op = op
  32151. }
  32152. // Type returns the node type of this mutation (WpChatroomMember).
  32153. func (m *WpChatroomMemberMutation) Type() string {
  32154. return m.typ
  32155. }
  32156. // Fields returns all fields that were changed during this mutation. Note that in
  32157. // order to get all numeric fields that were incremented/decremented, call
  32158. // AddedFields().
  32159. func (m *WpChatroomMemberMutation) Fields() []string {
  32160. fields := make([]string, 0, 7)
  32161. if m.created_at != nil {
  32162. fields = append(fields, wpchatroommember.FieldCreatedAt)
  32163. }
  32164. if m.updated_at != nil {
  32165. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  32166. }
  32167. if m.status != nil {
  32168. fields = append(fields, wpchatroommember.FieldStatus)
  32169. }
  32170. if m.wx_wxid != nil {
  32171. fields = append(fields, wpchatroommember.FieldWxWxid)
  32172. }
  32173. if m.wxid != nil {
  32174. fields = append(fields, wpchatroommember.FieldWxid)
  32175. }
  32176. if m.nickname != nil {
  32177. fields = append(fields, wpchatroommember.FieldNickname)
  32178. }
  32179. if m.avatar != nil {
  32180. fields = append(fields, wpchatroommember.FieldAvatar)
  32181. }
  32182. return fields
  32183. }
  32184. // Field returns the value of a field with the given name. The second boolean
  32185. // return value indicates that this field was not set, or was not defined in the
  32186. // schema.
  32187. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  32188. switch name {
  32189. case wpchatroommember.FieldCreatedAt:
  32190. return m.CreatedAt()
  32191. case wpchatroommember.FieldUpdatedAt:
  32192. return m.UpdatedAt()
  32193. case wpchatroommember.FieldStatus:
  32194. return m.Status()
  32195. case wpchatroommember.FieldWxWxid:
  32196. return m.WxWxid()
  32197. case wpchatroommember.FieldWxid:
  32198. return m.Wxid()
  32199. case wpchatroommember.FieldNickname:
  32200. return m.Nickname()
  32201. case wpchatroommember.FieldAvatar:
  32202. return m.Avatar()
  32203. }
  32204. return nil, false
  32205. }
  32206. // OldField returns the old value of the field from the database. An error is
  32207. // returned if the mutation operation is not UpdateOne, or the query to the
  32208. // database failed.
  32209. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32210. switch name {
  32211. case wpchatroommember.FieldCreatedAt:
  32212. return m.OldCreatedAt(ctx)
  32213. case wpchatroommember.FieldUpdatedAt:
  32214. return m.OldUpdatedAt(ctx)
  32215. case wpchatroommember.FieldStatus:
  32216. return m.OldStatus(ctx)
  32217. case wpchatroommember.FieldWxWxid:
  32218. return m.OldWxWxid(ctx)
  32219. case wpchatroommember.FieldWxid:
  32220. return m.OldWxid(ctx)
  32221. case wpchatroommember.FieldNickname:
  32222. return m.OldNickname(ctx)
  32223. case wpchatroommember.FieldAvatar:
  32224. return m.OldAvatar(ctx)
  32225. }
  32226. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  32227. }
  32228. // SetField sets the value of a field with the given name. It returns an error if
  32229. // the field is not defined in the schema, or if the type mismatched the field
  32230. // type.
  32231. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  32232. switch name {
  32233. case wpchatroommember.FieldCreatedAt:
  32234. v, ok := value.(time.Time)
  32235. if !ok {
  32236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32237. }
  32238. m.SetCreatedAt(v)
  32239. return nil
  32240. case wpchatroommember.FieldUpdatedAt:
  32241. v, ok := value.(time.Time)
  32242. if !ok {
  32243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32244. }
  32245. m.SetUpdatedAt(v)
  32246. return nil
  32247. case wpchatroommember.FieldStatus:
  32248. v, ok := value.(uint8)
  32249. if !ok {
  32250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32251. }
  32252. m.SetStatus(v)
  32253. return nil
  32254. case wpchatroommember.FieldWxWxid:
  32255. v, ok := value.(string)
  32256. if !ok {
  32257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32258. }
  32259. m.SetWxWxid(v)
  32260. return nil
  32261. case wpchatroommember.FieldWxid:
  32262. v, ok := value.(string)
  32263. if !ok {
  32264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32265. }
  32266. m.SetWxid(v)
  32267. return nil
  32268. case wpchatroommember.FieldNickname:
  32269. v, ok := value.(string)
  32270. if !ok {
  32271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32272. }
  32273. m.SetNickname(v)
  32274. return nil
  32275. case wpchatroommember.FieldAvatar:
  32276. v, ok := value.(string)
  32277. if !ok {
  32278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32279. }
  32280. m.SetAvatar(v)
  32281. return nil
  32282. }
  32283. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  32284. }
  32285. // AddedFields returns all numeric fields that were incremented/decremented during
  32286. // this mutation.
  32287. func (m *WpChatroomMemberMutation) AddedFields() []string {
  32288. var fields []string
  32289. if m.addstatus != nil {
  32290. fields = append(fields, wpchatroommember.FieldStatus)
  32291. }
  32292. return fields
  32293. }
  32294. // AddedField returns the numeric value that was incremented/decremented on a field
  32295. // with the given name. The second boolean return value indicates that this field
  32296. // was not set, or was not defined in the schema.
  32297. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  32298. switch name {
  32299. case wpchatroommember.FieldStatus:
  32300. return m.AddedStatus()
  32301. }
  32302. return nil, false
  32303. }
  32304. // AddField adds the value to the field with the given name. It returns an error if
  32305. // the field is not defined in the schema, or if the type mismatched the field
  32306. // type.
  32307. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  32308. switch name {
  32309. case wpchatroommember.FieldStatus:
  32310. v, ok := value.(int8)
  32311. if !ok {
  32312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32313. }
  32314. m.AddStatus(v)
  32315. return nil
  32316. }
  32317. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  32318. }
  32319. // ClearedFields returns all nullable fields that were cleared during this
  32320. // mutation.
  32321. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  32322. var fields []string
  32323. if m.FieldCleared(wpchatroommember.FieldStatus) {
  32324. fields = append(fields, wpchatroommember.FieldStatus)
  32325. }
  32326. return fields
  32327. }
  32328. // FieldCleared returns a boolean indicating if a field with the given name was
  32329. // cleared in this mutation.
  32330. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  32331. _, ok := m.clearedFields[name]
  32332. return ok
  32333. }
  32334. // ClearField clears the value of the field with the given name. It returns an
  32335. // error if the field is not defined in the schema.
  32336. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  32337. switch name {
  32338. case wpchatroommember.FieldStatus:
  32339. m.ClearStatus()
  32340. return nil
  32341. }
  32342. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  32343. }
  32344. // ResetField resets all changes in the mutation for the field with the given name.
  32345. // It returns an error if the field is not defined in the schema.
  32346. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  32347. switch name {
  32348. case wpchatroommember.FieldCreatedAt:
  32349. m.ResetCreatedAt()
  32350. return nil
  32351. case wpchatroommember.FieldUpdatedAt:
  32352. m.ResetUpdatedAt()
  32353. return nil
  32354. case wpchatroommember.FieldStatus:
  32355. m.ResetStatus()
  32356. return nil
  32357. case wpchatroommember.FieldWxWxid:
  32358. m.ResetWxWxid()
  32359. return nil
  32360. case wpchatroommember.FieldWxid:
  32361. m.ResetWxid()
  32362. return nil
  32363. case wpchatroommember.FieldNickname:
  32364. m.ResetNickname()
  32365. return nil
  32366. case wpchatroommember.FieldAvatar:
  32367. m.ResetAvatar()
  32368. return nil
  32369. }
  32370. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  32371. }
  32372. // AddedEdges returns all edge names that were set/added in this mutation.
  32373. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  32374. edges := make([]string, 0, 0)
  32375. return edges
  32376. }
  32377. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32378. // name in this mutation.
  32379. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  32380. return nil
  32381. }
  32382. // RemovedEdges returns all edge names that were removed in this mutation.
  32383. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  32384. edges := make([]string, 0, 0)
  32385. return edges
  32386. }
  32387. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32388. // the given name in this mutation.
  32389. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  32390. return nil
  32391. }
  32392. // ClearedEdges returns all edge names that were cleared in this mutation.
  32393. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  32394. edges := make([]string, 0, 0)
  32395. return edges
  32396. }
  32397. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32398. // was cleared in this mutation.
  32399. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  32400. return false
  32401. }
  32402. // ClearEdge clears the value of the edge with the given name. It returns an error
  32403. // if that edge is not defined in the schema.
  32404. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  32405. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  32406. }
  32407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32408. // It returns an error if the edge is not defined in the schema.
  32409. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  32410. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  32411. }
  32412. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  32413. type WxMutation struct {
  32414. config
  32415. op Op
  32416. typ string
  32417. id *uint64
  32418. created_at *time.Time
  32419. updated_at *time.Time
  32420. status *uint8
  32421. addstatus *int8
  32422. deleted_at *time.Time
  32423. port *string
  32424. process_id *string
  32425. callback *string
  32426. wxid *string
  32427. account *string
  32428. nickname *string
  32429. tel *string
  32430. head_big *string
  32431. organization_id *uint64
  32432. addorganization_id *int64
  32433. api_base *string
  32434. api_key *string
  32435. allow_list *[]string
  32436. appendallow_list []string
  32437. group_allow_list *[]string
  32438. appendgroup_allow_list []string
  32439. block_list *[]string
  32440. appendblock_list []string
  32441. group_block_list *[]string
  32442. appendgroup_block_list []string
  32443. clearedFields map[string]struct{}
  32444. server *uint64
  32445. clearedserver bool
  32446. agent *uint64
  32447. clearedagent bool
  32448. done bool
  32449. oldValue func(context.Context) (*Wx, error)
  32450. predicates []predicate.Wx
  32451. }
  32452. var _ ent.Mutation = (*WxMutation)(nil)
  32453. // wxOption allows management of the mutation configuration using functional options.
  32454. type wxOption func(*WxMutation)
  32455. // newWxMutation creates new mutation for the Wx entity.
  32456. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  32457. m := &WxMutation{
  32458. config: c,
  32459. op: op,
  32460. typ: TypeWx,
  32461. clearedFields: make(map[string]struct{}),
  32462. }
  32463. for _, opt := range opts {
  32464. opt(m)
  32465. }
  32466. return m
  32467. }
  32468. // withWxID sets the ID field of the mutation.
  32469. func withWxID(id uint64) wxOption {
  32470. return func(m *WxMutation) {
  32471. var (
  32472. err error
  32473. once sync.Once
  32474. value *Wx
  32475. )
  32476. m.oldValue = func(ctx context.Context) (*Wx, error) {
  32477. once.Do(func() {
  32478. if m.done {
  32479. err = errors.New("querying old values post mutation is not allowed")
  32480. } else {
  32481. value, err = m.Client().Wx.Get(ctx, id)
  32482. }
  32483. })
  32484. return value, err
  32485. }
  32486. m.id = &id
  32487. }
  32488. }
  32489. // withWx sets the old Wx of the mutation.
  32490. func withWx(node *Wx) wxOption {
  32491. return func(m *WxMutation) {
  32492. m.oldValue = func(context.Context) (*Wx, error) {
  32493. return node, nil
  32494. }
  32495. m.id = &node.ID
  32496. }
  32497. }
  32498. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32499. // executed in a transaction (ent.Tx), a transactional client is returned.
  32500. func (m WxMutation) Client() *Client {
  32501. client := &Client{config: m.config}
  32502. client.init()
  32503. return client
  32504. }
  32505. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32506. // it returns an error otherwise.
  32507. func (m WxMutation) Tx() (*Tx, error) {
  32508. if _, ok := m.driver.(*txDriver); !ok {
  32509. return nil, errors.New("ent: mutation is not running in a transaction")
  32510. }
  32511. tx := &Tx{config: m.config}
  32512. tx.init()
  32513. return tx, nil
  32514. }
  32515. // SetID sets the value of the id field. Note that this
  32516. // operation is only accepted on creation of Wx entities.
  32517. func (m *WxMutation) SetID(id uint64) {
  32518. m.id = &id
  32519. }
  32520. // ID returns the ID value in the mutation. Note that the ID is only available
  32521. // if it was provided to the builder or after it was returned from the database.
  32522. func (m *WxMutation) ID() (id uint64, exists bool) {
  32523. if m.id == nil {
  32524. return
  32525. }
  32526. return *m.id, true
  32527. }
  32528. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32529. // That means, if the mutation is applied within a transaction with an isolation level such
  32530. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32531. // or updated by the mutation.
  32532. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  32533. switch {
  32534. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32535. id, exists := m.ID()
  32536. if exists {
  32537. return []uint64{id}, nil
  32538. }
  32539. fallthrough
  32540. case m.op.Is(OpUpdate | OpDelete):
  32541. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  32542. default:
  32543. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32544. }
  32545. }
  32546. // SetCreatedAt sets the "created_at" field.
  32547. func (m *WxMutation) SetCreatedAt(t time.Time) {
  32548. m.created_at = &t
  32549. }
  32550. // CreatedAt returns the value of the "created_at" field in the mutation.
  32551. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  32552. v := m.created_at
  32553. if v == nil {
  32554. return
  32555. }
  32556. return *v, true
  32557. }
  32558. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  32559. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32561. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32562. if !m.op.Is(OpUpdateOne) {
  32563. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32564. }
  32565. if m.id == nil || m.oldValue == nil {
  32566. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32567. }
  32568. oldValue, err := m.oldValue(ctx)
  32569. if err != nil {
  32570. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32571. }
  32572. return oldValue.CreatedAt, nil
  32573. }
  32574. // ResetCreatedAt resets all changes to the "created_at" field.
  32575. func (m *WxMutation) ResetCreatedAt() {
  32576. m.created_at = nil
  32577. }
  32578. // SetUpdatedAt sets the "updated_at" field.
  32579. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  32580. m.updated_at = &t
  32581. }
  32582. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32583. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  32584. v := m.updated_at
  32585. if v == nil {
  32586. return
  32587. }
  32588. return *v, true
  32589. }
  32590. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  32591. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32593. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32594. if !m.op.Is(OpUpdateOne) {
  32595. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32596. }
  32597. if m.id == nil || m.oldValue == nil {
  32598. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32599. }
  32600. oldValue, err := m.oldValue(ctx)
  32601. if err != nil {
  32602. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32603. }
  32604. return oldValue.UpdatedAt, nil
  32605. }
  32606. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32607. func (m *WxMutation) ResetUpdatedAt() {
  32608. m.updated_at = nil
  32609. }
  32610. // SetStatus sets the "status" field.
  32611. func (m *WxMutation) SetStatus(u uint8) {
  32612. m.status = &u
  32613. m.addstatus = nil
  32614. }
  32615. // Status returns the value of the "status" field in the mutation.
  32616. func (m *WxMutation) Status() (r uint8, exists bool) {
  32617. v := m.status
  32618. if v == nil {
  32619. return
  32620. }
  32621. return *v, true
  32622. }
  32623. // OldStatus returns the old "status" field's value of the Wx entity.
  32624. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32626. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32627. if !m.op.Is(OpUpdateOne) {
  32628. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32629. }
  32630. if m.id == nil || m.oldValue == nil {
  32631. return v, errors.New("OldStatus requires an ID field in the mutation")
  32632. }
  32633. oldValue, err := m.oldValue(ctx)
  32634. if err != nil {
  32635. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32636. }
  32637. return oldValue.Status, nil
  32638. }
  32639. // AddStatus adds u to the "status" field.
  32640. func (m *WxMutation) AddStatus(u int8) {
  32641. if m.addstatus != nil {
  32642. *m.addstatus += u
  32643. } else {
  32644. m.addstatus = &u
  32645. }
  32646. }
  32647. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32648. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  32649. v := m.addstatus
  32650. if v == nil {
  32651. return
  32652. }
  32653. return *v, true
  32654. }
  32655. // ClearStatus clears the value of the "status" field.
  32656. func (m *WxMutation) ClearStatus() {
  32657. m.status = nil
  32658. m.addstatus = nil
  32659. m.clearedFields[wx.FieldStatus] = struct{}{}
  32660. }
  32661. // StatusCleared returns if the "status" field was cleared in this mutation.
  32662. func (m *WxMutation) StatusCleared() bool {
  32663. _, ok := m.clearedFields[wx.FieldStatus]
  32664. return ok
  32665. }
  32666. // ResetStatus resets all changes to the "status" field.
  32667. func (m *WxMutation) ResetStatus() {
  32668. m.status = nil
  32669. m.addstatus = nil
  32670. delete(m.clearedFields, wx.FieldStatus)
  32671. }
  32672. // SetDeletedAt sets the "deleted_at" field.
  32673. func (m *WxMutation) SetDeletedAt(t time.Time) {
  32674. m.deleted_at = &t
  32675. }
  32676. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32677. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  32678. v := m.deleted_at
  32679. if v == nil {
  32680. return
  32681. }
  32682. return *v, true
  32683. }
  32684. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  32685. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32687. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32688. if !m.op.Is(OpUpdateOne) {
  32689. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32690. }
  32691. if m.id == nil || m.oldValue == nil {
  32692. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32693. }
  32694. oldValue, err := m.oldValue(ctx)
  32695. if err != nil {
  32696. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32697. }
  32698. return oldValue.DeletedAt, nil
  32699. }
  32700. // ClearDeletedAt clears the value of the "deleted_at" field.
  32701. func (m *WxMutation) ClearDeletedAt() {
  32702. m.deleted_at = nil
  32703. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  32704. }
  32705. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32706. func (m *WxMutation) DeletedAtCleared() bool {
  32707. _, ok := m.clearedFields[wx.FieldDeletedAt]
  32708. return ok
  32709. }
  32710. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32711. func (m *WxMutation) ResetDeletedAt() {
  32712. m.deleted_at = nil
  32713. delete(m.clearedFields, wx.FieldDeletedAt)
  32714. }
  32715. // SetServerID sets the "server_id" field.
  32716. func (m *WxMutation) SetServerID(u uint64) {
  32717. m.server = &u
  32718. }
  32719. // ServerID returns the value of the "server_id" field in the mutation.
  32720. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  32721. v := m.server
  32722. if v == nil {
  32723. return
  32724. }
  32725. return *v, true
  32726. }
  32727. // OldServerID returns the old "server_id" field's value of the Wx entity.
  32728. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32730. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  32731. if !m.op.Is(OpUpdateOne) {
  32732. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  32733. }
  32734. if m.id == nil || m.oldValue == nil {
  32735. return v, errors.New("OldServerID requires an ID field in the mutation")
  32736. }
  32737. oldValue, err := m.oldValue(ctx)
  32738. if err != nil {
  32739. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  32740. }
  32741. return oldValue.ServerID, nil
  32742. }
  32743. // ClearServerID clears the value of the "server_id" field.
  32744. func (m *WxMutation) ClearServerID() {
  32745. m.server = nil
  32746. m.clearedFields[wx.FieldServerID] = struct{}{}
  32747. }
  32748. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  32749. func (m *WxMutation) ServerIDCleared() bool {
  32750. _, ok := m.clearedFields[wx.FieldServerID]
  32751. return ok
  32752. }
  32753. // ResetServerID resets all changes to the "server_id" field.
  32754. func (m *WxMutation) ResetServerID() {
  32755. m.server = nil
  32756. delete(m.clearedFields, wx.FieldServerID)
  32757. }
  32758. // SetPort sets the "port" field.
  32759. func (m *WxMutation) SetPort(s string) {
  32760. m.port = &s
  32761. }
  32762. // Port returns the value of the "port" field in the mutation.
  32763. func (m *WxMutation) Port() (r string, exists bool) {
  32764. v := m.port
  32765. if v == nil {
  32766. return
  32767. }
  32768. return *v, true
  32769. }
  32770. // OldPort returns the old "port" field's value of the Wx entity.
  32771. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32773. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  32774. if !m.op.Is(OpUpdateOne) {
  32775. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  32776. }
  32777. if m.id == nil || m.oldValue == nil {
  32778. return v, errors.New("OldPort requires an ID field in the mutation")
  32779. }
  32780. oldValue, err := m.oldValue(ctx)
  32781. if err != nil {
  32782. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  32783. }
  32784. return oldValue.Port, nil
  32785. }
  32786. // ResetPort resets all changes to the "port" field.
  32787. func (m *WxMutation) ResetPort() {
  32788. m.port = nil
  32789. }
  32790. // SetProcessID sets the "process_id" field.
  32791. func (m *WxMutation) SetProcessID(s string) {
  32792. m.process_id = &s
  32793. }
  32794. // ProcessID returns the value of the "process_id" field in the mutation.
  32795. func (m *WxMutation) ProcessID() (r string, exists bool) {
  32796. v := m.process_id
  32797. if v == nil {
  32798. return
  32799. }
  32800. return *v, true
  32801. }
  32802. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  32803. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32805. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  32806. if !m.op.Is(OpUpdateOne) {
  32807. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  32808. }
  32809. if m.id == nil || m.oldValue == nil {
  32810. return v, errors.New("OldProcessID requires an ID field in the mutation")
  32811. }
  32812. oldValue, err := m.oldValue(ctx)
  32813. if err != nil {
  32814. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  32815. }
  32816. return oldValue.ProcessID, nil
  32817. }
  32818. // ResetProcessID resets all changes to the "process_id" field.
  32819. func (m *WxMutation) ResetProcessID() {
  32820. m.process_id = nil
  32821. }
  32822. // SetCallback sets the "callback" field.
  32823. func (m *WxMutation) SetCallback(s string) {
  32824. m.callback = &s
  32825. }
  32826. // Callback returns the value of the "callback" field in the mutation.
  32827. func (m *WxMutation) Callback() (r string, exists bool) {
  32828. v := m.callback
  32829. if v == nil {
  32830. return
  32831. }
  32832. return *v, true
  32833. }
  32834. // OldCallback returns the old "callback" field's value of the Wx entity.
  32835. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32837. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  32838. if !m.op.Is(OpUpdateOne) {
  32839. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  32840. }
  32841. if m.id == nil || m.oldValue == nil {
  32842. return v, errors.New("OldCallback requires an ID field in the mutation")
  32843. }
  32844. oldValue, err := m.oldValue(ctx)
  32845. if err != nil {
  32846. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  32847. }
  32848. return oldValue.Callback, nil
  32849. }
  32850. // ResetCallback resets all changes to the "callback" field.
  32851. func (m *WxMutation) ResetCallback() {
  32852. m.callback = nil
  32853. }
  32854. // SetWxid sets the "wxid" field.
  32855. func (m *WxMutation) SetWxid(s string) {
  32856. m.wxid = &s
  32857. }
  32858. // Wxid returns the value of the "wxid" field in the mutation.
  32859. func (m *WxMutation) Wxid() (r string, exists bool) {
  32860. v := m.wxid
  32861. if v == nil {
  32862. return
  32863. }
  32864. return *v, true
  32865. }
  32866. // OldWxid returns the old "wxid" field's value of the Wx entity.
  32867. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32869. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  32870. if !m.op.Is(OpUpdateOne) {
  32871. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  32872. }
  32873. if m.id == nil || m.oldValue == nil {
  32874. return v, errors.New("OldWxid requires an ID field in the mutation")
  32875. }
  32876. oldValue, err := m.oldValue(ctx)
  32877. if err != nil {
  32878. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  32879. }
  32880. return oldValue.Wxid, nil
  32881. }
  32882. // ResetWxid resets all changes to the "wxid" field.
  32883. func (m *WxMutation) ResetWxid() {
  32884. m.wxid = nil
  32885. }
  32886. // SetAccount sets the "account" field.
  32887. func (m *WxMutation) SetAccount(s string) {
  32888. m.account = &s
  32889. }
  32890. // Account returns the value of the "account" field in the mutation.
  32891. func (m *WxMutation) Account() (r string, exists bool) {
  32892. v := m.account
  32893. if v == nil {
  32894. return
  32895. }
  32896. return *v, true
  32897. }
  32898. // OldAccount returns the old "account" field's value of the Wx entity.
  32899. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32901. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  32902. if !m.op.Is(OpUpdateOne) {
  32903. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  32904. }
  32905. if m.id == nil || m.oldValue == nil {
  32906. return v, errors.New("OldAccount requires an ID field in the mutation")
  32907. }
  32908. oldValue, err := m.oldValue(ctx)
  32909. if err != nil {
  32910. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  32911. }
  32912. return oldValue.Account, nil
  32913. }
  32914. // ResetAccount resets all changes to the "account" field.
  32915. func (m *WxMutation) ResetAccount() {
  32916. m.account = nil
  32917. }
  32918. // SetNickname sets the "nickname" field.
  32919. func (m *WxMutation) SetNickname(s string) {
  32920. m.nickname = &s
  32921. }
  32922. // Nickname returns the value of the "nickname" field in the mutation.
  32923. func (m *WxMutation) Nickname() (r string, exists bool) {
  32924. v := m.nickname
  32925. if v == nil {
  32926. return
  32927. }
  32928. return *v, true
  32929. }
  32930. // OldNickname returns the old "nickname" field's value of the Wx entity.
  32931. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32933. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  32934. if !m.op.Is(OpUpdateOne) {
  32935. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32936. }
  32937. if m.id == nil || m.oldValue == nil {
  32938. return v, errors.New("OldNickname requires an ID field in the mutation")
  32939. }
  32940. oldValue, err := m.oldValue(ctx)
  32941. if err != nil {
  32942. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32943. }
  32944. return oldValue.Nickname, nil
  32945. }
  32946. // ResetNickname resets all changes to the "nickname" field.
  32947. func (m *WxMutation) ResetNickname() {
  32948. m.nickname = nil
  32949. }
  32950. // SetTel sets the "tel" field.
  32951. func (m *WxMutation) SetTel(s string) {
  32952. m.tel = &s
  32953. }
  32954. // Tel returns the value of the "tel" field in the mutation.
  32955. func (m *WxMutation) Tel() (r string, exists bool) {
  32956. v := m.tel
  32957. if v == nil {
  32958. return
  32959. }
  32960. return *v, true
  32961. }
  32962. // OldTel returns the old "tel" field's value of the Wx entity.
  32963. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32965. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  32966. if !m.op.Is(OpUpdateOne) {
  32967. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  32968. }
  32969. if m.id == nil || m.oldValue == nil {
  32970. return v, errors.New("OldTel requires an ID field in the mutation")
  32971. }
  32972. oldValue, err := m.oldValue(ctx)
  32973. if err != nil {
  32974. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  32975. }
  32976. return oldValue.Tel, nil
  32977. }
  32978. // ResetTel resets all changes to the "tel" field.
  32979. func (m *WxMutation) ResetTel() {
  32980. m.tel = nil
  32981. }
  32982. // SetHeadBig sets the "head_big" field.
  32983. func (m *WxMutation) SetHeadBig(s string) {
  32984. m.head_big = &s
  32985. }
  32986. // HeadBig returns the value of the "head_big" field in the mutation.
  32987. func (m *WxMutation) HeadBig() (r string, exists bool) {
  32988. v := m.head_big
  32989. if v == nil {
  32990. return
  32991. }
  32992. return *v, true
  32993. }
  32994. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  32995. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32997. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  32998. if !m.op.Is(OpUpdateOne) {
  32999. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  33000. }
  33001. if m.id == nil || m.oldValue == nil {
  33002. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  33003. }
  33004. oldValue, err := m.oldValue(ctx)
  33005. if err != nil {
  33006. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  33007. }
  33008. return oldValue.HeadBig, nil
  33009. }
  33010. // ResetHeadBig resets all changes to the "head_big" field.
  33011. func (m *WxMutation) ResetHeadBig() {
  33012. m.head_big = nil
  33013. }
  33014. // SetOrganizationID sets the "organization_id" field.
  33015. func (m *WxMutation) SetOrganizationID(u uint64) {
  33016. m.organization_id = &u
  33017. m.addorganization_id = nil
  33018. }
  33019. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33020. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  33021. v := m.organization_id
  33022. if v == nil {
  33023. return
  33024. }
  33025. return *v, true
  33026. }
  33027. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  33028. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33030. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33031. if !m.op.Is(OpUpdateOne) {
  33032. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33033. }
  33034. if m.id == nil || m.oldValue == nil {
  33035. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33036. }
  33037. oldValue, err := m.oldValue(ctx)
  33038. if err != nil {
  33039. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33040. }
  33041. return oldValue.OrganizationID, nil
  33042. }
  33043. // AddOrganizationID adds u to the "organization_id" field.
  33044. func (m *WxMutation) AddOrganizationID(u int64) {
  33045. if m.addorganization_id != nil {
  33046. *m.addorganization_id += u
  33047. } else {
  33048. m.addorganization_id = &u
  33049. }
  33050. }
  33051. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33052. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  33053. v := m.addorganization_id
  33054. if v == nil {
  33055. return
  33056. }
  33057. return *v, true
  33058. }
  33059. // ClearOrganizationID clears the value of the "organization_id" field.
  33060. func (m *WxMutation) ClearOrganizationID() {
  33061. m.organization_id = nil
  33062. m.addorganization_id = nil
  33063. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  33064. }
  33065. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33066. func (m *WxMutation) OrganizationIDCleared() bool {
  33067. _, ok := m.clearedFields[wx.FieldOrganizationID]
  33068. return ok
  33069. }
  33070. // ResetOrganizationID resets all changes to the "organization_id" field.
  33071. func (m *WxMutation) ResetOrganizationID() {
  33072. m.organization_id = nil
  33073. m.addorganization_id = nil
  33074. delete(m.clearedFields, wx.FieldOrganizationID)
  33075. }
  33076. // SetAgentID sets the "agent_id" field.
  33077. func (m *WxMutation) SetAgentID(u uint64) {
  33078. m.agent = &u
  33079. }
  33080. // AgentID returns the value of the "agent_id" field in the mutation.
  33081. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  33082. v := m.agent
  33083. if v == nil {
  33084. return
  33085. }
  33086. return *v, true
  33087. }
  33088. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  33089. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33091. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  33092. if !m.op.Is(OpUpdateOne) {
  33093. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  33094. }
  33095. if m.id == nil || m.oldValue == nil {
  33096. return v, errors.New("OldAgentID requires an ID field in the mutation")
  33097. }
  33098. oldValue, err := m.oldValue(ctx)
  33099. if err != nil {
  33100. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  33101. }
  33102. return oldValue.AgentID, nil
  33103. }
  33104. // ResetAgentID resets all changes to the "agent_id" field.
  33105. func (m *WxMutation) ResetAgentID() {
  33106. m.agent = nil
  33107. }
  33108. // SetAPIBase sets the "api_base" field.
  33109. func (m *WxMutation) SetAPIBase(s string) {
  33110. m.api_base = &s
  33111. }
  33112. // APIBase returns the value of the "api_base" field in the mutation.
  33113. func (m *WxMutation) APIBase() (r string, exists bool) {
  33114. v := m.api_base
  33115. if v == nil {
  33116. return
  33117. }
  33118. return *v, true
  33119. }
  33120. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  33121. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33123. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  33124. if !m.op.Is(OpUpdateOne) {
  33125. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  33126. }
  33127. if m.id == nil || m.oldValue == nil {
  33128. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  33129. }
  33130. oldValue, err := m.oldValue(ctx)
  33131. if err != nil {
  33132. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  33133. }
  33134. return oldValue.APIBase, nil
  33135. }
  33136. // ClearAPIBase clears the value of the "api_base" field.
  33137. func (m *WxMutation) ClearAPIBase() {
  33138. m.api_base = nil
  33139. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  33140. }
  33141. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  33142. func (m *WxMutation) APIBaseCleared() bool {
  33143. _, ok := m.clearedFields[wx.FieldAPIBase]
  33144. return ok
  33145. }
  33146. // ResetAPIBase resets all changes to the "api_base" field.
  33147. func (m *WxMutation) ResetAPIBase() {
  33148. m.api_base = nil
  33149. delete(m.clearedFields, wx.FieldAPIBase)
  33150. }
  33151. // SetAPIKey sets the "api_key" field.
  33152. func (m *WxMutation) SetAPIKey(s string) {
  33153. m.api_key = &s
  33154. }
  33155. // APIKey returns the value of the "api_key" field in the mutation.
  33156. func (m *WxMutation) APIKey() (r string, exists bool) {
  33157. v := m.api_key
  33158. if v == nil {
  33159. return
  33160. }
  33161. return *v, true
  33162. }
  33163. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  33164. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33166. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33167. if !m.op.Is(OpUpdateOne) {
  33168. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33169. }
  33170. if m.id == nil || m.oldValue == nil {
  33171. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33172. }
  33173. oldValue, err := m.oldValue(ctx)
  33174. if err != nil {
  33175. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33176. }
  33177. return oldValue.APIKey, nil
  33178. }
  33179. // ClearAPIKey clears the value of the "api_key" field.
  33180. func (m *WxMutation) ClearAPIKey() {
  33181. m.api_key = nil
  33182. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  33183. }
  33184. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33185. func (m *WxMutation) APIKeyCleared() bool {
  33186. _, ok := m.clearedFields[wx.FieldAPIKey]
  33187. return ok
  33188. }
  33189. // ResetAPIKey resets all changes to the "api_key" field.
  33190. func (m *WxMutation) ResetAPIKey() {
  33191. m.api_key = nil
  33192. delete(m.clearedFields, wx.FieldAPIKey)
  33193. }
  33194. // SetAllowList sets the "allow_list" field.
  33195. func (m *WxMutation) SetAllowList(s []string) {
  33196. m.allow_list = &s
  33197. m.appendallow_list = nil
  33198. }
  33199. // AllowList returns the value of the "allow_list" field in the mutation.
  33200. func (m *WxMutation) AllowList() (r []string, exists bool) {
  33201. v := m.allow_list
  33202. if v == nil {
  33203. return
  33204. }
  33205. return *v, true
  33206. }
  33207. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  33208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33210. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  33211. if !m.op.Is(OpUpdateOne) {
  33212. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  33213. }
  33214. if m.id == nil || m.oldValue == nil {
  33215. return v, errors.New("OldAllowList requires an ID field in the mutation")
  33216. }
  33217. oldValue, err := m.oldValue(ctx)
  33218. if err != nil {
  33219. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  33220. }
  33221. return oldValue.AllowList, nil
  33222. }
  33223. // AppendAllowList adds s to the "allow_list" field.
  33224. func (m *WxMutation) AppendAllowList(s []string) {
  33225. m.appendallow_list = append(m.appendallow_list, s...)
  33226. }
  33227. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  33228. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  33229. if len(m.appendallow_list) == 0 {
  33230. return nil, false
  33231. }
  33232. return m.appendallow_list, true
  33233. }
  33234. // ResetAllowList resets all changes to the "allow_list" field.
  33235. func (m *WxMutation) ResetAllowList() {
  33236. m.allow_list = nil
  33237. m.appendallow_list = nil
  33238. }
  33239. // SetGroupAllowList sets the "group_allow_list" field.
  33240. func (m *WxMutation) SetGroupAllowList(s []string) {
  33241. m.group_allow_list = &s
  33242. m.appendgroup_allow_list = nil
  33243. }
  33244. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  33245. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  33246. v := m.group_allow_list
  33247. if v == nil {
  33248. return
  33249. }
  33250. return *v, true
  33251. }
  33252. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  33253. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33255. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  33256. if !m.op.Is(OpUpdateOne) {
  33257. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  33258. }
  33259. if m.id == nil || m.oldValue == nil {
  33260. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  33261. }
  33262. oldValue, err := m.oldValue(ctx)
  33263. if err != nil {
  33264. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  33265. }
  33266. return oldValue.GroupAllowList, nil
  33267. }
  33268. // AppendGroupAllowList adds s to the "group_allow_list" field.
  33269. func (m *WxMutation) AppendGroupAllowList(s []string) {
  33270. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  33271. }
  33272. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  33273. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  33274. if len(m.appendgroup_allow_list) == 0 {
  33275. return nil, false
  33276. }
  33277. return m.appendgroup_allow_list, true
  33278. }
  33279. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  33280. func (m *WxMutation) ResetGroupAllowList() {
  33281. m.group_allow_list = nil
  33282. m.appendgroup_allow_list = nil
  33283. }
  33284. // SetBlockList sets the "block_list" field.
  33285. func (m *WxMutation) SetBlockList(s []string) {
  33286. m.block_list = &s
  33287. m.appendblock_list = nil
  33288. }
  33289. // BlockList returns the value of the "block_list" field in the mutation.
  33290. func (m *WxMutation) BlockList() (r []string, exists bool) {
  33291. v := m.block_list
  33292. if v == nil {
  33293. return
  33294. }
  33295. return *v, true
  33296. }
  33297. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  33298. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33300. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  33301. if !m.op.Is(OpUpdateOne) {
  33302. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  33303. }
  33304. if m.id == nil || m.oldValue == nil {
  33305. return v, errors.New("OldBlockList requires an ID field in the mutation")
  33306. }
  33307. oldValue, err := m.oldValue(ctx)
  33308. if err != nil {
  33309. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  33310. }
  33311. return oldValue.BlockList, nil
  33312. }
  33313. // AppendBlockList adds s to the "block_list" field.
  33314. func (m *WxMutation) AppendBlockList(s []string) {
  33315. m.appendblock_list = append(m.appendblock_list, s...)
  33316. }
  33317. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  33318. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  33319. if len(m.appendblock_list) == 0 {
  33320. return nil, false
  33321. }
  33322. return m.appendblock_list, true
  33323. }
  33324. // ResetBlockList resets all changes to the "block_list" field.
  33325. func (m *WxMutation) ResetBlockList() {
  33326. m.block_list = nil
  33327. m.appendblock_list = nil
  33328. }
  33329. // SetGroupBlockList sets the "group_block_list" field.
  33330. func (m *WxMutation) SetGroupBlockList(s []string) {
  33331. m.group_block_list = &s
  33332. m.appendgroup_block_list = nil
  33333. }
  33334. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  33335. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  33336. v := m.group_block_list
  33337. if v == nil {
  33338. return
  33339. }
  33340. return *v, true
  33341. }
  33342. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  33343. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33345. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  33346. if !m.op.Is(OpUpdateOne) {
  33347. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  33348. }
  33349. if m.id == nil || m.oldValue == nil {
  33350. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  33351. }
  33352. oldValue, err := m.oldValue(ctx)
  33353. if err != nil {
  33354. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  33355. }
  33356. return oldValue.GroupBlockList, nil
  33357. }
  33358. // AppendGroupBlockList adds s to the "group_block_list" field.
  33359. func (m *WxMutation) AppendGroupBlockList(s []string) {
  33360. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  33361. }
  33362. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  33363. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  33364. if len(m.appendgroup_block_list) == 0 {
  33365. return nil, false
  33366. }
  33367. return m.appendgroup_block_list, true
  33368. }
  33369. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  33370. func (m *WxMutation) ResetGroupBlockList() {
  33371. m.group_block_list = nil
  33372. m.appendgroup_block_list = nil
  33373. }
  33374. // ClearServer clears the "server" edge to the Server entity.
  33375. func (m *WxMutation) ClearServer() {
  33376. m.clearedserver = true
  33377. m.clearedFields[wx.FieldServerID] = struct{}{}
  33378. }
  33379. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  33380. func (m *WxMutation) ServerCleared() bool {
  33381. return m.ServerIDCleared() || m.clearedserver
  33382. }
  33383. // ServerIDs returns the "server" edge IDs in the mutation.
  33384. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33385. // ServerID instead. It exists only for internal usage by the builders.
  33386. func (m *WxMutation) ServerIDs() (ids []uint64) {
  33387. if id := m.server; id != nil {
  33388. ids = append(ids, *id)
  33389. }
  33390. return
  33391. }
  33392. // ResetServer resets all changes to the "server" edge.
  33393. func (m *WxMutation) ResetServer() {
  33394. m.server = nil
  33395. m.clearedserver = false
  33396. }
  33397. // ClearAgent clears the "agent" edge to the Agent entity.
  33398. func (m *WxMutation) ClearAgent() {
  33399. m.clearedagent = true
  33400. m.clearedFields[wx.FieldAgentID] = struct{}{}
  33401. }
  33402. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  33403. func (m *WxMutation) AgentCleared() bool {
  33404. return m.clearedagent
  33405. }
  33406. // AgentIDs returns the "agent" edge IDs in the mutation.
  33407. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33408. // AgentID instead. It exists only for internal usage by the builders.
  33409. func (m *WxMutation) AgentIDs() (ids []uint64) {
  33410. if id := m.agent; id != nil {
  33411. ids = append(ids, *id)
  33412. }
  33413. return
  33414. }
  33415. // ResetAgent resets all changes to the "agent" edge.
  33416. func (m *WxMutation) ResetAgent() {
  33417. m.agent = nil
  33418. m.clearedagent = false
  33419. }
  33420. // Where appends a list predicates to the WxMutation builder.
  33421. func (m *WxMutation) Where(ps ...predicate.Wx) {
  33422. m.predicates = append(m.predicates, ps...)
  33423. }
  33424. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  33425. // users can use type-assertion to append predicates that do not depend on any generated package.
  33426. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  33427. p := make([]predicate.Wx, len(ps))
  33428. for i := range ps {
  33429. p[i] = ps[i]
  33430. }
  33431. m.Where(p...)
  33432. }
  33433. // Op returns the operation name.
  33434. func (m *WxMutation) Op() Op {
  33435. return m.op
  33436. }
  33437. // SetOp allows setting the mutation operation.
  33438. func (m *WxMutation) SetOp(op Op) {
  33439. m.op = op
  33440. }
  33441. // Type returns the node type of this mutation (Wx).
  33442. func (m *WxMutation) Type() string {
  33443. return m.typ
  33444. }
  33445. // Fields returns all fields that were changed during this mutation. Note that in
  33446. // order to get all numeric fields that were incremented/decremented, call
  33447. // AddedFields().
  33448. func (m *WxMutation) Fields() []string {
  33449. fields := make([]string, 0, 21)
  33450. if m.created_at != nil {
  33451. fields = append(fields, wx.FieldCreatedAt)
  33452. }
  33453. if m.updated_at != nil {
  33454. fields = append(fields, wx.FieldUpdatedAt)
  33455. }
  33456. if m.status != nil {
  33457. fields = append(fields, wx.FieldStatus)
  33458. }
  33459. if m.deleted_at != nil {
  33460. fields = append(fields, wx.FieldDeletedAt)
  33461. }
  33462. if m.server != nil {
  33463. fields = append(fields, wx.FieldServerID)
  33464. }
  33465. if m.port != nil {
  33466. fields = append(fields, wx.FieldPort)
  33467. }
  33468. if m.process_id != nil {
  33469. fields = append(fields, wx.FieldProcessID)
  33470. }
  33471. if m.callback != nil {
  33472. fields = append(fields, wx.FieldCallback)
  33473. }
  33474. if m.wxid != nil {
  33475. fields = append(fields, wx.FieldWxid)
  33476. }
  33477. if m.account != nil {
  33478. fields = append(fields, wx.FieldAccount)
  33479. }
  33480. if m.nickname != nil {
  33481. fields = append(fields, wx.FieldNickname)
  33482. }
  33483. if m.tel != nil {
  33484. fields = append(fields, wx.FieldTel)
  33485. }
  33486. if m.head_big != nil {
  33487. fields = append(fields, wx.FieldHeadBig)
  33488. }
  33489. if m.organization_id != nil {
  33490. fields = append(fields, wx.FieldOrganizationID)
  33491. }
  33492. if m.agent != nil {
  33493. fields = append(fields, wx.FieldAgentID)
  33494. }
  33495. if m.api_base != nil {
  33496. fields = append(fields, wx.FieldAPIBase)
  33497. }
  33498. if m.api_key != nil {
  33499. fields = append(fields, wx.FieldAPIKey)
  33500. }
  33501. if m.allow_list != nil {
  33502. fields = append(fields, wx.FieldAllowList)
  33503. }
  33504. if m.group_allow_list != nil {
  33505. fields = append(fields, wx.FieldGroupAllowList)
  33506. }
  33507. if m.block_list != nil {
  33508. fields = append(fields, wx.FieldBlockList)
  33509. }
  33510. if m.group_block_list != nil {
  33511. fields = append(fields, wx.FieldGroupBlockList)
  33512. }
  33513. return fields
  33514. }
  33515. // Field returns the value of a field with the given name. The second boolean
  33516. // return value indicates that this field was not set, or was not defined in the
  33517. // schema.
  33518. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  33519. switch name {
  33520. case wx.FieldCreatedAt:
  33521. return m.CreatedAt()
  33522. case wx.FieldUpdatedAt:
  33523. return m.UpdatedAt()
  33524. case wx.FieldStatus:
  33525. return m.Status()
  33526. case wx.FieldDeletedAt:
  33527. return m.DeletedAt()
  33528. case wx.FieldServerID:
  33529. return m.ServerID()
  33530. case wx.FieldPort:
  33531. return m.Port()
  33532. case wx.FieldProcessID:
  33533. return m.ProcessID()
  33534. case wx.FieldCallback:
  33535. return m.Callback()
  33536. case wx.FieldWxid:
  33537. return m.Wxid()
  33538. case wx.FieldAccount:
  33539. return m.Account()
  33540. case wx.FieldNickname:
  33541. return m.Nickname()
  33542. case wx.FieldTel:
  33543. return m.Tel()
  33544. case wx.FieldHeadBig:
  33545. return m.HeadBig()
  33546. case wx.FieldOrganizationID:
  33547. return m.OrganizationID()
  33548. case wx.FieldAgentID:
  33549. return m.AgentID()
  33550. case wx.FieldAPIBase:
  33551. return m.APIBase()
  33552. case wx.FieldAPIKey:
  33553. return m.APIKey()
  33554. case wx.FieldAllowList:
  33555. return m.AllowList()
  33556. case wx.FieldGroupAllowList:
  33557. return m.GroupAllowList()
  33558. case wx.FieldBlockList:
  33559. return m.BlockList()
  33560. case wx.FieldGroupBlockList:
  33561. return m.GroupBlockList()
  33562. }
  33563. return nil, false
  33564. }
  33565. // OldField returns the old value of the field from the database. An error is
  33566. // returned if the mutation operation is not UpdateOne, or the query to the
  33567. // database failed.
  33568. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33569. switch name {
  33570. case wx.FieldCreatedAt:
  33571. return m.OldCreatedAt(ctx)
  33572. case wx.FieldUpdatedAt:
  33573. return m.OldUpdatedAt(ctx)
  33574. case wx.FieldStatus:
  33575. return m.OldStatus(ctx)
  33576. case wx.FieldDeletedAt:
  33577. return m.OldDeletedAt(ctx)
  33578. case wx.FieldServerID:
  33579. return m.OldServerID(ctx)
  33580. case wx.FieldPort:
  33581. return m.OldPort(ctx)
  33582. case wx.FieldProcessID:
  33583. return m.OldProcessID(ctx)
  33584. case wx.FieldCallback:
  33585. return m.OldCallback(ctx)
  33586. case wx.FieldWxid:
  33587. return m.OldWxid(ctx)
  33588. case wx.FieldAccount:
  33589. return m.OldAccount(ctx)
  33590. case wx.FieldNickname:
  33591. return m.OldNickname(ctx)
  33592. case wx.FieldTel:
  33593. return m.OldTel(ctx)
  33594. case wx.FieldHeadBig:
  33595. return m.OldHeadBig(ctx)
  33596. case wx.FieldOrganizationID:
  33597. return m.OldOrganizationID(ctx)
  33598. case wx.FieldAgentID:
  33599. return m.OldAgentID(ctx)
  33600. case wx.FieldAPIBase:
  33601. return m.OldAPIBase(ctx)
  33602. case wx.FieldAPIKey:
  33603. return m.OldAPIKey(ctx)
  33604. case wx.FieldAllowList:
  33605. return m.OldAllowList(ctx)
  33606. case wx.FieldGroupAllowList:
  33607. return m.OldGroupAllowList(ctx)
  33608. case wx.FieldBlockList:
  33609. return m.OldBlockList(ctx)
  33610. case wx.FieldGroupBlockList:
  33611. return m.OldGroupBlockList(ctx)
  33612. }
  33613. return nil, fmt.Errorf("unknown Wx field %s", name)
  33614. }
  33615. // SetField sets the value of a field with the given name. It returns an error if
  33616. // the field is not defined in the schema, or if the type mismatched the field
  33617. // type.
  33618. func (m *WxMutation) SetField(name string, value ent.Value) error {
  33619. switch name {
  33620. case wx.FieldCreatedAt:
  33621. v, ok := value.(time.Time)
  33622. if !ok {
  33623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33624. }
  33625. m.SetCreatedAt(v)
  33626. return nil
  33627. case wx.FieldUpdatedAt:
  33628. v, ok := value.(time.Time)
  33629. if !ok {
  33630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33631. }
  33632. m.SetUpdatedAt(v)
  33633. return nil
  33634. case wx.FieldStatus:
  33635. v, ok := value.(uint8)
  33636. if !ok {
  33637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33638. }
  33639. m.SetStatus(v)
  33640. return nil
  33641. case wx.FieldDeletedAt:
  33642. v, ok := value.(time.Time)
  33643. if !ok {
  33644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33645. }
  33646. m.SetDeletedAt(v)
  33647. return nil
  33648. case wx.FieldServerID:
  33649. v, ok := value.(uint64)
  33650. if !ok {
  33651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33652. }
  33653. m.SetServerID(v)
  33654. return nil
  33655. case wx.FieldPort:
  33656. v, ok := value.(string)
  33657. if !ok {
  33658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33659. }
  33660. m.SetPort(v)
  33661. return nil
  33662. case wx.FieldProcessID:
  33663. v, ok := value.(string)
  33664. if !ok {
  33665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33666. }
  33667. m.SetProcessID(v)
  33668. return nil
  33669. case wx.FieldCallback:
  33670. v, ok := value.(string)
  33671. if !ok {
  33672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33673. }
  33674. m.SetCallback(v)
  33675. return nil
  33676. case wx.FieldWxid:
  33677. v, ok := value.(string)
  33678. if !ok {
  33679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33680. }
  33681. m.SetWxid(v)
  33682. return nil
  33683. case wx.FieldAccount:
  33684. v, ok := value.(string)
  33685. if !ok {
  33686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33687. }
  33688. m.SetAccount(v)
  33689. return nil
  33690. case wx.FieldNickname:
  33691. v, ok := value.(string)
  33692. if !ok {
  33693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33694. }
  33695. m.SetNickname(v)
  33696. return nil
  33697. case wx.FieldTel:
  33698. v, ok := value.(string)
  33699. if !ok {
  33700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33701. }
  33702. m.SetTel(v)
  33703. return nil
  33704. case wx.FieldHeadBig:
  33705. v, ok := value.(string)
  33706. if !ok {
  33707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33708. }
  33709. m.SetHeadBig(v)
  33710. return nil
  33711. case wx.FieldOrganizationID:
  33712. v, ok := value.(uint64)
  33713. if !ok {
  33714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33715. }
  33716. m.SetOrganizationID(v)
  33717. return nil
  33718. case wx.FieldAgentID:
  33719. v, ok := value.(uint64)
  33720. if !ok {
  33721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33722. }
  33723. m.SetAgentID(v)
  33724. return nil
  33725. case wx.FieldAPIBase:
  33726. v, ok := value.(string)
  33727. if !ok {
  33728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33729. }
  33730. m.SetAPIBase(v)
  33731. return nil
  33732. case wx.FieldAPIKey:
  33733. v, ok := value.(string)
  33734. if !ok {
  33735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33736. }
  33737. m.SetAPIKey(v)
  33738. return nil
  33739. case wx.FieldAllowList:
  33740. v, ok := value.([]string)
  33741. if !ok {
  33742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33743. }
  33744. m.SetAllowList(v)
  33745. return nil
  33746. case wx.FieldGroupAllowList:
  33747. v, ok := value.([]string)
  33748. if !ok {
  33749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33750. }
  33751. m.SetGroupAllowList(v)
  33752. return nil
  33753. case wx.FieldBlockList:
  33754. v, ok := value.([]string)
  33755. if !ok {
  33756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33757. }
  33758. m.SetBlockList(v)
  33759. return nil
  33760. case wx.FieldGroupBlockList:
  33761. v, ok := value.([]string)
  33762. if !ok {
  33763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33764. }
  33765. m.SetGroupBlockList(v)
  33766. return nil
  33767. }
  33768. return fmt.Errorf("unknown Wx field %s", name)
  33769. }
  33770. // AddedFields returns all numeric fields that were incremented/decremented during
  33771. // this mutation.
  33772. func (m *WxMutation) AddedFields() []string {
  33773. var fields []string
  33774. if m.addstatus != nil {
  33775. fields = append(fields, wx.FieldStatus)
  33776. }
  33777. if m.addorganization_id != nil {
  33778. fields = append(fields, wx.FieldOrganizationID)
  33779. }
  33780. return fields
  33781. }
  33782. // AddedField returns the numeric value that was incremented/decremented on a field
  33783. // with the given name. The second boolean return value indicates that this field
  33784. // was not set, or was not defined in the schema.
  33785. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  33786. switch name {
  33787. case wx.FieldStatus:
  33788. return m.AddedStatus()
  33789. case wx.FieldOrganizationID:
  33790. return m.AddedOrganizationID()
  33791. }
  33792. return nil, false
  33793. }
  33794. // AddField adds the value to the field with the given name. It returns an error if
  33795. // the field is not defined in the schema, or if the type mismatched the field
  33796. // type.
  33797. func (m *WxMutation) AddField(name string, value ent.Value) error {
  33798. switch name {
  33799. case wx.FieldStatus:
  33800. v, ok := value.(int8)
  33801. if !ok {
  33802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33803. }
  33804. m.AddStatus(v)
  33805. return nil
  33806. case wx.FieldOrganizationID:
  33807. v, ok := value.(int64)
  33808. if !ok {
  33809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33810. }
  33811. m.AddOrganizationID(v)
  33812. return nil
  33813. }
  33814. return fmt.Errorf("unknown Wx numeric field %s", name)
  33815. }
  33816. // ClearedFields returns all nullable fields that were cleared during this
  33817. // mutation.
  33818. func (m *WxMutation) ClearedFields() []string {
  33819. var fields []string
  33820. if m.FieldCleared(wx.FieldStatus) {
  33821. fields = append(fields, wx.FieldStatus)
  33822. }
  33823. if m.FieldCleared(wx.FieldDeletedAt) {
  33824. fields = append(fields, wx.FieldDeletedAt)
  33825. }
  33826. if m.FieldCleared(wx.FieldServerID) {
  33827. fields = append(fields, wx.FieldServerID)
  33828. }
  33829. if m.FieldCleared(wx.FieldOrganizationID) {
  33830. fields = append(fields, wx.FieldOrganizationID)
  33831. }
  33832. if m.FieldCleared(wx.FieldAPIBase) {
  33833. fields = append(fields, wx.FieldAPIBase)
  33834. }
  33835. if m.FieldCleared(wx.FieldAPIKey) {
  33836. fields = append(fields, wx.FieldAPIKey)
  33837. }
  33838. return fields
  33839. }
  33840. // FieldCleared returns a boolean indicating if a field with the given name was
  33841. // cleared in this mutation.
  33842. func (m *WxMutation) FieldCleared(name string) bool {
  33843. _, ok := m.clearedFields[name]
  33844. return ok
  33845. }
  33846. // ClearField clears the value of the field with the given name. It returns an
  33847. // error if the field is not defined in the schema.
  33848. func (m *WxMutation) ClearField(name string) error {
  33849. switch name {
  33850. case wx.FieldStatus:
  33851. m.ClearStatus()
  33852. return nil
  33853. case wx.FieldDeletedAt:
  33854. m.ClearDeletedAt()
  33855. return nil
  33856. case wx.FieldServerID:
  33857. m.ClearServerID()
  33858. return nil
  33859. case wx.FieldOrganizationID:
  33860. m.ClearOrganizationID()
  33861. return nil
  33862. case wx.FieldAPIBase:
  33863. m.ClearAPIBase()
  33864. return nil
  33865. case wx.FieldAPIKey:
  33866. m.ClearAPIKey()
  33867. return nil
  33868. }
  33869. return fmt.Errorf("unknown Wx nullable field %s", name)
  33870. }
  33871. // ResetField resets all changes in the mutation for the field with the given name.
  33872. // It returns an error if the field is not defined in the schema.
  33873. func (m *WxMutation) ResetField(name string) error {
  33874. switch name {
  33875. case wx.FieldCreatedAt:
  33876. m.ResetCreatedAt()
  33877. return nil
  33878. case wx.FieldUpdatedAt:
  33879. m.ResetUpdatedAt()
  33880. return nil
  33881. case wx.FieldStatus:
  33882. m.ResetStatus()
  33883. return nil
  33884. case wx.FieldDeletedAt:
  33885. m.ResetDeletedAt()
  33886. return nil
  33887. case wx.FieldServerID:
  33888. m.ResetServerID()
  33889. return nil
  33890. case wx.FieldPort:
  33891. m.ResetPort()
  33892. return nil
  33893. case wx.FieldProcessID:
  33894. m.ResetProcessID()
  33895. return nil
  33896. case wx.FieldCallback:
  33897. m.ResetCallback()
  33898. return nil
  33899. case wx.FieldWxid:
  33900. m.ResetWxid()
  33901. return nil
  33902. case wx.FieldAccount:
  33903. m.ResetAccount()
  33904. return nil
  33905. case wx.FieldNickname:
  33906. m.ResetNickname()
  33907. return nil
  33908. case wx.FieldTel:
  33909. m.ResetTel()
  33910. return nil
  33911. case wx.FieldHeadBig:
  33912. m.ResetHeadBig()
  33913. return nil
  33914. case wx.FieldOrganizationID:
  33915. m.ResetOrganizationID()
  33916. return nil
  33917. case wx.FieldAgentID:
  33918. m.ResetAgentID()
  33919. return nil
  33920. case wx.FieldAPIBase:
  33921. m.ResetAPIBase()
  33922. return nil
  33923. case wx.FieldAPIKey:
  33924. m.ResetAPIKey()
  33925. return nil
  33926. case wx.FieldAllowList:
  33927. m.ResetAllowList()
  33928. return nil
  33929. case wx.FieldGroupAllowList:
  33930. m.ResetGroupAllowList()
  33931. return nil
  33932. case wx.FieldBlockList:
  33933. m.ResetBlockList()
  33934. return nil
  33935. case wx.FieldGroupBlockList:
  33936. m.ResetGroupBlockList()
  33937. return nil
  33938. }
  33939. return fmt.Errorf("unknown Wx field %s", name)
  33940. }
  33941. // AddedEdges returns all edge names that were set/added in this mutation.
  33942. func (m *WxMutation) AddedEdges() []string {
  33943. edges := make([]string, 0, 2)
  33944. if m.server != nil {
  33945. edges = append(edges, wx.EdgeServer)
  33946. }
  33947. if m.agent != nil {
  33948. edges = append(edges, wx.EdgeAgent)
  33949. }
  33950. return edges
  33951. }
  33952. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33953. // name in this mutation.
  33954. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  33955. switch name {
  33956. case wx.EdgeServer:
  33957. if id := m.server; id != nil {
  33958. return []ent.Value{*id}
  33959. }
  33960. case wx.EdgeAgent:
  33961. if id := m.agent; id != nil {
  33962. return []ent.Value{*id}
  33963. }
  33964. }
  33965. return nil
  33966. }
  33967. // RemovedEdges returns all edge names that were removed in this mutation.
  33968. func (m *WxMutation) RemovedEdges() []string {
  33969. edges := make([]string, 0, 2)
  33970. return edges
  33971. }
  33972. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33973. // the given name in this mutation.
  33974. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  33975. return nil
  33976. }
  33977. // ClearedEdges returns all edge names that were cleared in this mutation.
  33978. func (m *WxMutation) ClearedEdges() []string {
  33979. edges := make([]string, 0, 2)
  33980. if m.clearedserver {
  33981. edges = append(edges, wx.EdgeServer)
  33982. }
  33983. if m.clearedagent {
  33984. edges = append(edges, wx.EdgeAgent)
  33985. }
  33986. return edges
  33987. }
  33988. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33989. // was cleared in this mutation.
  33990. func (m *WxMutation) EdgeCleared(name string) bool {
  33991. switch name {
  33992. case wx.EdgeServer:
  33993. return m.clearedserver
  33994. case wx.EdgeAgent:
  33995. return m.clearedagent
  33996. }
  33997. return false
  33998. }
  33999. // ClearEdge clears the value of the edge with the given name. It returns an error
  34000. // if that edge is not defined in the schema.
  34001. func (m *WxMutation) ClearEdge(name string) error {
  34002. switch name {
  34003. case wx.EdgeServer:
  34004. m.ClearServer()
  34005. return nil
  34006. case wx.EdgeAgent:
  34007. m.ClearAgent()
  34008. return nil
  34009. }
  34010. return fmt.Errorf("unknown Wx unique edge %s", name)
  34011. }
  34012. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34013. // It returns an error if the edge is not defined in the schema.
  34014. func (m *WxMutation) ResetEdge(name string) error {
  34015. switch name {
  34016. case wx.EdgeServer:
  34017. m.ResetServer()
  34018. return nil
  34019. case wx.EdgeAgent:
  34020. m.ResetAgent()
  34021. return nil
  34022. }
  34023. return fmt.Errorf("unknown Wx edge %s", name)
  34024. }
  34025. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  34026. type WxCardMutation struct {
  34027. config
  34028. op Op
  34029. typ string
  34030. id *uint64
  34031. created_at *time.Time
  34032. updated_at *time.Time
  34033. deleted_at *time.Time
  34034. user_id *uint64
  34035. adduser_id *int64
  34036. wx_user_id *uint64
  34037. addwx_user_id *int64
  34038. avatar *string
  34039. logo *string
  34040. name *string
  34041. company *string
  34042. address *string
  34043. phone *string
  34044. official_account *string
  34045. wechat_account *string
  34046. email *string
  34047. api_base *string
  34048. api_key *string
  34049. ai_info *string
  34050. intro *string
  34051. clearedFields map[string]struct{}
  34052. done bool
  34053. oldValue func(context.Context) (*WxCard, error)
  34054. predicates []predicate.WxCard
  34055. }
  34056. var _ ent.Mutation = (*WxCardMutation)(nil)
  34057. // wxcardOption allows management of the mutation configuration using functional options.
  34058. type wxcardOption func(*WxCardMutation)
  34059. // newWxCardMutation creates new mutation for the WxCard entity.
  34060. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  34061. m := &WxCardMutation{
  34062. config: c,
  34063. op: op,
  34064. typ: TypeWxCard,
  34065. clearedFields: make(map[string]struct{}),
  34066. }
  34067. for _, opt := range opts {
  34068. opt(m)
  34069. }
  34070. return m
  34071. }
  34072. // withWxCardID sets the ID field of the mutation.
  34073. func withWxCardID(id uint64) wxcardOption {
  34074. return func(m *WxCardMutation) {
  34075. var (
  34076. err error
  34077. once sync.Once
  34078. value *WxCard
  34079. )
  34080. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  34081. once.Do(func() {
  34082. if m.done {
  34083. err = errors.New("querying old values post mutation is not allowed")
  34084. } else {
  34085. value, err = m.Client().WxCard.Get(ctx, id)
  34086. }
  34087. })
  34088. return value, err
  34089. }
  34090. m.id = &id
  34091. }
  34092. }
  34093. // withWxCard sets the old WxCard of the mutation.
  34094. func withWxCard(node *WxCard) wxcardOption {
  34095. return func(m *WxCardMutation) {
  34096. m.oldValue = func(context.Context) (*WxCard, error) {
  34097. return node, nil
  34098. }
  34099. m.id = &node.ID
  34100. }
  34101. }
  34102. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34103. // executed in a transaction (ent.Tx), a transactional client is returned.
  34104. func (m WxCardMutation) Client() *Client {
  34105. client := &Client{config: m.config}
  34106. client.init()
  34107. return client
  34108. }
  34109. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34110. // it returns an error otherwise.
  34111. func (m WxCardMutation) Tx() (*Tx, error) {
  34112. if _, ok := m.driver.(*txDriver); !ok {
  34113. return nil, errors.New("ent: mutation is not running in a transaction")
  34114. }
  34115. tx := &Tx{config: m.config}
  34116. tx.init()
  34117. return tx, nil
  34118. }
  34119. // SetID sets the value of the id field. Note that this
  34120. // operation is only accepted on creation of WxCard entities.
  34121. func (m *WxCardMutation) SetID(id uint64) {
  34122. m.id = &id
  34123. }
  34124. // ID returns the ID value in the mutation. Note that the ID is only available
  34125. // if it was provided to the builder or after it was returned from the database.
  34126. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  34127. if m.id == nil {
  34128. return
  34129. }
  34130. return *m.id, true
  34131. }
  34132. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34133. // That means, if the mutation is applied within a transaction with an isolation level such
  34134. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34135. // or updated by the mutation.
  34136. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  34137. switch {
  34138. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34139. id, exists := m.ID()
  34140. if exists {
  34141. return []uint64{id}, nil
  34142. }
  34143. fallthrough
  34144. case m.op.Is(OpUpdate | OpDelete):
  34145. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  34146. default:
  34147. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34148. }
  34149. }
  34150. // SetCreatedAt sets the "created_at" field.
  34151. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  34152. m.created_at = &t
  34153. }
  34154. // CreatedAt returns the value of the "created_at" field in the mutation.
  34155. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  34156. v := m.created_at
  34157. if v == nil {
  34158. return
  34159. }
  34160. return *v, true
  34161. }
  34162. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  34163. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34165. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34166. if !m.op.Is(OpUpdateOne) {
  34167. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34168. }
  34169. if m.id == nil || m.oldValue == nil {
  34170. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34171. }
  34172. oldValue, err := m.oldValue(ctx)
  34173. if err != nil {
  34174. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34175. }
  34176. return oldValue.CreatedAt, nil
  34177. }
  34178. // ResetCreatedAt resets all changes to the "created_at" field.
  34179. func (m *WxCardMutation) ResetCreatedAt() {
  34180. m.created_at = nil
  34181. }
  34182. // SetUpdatedAt sets the "updated_at" field.
  34183. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  34184. m.updated_at = &t
  34185. }
  34186. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34187. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  34188. v := m.updated_at
  34189. if v == nil {
  34190. return
  34191. }
  34192. return *v, true
  34193. }
  34194. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  34195. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34197. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34198. if !m.op.Is(OpUpdateOne) {
  34199. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34200. }
  34201. if m.id == nil || m.oldValue == nil {
  34202. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34203. }
  34204. oldValue, err := m.oldValue(ctx)
  34205. if err != nil {
  34206. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34207. }
  34208. return oldValue.UpdatedAt, nil
  34209. }
  34210. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34211. func (m *WxCardMutation) ResetUpdatedAt() {
  34212. m.updated_at = nil
  34213. }
  34214. // SetDeletedAt sets the "deleted_at" field.
  34215. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  34216. m.deleted_at = &t
  34217. }
  34218. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34219. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  34220. v := m.deleted_at
  34221. if v == nil {
  34222. return
  34223. }
  34224. return *v, true
  34225. }
  34226. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  34227. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34229. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34230. if !m.op.Is(OpUpdateOne) {
  34231. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34232. }
  34233. if m.id == nil || m.oldValue == nil {
  34234. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34235. }
  34236. oldValue, err := m.oldValue(ctx)
  34237. if err != nil {
  34238. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34239. }
  34240. return oldValue.DeletedAt, nil
  34241. }
  34242. // ClearDeletedAt clears the value of the "deleted_at" field.
  34243. func (m *WxCardMutation) ClearDeletedAt() {
  34244. m.deleted_at = nil
  34245. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  34246. }
  34247. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34248. func (m *WxCardMutation) DeletedAtCleared() bool {
  34249. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  34250. return ok
  34251. }
  34252. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34253. func (m *WxCardMutation) ResetDeletedAt() {
  34254. m.deleted_at = nil
  34255. delete(m.clearedFields, wxcard.FieldDeletedAt)
  34256. }
  34257. // SetUserID sets the "user_id" field.
  34258. func (m *WxCardMutation) SetUserID(u uint64) {
  34259. m.user_id = &u
  34260. m.adduser_id = nil
  34261. }
  34262. // UserID returns the value of the "user_id" field in the mutation.
  34263. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  34264. v := m.user_id
  34265. if v == nil {
  34266. return
  34267. }
  34268. return *v, true
  34269. }
  34270. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  34271. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34273. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  34274. if !m.op.Is(OpUpdateOne) {
  34275. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  34276. }
  34277. if m.id == nil || m.oldValue == nil {
  34278. return v, errors.New("OldUserID requires an ID field in the mutation")
  34279. }
  34280. oldValue, err := m.oldValue(ctx)
  34281. if err != nil {
  34282. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  34283. }
  34284. return oldValue.UserID, nil
  34285. }
  34286. // AddUserID adds u to the "user_id" field.
  34287. func (m *WxCardMutation) AddUserID(u int64) {
  34288. if m.adduser_id != nil {
  34289. *m.adduser_id += u
  34290. } else {
  34291. m.adduser_id = &u
  34292. }
  34293. }
  34294. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  34295. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  34296. v := m.adduser_id
  34297. if v == nil {
  34298. return
  34299. }
  34300. return *v, true
  34301. }
  34302. // ClearUserID clears the value of the "user_id" field.
  34303. func (m *WxCardMutation) ClearUserID() {
  34304. m.user_id = nil
  34305. m.adduser_id = nil
  34306. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  34307. }
  34308. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  34309. func (m *WxCardMutation) UserIDCleared() bool {
  34310. _, ok := m.clearedFields[wxcard.FieldUserID]
  34311. return ok
  34312. }
  34313. // ResetUserID resets all changes to the "user_id" field.
  34314. func (m *WxCardMutation) ResetUserID() {
  34315. m.user_id = nil
  34316. m.adduser_id = nil
  34317. delete(m.clearedFields, wxcard.FieldUserID)
  34318. }
  34319. // SetWxUserID sets the "wx_user_id" field.
  34320. func (m *WxCardMutation) SetWxUserID(u uint64) {
  34321. m.wx_user_id = &u
  34322. m.addwx_user_id = nil
  34323. }
  34324. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  34325. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  34326. v := m.wx_user_id
  34327. if v == nil {
  34328. return
  34329. }
  34330. return *v, true
  34331. }
  34332. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  34333. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34335. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  34336. if !m.op.Is(OpUpdateOne) {
  34337. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  34338. }
  34339. if m.id == nil || m.oldValue == nil {
  34340. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  34341. }
  34342. oldValue, err := m.oldValue(ctx)
  34343. if err != nil {
  34344. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  34345. }
  34346. return oldValue.WxUserID, nil
  34347. }
  34348. // AddWxUserID adds u to the "wx_user_id" field.
  34349. func (m *WxCardMutation) AddWxUserID(u int64) {
  34350. if m.addwx_user_id != nil {
  34351. *m.addwx_user_id += u
  34352. } else {
  34353. m.addwx_user_id = &u
  34354. }
  34355. }
  34356. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  34357. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  34358. v := m.addwx_user_id
  34359. if v == nil {
  34360. return
  34361. }
  34362. return *v, true
  34363. }
  34364. // ClearWxUserID clears the value of the "wx_user_id" field.
  34365. func (m *WxCardMutation) ClearWxUserID() {
  34366. m.wx_user_id = nil
  34367. m.addwx_user_id = nil
  34368. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  34369. }
  34370. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  34371. func (m *WxCardMutation) WxUserIDCleared() bool {
  34372. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  34373. return ok
  34374. }
  34375. // ResetWxUserID resets all changes to the "wx_user_id" field.
  34376. func (m *WxCardMutation) ResetWxUserID() {
  34377. m.wx_user_id = nil
  34378. m.addwx_user_id = nil
  34379. delete(m.clearedFields, wxcard.FieldWxUserID)
  34380. }
  34381. // SetAvatar sets the "avatar" field.
  34382. func (m *WxCardMutation) SetAvatar(s string) {
  34383. m.avatar = &s
  34384. }
  34385. // Avatar returns the value of the "avatar" field in the mutation.
  34386. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  34387. v := m.avatar
  34388. if v == nil {
  34389. return
  34390. }
  34391. return *v, true
  34392. }
  34393. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  34394. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34396. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34397. if !m.op.Is(OpUpdateOne) {
  34398. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34399. }
  34400. if m.id == nil || m.oldValue == nil {
  34401. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34402. }
  34403. oldValue, err := m.oldValue(ctx)
  34404. if err != nil {
  34405. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34406. }
  34407. return oldValue.Avatar, nil
  34408. }
  34409. // ResetAvatar resets all changes to the "avatar" field.
  34410. func (m *WxCardMutation) ResetAvatar() {
  34411. m.avatar = nil
  34412. }
  34413. // SetLogo sets the "logo" field.
  34414. func (m *WxCardMutation) SetLogo(s string) {
  34415. m.logo = &s
  34416. }
  34417. // Logo returns the value of the "logo" field in the mutation.
  34418. func (m *WxCardMutation) Logo() (r string, exists bool) {
  34419. v := m.logo
  34420. if v == nil {
  34421. return
  34422. }
  34423. return *v, true
  34424. }
  34425. // OldLogo returns the old "logo" field's value of the WxCard entity.
  34426. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34428. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  34429. if !m.op.Is(OpUpdateOne) {
  34430. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  34431. }
  34432. if m.id == nil || m.oldValue == nil {
  34433. return v, errors.New("OldLogo requires an ID field in the mutation")
  34434. }
  34435. oldValue, err := m.oldValue(ctx)
  34436. if err != nil {
  34437. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  34438. }
  34439. return oldValue.Logo, nil
  34440. }
  34441. // ResetLogo resets all changes to the "logo" field.
  34442. func (m *WxCardMutation) ResetLogo() {
  34443. m.logo = nil
  34444. }
  34445. // SetName sets the "name" field.
  34446. func (m *WxCardMutation) SetName(s string) {
  34447. m.name = &s
  34448. }
  34449. // Name returns the value of the "name" field in the mutation.
  34450. func (m *WxCardMutation) Name() (r string, exists bool) {
  34451. v := m.name
  34452. if v == nil {
  34453. return
  34454. }
  34455. return *v, true
  34456. }
  34457. // OldName returns the old "name" field's value of the WxCard entity.
  34458. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34460. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  34461. if !m.op.Is(OpUpdateOne) {
  34462. return v, errors.New("OldName is only allowed on UpdateOne operations")
  34463. }
  34464. if m.id == nil || m.oldValue == nil {
  34465. return v, errors.New("OldName requires an ID field in the mutation")
  34466. }
  34467. oldValue, err := m.oldValue(ctx)
  34468. if err != nil {
  34469. return v, fmt.Errorf("querying old value for OldName: %w", err)
  34470. }
  34471. return oldValue.Name, nil
  34472. }
  34473. // ResetName resets all changes to the "name" field.
  34474. func (m *WxCardMutation) ResetName() {
  34475. m.name = nil
  34476. }
  34477. // SetCompany sets the "company" field.
  34478. func (m *WxCardMutation) SetCompany(s string) {
  34479. m.company = &s
  34480. }
  34481. // Company returns the value of the "company" field in the mutation.
  34482. func (m *WxCardMutation) Company() (r string, exists bool) {
  34483. v := m.company
  34484. if v == nil {
  34485. return
  34486. }
  34487. return *v, true
  34488. }
  34489. // OldCompany returns the old "company" field's value of the WxCard entity.
  34490. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34492. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  34493. if !m.op.Is(OpUpdateOne) {
  34494. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  34495. }
  34496. if m.id == nil || m.oldValue == nil {
  34497. return v, errors.New("OldCompany requires an ID field in the mutation")
  34498. }
  34499. oldValue, err := m.oldValue(ctx)
  34500. if err != nil {
  34501. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  34502. }
  34503. return oldValue.Company, nil
  34504. }
  34505. // ResetCompany resets all changes to the "company" field.
  34506. func (m *WxCardMutation) ResetCompany() {
  34507. m.company = nil
  34508. }
  34509. // SetAddress sets the "address" field.
  34510. func (m *WxCardMutation) SetAddress(s string) {
  34511. m.address = &s
  34512. }
  34513. // Address returns the value of the "address" field in the mutation.
  34514. func (m *WxCardMutation) Address() (r string, exists bool) {
  34515. v := m.address
  34516. if v == nil {
  34517. return
  34518. }
  34519. return *v, true
  34520. }
  34521. // OldAddress returns the old "address" field's value of the WxCard entity.
  34522. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34524. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  34525. if !m.op.Is(OpUpdateOne) {
  34526. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  34527. }
  34528. if m.id == nil || m.oldValue == nil {
  34529. return v, errors.New("OldAddress requires an ID field in the mutation")
  34530. }
  34531. oldValue, err := m.oldValue(ctx)
  34532. if err != nil {
  34533. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  34534. }
  34535. return oldValue.Address, nil
  34536. }
  34537. // ResetAddress resets all changes to the "address" field.
  34538. func (m *WxCardMutation) ResetAddress() {
  34539. m.address = nil
  34540. }
  34541. // SetPhone sets the "phone" field.
  34542. func (m *WxCardMutation) SetPhone(s string) {
  34543. m.phone = &s
  34544. }
  34545. // Phone returns the value of the "phone" field in the mutation.
  34546. func (m *WxCardMutation) Phone() (r string, exists bool) {
  34547. v := m.phone
  34548. if v == nil {
  34549. return
  34550. }
  34551. return *v, true
  34552. }
  34553. // OldPhone returns the old "phone" field's value of the WxCard entity.
  34554. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34556. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  34557. if !m.op.Is(OpUpdateOne) {
  34558. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34559. }
  34560. if m.id == nil || m.oldValue == nil {
  34561. return v, errors.New("OldPhone requires an ID field in the mutation")
  34562. }
  34563. oldValue, err := m.oldValue(ctx)
  34564. if err != nil {
  34565. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34566. }
  34567. return oldValue.Phone, nil
  34568. }
  34569. // ResetPhone resets all changes to the "phone" field.
  34570. func (m *WxCardMutation) ResetPhone() {
  34571. m.phone = nil
  34572. }
  34573. // SetOfficialAccount sets the "official_account" field.
  34574. func (m *WxCardMutation) SetOfficialAccount(s string) {
  34575. m.official_account = &s
  34576. }
  34577. // OfficialAccount returns the value of the "official_account" field in the mutation.
  34578. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  34579. v := m.official_account
  34580. if v == nil {
  34581. return
  34582. }
  34583. return *v, true
  34584. }
  34585. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  34586. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34588. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  34589. if !m.op.Is(OpUpdateOne) {
  34590. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  34591. }
  34592. if m.id == nil || m.oldValue == nil {
  34593. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  34594. }
  34595. oldValue, err := m.oldValue(ctx)
  34596. if err != nil {
  34597. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  34598. }
  34599. return oldValue.OfficialAccount, nil
  34600. }
  34601. // ResetOfficialAccount resets all changes to the "official_account" field.
  34602. func (m *WxCardMutation) ResetOfficialAccount() {
  34603. m.official_account = nil
  34604. }
  34605. // SetWechatAccount sets the "wechat_account" field.
  34606. func (m *WxCardMutation) SetWechatAccount(s string) {
  34607. m.wechat_account = &s
  34608. }
  34609. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  34610. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  34611. v := m.wechat_account
  34612. if v == nil {
  34613. return
  34614. }
  34615. return *v, true
  34616. }
  34617. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  34618. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34620. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  34621. if !m.op.Is(OpUpdateOne) {
  34622. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  34623. }
  34624. if m.id == nil || m.oldValue == nil {
  34625. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  34626. }
  34627. oldValue, err := m.oldValue(ctx)
  34628. if err != nil {
  34629. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  34630. }
  34631. return oldValue.WechatAccount, nil
  34632. }
  34633. // ResetWechatAccount resets all changes to the "wechat_account" field.
  34634. func (m *WxCardMutation) ResetWechatAccount() {
  34635. m.wechat_account = nil
  34636. }
  34637. // SetEmail sets the "email" field.
  34638. func (m *WxCardMutation) SetEmail(s string) {
  34639. m.email = &s
  34640. }
  34641. // Email returns the value of the "email" field in the mutation.
  34642. func (m *WxCardMutation) Email() (r string, exists bool) {
  34643. v := m.email
  34644. if v == nil {
  34645. return
  34646. }
  34647. return *v, true
  34648. }
  34649. // OldEmail returns the old "email" field's value of the WxCard entity.
  34650. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34652. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  34653. if !m.op.Is(OpUpdateOne) {
  34654. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  34655. }
  34656. if m.id == nil || m.oldValue == nil {
  34657. return v, errors.New("OldEmail requires an ID field in the mutation")
  34658. }
  34659. oldValue, err := m.oldValue(ctx)
  34660. if err != nil {
  34661. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  34662. }
  34663. return oldValue.Email, nil
  34664. }
  34665. // ClearEmail clears the value of the "email" field.
  34666. func (m *WxCardMutation) ClearEmail() {
  34667. m.email = nil
  34668. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  34669. }
  34670. // EmailCleared returns if the "email" field was cleared in this mutation.
  34671. func (m *WxCardMutation) EmailCleared() bool {
  34672. _, ok := m.clearedFields[wxcard.FieldEmail]
  34673. return ok
  34674. }
  34675. // ResetEmail resets all changes to the "email" field.
  34676. func (m *WxCardMutation) ResetEmail() {
  34677. m.email = nil
  34678. delete(m.clearedFields, wxcard.FieldEmail)
  34679. }
  34680. // SetAPIBase sets the "api_base" field.
  34681. func (m *WxCardMutation) SetAPIBase(s string) {
  34682. m.api_base = &s
  34683. }
  34684. // APIBase returns the value of the "api_base" field in the mutation.
  34685. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  34686. v := m.api_base
  34687. if v == nil {
  34688. return
  34689. }
  34690. return *v, true
  34691. }
  34692. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  34693. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34695. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34696. if !m.op.Is(OpUpdateOne) {
  34697. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34698. }
  34699. if m.id == nil || m.oldValue == nil {
  34700. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34701. }
  34702. oldValue, err := m.oldValue(ctx)
  34703. if err != nil {
  34704. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34705. }
  34706. return oldValue.APIBase, nil
  34707. }
  34708. // ClearAPIBase clears the value of the "api_base" field.
  34709. func (m *WxCardMutation) ClearAPIBase() {
  34710. m.api_base = nil
  34711. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  34712. }
  34713. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34714. func (m *WxCardMutation) APIBaseCleared() bool {
  34715. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  34716. return ok
  34717. }
  34718. // ResetAPIBase resets all changes to the "api_base" field.
  34719. func (m *WxCardMutation) ResetAPIBase() {
  34720. m.api_base = nil
  34721. delete(m.clearedFields, wxcard.FieldAPIBase)
  34722. }
  34723. // SetAPIKey sets the "api_key" field.
  34724. func (m *WxCardMutation) SetAPIKey(s string) {
  34725. m.api_key = &s
  34726. }
  34727. // APIKey returns the value of the "api_key" field in the mutation.
  34728. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  34729. v := m.api_key
  34730. if v == nil {
  34731. return
  34732. }
  34733. return *v, true
  34734. }
  34735. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  34736. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34738. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34739. if !m.op.Is(OpUpdateOne) {
  34740. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34741. }
  34742. if m.id == nil || m.oldValue == nil {
  34743. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34744. }
  34745. oldValue, err := m.oldValue(ctx)
  34746. if err != nil {
  34747. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34748. }
  34749. return oldValue.APIKey, nil
  34750. }
  34751. // ClearAPIKey clears the value of the "api_key" field.
  34752. func (m *WxCardMutation) ClearAPIKey() {
  34753. m.api_key = nil
  34754. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  34755. }
  34756. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34757. func (m *WxCardMutation) APIKeyCleared() bool {
  34758. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  34759. return ok
  34760. }
  34761. // ResetAPIKey resets all changes to the "api_key" field.
  34762. func (m *WxCardMutation) ResetAPIKey() {
  34763. m.api_key = nil
  34764. delete(m.clearedFields, wxcard.FieldAPIKey)
  34765. }
  34766. // SetAiInfo sets the "ai_info" field.
  34767. func (m *WxCardMutation) SetAiInfo(s string) {
  34768. m.ai_info = &s
  34769. }
  34770. // AiInfo returns the value of the "ai_info" field in the mutation.
  34771. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  34772. v := m.ai_info
  34773. if v == nil {
  34774. return
  34775. }
  34776. return *v, true
  34777. }
  34778. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  34779. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34781. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  34782. if !m.op.Is(OpUpdateOne) {
  34783. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  34784. }
  34785. if m.id == nil || m.oldValue == nil {
  34786. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  34787. }
  34788. oldValue, err := m.oldValue(ctx)
  34789. if err != nil {
  34790. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  34791. }
  34792. return oldValue.AiInfo, nil
  34793. }
  34794. // ClearAiInfo clears the value of the "ai_info" field.
  34795. func (m *WxCardMutation) ClearAiInfo() {
  34796. m.ai_info = nil
  34797. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  34798. }
  34799. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  34800. func (m *WxCardMutation) AiInfoCleared() bool {
  34801. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  34802. return ok
  34803. }
  34804. // ResetAiInfo resets all changes to the "ai_info" field.
  34805. func (m *WxCardMutation) ResetAiInfo() {
  34806. m.ai_info = nil
  34807. delete(m.clearedFields, wxcard.FieldAiInfo)
  34808. }
  34809. // SetIntro sets the "intro" field.
  34810. func (m *WxCardMutation) SetIntro(s string) {
  34811. m.intro = &s
  34812. }
  34813. // Intro returns the value of the "intro" field in the mutation.
  34814. func (m *WxCardMutation) Intro() (r string, exists bool) {
  34815. v := m.intro
  34816. if v == nil {
  34817. return
  34818. }
  34819. return *v, true
  34820. }
  34821. // OldIntro returns the old "intro" field's value of the WxCard entity.
  34822. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34824. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  34825. if !m.op.Is(OpUpdateOne) {
  34826. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  34827. }
  34828. if m.id == nil || m.oldValue == nil {
  34829. return v, errors.New("OldIntro requires an ID field in the mutation")
  34830. }
  34831. oldValue, err := m.oldValue(ctx)
  34832. if err != nil {
  34833. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  34834. }
  34835. return oldValue.Intro, nil
  34836. }
  34837. // ClearIntro clears the value of the "intro" field.
  34838. func (m *WxCardMutation) ClearIntro() {
  34839. m.intro = nil
  34840. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  34841. }
  34842. // IntroCleared returns if the "intro" field was cleared in this mutation.
  34843. func (m *WxCardMutation) IntroCleared() bool {
  34844. _, ok := m.clearedFields[wxcard.FieldIntro]
  34845. return ok
  34846. }
  34847. // ResetIntro resets all changes to the "intro" field.
  34848. func (m *WxCardMutation) ResetIntro() {
  34849. m.intro = nil
  34850. delete(m.clearedFields, wxcard.FieldIntro)
  34851. }
  34852. // Where appends a list predicates to the WxCardMutation builder.
  34853. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  34854. m.predicates = append(m.predicates, ps...)
  34855. }
  34856. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  34857. // users can use type-assertion to append predicates that do not depend on any generated package.
  34858. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  34859. p := make([]predicate.WxCard, len(ps))
  34860. for i := range ps {
  34861. p[i] = ps[i]
  34862. }
  34863. m.Where(p...)
  34864. }
  34865. // Op returns the operation name.
  34866. func (m *WxCardMutation) Op() Op {
  34867. return m.op
  34868. }
  34869. // SetOp allows setting the mutation operation.
  34870. func (m *WxCardMutation) SetOp(op Op) {
  34871. m.op = op
  34872. }
  34873. // Type returns the node type of this mutation (WxCard).
  34874. func (m *WxCardMutation) Type() string {
  34875. return m.typ
  34876. }
  34877. // Fields returns all fields that were changed during this mutation. Note that in
  34878. // order to get all numeric fields that were incremented/decremented, call
  34879. // AddedFields().
  34880. func (m *WxCardMutation) Fields() []string {
  34881. fields := make([]string, 0, 18)
  34882. if m.created_at != nil {
  34883. fields = append(fields, wxcard.FieldCreatedAt)
  34884. }
  34885. if m.updated_at != nil {
  34886. fields = append(fields, wxcard.FieldUpdatedAt)
  34887. }
  34888. if m.deleted_at != nil {
  34889. fields = append(fields, wxcard.FieldDeletedAt)
  34890. }
  34891. if m.user_id != nil {
  34892. fields = append(fields, wxcard.FieldUserID)
  34893. }
  34894. if m.wx_user_id != nil {
  34895. fields = append(fields, wxcard.FieldWxUserID)
  34896. }
  34897. if m.avatar != nil {
  34898. fields = append(fields, wxcard.FieldAvatar)
  34899. }
  34900. if m.logo != nil {
  34901. fields = append(fields, wxcard.FieldLogo)
  34902. }
  34903. if m.name != nil {
  34904. fields = append(fields, wxcard.FieldName)
  34905. }
  34906. if m.company != nil {
  34907. fields = append(fields, wxcard.FieldCompany)
  34908. }
  34909. if m.address != nil {
  34910. fields = append(fields, wxcard.FieldAddress)
  34911. }
  34912. if m.phone != nil {
  34913. fields = append(fields, wxcard.FieldPhone)
  34914. }
  34915. if m.official_account != nil {
  34916. fields = append(fields, wxcard.FieldOfficialAccount)
  34917. }
  34918. if m.wechat_account != nil {
  34919. fields = append(fields, wxcard.FieldWechatAccount)
  34920. }
  34921. if m.email != nil {
  34922. fields = append(fields, wxcard.FieldEmail)
  34923. }
  34924. if m.api_base != nil {
  34925. fields = append(fields, wxcard.FieldAPIBase)
  34926. }
  34927. if m.api_key != nil {
  34928. fields = append(fields, wxcard.FieldAPIKey)
  34929. }
  34930. if m.ai_info != nil {
  34931. fields = append(fields, wxcard.FieldAiInfo)
  34932. }
  34933. if m.intro != nil {
  34934. fields = append(fields, wxcard.FieldIntro)
  34935. }
  34936. return fields
  34937. }
  34938. // Field returns the value of a field with the given name. The second boolean
  34939. // return value indicates that this field was not set, or was not defined in the
  34940. // schema.
  34941. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  34942. switch name {
  34943. case wxcard.FieldCreatedAt:
  34944. return m.CreatedAt()
  34945. case wxcard.FieldUpdatedAt:
  34946. return m.UpdatedAt()
  34947. case wxcard.FieldDeletedAt:
  34948. return m.DeletedAt()
  34949. case wxcard.FieldUserID:
  34950. return m.UserID()
  34951. case wxcard.FieldWxUserID:
  34952. return m.WxUserID()
  34953. case wxcard.FieldAvatar:
  34954. return m.Avatar()
  34955. case wxcard.FieldLogo:
  34956. return m.Logo()
  34957. case wxcard.FieldName:
  34958. return m.Name()
  34959. case wxcard.FieldCompany:
  34960. return m.Company()
  34961. case wxcard.FieldAddress:
  34962. return m.Address()
  34963. case wxcard.FieldPhone:
  34964. return m.Phone()
  34965. case wxcard.FieldOfficialAccount:
  34966. return m.OfficialAccount()
  34967. case wxcard.FieldWechatAccount:
  34968. return m.WechatAccount()
  34969. case wxcard.FieldEmail:
  34970. return m.Email()
  34971. case wxcard.FieldAPIBase:
  34972. return m.APIBase()
  34973. case wxcard.FieldAPIKey:
  34974. return m.APIKey()
  34975. case wxcard.FieldAiInfo:
  34976. return m.AiInfo()
  34977. case wxcard.FieldIntro:
  34978. return m.Intro()
  34979. }
  34980. return nil, false
  34981. }
  34982. // OldField returns the old value of the field from the database. An error is
  34983. // returned if the mutation operation is not UpdateOne, or the query to the
  34984. // database failed.
  34985. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34986. switch name {
  34987. case wxcard.FieldCreatedAt:
  34988. return m.OldCreatedAt(ctx)
  34989. case wxcard.FieldUpdatedAt:
  34990. return m.OldUpdatedAt(ctx)
  34991. case wxcard.FieldDeletedAt:
  34992. return m.OldDeletedAt(ctx)
  34993. case wxcard.FieldUserID:
  34994. return m.OldUserID(ctx)
  34995. case wxcard.FieldWxUserID:
  34996. return m.OldWxUserID(ctx)
  34997. case wxcard.FieldAvatar:
  34998. return m.OldAvatar(ctx)
  34999. case wxcard.FieldLogo:
  35000. return m.OldLogo(ctx)
  35001. case wxcard.FieldName:
  35002. return m.OldName(ctx)
  35003. case wxcard.FieldCompany:
  35004. return m.OldCompany(ctx)
  35005. case wxcard.FieldAddress:
  35006. return m.OldAddress(ctx)
  35007. case wxcard.FieldPhone:
  35008. return m.OldPhone(ctx)
  35009. case wxcard.FieldOfficialAccount:
  35010. return m.OldOfficialAccount(ctx)
  35011. case wxcard.FieldWechatAccount:
  35012. return m.OldWechatAccount(ctx)
  35013. case wxcard.FieldEmail:
  35014. return m.OldEmail(ctx)
  35015. case wxcard.FieldAPIBase:
  35016. return m.OldAPIBase(ctx)
  35017. case wxcard.FieldAPIKey:
  35018. return m.OldAPIKey(ctx)
  35019. case wxcard.FieldAiInfo:
  35020. return m.OldAiInfo(ctx)
  35021. case wxcard.FieldIntro:
  35022. return m.OldIntro(ctx)
  35023. }
  35024. return nil, fmt.Errorf("unknown WxCard field %s", name)
  35025. }
  35026. // SetField sets the value of a field with the given name. It returns an error if
  35027. // the field is not defined in the schema, or if the type mismatched the field
  35028. // type.
  35029. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  35030. switch name {
  35031. case wxcard.FieldCreatedAt:
  35032. v, ok := value.(time.Time)
  35033. if !ok {
  35034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35035. }
  35036. m.SetCreatedAt(v)
  35037. return nil
  35038. case wxcard.FieldUpdatedAt:
  35039. v, ok := value.(time.Time)
  35040. if !ok {
  35041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35042. }
  35043. m.SetUpdatedAt(v)
  35044. return nil
  35045. case wxcard.FieldDeletedAt:
  35046. v, ok := value.(time.Time)
  35047. if !ok {
  35048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35049. }
  35050. m.SetDeletedAt(v)
  35051. return nil
  35052. case wxcard.FieldUserID:
  35053. v, ok := value.(uint64)
  35054. if !ok {
  35055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35056. }
  35057. m.SetUserID(v)
  35058. return nil
  35059. case wxcard.FieldWxUserID:
  35060. v, ok := value.(uint64)
  35061. if !ok {
  35062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35063. }
  35064. m.SetWxUserID(v)
  35065. return nil
  35066. case wxcard.FieldAvatar:
  35067. v, ok := value.(string)
  35068. if !ok {
  35069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35070. }
  35071. m.SetAvatar(v)
  35072. return nil
  35073. case wxcard.FieldLogo:
  35074. v, ok := value.(string)
  35075. if !ok {
  35076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35077. }
  35078. m.SetLogo(v)
  35079. return nil
  35080. case wxcard.FieldName:
  35081. v, ok := value.(string)
  35082. if !ok {
  35083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35084. }
  35085. m.SetName(v)
  35086. return nil
  35087. case wxcard.FieldCompany:
  35088. v, ok := value.(string)
  35089. if !ok {
  35090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35091. }
  35092. m.SetCompany(v)
  35093. return nil
  35094. case wxcard.FieldAddress:
  35095. v, ok := value.(string)
  35096. if !ok {
  35097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35098. }
  35099. m.SetAddress(v)
  35100. return nil
  35101. case wxcard.FieldPhone:
  35102. v, ok := value.(string)
  35103. if !ok {
  35104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35105. }
  35106. m.SetPhone(v)
  35107. return nil
  35108. case wxcard.FieldOfficialAccount:
  35109. v, ok := value.(string)
  35110. if !ok {
  35111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35112. }
  35113. m.SetOfficialAccount(v)
  35114. return nil
  35115. case wxcard.FieldWechatAccount:
  35116. v, ok := value.(string)
  35117. if !ok {
  35118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35119. }
  35120. m.SetWechatAccount(v)
  35121. return nil
  35122. case wxcard.FieldEmail:
  35123. v, ok := value.(string)
  35124. if !ok {
  35125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35126. }
  35127. m.SetEmail(v)
  35128. return nil
  35129. case wxcard.FieldAPIBase:
  35130. v, ok := value.(string)
  35131. if !ok {
  35132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35133. }
  35134. m.SetAPIBase(v)
  35135. return nil
  35136. case wxcard.FieldAPIKey:
  35137. v, ok := value.(string)
  35138. if !ok {
  35139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35140. }
  35141. m.SetAPIKey(v)
  35142. return nil
  35143. case wxcard.FieldAiInfo:
  35144. v, ok := value.(string)
  35145. if !ok {
  35146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35147. }
  35148. m.SetAiInfo(v)
  35149. return nil
  35150. case wxcard.FieldIntro:
  35151. v, ok := value.(string)
  35152. if !ok {
  35153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35154. }
  35155. m.SetIntro(v)
  35156. return nil
  35157. }
  35158. return fmt.Errorf("unknown WxCard field %s", name)
  35159. }
  35160. // AddedFields returns all numeric fields that were incremented/decremented during
  35161. // this mutation.
  35162. func (m *WxCardMutation) AddedFields() []string {
  35163. var fields []string
  35164. if m.adduser_id != nil {
  35165. fields = append(fields, wxcard.FieldUserID)
  35166. }
  35167. if m.addwx_user_id != nil {
  35168. fields = append(fields, wxcard.FieldWxUserID)
  35169. }
  35170. return fields
  35171. }
  35172. // AddedField returns the numeric value that was incremented/decremented on a field
  35173. // with the given name. The second boolean return value indicates that this field
  35174. // was not set, or was not defined in the schema.
  35175. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  35176. switch name {
  35177. case wxcard.FieldUserID:
  35178. return m.AddedUserID()
  35179. case wxcard.FieldWxUserID:
  35180. return m.AddedWxUserID()
  35181. }
  35182. return nil, false
  35183. }
  35184. // AddField adds the value to the field with the given name. It returns an error if
  35185. // the field is not defined in the schema, or if the type mismatched the field
  35186. // type.
  35187. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  35188. switch name {
  35189. case wxcard.FieldUserID:
  35190. v, ok := value.(int64)
  35191. if !ok {
  35192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35193. }
  35194. m.AddUserID(v)
  35195. return nil
  35196. case wxcard.FieldWxUserID:
  35197. v, ok := value.(int64)
  35198. if !ok {
  35199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35200. }
  35201. m.AddWxUserID(v)
  35202. return nil
  35203. }
  35204. return fmt.Errorf("unknown WxCard numeric field %s", name)
  35205. }
  35206. // ClearedFields returns all nullable fields that were cleared during this
  35207. // mutation.
  35208. func (m *WxCardMutation) ClearedFields() []string {
  35209. var fields []string
  35210. if m.FieldCleared(wxcard.FieldDeletedAt) {
  35211. fields = append(fields, wxcard.FieldDeletedAt)
  35212. }
  35213. if m.FieldCleared(wxcard.FieldUserID) {
  35214. fields = append(fields, wxcard.FieldUserID)
  35215. }
  35216. if m.FieldCleared(wxcard.FieldWxUserID) {
  35217. fields = append(fields, wxcard.FieldWxUserID)
  35218. }
  35219. if m.FieldCleared(wxcard.FieldEmail) {
  35220. fields = append(fields, wxcard.FieldEmail)
  35221. }
  35222. if m.FieldCleared(wxcard.FieldAPIBase) {
  35223. fields = append(fields, wxcard.FieldAPIBase)
  35224. }
  35225. if m.FieldCleared(wxcard.FieldAPIKey) {
  35226. fields = append(fields, wxcard.FieldAPIKey)
  35227. }
  35228. if m.FieldCleared(wxcard.FieldAiInfo) {
  35229. fields = append(fields, wxcard.FieldAiInfo)
  35230. }
  35231. if m.FieldCleared(wxcard.FieldIntro) {
  35232. fields = append(fields, wxcard.FieldIntro)
  35233. }
  35234. return fields
  35235. }
  35236. // FieldCleared returns a boolean indicating if a field with the given name was
  35237. // cleared in this mutation.
  35238. func (m *WxCardMutation) FieldCleared(name string) bool {
  35239. _, ok := m.clearedFields[name]
  35240. return ok
  35241. }
  35242. // ClearField clears the value of the field with the given name. It returns an
  35243. // error if the field is not defined in the schema.
  35244. func (m *WxCardMutation) ClearField(name string) error {
  35245. switch name {
  35246. case wxcard.FieldDeletedAt:
  35247. m.ClearDeletedAt()
  35248. return nil
  35249. case wxcard.FieldUserID:
  35250. m.ClearUserID()
  35251. return nil
  35252. case wxcard.FieldWxUserID:
  35253. m.ClearWxUserID()
  35254. return nil
  35255. case wxcard.FieldEmail:
  35256. m.ClearEmail()
  35257. return nil
  35258. case wxcard.FieldAPIBase:
  35259. m.ClearAPIBase()
  35260. return nil
  35261. case wxcard.FieldAPIKey:
  35262. m.ClearAPIKey()
  35263. return nil
  35264. case wxcard.FieldAiInfo:
  35265. m.ClearAiInfo()
  35266. return nil
  35267. case wxcard.FieldIntro:
  35268. m.ClearIntro()
  35269. return nil
  35270. }
  35271. return fmt.Errorf("unknown WxCard nullable field %s", name)
  35272. }
  35273. // ResetField resets all changes in the mutation for the field with the given name.
  35274. // It returns an error if the field is not defined in the schema.
  35275. func (m *WxCardMutation) ResetField(name string) error {
  35276. switch name {
  35277. case wxcard.FieldCreatedAt:
  35278. m.ResetCreatedAt()
  35279. return nil
  35280. case wxcard.FieldUpdatedAt:
  35281. m.ResetUpdatedAt()
  35282. return nil
  35283. case wxcard.FieldDeletedAt:
  35284. m.ResetDeletedAt()
  35285. return nil
  35286. case wxcard.FieldUserID:
  35287. m.ResetUserID()
  35288. return nil
  35289. case wxcard.FieldWxUserID:
  35290. m.ResetWxUserID()
  35291. return nil
  35292. case wxcard.FieldAvatar:
  35293. m.ResetAvatar()
  35294. return nil
  35295. case wxcard.FieldLogo:
  35296. m.ResetLogo()
  35297. return nil
  35298. case wxcard.FieldName:
  35299. m.ResetName()
  35300. return nil
  35301. case wxcard.FieldCompany:
  35302. m.ResetCompany()
  35303. return nil
  35304. case wxcard.FieldAddress:
  35305. m.ResetAddress()
  35306. return nil
  35307. case wxcard.FieldPhone:
  35308. m.ResetPhone()
  35309. return nil
  35310. case wxcard.FieldOfficialAccount:
  35311. m.ResetOfficialAccount()
  35312. return nil
  35313. case wxcard.FieldWechatAccount:
  35314. m.ResetWechatAccount()
  35315. return nil
  35316. case wxcard.FieldEmail:
  35317. m.ResetEmail()
  35318. return nil
  35319. case wxcard.FieldAPIBase:
  35320. m.ResetAPIBase()
  35321. return nil
  35322. case wxcard.FieldAPIKey:
  35323. m.ResetAPIKey()
  35324. return nil
  35325. case wxcard.FieldAiInfo:
  35326. m.ResetAiInfo()
  35327. return nil
  35328. case wxcard.FieldIntro:
  35329. m.ResetIntro()
  35330. return nil
  35331. }
  35332. return fmt.Errorf("unknown WxCard field %s", name)
  35333. }
  35334. // AddedEdges returns all edge names that were set/added in this mutation.
  35335. func (m *WxCardMutation) AddedEdges() []string {
  35336. edges := make([]string, 0, 0)
  35337. return edges
  35338. }
  35339. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35340. // name in this mutation.
  35341. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  35342. return nil
  35343. }
  35344. // RemovedEdges returns all edge names that were removed in this mutation.
  35345. func (m *WxCardMutation) RemovedEdges() []string {
  35346. edges := make([]string, 0, 0)
  35347. return edges
  35348. }
  35349. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35350. // the given name in this mutation.
  35351. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  35352. return nil
  35353. }
  35354. // ClearedEdges returns all edge names that were cleared in this mutation.
  35355. func (m *WxCardMutation) ClearedEdges() []string {
  35356. edges := make([]string, 0, 0)
  35357. return edges
  35358. }
  35359. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35360. // was cleared in this mutation.
  35361. func (m *WxCardMutation) EdgeCleared(name string) bool {
  35362. return false
  35363. }
  35364. // ClearEdge clears the value of the edge with the given name. It returns an error
  35365. // if that edge is not defined in the schema.
  35366. func (m *WxCardMutation) ClearEdge(name string) error {
  35367. return fmt.Errorf("unknown WxCard unique edge %s", name)
  35368. }
  35369. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35370. // It returns an error if the edge is not defined in the schema.
  35371. func (m *WxCardMutation) ResetEdge(name string) error {
  35372. return fmt.Errorf("unknown WxCard edge %s", name)
  35373. }
  35374. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  35375. type WxCardUserMutation struct {
  35376. config
  35377. op Op
  35378. typ string
  35379. id *uint64
  35380. created_at *time.Time
  35381. updated_at *time.Time
  35382. deleted_at *time.Time
  35383. wxid *string
  35384. account *string
  35385. avatar *string
  35386. nickname *string
  35387. remark *string
  35388. phone *string
  35389. open_id *string
  35390. union_id *string
  35391. session_key *string
  35392. is_vip *int
  35393. addis_vip *int
  35394. clearedFields map[string]struct{}
  35395. done bool
  35396. oldValue func(context.Context) (*WxCardUser, error)
  35397. predicates []predicate.WxCardUser
  35398. }
  35399. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  35400. // wxcarduserOption allows management of the mutation configuration using functional options.
  35401. type wxcarduserOption func(*WxCardUserMutation)
  35402. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  35403. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  35404. m := &WxCardUserMutation{
  35405. config: c,
  35406. op: op,
  35407. typ: TypeWxCardUser,
  35408. clearedFields: make(map[string]struct{}),
  35409. }
  35410. for _, opt := range opts {
  35411. opt(m)
  35412. }
  35413. return m
  35414. }
  35415. // withWxCardUserID sets the ID field of the mutation.
  35416. func withWxCardUserID(id uint64) wxcarduserOption {
  35417. return func(m *WxCardUserMutation) {
  35418. var (
  35419. err error
  35420. once sync.Once
  35421. value *WxCardUser
  35422. )
  35423. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  35424. once.Do(func() {
  35425. if m.done {
  35426. err = errors.New("querying old values post mutation is not allowed")
  35427. } else {
  35428. value, err = m.Client().WxCardUser.Get(ctx, id)
  35429. }
  35430. })
  35431. return value, err
  35432. }
  35433. m.id = &id
  35434. }
  35435. }
  35436. // withWxCardUser sets the old WxCardUser of the mutation.
  35437. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  35438. return func(m *WxCardUserMutation) {
  35439. m.oldValue = func(context.Context) (*WxCardUser, error) {
  35440. return node, nil
  35441. }
  35442. m.id = &node.ID
  35443. }
  35444. }
  35445. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35446. // executed in a transaction (ent.Tx), a transactional client is returned.
  35447. func (m WxCardUserMutation) Client() *Client {
  35448. client := &Client{config: m.config}
  35449. client.init()
  35450. return client
  35451. }
  35452. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35453. // it returns an error otherwise.
  35454. func (m WxCardUserMutation) Tx() (*Tx, error) {
  35455. if _, ok := m.driver.(*txDriver); !ok {
  35456. return nil, errors.New("ent: mutation is not running in a transaction")
  35457. }
  35458. tx := &Tx{config: m.config}
  35459. tx.init()
  35460. return tx, nil
  35461. }
  35462. // SetID sets the value of the id field. Note that this
  35463. // operation is only accepted on creation of WxCardUser entities.
  35464. func (m *WxCardUserMutation) SetID(id uint64) {
  35465. m.id = &id
  35466. }
  35467. // ID returns the ID value in the mutation. Note that the ID is only available
  35468. // if it was provided to the builder or after it was returned from the database.
  35469. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  35470. if m.id == nil {
  35471. return
  35472. }
  35473. return *m.id, true
  35474. }
  35475. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35476. // That means, if the mutation is applied within a transaction with an isolation level such
  35477. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35478. // or updated by the mutation.
  35479. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  35480. switch {
  35481. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35482. id, exists := m.ID()
  35483. if exists {
  35484. return []uint64{id}, nil
  35485. }
  35486. fallthrough
  35487. case m.op.Is(OpUpdate | OpDelete):
  35488. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  35489. default:
  35490. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35491. }
  35492. }
  35493. // SetCreatedAt sets the "created_at" field.
  35494. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  35495. m.created_at = &t
  35496. }
  35497. // CreatedAt returns the value of the "created_at" field in the mutation.
  35498. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  35499. v := m.created_at
  35500. if v == nil {
  35501. return
  35502. }
  35503. return *v, true
  35504. }
  35505. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  35506. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35508. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35509. if !m.op.Is(OpUpdateOne) {
  35510. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35511. }
  35512. if m.id == nil || m.oldValue == nil {
  35513. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35514. }
  35515. oldValue, err := m.oldValue(ctx)
  35516. if err != nil {
  35517. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35518. }
  35519. return oldValue.CreatedAt, nil
  35520. }
  35521. // ResetCreatedAt resets all changes to the "created_at" field.
  35522. func (m *WxCardUserMutation) ResetCreatedAt() {
  35523. m.created_at = nil
  35524. }
  35525. // SetUpdatedAt sets the "updated_at" field.
  35526. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  35527. m.updated_at = &t
  35528. }
  35529. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35530. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  35531. v := m.updated_at
  35532. if v == nil {
  35533. return
  35534. }
  35535. return *v, true
  35536. }
  35537. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  35538. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35540. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35541. if !m.op.Is(OpUpdateOne) {
  35542. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35543. }
  35544. if m.id == nil || m.oldValue == nil {
  35545. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35546. }
  35547. oldValue, err := m.oldValue(ctx)
  35548. if err != nil {
  35549. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35550. }
  35551. return oldValue.UpdatedAt, nil
  35552. }
  35553. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35554. func (m *WxCardUserMutation) ResetUpdatedAt() {
  35555. m.updated_at = nil
  35556. }
  35557. // SetDeletedAt sets the "deleted_at" field.
  35558. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  35559. m.deleted_at = &t
  35560. }
  35561. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35562. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  35563. v := m.deleted_at
  35564. if v == nil {
  35565. return
  35566. }
  35567. return *v, true
  35568. }
  35569. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  35570. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35572. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35573. if !m.op.Is(OpUpdateOne) {
  35574. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35575. }
  35576. if m.id == nil || m.oldValue == nil {
  35577. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35578. }
  35579. oldValue, err := m.oldValue(ctx)
  35580. if err != nil {
  35581. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35582. }
  35583. return oldValue.DeletedAt, nil
  35584. }
  35585. // ClearDeletedAt clears the value of the "deleted_at" field.
  35586. func (m *WxCardUserMutation) ClearDeletedAt() {
  35587. m.deleted_at = nil
  35588. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  35589. }
  35590. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35591. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  35592. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  35593. return ok
  35594. }
  35595. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35596. func (m *WxCardUserMutation) ResetDeletedAt() {
  35597. m.deleted_at = nil
  35598. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  35599. }
  35600. // SetWxid sets the "wxid" field.
  35601. func (m *WxCardUserMutation) SetWxid(s string) {
  35602. m.wxid = &s
  35603. }
  35604. // Wxid returns the value of the "wxid" field in the mutation.
  35605. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  35606. v := m.wxid
  35607. if v == nil {
  35608. return
  35609. }
  35610. return *v, true
  35611. }
  35612. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  35613. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35615. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  35616. if !m.op.Is(OpUpdateOne) {
  35617. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  35618. }
  35619. if m.id == nil || m.oldValue == nil {
  35620. return v, errors.New("OldWxid requires an ID field in the mutation")
  35621. }
  35622. oldValue, err := m.oldValue(ctx)
  35623. if err != nil {
  35624. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  35625. }
  35626. return oldValue.Wxid, nil
  35627. }
  35628. // ResetWxid resets all changes to the "wxid" field.
  35629. func (m *WxCardUserMutation) ResetWxid() {
  35630. m.wxid = nil
  35631. }
  35632. // SetAccount sets the "account" field.
  35633. func (m *WxCardUserMutation) SetAccount(s string) {
  35634. m.account = &s
  35635. }
  35636. // Account returns the value of the "account" field in the mutation.
  35637. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  35638. v := m.account
  35639. if v == nil {
  35640. return
  35641. }
  35642. return *v, true
  35643. }
  35644. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  35645. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35647. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  35648. if !m.op.Is(OpUpdateOne) {
  35649. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35650. }
  35651. if m.id == nil || m.oldValue == nil {
  35652. return v, errors.New("OldAccount requires an ID field in the mutation")
  35653. }
  35654. oldValue, err := m.oldValue(ctx)
  35655. if err != nil {
  35656. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35657. }
  35658. return oldValue.Account, nil
  35659. }
  35660. // ResetAccount resets all changes to the "account" field.
  35661. func (m *WxCardUserMutation) ResetAccount() {
  35662. m.account = nil
  35663. }
  35664. // SetAvatar sets the "avatar" field.
  35665. func (m *WxCardUserMutation) SetAvatar(s string) {
  35666. m.avatar = &s
  35667. }
  35668. // Avatar returns the value of the "avatar" field in the mutation.
  35669. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  35670. v := m.avatar
  35671. if v == nil {
  35672. return
  35673. }
  35674. return *v, true
  35675. }
  35676. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  35677. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35679. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35680. if !m.op.Is(OpUpdateOne) {
  35681. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35682. }
  35683. if m.id == nil || m.oldValue == nil {
  35684. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35685. }
  35686. oldValue, err := m.oldValue(ctx)
  35687. if err != nil {
  35688. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35689. }
  35690. return oldValue.Avatar, nil
  35691. }
  35692. // ResetAvatar resets all changes to the "avatar" field.
  35693. func (m *WxCardUserMutation) ResetAvatar() {
  35694. m.avatar = nil
  35695. }
  35696. // SetNickname sets the "nickname" field.
  35697. func (m *WxCardUserMutation) SetNickname(s string) {
  35698. m.nickname = &s
  35699. }
  35700. // Nickname returns the value of the "nickname" field in the mutation.
  35701. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  35702. v := m.nickname
  35703. if v == nil {
  35704. return
  35705. }
  35706. return *v, true
  35707. }
  35708. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  35709. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35711. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  35712. if !m.op.Is(OpUpdateOne) {
  35713. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  35714. }
  35715. if m.id == nil || m.oldValue == nil {
  35716. return v, errors.New("OldNickname requires an ID field in the mutation")
  35717. }
  35718. oldValue, err := m.oldValue(ctx)
  35719. if err != nil {
  35720. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  35721. }
  35722. return oldValue.Nickname, nil
  35723. }
  35724. // ResetNickname resets all changes to the "nickname" field.
  35725. func (m *WxCardUserMutation) ResetNickname() {
  35726. m.nickname = nil
  35727. }
  35728. // SetRemark sets the "remark" field.
  35729. func (m *WxCardUserMutation) SetRemark(s string) {
  35730. m.remark = &s
  35731. }
  35732. // Remark returns the value of the "remark" field in the mutation.
  35733. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  35734. v := m.remark
  35735. if v == nil {
  35736. return
  35737. }
  35738. return *v, true
  35739. }
  35740. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  35741. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35743. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  35744. if !m.op.Is(OpUpdateOne) {
  35745. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  35746. }
  35747. if m.id == nil || m.oldValue == nil {
  35748. return v, errors.New("OldRemark requires an ID field in the mutation")
  35749. }
  35750. oldValue, err := m.oldValue(ctx)
  35751. if err != nil {
  35752. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  35753. }
  35754. return oldValue.Remark, nil
  35755. }
  35756. // ResetRemark resets all changes to the "remark" field.
  35757. func (m *WxCardUserMutation) ResetRemark() {
  35758. m.remark = nil
  35759. }
  35760. // SetPhone sets the "phone" field.
  35761. func (m *WxCardUserMutation) SetPhone(s string) {
  35762. m.phone = &s
  35763. }
  35764. // Phone returns the value of the "phone" field in the mutation.
  35765. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  35766. v := m.phone
  35767. if v == nil {
  35768. return
  35769. }
  35770. return *v, true
  35771. }
  35772. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  35773. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35775. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  35776. if !m.op.Is(OpUpdateOne) {
  35777. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35778. }
  35779. if m.id == nil || m.oldValue == nil {
  35780. return v, errors.New("OldPhone requires an ID field in the mutation")
  35781. }
  35782. oldValue, err := m.oldValue(ctx)
  35783. if err != nil {
  35784. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35785. }
  35786. return oldValue.Phone, nil
  35787. }
  35788. // ResetPhone resets all changes to the "phone" field.
  35789. func (m *WxCardUserMutation) ResetPhone() {
  35790. m.phone = nil
  35791. }
  35792. // SetOpenID sets the "open_id" field.
  35793. func (m *WxCardUserMutation) SetOpenID(s string) {
  35794. m.open_id = &s
  35795. }
  35796. // OpenID returns the value of the "open_id" field in the mutation.
  35797. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  35798. v := m.open_id
  35799. if v == nil {
  35800. return
  35801. }
  35802. return *v, true
  35803. }
  35804. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  35805. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35807. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  35808. if !m.op.Is(OpUpdateOne) {
  35809. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  35810. }
  35811. if m.id == nil || m.oldValue == nil {
  35812. return v, errors.New("OldOpenID requires an ID field in the mutation")
  35813. }
  35814. oldValue, err := m.oldValue(ctx)
  35815. if err != nil {
  35816. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  35817. }
  35818. return oldValue.OpenID, nil
  35819. }
  35820. // ResetOpenID resets all changes to the "open_id" field.
  35821. func (m *WxCardUserMutation) ResetOpenID() {
  35822. m.open_id = nil
  35823. }
  35824. // SetUnionID sets the "union_id" field.
  35825. func (m *WxCardUserMutation) SetUnionID(s string) {
  35826. m.union_id = &s
  35827. }
  35828. // UnionID returns the value of the "union_id" field in the mutation.
  35829. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  35830. v := m.union_id
  35831. if v == nil {
  35832. return
  35833. }
  35834. return *v, true
  35835. }
  35836. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  35837. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35839. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  35840. if !m.op.Is(OpUpdateOne) {
  35841. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  35842. }
  35843. if m.id == nil || m.oldValue == nil {
  35844. return v, errors.New("OldUnionID requires an ID field in the mutation")
  35845. }
  35846. oldValue, err := m.oldValue(ctx)
  35847. if err != nil {
  35848. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  35849. }
  35850. return oldValue.UnionID, nil
  35851. }
  35852. // ResetUnionID resets all changes to the "union_id" field.
  35853. func (m *WxCardUserMutation) ResetUnionID() {
  35854. m.union_id = nil
  35855. }
  35856. // SetSessionKey sets the "session_key" field.
  35857. func (m *WxCardUserMutation) SetSessionKey(s string) {
  35858. m.session_key = &s
  35859. }
  35860. // SessionKey returns the value of the "session_key" field in the mutation.
  35861. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  35862. v := m.session_key
  35863. if v == nil {
  35864. return
  35865. }
  35866. return *v, true
  35867. }
  35868. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  35869. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35871. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  35872. if !m.op.Is(OpUpdateOne) {
  35873. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  35874. }
  35875. if m.id == nil || m.oldValue == nil {
  35876. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  35877. }
  35878. oldValue, err := m.oldValue(ctx)
  35879. if err != nil {
  35880. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  35881. }
  35882. return oldValue.SessionKey, nil
  35883. }
  35884. // ResetSessionKey resets all changes to the "session_key" field.
  35885. func (m *WxCardUserMutation) ResetSessionKey() {
  35886. m.session_key = nil
  35887. }
  35888. // SetIsVip sets the "is_vip" field.
  35889. func (m *WxCardUserMutation) SetIsVip(i int) {
  35890. m.is_vip = &i
  35891. m.addis_vip = nil
  35892. }
  35893. // IsVip returns the value of the "is_vip" field in the mutation.
  35894. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  35895. v := m.is_vip
  35896. if v == nil {
  35897. return
  35898. }
  35899. return *v, true
  35900. }
  35901. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  35902. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35904. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  35905. if !m.op.Is(OpUpdateOne) {
  35906. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  35907. }
  35908. if m.id == nil || m.oldValue == nil {
  35909. return v, errors.New("OldIsVip requires an ID field in the mutation")
  35910. }
  35911. oldValue, err := m.oldValue(ctx)
  35912. if err != nil {
  35913. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  35914. }
  35915. return oldValue.IsVip, nil
  35916. }
  35917. // AddIsVip adds i to the "is_vip" field.
  35918. func (m *WxCardUserMutation) AddIsVip(i int) {
  35919. if m.addis_vip != nil {
  35920. *m.addis_vip += i
  35921. } else {
  35922. m.addis_vip = &i
  35923. }
  35924. }
  35925. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  35926. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  35927. v := m.addis_vip
  35928. if v == nil {
  35929. return
  35930. }
  35931. return *v, true
  35932. }
  35933. // ResetIsVip resets all changes to the "is_vip" field.
  35934. func (m *WxCardUserMutation) ResetIsVip() {
  35935. m.is_vip = nil
  35936. m.addis_vip = nil
  35937. }
  35938. // Where appends a list predicates to the WxCardUserMutation builder.
  35939. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  35940. m.predicates = append(m.predicates, ps...)
  35941. }
  35942. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  35943. // users can use type-assertion to append predicates that do not depend on any generated package.
  35944. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  35945. p := make([]predicate.WxCardUser, len(ps))
  35946. for i := range ps {
  35947. p[i] = ps[i]
  35948. }
  35949. m.Where(p...)
  35950. }
  35951. // Op returns the operation name.
  35952. func (m *WxCardUserMutation) Op() Op {
  35953. return m.op
  35954. }
  35955. // SetOp allows setting the mutation operation.
  35956. func (m *WxCardUserMutation) SetOp(op Op) {
  35957. m.op = op
  35958. }
  35959. // Type returns the node type of this mutation (WxCardUser).
  35960. func (m *WxCardUserMutation) Type() string {
  35961. return m.typ
  35962. }
  35963. // Fields returns all fields that were changed during this mutation. Note that in
  35964. // order to get all numeric fields that were incremented/decremented, call
  35965. // AddedFields().
  35966. func (m *WxCardUserMutation) Fields() []string {
  35967. fields := make([]string, 0, 13)
  35968. if m.created_at != nil {
  35969. fields = append(fields, wxcarduser.FieldCreatedAt)
  35970. }
  35971. if m.updated_at != nil {
  35972. fields = append(fields, wxcarduser.FieldUpdatedAt)
  35973. }
  35974. if m.deleted_at != nil {
  35975. fields = append(fields, wxcarduser.FieldDeletedAt)
  35976. }
  35977. if m.wxid != nil {
  35978. fields = append(fields, wxcarduser.FieldWxid)
  35979. }
  35980. if m.account != nil {
  35981. fields = append(fields, wxcarduser.FieldAccount)
  35982. }
  35983. if m.avatar != nil {
  35984. fields = append(fields, wxcarduser.FieldAvatar)
  35985. }
  35986. if m.nickname != nil {
  35987. fields = append(fields, wxcarduser.FieldNickname)
  35988. }
  35989. if m.remark != nil {
  35990. fields = append(fields, wxcarduser.FieldRemark)
  35991. }
  35992. if m.phone != nil {
  35993. fields = append(fields, wxcarduser.FieldPhone)
  35994. }
  35995. if m.open_id != nil {
  35996. fields = append(fields, wxcarduser.FieldOpenID)
  35997. }
  35998. if m.union_id != nil {
  35999. fields = append(fields, wxcarduser.FieldUnionID)
  36000. }
  36001. if m.session_key != nil {
  36002. fields = append(fields, wxcarduser.FieldSessionKey)
  36003. }
  36004. if m.is_vip != nil {
  36005. fields = append(fields, wxcarduser.FieldIsVip)
  36006. }
  36007. return fields
  36008. }
  36009. // Field returns the value of a field with the given name. The second boolean
  36010. // return value indicates that this field was not set, or was not defined in the
  36011. // schema.
  36012. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  36013. switch name {
  36014. case wxcarduser.FieldCreatedAt:
  36015. return m.CreatedAt()
  36016. case wxcarduser.FieldUpdatedAt:
  36017. return m.UpdatedAt()
  36018. case wxcarduser.FieldDeletedAt:
  36019. return m.DeletedAt()
  36020. case wxcarduser.FieldWxid:
  36021. return m.Wxid()
  36022. case wxcarduser.FieldAccount:
  36023. return m.Account()
  36024. case wxcarduser.FieldAvatar:
  36025. return m.Avatar()
  36026. case wxcarduser.FieldNickname:
  36027. return m.Nickname()
  36028. case wxcarduser.FieldRemark:
  36029. return m.Remark()
  36030. case wxcarduser.FieldPhone:
  36031. return m.Phone()
  36032. case wxcarduser.FieldOpenID:
  36033. return m.OpenID()
  36034. case wxcarduser.FieldUnionID:
  36035. return m.UnionID()
  36036. case wxcarduser.FieldSessionKey:
  36037. return m.SessionKey()
  36038. case wxcarduser.FieldIsVip:
  36039. return m.IsVip()
  36040. }
  36041. return nil, false
  36042. }
  36043. // OldField returns the old value of the field from the database. An error is
  36044. // returned if the mutation operation is not UpdateOne, or the query to the
  36045. // database failed.
  36046. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36047. switch name {
  36048. case wxcarduser.FieldCreatedAt:
  36049. return m.OldCreatedAt(ctx)
  36050. case wxcarduser.FieldUpdatedAt:
  36051. return m.OldUpdatedAt(ctx)
  36052. case wxcarduser.FieldDeletedAt:
  36053. return m.OldDeletedAt(ctx)
  36054. case wxcarduser.FieldWxid:
  36055. return m.OldWxid(ctx)
  36056. case wxcarduser.FieldAccount:
  36057. return m.OldAccount(ctx)
  36058. case wxcarduser.FieldAvatar:
  36059. return m.OldAvatar(ctx)
  36060. case wxcarduser.FieldNickname:
  36061. return m.OldNickname(ctx)
  36062. case wxcarduser.FieldRemark:
  36063. return m.OldRemark(ctx)
  36064. case wxcarduser.FieldPhone:
  36065. return m.OldPhone(ctx)
  36066. case wxcarduser.FieldOpenID:
  36067. return m.OldOpenID(ctx)
  36068. case wxcarduser.FieldUnionID:
  36069. return m.OldUnionID(ctx)
  36070. case wxcarduser.FieldSessionKey:
  36071. return m.OldSessionKey(ctx)
  36072. case wxcarduser.FieldIsVip:
  36073. return m.OldIsVip(ctx)
  36074. }
  36075. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  36076. }
  36077. // SetField sets the value of a field with the given name. It returns an error if
  36078. // the field is not defined in the schema, or if the type mismatched the field
  36079. // type.
  36080. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  36081. switch name {
  36082. case wxcarduser.FieldCreatedAt:
  36083. v, ok := value.(time.Time)
  36084. if !ok {
  36085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36086. }
  36087. m.SetCreatedAt(v)
  36088. return nil
  36089. case wxcarduser.FieldUpdatedAt:
  36090. v, ok := value.(time.Time)
  36091. if !ok {
  36092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36093. }
  36094. m.SetUpdatedAt(v)
  36095. return nil
  36096. case wxcarduser.FieldDeletedAt:
  36097. v, ok := value.(time.Time)
  36098. if !ok {
  36099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36100. }
  36101. m.SetDeletedAt(v)
  36102. return nil
  36103. case wxcarduser.FieldWxid:
  36104. v, ok := value.(string)
  36105. if !ok {
  36106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36107. }
  36108. m.SetWxid(v)
  36109. return nil
  36110. case wxcarduser.FieldAccount:
  36111. v, ok := value.(string)
  36112. if !ok {
  36113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36114. }
  36115. m.SetAccount(v)
  36116. return nil
  36117. case wxcarduser.FieldAvatar:
  36118. v, ok := value.(string)
  36119. if !ok {
  36120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36121. }
  36122. m.SetAvatar(v)
  36123. return nil
  36124. case wxcarduser.FieldNickname:
  36125. v, ok := value.(string)
  36126. if !ok {
  36127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36128. }
  36129. m.SetNickname(v)
  36130. return nil
  36131. case wxcarduser.FieldRemark:
  36132. v, ok := value.(string)
  36133. if !ok {
  36134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36135. }
  36136. m.SetRemark(v)
  36137. return nil
  36138. case wxcarduser.FieldPhone:
  36139. v, ok := value.(string)
  36140. if !ok {
  36141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36142. }
  36143. m.SetPhone(v)
  36144. return nil
  36145. case wxcarduser.FieldOpenID:
  36146. v, ok := value.(string)
  36147. if !ok {
  36148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36149. }
  36150. m.SetOpenID(v)
  36151. return nil
  36152. case wxcarduser.FieldUnionID:
  36153. v, ok := value.(string)
  36154. if !ok {
  36155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36156. }
  36157. m.SetUnionID(v)
  36158. return nil
  36159. case wxcarduser.FieldSessionKey:
  36160. v, ok := value.(string)
  36161. if !ok {
  36162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36163. }
  36164. m.SetSessionKey(v)
  36165. return nil
  36166. case wxcarduser.FieldIsVip:
  36167. v, ok := value.(int)
  36168. if !ok {
  36169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36170. }
  36171. m.SetIsVip(v)
  36172. return nil
  36173. }
  36174. return fmt.Errorf("unknown WxCardUser field %s", name)
  36175. }
  36176. // AddedFields returns all numeric fields that were incremented/decremented during
  36177. // this mutation.
  36178. func (m *WxCardUserMutation) AddedFields() []string {
  36179. var fields []string
  36180. if m.addis_vip != nil {
  36181. fields = append(fields, wxcarduser.FieldIsVip)
  36182. }
  36183. return fields
  36184. }
  36185. // AddedField returns the numeric value that was incremented/decremented on a field
  36186. // with the given name. The second boolean return value indicates that this field
  36187. // was not set, or was not defined in the schema.
  36188. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  36189. switch name {
  36190. case wxcarduser.FieldIsVip:
  36191. return m.AddedIsVip()
  36192. }
  36193. return nil, false
  36194. }
  36195. // AddField adds the value to the field with the given name. It returns an error if
  36196. // the field is not defined in the schema, or if the type mismatched the field
  36197. // type.
  36198. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  36199. switch name {
  36200. case wxcarduser.FieldIsVip:
  36201. v, ok := value.(int)
  36202. if !ok {
  36203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36204. }
  36205. m.AddIsVip(v)
  36206. return nil
  36207. }
  36208. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  36209. }
  36210. // ClearedFields returns all nullable fields that were cleared during this
  36211. // mutation.
  36212. func (m *WxCardUserMutation) ClearedFields() []string {
  36213. var fields []string
  36214. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  36215. fields = append(fields, wxcarduser.FieldDeletedAt)
  36216. }
  36217. return fields
  36218. }
  36219. // FieldCleared returns a boolean indicating if a field with the given name was
  36220. // cleared in this mutation.
  36221. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  36222. _, ok := m.clearedFields[name]
  36223. return ok
  36224. }
  36225. // ClearField clears the value of the field with the given name. It returns an
  36226. // error if the field is not defined in the schema.
  36227. func (m *WxCardUserMutation) ClearField(name string) error {
  36228. switch name {
  36229. case wxcarduser.FieldDeletedAt:
  36230. m.ClearDeletedAt()
  36231. return nil
  36232. }
  36233. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  36234. }
  36235. // ResetField resets all changes in the mutation for the field with the given name.
  36236. // It returns an error if the field is not defined in the schema.
  36237. func (m *WxCardUserMutation) ResetField(name string) error {
  36238. switch name {
  36239. case wxcarduser.FieldCreatedAt:
  36240. m.ResetCreatedAt()
  36241. return nil
  36242. case wxcarduser.FieldUpdatedAt:
  36243. m.ResetUpdatedAt()
  36244. return nil
  36245. case wxcarduser.FieldDeletedAt:
  36246. m.ResetDeletedAt()
  36247. return nil
  36248. case wxcarduser.FieldWxid:
  36249. m.ResetWxid()
  36250. return nil
  36251. case wxcarduser.FieldAccount:
  36252. m.ResetAccount()
  36253. return nil
  36254. case wxcarduser.FieldAvatar:
  36255. m.ResetAvatar()
  36256. return nil
  36257. case wxcarduser.FieldNickname:
  36258. m.ResetNickname()
  36259. return nil
  36260. case wxcarduser.FieldRemark:
  36261. m.ResetRemark()
  36262. return nil
  36263. case wxcarduser.FieldPhone:
  36264. m.ResetPhone()
  36265. return nil
  36266. case wxcarduser.FieldOpenID:
  36267. m.ResetOpenID()
  36268. return nil
  36269. case wxcarduser.FieldUnionID:
  36270. m.ResetUnionID()
  36271. return nil
  36272. case wxcarduser.FieldSessionKey:
  36273. m.ResetSessionKey()
  36274. return nil
  36275. case wxcarduser.FieldIsVip:
  36276. m.ResetIsVip()
  36277. return nil
  36278. }
  36279. return fmt.Errorf("unknown WxCardUser field %s", name)
  36280. }
  36281. // AddedEdges returns all edge names that were set/added in this mutation.
  36282. func (m *WxCardUserMutation) AddedEdges() []string {
  36283. edges := make([]string, 0, 0)
  36284. return edges
  36285. }
  36286. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36287. // name in this mutation.
  36288. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  36289. return nil
  36290. }
  36291. // RemovedEdges returns all edge names that were removed in this mutation.
  36292. func (m *WxCardUserMutation) RemovedEdges() []string {
  36293. edges := make([]string, 0, 0)
  36294. return edges
  36295. }
  36296. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36297. // the given name in this mutation.
  36298. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  36299. return nil
  36300. }
  36301. // ClearedEdges returns all edge names that were cleared in this mutation.
  36302. func (m *WxCardUserMutation) ClearedEdges() []string {
  36303. edges := make([]string, 0, 0)
  36304. return edges
  36305. }
  36306. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36307. // was cleared in this mutation.
  36308. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  36309. return false
  36310. }
  36311. // ClearEdge clears the value of the edge with the given name. It returns an error
  36312. // if that edge is not defined in the schema.
  36313. func (m *WxCardUserMutation) ClearEdge(name string) error {
  36314. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  36315. }
  36316. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36317. // It returns an error if the edge is not defined in the schema.
  36318. func (m *WxCardUserMutation) ResetEdge(name string) error {
  36319. return fmt.Errorf("unknown WxCardUser edge %s", name)
  36320. }
  36321. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  36322. type WxCardVisitMutation struct {
  36323. config
  36324. op Op
  36325. typ string
  36326. id *uint64
  36327. created_at *time.Time
  36328. updated_at *time.Time
  36329. deleted_at *time.Time
  36330. user_id *uint64
  36331. adduser_id *int64
  36332. bot_id *uint64
  36333. addbot_id *int64
  36334. bot_type *uint8
  36335. addbot_type *int8
  36336. clearedFields map[string]struct{}
  36337. done bool
  36338. oldValue func(context.Context) (*WxCardVisit, error)
  36339. predicates []predicate.WxCardVisit
  36340. }
  36341. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  36342. // wxcardvisitOption allows management of the mutation configuration using functional options.
  36343. type wxcardvisitOption func(*WxCardVisitMutation)
  36344. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  36345. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  36346. m := &WxCardVisitMutation{
  36347. config: c,
  36348. op: op,
  36349. typ: TypeWxCardVisit,
  36350. clearedFields: make(map[string]struct{}),
  36351. }
  36352. for _, opt := range opts {
  36353. opt(m)
  36354. }
  36355. return m
  36356. }
  36357. // withWxCardVisitID sets the ID field of the mutation.
  36358. func withWxCardVisitID(id uint64) wxcardvisitOption {
  36359. return func(m *WxCardVisitMutation) {
  36360. var (
  36361. err error
  36362. once sync.Once
  36363. value *WxCardVisit
  36364. )
  36365. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  36366. once.Do(func() {
  36367. if m.done {
  36368. err = errors.New("querying old values post mutation is not allowed")
  36369. } else {
  36370. value, err = m.Client().WxCardVisit.Get(ctx, id)
  36371. }
  36372. })
  36373. return value, err
  36374. }
  36375. m.id = &id
  36376. }
  36377. }
  36378. // withWxCardVisit sets the old WxCardVisit of the mutation.
  36379. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  36380. return func(m *WxCardVisitMutation) {
  36381. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  36382. return node, nil
  36383. }
  36384. m.id = &node.ID
  36385. }
  36386. }
  36387. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36388. // executed in a transaction (ent.Tx), a transactional client is returned.
  36389. func (m WxCardVisitMutation) Client() *Client {
  36390. client := &Client{config: m.config}
  36391. client.init()
  36392. return client
  36393. }
  36394. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36395. // it returns an error otherwise.
  36396. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  36397. if _, ok := m.driver.(*txDriver); !ok {
  36398. return nil, errors.New("ent: mutation is not running in a transaction")
  36399. }
  36400. tx := &Tx{config: m.config}
  36401. tx.init()
  36402. return tx, nil
  36403. }
  36404. // SetID sets the value of the id field. Note that this
  36405. // operation is only accepted on creation of WxCardVisit entities.
  36406. func (m *WxCardVisitMutation) SetID(id uint64) {
  36407. m.id = &id
  36408. }
  36409. // ID returns the ID value in the mutation. Note that the ID is only available
  36410. // if it was provided to the builder or after it was returned from the database.
  36411. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  36412. if m.id == nil {
  36413. return
  36414. }
  36415. return *m.id, true
  36416. }
  36417. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36418. // That means, if the mutation is applied within a transaction with an isolation level such
  36419. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36420. // or updated by the mutation.
  36421. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  36422. switch {
  36423. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36424. id, exists := m.ID()
  36425. if exists {
  36426. return []uint64{id}, nil
  36427. }
  36428. fallthrough
  36429. case m.op.Is(OpUpdate | OpDelete):
  36430. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  36431. default:
  36432. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36433. }
  36434. }
  36435. // SetCreatedAt sets the "created_at" field.
  36436. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  36437. m.created_at = &t
  36438. }
  36439. // CreatedAt returns the value of the "created_at" field in the mutation.
  36440. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  36441. v := m.created_at
  36442. if v == nil {
  36443. return
  36444. }
  36445. return *v, true
  36446. }
  36447. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  36448. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36450. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36451. if !m.op.Is(OpUpdateOne) {
  36452. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36453. }
  36454. if m.id == nil || m.oldValue == nil {
  36455. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36456. }
  36457. oldValue, err := m.oldValue(ctx)
  36458. if err != nil {
  36459. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36460. }
  36461. return oldValue.CreatedAt, nil
  36462. }
  36463. // ResetCreatedAt resets all changes to the "created_at" field.
  36464. func (m *WxCardVisitMutation) ResetCreatedAt() {
  36465. m.created_at = nil
  36466. }
  36467. // SetUpdatedAt sets the "updated_at" field.
  36468. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  36469. m.updated_at = &t
  36470. }
  36471. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36472. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  36473. v := m.updated_at
  36474. if v == nil {
  36475. return
  36476. }
  36477. return *v, true
  36478. }
  36479. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  36480. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36482. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36483. if !m.op.Is(OpUpdateOne) {
  36484. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36485. }
  36486. if m.id == nil || m.oldValue == nil {
  36487. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36488. }
  36489. oldValue, err := m.oldValue(ctx)
  36490. if err != nil {
  36491. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36492. }
  36493. return oldValue.UpdatedAt, nil
  36494. }
  36495. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36496. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  36497. m.updated_at = nil
  36498. }
  36499. // SetDeletedAt sets the "deleted_at" field.
  36500. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  36501. m.deleted_at = &t
  36502. }
  36503. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36504. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  36505. v := m.deleted_at
  36506. if v == nil {
  36507. return
  36508. }
  36509. return *v, true
  36510. }
  36511. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  36512. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36514. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36515. if !m.op.Is(OpUpdateOne) {
  36516. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36517. }
  36518. if m.id == nil || m.oldValue == nil {
  36519. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36520. }
  36521. oldValue, err := m.oldValue(ctx)
  36522. if err != nil {
  36523. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36524. }
  36525. return oldValue.DeletedAt, nil
  36526. }
  36527. // ClearDeletedAt clears the value of the "deleted_at" field.
  36528. func (m *WxCardVisitMutation) ClearDeletedAt() {
  36529. m.deleted_at = nil
  36530. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  36531. }
  36532. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36533. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  36534. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  36535. return ok
  36536. }
  36537. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36538. func (m *WxCardVisitMutation) ResetDeletedAt() {
  36539. m.deleted_at = nil
  36540. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  36541. }
  36542. // SetUserID sets the "user_id" field.
  36543. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  36544. m.user_id = &u
  36545. m.adduser_id = nil
  36546. }
  36547. // UserID returns the value of the "user_id" field in the mutation.
  36548. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  36549. v := m.user_id
  36550. if v == nil {
  36551. return
  36552. }
  36553. return *v, true
  36554. }
  36555. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  36556. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36558. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  36559. if !m.op.Is(OpUpdateOne) {
  36560. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  36561. }
  36562. if m.id == nil || m.oldValue == nil {
  36563. return v, errors.New("OldUserID requires an ID field in the mutation")
  36564. }
  36565. oldValue, err := m.oldValue(ctx)
  36566. if err != nil {
  36567. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  36568. }
  36569. return oldValue.UserID, nil
  36570. }
  36571. // AddUserID adds u to the "user_id" field.
  36572. func (m *WxCardVisitMutation) AddUserID(u int64) {
  36573. if m.adduser_id != nil {
  36574. *m.adduser_id += u
  36575. } else {
  36576. m.adduser_id = &u
  36577. }
  36578. }
  36579. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  36580. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  36581. v := m.adduser_id
  36582. if v == nil {
  36583. return
  36584. }
  36585. return *v, true
  36586. }
  36587. // ClearUserID clears the value of the "user_id" field.
  36588. func (m *WxCardVisitMutation) ClearUserID() {
  36589. m.user_id = nil
  36590. m.adduser_id = nil
  36591. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  36592. }
  36593. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  36594. func (m *WxCardVisitMutation) UserIDCleared() bool {
  36595. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  36596. return ok
  36597. }
  36598. // ResetUserID resets all changes to the "user_id" field.
  36599. func (m *WxCardVisitMutation) ResetUserID() {
  36600. m.user_id = nil
  36601. m.adduser_id = nil
  36602. delete(m.clearedFields, wxcardvisit.FieldUserID)
  36603. }
  36604. // SetBotID sets the "bot_id" field.
  36605. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  36606. m.bot_id = &u
  36607. m.addbot_id = nil
  36608. }
  36609. // BotID returns the value of the "bot_id" field in the mutation.
  36610. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  36611. v := m.bot_id
  36612. if v == nil {
  36613. return
  36614. }
  36615. return *v, true
  36616. }
  36617. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  36618. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36620. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  36621. if !m.op.Is(OpUpdateOne) {
  36622. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36623. }
  36624. if m.id == nil || m.oldValue == nil {
  36625. return v, errors.New("OldBotID requires an ID field in the mutation")
  36626. }
  36627. oldValue, err := m.oldValue(ctx)
  36628. if err != nil {
  36629. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36630. }
  36631. return oldValue.BotID, nil
  36632. }
  36633. // AddBotID adds u to the "bot_id" field.
  36634. func (m *WxCardVisitMutation) AddBotID(u int64) {
  36635. if m.addbot_id != nil {
  36636. *m.addbot_id += u
  36637. } else {
  36638. m.addbot_id = &u
  36639. }
  36640. }
  36641. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  36642. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  36643. v := m.addbot_id
  36644. if v == nil {
  36645. return
  36646. }
  36647. return *v, true
  36648. }
  36649. // ResetBotID resets all changes to the "bot_id" field.
  36650. func (m *WxCardVisitMutation) ResetBotID() {
  36651. m.bot_id = nil
  36652. m.addbot_id = nil
  36653. }
  36654. // SetBotType sets the "bot_type" field.
  36655. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  36656. m.bot_type = &u
  36657. m.addbot_type = nil
  36658. }
  36659. // BotType returns the value of the "bot_type" field in the mutation.
  36660. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  36661. v := m.bot_type
  36662. if v == nil {
  36663. return
  36664. }
  36665. return *v, true
  36666. }
  36667. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  36668. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36670. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  36671. if !m.op.Is(OpUpdateOne) {
  36672. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  36673. }
  36674. if m.id == nil || m.oldValue == nil {
  36675. return v, errors.New("OldBotType requires an ID field in the mutation")
  36676. }
  36677. oldValue, err := m.oldValue(ctx)
  36678. if err != nil {
  36679. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  36680. }
  36681. return oldValue.BotType, nil
  36682. }
  36683. // AddBotType adds u to the "bot_type" field.
  36684. func (m *WxCardVisitMutation) AddBotType(u int8) {
  36685. if m.addbot_type != nil {
  36686. *m.addbot_type += u
  36687. } else {
  36688. m.addbot_type = &u
  36689. }
  36690. }
  36691. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  36692. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  36693. v := m.addbot_type
  36694. if v == nil {
  36695. return
  36696. }
  36697. return *v, true
  36698. }
  36699. // ResetBotType resets all changes to the "bot_type" field.
  36700. func (m *WxCardVisitMutation) ResetBotType() {
  36701. m.bot_type = nil
  36702. m.addbot_type = nil
  36703. }
  36704. // Where appends a list predicates to the WxCardVisitMutation builder.
  36705. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  36706. m.predicates = append(m.predicates, ps...)
  36707. }
  36708. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  36709. // users can use type-assertion to append predicates that do not depend on any generated package.
  36710. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  36711. p := make([]predicate.WxCardVisit, len(ps))
  36712. for i := range ps {
  36713. p[i] = ps[i]
  36714. }
  36715. m.Where(p...)
  36716. }
  36717. // Op returns the operation name.
  36718. func (m *WxCardVisitMutation) Op() Op {
  36719. return m.op
  36720. }
  36721. // SetOp allows setting the mutation operation.
  36722. func (m *WxCardVisitMutation) SetOp(op Op) {
  36723. m.op = op
  36724. }
  36725. // Type returns the node type of this mutation (WxCardVisit).
  36726. func (m *WxCardVisitMutation) Type() string {
  36727. return m.typ
  36728. }
  36729. // Fields returns all fields that were changed during this mutation. Note that in
  36730. // order to get all numeric fields that were incremented/decremented, call
  36731. // AddedFields().
  36732. func (m *WxCardVisitMutation) Fields() []string {
  36733. fields := make([]string, 0, 6)
  36734. if m.created_at != nil {
  36735. fields = append(fields, wxcardvisit.FieldCreatedAt)
  36736. }
  36737. if m.updated_at != nil {
  36738. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  36739. }
  36740. if m.deleted_at != nil {
  36741. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36742. }
  36743. if m.user_id != nil {
  36744. fields = append(fields, wxcardvisit.FieldUserID)
  36745. }
  36746. if m.bot_id != nil {
  36747. fields = append(fields, wxcardvisit.FieldBotID)
  36748. }
  36749. if m.bot_type != nil {
  36750. fields = append(fields, wxcardvisit.FieldBotType)
  36751. }
  36752. return fields
  36753. }
  36754. // Field returns the value of a field with the given name. The second boolean
  36755. // return value indicates that this field was not set, or was not defined in the
  36756. // schema.
  36757. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  36758. switch name {
  36759. case wxcardvisit.FieldCreatedAt:
  36760. return m.CreatedAt()
  36761. case wxcardvisit.FieldUpdatedAt:
  36762. return m.UpdatedAt()
  36763. case wxcardvisit.FieldDeletedAt:
  36764. return m.DeletedAt()
  36765. case wxcardvisit.FieldUserID:
  36766. return m.UserID()
  36767. case wxcardvisit.FieldBotID:
  36768. return m.BotID()
  36769. case wxcardvisit.FieldBotType:
  36770. return m.BotType()
  36771. }
  36772. return nil, false
  36773. }
  36774. // OldField returns the old value of the field from the database. An error is
  36775. // returned if the mutation operation is not UpdateOne, or the query to the
  36776. // database failed.
  36777. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36778. switch name {
  36779. case wxcardvisit.FieldCreatedAt:
  36780. return m.OldCreatedAt(ctx)
  36781. case wxcardvisit.FieldUpdatedAt:
  36782. return m.OldUpdatedAt(ctx)
  36783. case wxcardvisit.FieldDeletedAt:
  36784. return m.OldDeletedAt(ctx)
  36785. case wxcardvisit.FieldUserID:
  36786. return m.OldUserID(ctx)
  36787. case wxcardvisit.FieldBotID:
  36788. return m.OldBotID(ctx)
  36789. case wxcardvisit.FieldBotType:
  36790. return m.OldBotType(ctx)
  36791. }
  36792. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  36793. }
  36794. // SetField sets the value of a field with the given name. It returns an error if
  36795. // the field is not defined in the schema, or if the type mismatched the field
  36796. // type.
  36797. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  36798. switch name {
  36799. case wxcardvisit.FieldCreatedAt:
  36800. v, ok := value.(time.Time)
  36801. if !ok {
  36802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36803. }
  36804. m.SetCreatedAt(v)
  36805. return nil
  36806. case wxcardvisit.FieldUpdatedAt:
  36807. v, ok := value.(time.Time)
  36808. if !ok {
  36809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36810. }
  36811. m.SetUpdatedAt(v)
  36812. return nil
  36813. case wxcardvisit.FieldDeletedAt:
  36814. v, ok := value.(time.Time)
  36815. if !ok {
  36816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36817. }
  36818. m.SetDeletedAt(v)
  36819. return nil
  36820. case wxcardvisit.FieldUserID:
  36821. v, ok := value.(uint64)
  36822. if !ok {
  36823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36824. }
  36825. m.SetUserID(v)
  36826. return nil
  36827. case wxcardvisit.FieldBotID:
  36828. v, ok := value.(uint64)
  36829. if !ok {
  36830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36831. }
  36832. m.SetBotID(v)
  36833. return nil
  36834. case wxcardvisit.FieldBotType:
  36835. v, ok := value.(uint8)
  36836. if !ok {
  36837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36838. }
  36839. m.SetBotType(v)
  36840. return nil
  36841. }
  36842. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36843. }
  36844. // AddedFields returns all numeric fields that were incremented/decremented during
  36845. // this mutation.
  36846. func (m *WxCardVisitMutation) AddedFields() []string {
  36847. var fields []string
  36848. if m.adduser_id != nil {
  36849. fields = append(fields, wxcardvisit.FieldUserID)
  36850. }
  36851. if m.addbot_id != nil {
  36852. fields = append(fields, wxcardvisit.FieldBotID)
  36853. }
  36854. if m.addbot_type != nil {
  36855. fields = append(fields, wxcardvisit.FieldBotType)
  36856. }
  36857. return fields
  36858. }
  36859. // AddedField returns the numeric value that was incremented/decremented on a field
  36860. // with the given name. The second boolean return value indicates that this field
  36861. // was not set, or was not defined in the schema.
  36862. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  36863. switch name {
  36864. case wxcardvisit.FieldUserID:
  36865. return m.AddedUserID()
  36866. case wxcardvisit.FieldBotID:
  36867. return m.AddedBotID()
  36868. case wxcardvisit.FieldBotType:
  36869. return m.AddedBotType()
  36870. }
  36871. return nil, false
  36872. }
  36873. // AddField adds the value to the field with the given name. It returns an error if
  36874. // the field is not defined in the schema, or if the type mismatched the field
  36875. // type.
  36876. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  36877. switch name {
  36878. case wxcardvisit.FieldUserID:
  36879. v, ok := value.(int64)
  36880. if !ok {
  36881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36882. }
  36883. m.AddUserID(v)
  36884. return nil
  36885. case wxcardvisit.FieldBotID:
  36886. v, ok := value.(int64)
  36887. if !ok {
  36888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36889. }
  36890. m.AddBotID(v)
  36891. return nil
  36892. case wxcardvisit.FieldBotType:
  36893. v, ok := value.(int8)
  36894. if !ok {
  36895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36896. }
  36897. m.AddBotType(v)
  36898. return nil
  36899. }
  36900. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  36901. }
  36902. // ClearedFields returns all nullable fields that were cleared during this
  36903. // mutation.
  36904. func (m *WxCardVisitMutation) ClearedFields() []string {
  36905. var fields []string
  36906. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  36907. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36908. }
  36909. if m.FieldCleared(wxcardvisit.FieldUserID) {
  36910. fields = append(fields, wxcardvisit.FieldUserID)
  36911. }
  36912. return fields
  36913. }
  36914. // FieldCleared returns a boolean indicating if a field with the given name was
  36915. // cleared in this mutation.
  36916. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  36917. _, ok := m.clearedFields[name]
  36918. return ok
  36919. }
  36920. // ClearField clears the value of the field with the given name. It returns an
  36921. // error if the field is not defined in the schema.
  36922. func (m *WxCardVisitMutation) ClearField(name string) error {
  36923. switch name {
  36924. case wxcardvisit.FieldDeletedAt:
  36925. m.ClearDeletedAt()
  36926. return nil
  36927. case wxcardvisit.FieldUserID:
  36928. m.ClearUserID()
  36929. return nil
  36930. }
  36931. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  36932. }
  36933. // ResetField resets all changes in the mutation for the field with the given name.
  36934. // It returns an error if the field is not defined in the schema.
  36935. func (m *WxCardVisitMutation) ResetField(name string) error {
  36936. switch name {
  36937. case wxcardvisit.FieldCreatedAt:
  36938. m.ResetCreatedAt()
  36939. return nil
  36940. case wxcardvisit.FieldUpdatedAt:
  36941. m.ResetUpdatedAt()
  36942. return nil
  36943. case wxcardvisit.FieldDeletedAt:
  36944. m.ResetDeletedAt()
  36945. return nil
  36946. case wxcardvisit.FieldUserID:
  36947. m.ResetUserID()
  36948. return nil
  36949. case wxcardvisit.FieldBotID:
  36950. m.ResetBotID()
  36951. return nil
  36952. case wxcardvisit.FieldBotType:
  36953. m.ResetBotType()
  36954. return nil
  36955. }
  36956. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36957. }
  36958. // AddedEdges returns all edge names that were set/added in this mutation.
  36959. func (m *WxCardVisitMutation) AddedEdges() []string {
  36960. edges := make([]string, 0, 0)
  36961. return edges
  36962. }
  36963. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36964. // name in this mutation.
  36965. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  36966. return nil
  36967. }
  36968. // RemovedEdges returns all edge names that were removed in this mutation.
  36969. func (m *WxCardVisitMutation) RemovedEdges() []string {
  36970. edges := make([]string, 0, 0)
  36971. return edges
  36972. }
  36973. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36974. // the given name in this mutation.
  36975. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  36976. return nil
  36977. }
  36978. // ClearedEdges returns all edge names that were cleared in this mutation.
  36979. func (m *WxCardVisitMutation) ClearedEdges() []string {
  36980. edges := make([]string, 0, 0)
  36981. return edges
  36982. }
  36983. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36984. // was cleared in this mutation.
  36985. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  36986. return false
  36987. }
  36988. // ClearEdge clears the value of the edge with the given name. It returns an error
  36989. // if that edge is not defined in the schema.
  36990. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  36991. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  36992. }
  36993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36994. // It returns an error if the edge is not defined in the schema.
  36995. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  36996. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  36997. }