mutation.go 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410
  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/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/custom_types"
  19. "wechat-api/ent/employee"
  20. "wechat-api/ent/employeeconfig"
  21. "wechat-api/ent/label"
  22. "wechat-api/ent/labelrelationship"
  23. "wechat-api/ent/labeltagging"
  24. "wechat-api/ent/message"
  25. "wechat-api/ent/messagerecords"
  26. "wechat-api/ent/msg"
  27. "wechat-api/ent/predicate"
  28. "wechat-api/ent/server"
  29. "wechat-api/ent/sopnode"
  30. "wechat-api/ent/sopstage"
  31. "wechat-api/ent/soptask"
  32. "wechat-api/ent/token"
  33. "wechat-api/ent/tutorial"
  34. "wechat-api/ent/usagedetail"
  35. "wechat-api/ent/usagestatisticday"
  36. "wechat-api/ent/usagestatistichour"
  37. "wechat-api/ent/usagestatisticmonth"
  38. "wechat-api/ent/usagetotal"
  39. "wechat-api/ent/workexperience"
  40. "wechat-api/ent/wpchatroom"
  41. "wechat-api/ent/wpchatroommember"
  42. "wechat-api/ent/wx"
  43. "wechat-api/ent/wxcard"
  44. "wechat-api/ent/wxcarduser"
  45. "wechat-api/ent/wxcardvisit"
  46. "entgo.io/ent"
  47. "entgo.io/ent/dialect/sql"
  48. )
  49. const (
  50. // Operation types.
  51. OpCreate = ent.OpCreate
  52. OpDelete = ent.OpDelete
  53. OpDeleteOne = ent.OpDeleteOne
  54. OpUpdate = ent.OpUpdate
  55. OpUpdateOne = ent.OpUpdateOne
  56. // Node types.
  57. TypeAgent = "Agent"
  58. TypeAgentBase = "AgentBase"
  59. TypeAliyunAvatar = "AliyunAvatar"
  60. TypeAllocAgent = "AllocAgent"
  61. TypeBatchMsg = "BatchMsg"
  62. TypeCategory = "Category"
  63. TypeChatRecords = "ChatRecords"
  64. TypeChatSession = "ChatSession"
  65. TypeContact = "Contact"
  66. TypeEmployee = "Employee"
  67. TypeEmployeeConfig = "EmployeeConfig"
  68. TypeLabel = "Label"
  69. TypeLabelRelationship = "LabelRelationship"
  70. TypeLabelTagging = "LabelTagging"
  71. TypeMessage = "Message"
  72. TypeMessageRecords = "MessageRecords"
  73. TypeMsg = "Msg"
  74. TypeServer = "Server"
  75. TypeSopNode = "SopNode"
  76. TypeSopStage = "SopStage"
  77. TypeSopTask = "SopTask"
  78. TypeToken = "Token"
  79. TypeTutorial = "Tutorial"
  80. TypeUsageDetail = "UsageDetail"
  81. TypeUsageStatisticDay = "UsageStatisticDay"
  82. TypeUsageStatisticHour = "UsageStatisticHour"
  83. TypeUsageStatisticMonth = "UsageStatisticMonth"
  84. TypeUsageTotal = "UsageTotal"
  85. TypeWorkExperience = "WorkExperience"
  86. TypeWpChatroom = "WpChatroom"
  87. TypeWpChatroomMember = "WpChatroomMember"
  88. TypeWx = "Wx"
  89. TypeWxCard = "WxCard"
  90. TypeWxCardUser = "WxCardUser"
  91. TypeWxCardVisit = "WxCardVisit"
  92. )
  93. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  94. type AgentMutation struct {
  95. config
  96. op Op
  97. typ string
  98. id *uint64
  99. created_at *time.Time
  100. updated_at *time.Time
  101. deleted_at *time.Time
  102. name *string
  103. role *string
  104. status *int
  105. addstatus *int
  106. background *string
  107. examples *string
  108. organization_id *uint64
  109. addorganization_id *int64
  110. dataset_id *string
  111. collection_id *string
  112. clearedFields map[string]struct{}
  113. wx_agent map[uint64]struct{}
  114. removedwx_agent map[uint64]struct{}
  115. clearedwx_agent bool
  116. token_agent map[uint64]struct{}
  117. removedtoken_agent map[uint64]struct{}
  118. clearedtoken_agent bool
  119. done bool
  120. oldValue func(context.Context) (*Agent, error)
  121. predicates []predicate.Agent
  122. }
  123. var _ ent.Mutation = (*AgentMutation)(nil)
  124. // agentOption allows management of the mutation configuration using functional options.
  125. type agentOption func(*AgentMutation)
  126. // newAgentMutation creates new mutation for the Agent entity.
  127. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  128. m := &AgentMutation{
  129. config: c,
  130. op: op,
  131. typ: TypeAgent,
  132. clearedFields: make(map[string]struct{}),
  133. }
  134. for _, opt := range opts {
  135. opt(m)
  136. }
  137. return m
  138. }
  139. // withAgentID sets the ID field of the mutation.
  140. func withAgentID(id uint64) agentOption {
  141. return func(m *AgentMutation) {
  142. var (
  143. err error
  144. once sync.Once
  145. value *Agent
  146. )
  147. m.oldValue = func(ctx context.Context) (*Agent, error) {
  148. once.Do(func() {
  149. if m.done {
  150. err = errors.New("querying old values post mutation is not allowed")
  151. } else {
  152. value, err = m.Client().Agent.Get(ctx, id)
  153. }
  154. })
  155. return value, err
  156. }
  157. m.id = &id
  158. }
  159. }
  160. // withAgent sets the old Agent of the mutation.
  161. func withAgent(node *Agent) agentOption {
  162. return func(m *AgentMutation) {
  163. m.oldValue = func(context.Context) (*Agent, error) {
  164. return node, nil
  165. }
  166. m.id = &node.ID
  167. }
  168. }
  169. // Client returns a new `ent.Client` from the mutation. If the mutation was
  170. // executed in a transaction (ent.Tx), a transactional client is returned.
  171. func (m AgentMutation) Client() *Client {
  172. client := &Client{config: m.config}
  173. client.init()
  174. return client
  175. }
  176. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  177. // it returns an error otherwise.
  178. func (m AgentMutation) Tx() (*Tx, error) {
  179. if _, ok := m.driver.(*txDriver); !ok {
  180. return nil, errors.New("ent: mutation is not running in a transaction")
  181. }
  182. tx := &Tx{config: m.config}
  183. tx.init()
  184. return tx, nil
  185. }
  186. // SetID sets the value of the id field. Note that this
  187. // operation is only accepted on creation of Agent entities.
  188. func (m *AgentMutation) SetID(id uint64) {
  189. m.id = &id
  190. }
  191. // ID returns the ID value in the mutation. Note that the ID is only available
  192. // if it was provided to the builder or after it was returned from the database.
  193. func (m *AgentMutation) ID() (id uint64, exists bool) {
  194. if m.id == nil {
  195. return
  196. }
  197. return *m.id, true
  198. }
  199. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  200. // That means, if the mutation is applied within a transaction with an isolation level such
  201. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  202. // or updated by the mutation.
  203. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  204. switch {
  205. case m.op.Is(OpUpdateOne | OpDeleteOne):
  206. id, exists := m.ID()
  207. if exists {
  208. return []uint64{id}, nil
  209. }
  210. fallthrough
  211. case m.op.Is(OpUpdate | OpDelete):
  212. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  213. default:
  214. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  215. }
  216. }
  217. // SetCreatedAt sets the "created_at" field.
  218. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  219. m.created_at = &t
  220. }
  221. // CreatedAt returns the value of the "created_at" field in the mutation.
  222. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  223. v := m.created_at
  224. if v == nil {
  225. return
  226. }
  227. return *v, true
  228. }
  229. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  230. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  232. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  233. if !m.op.Is(OpUpdateOne) {
  234. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  235. }
  236. if m.id == nil || m.oldValue == nil {
  237. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  238. }
  239. oldValue, err := m.oldValue(ctx)
  240. if err != nil {
  241. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  242. }
  243. return oldValue.CreatedAt, nil
  244. }
  245. // ResetCreatedAt resets all changes to the "created_at" field.
  246. func (m *AgentMutation) ResetCreatedAt() {
  247. m.created_at = nil
  248. }
  249. // SetUpdatedAt sets the "updated_at" field.
  250. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  251. m.updated_at = &t
  252. }
  253. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  254. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  255. v := m.updated_at
  256. if v == nil {
  257. return
  258. }
  259. return *v, true
  260. }
  261. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  262. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  264. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  265. if !m.op.Is(OpUpdateOne) {
  266. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  267. }
  268. if m.id == nil || m.oldValue == nil {
  269. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  270. }
  271. oldValue, err := m.oldValue(ctx)
  272. if err != nil {
  273. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  274. }
  275. return oldValue.UpdatedAt, nil
  276. }
  277. // ResetUpdatedAt resets all changes to the "updated_at" field.
  278. func (m *AgentMutation) ResetUpdatedAt() {
  279. m.updated_at = nil
  280. }
  281. // SetDeletedAt sets the "deleted_at" field.
  282. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  283. m.deleted_at = &t
  284. }
  285. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  286. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  287. v := m.deleted_at
  288. if v == nil {
  289. return
  290. }
  291. return *v, true
  292. }
  293. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  294. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  296. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  297. if !m.op.Is(OpUpdateOne) {
  298. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  299. }
  300. if m.id == nil || m.oldValue == nil {
  301. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  302. }
  303. oldValue, err := m.oldValue(ctx)
  304. if err != nil {
  305. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  306. }
  307. return oldValue.DeletedAt, nil
  308. }
  309. // ClearDeletedAt clears the value of the "deleted_at" field.
  310. func (m *AgentMutation) ClearDeletedAt() {
  311. m.deleted_at = nil
  312. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  313. }
  314. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  315. func (m *AgentMutation) DeletedAtCleared() bool {
  316. _, ok := m.clearedFields[agent.FieldDeletedAt]
  317. return ok
  318. }
  319. // ResetDeletedAt resets all changes to the "deleted_at" field.
  320. func (m *AgentMutation) ResetDeletedAt() {
  321. m.deleted_at = nil
  322. delete(m.clearedFields, agent.FieldDeletedAt)
  323. }
  324. // SetName sets the "name" field.
  325. func (m *AgentMutation) SetName(s string) {
  326. m.name = &s
  327. }
  328. // Name returns the value of the "name" field in the mutation.
  329. func (m *AgentMutation) Name() (r string, exists bool) {
  330. v := m.name
  331. if v == nil {
  332. return
  333. }
  334. return *v, true
  335. }
  336. // OldName returns the old "name" field's value of the Agent entity.
  337. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  339. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  340. if !m.op.Is(OpUpdateOne) {
  341. return v, errors.New("OldName is only allowed on UpdateOne operations")
  342. }
  343. if m.id == nil || m.oldValue == nil {
  344. return v, errors.New("OldName requires an ID field in the mutation")
  345. }
  346. oldValue, err := m.oldValue(ctx)
  347. if err != nil {
  348. return v, fmt.Errorf("querying old value for OldName: %w", err)
  349. }
  350. return oldValue.Name, nil
  351. }
  352. // ResetName resets all changes to the "name" field.
  353. func (m *AgentMutation) ResetName() {
  354. m.name = nil
  355. }
  356. // SetRole sets the "role" field.
  357. func (m *AgentMutation) SetRole(s string) {
  358. m.role = &s
  359. }
  360. // Role returns the value of the "role" field in the mutation.
  361. func (m *AgentMutation) Role() (r string, exists bool) {
  362. v := m.role
  363. if v == nil {
  364. return
  365. }
  366. return *v, true
  367. }
  368. // OldRole returns the old "role" field's value of the Agent entity.
  369. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  371. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  372. if !m.op.Is(OpUpdateOne) {
  373. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  374. }
  375. if m.id == nil || m.oldValue == nil {
  376. return v, errors.New("OldRole requires an ID field in the mutation")
  377. }
  378. oldValue, err := m.oldValue(ctx)
  379. if err != nil {
  380. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  381. }
  382. return oldValue.Role, nil
  383. }
  384. // ResetRole resets all changes to the "role" field.
  385. func (m *AgentMutation) ResetRole() {
  386. m.role = nil
  387. }
  388. // SetStatus sets the "status" field.
  389. func (m *AgentMutation) SetStatus(i int) {
  390. m.status = &i
  391. m.addstatus = nil
  392. }
  393. // Status returns the value of the "status" field in the mutation.
  394. func (m *AgentMutation) Status() (r int, exists bool) {
  395. v := m.status
  396. if v == nil {
  397. return
  398. }
  399. return *v, true
  400. }
  401. // OldStatus returns the old "status" field's value of the Agent entity.
  402. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  404. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  405. if !m.op.Is(OpUpdateOne) {
  406. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  407. }
  408. if m.id == nil || m.oldValue == nil {
  409. return v, errors.New("OldStatus requires an ID field in the mutation")
  410. }
  411. oldValue, err := m.oldValue(ctx)
  412. if err != nil {
  413. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  414. }
  415. return oldValue.Status, nil
  416. }
  417. // AddStatus adds i to the "status" field.
  418. func (m *AgentMutation) AddStatus(i int) {
  419. if m.addstatus != nil {
  420. *m.addstatus += i
  421. } else {
  422. m.addstatus = &i
  423. }
  424. }
  425. // AddedStatus returns the value that was added to the "status" field in this mutation.
  426. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  427. v := m.addstatus
  428. if v == nil {
  429. return
  430. }
  431. return *v, true
  432. }
  433. // ClearStatus clears the value of the "status" field.
  434. func (m *AgentMutation) ClearStatus() {
  435. m.status = nil
  436. m.addstatus = nil
  437. m.clearedFields[agent.FieldStatus] = struct{}{}
  438. }
  439. // StatusCleared returns if the "status" field was cleared in this mutation.
  440. func (m *AgentMutation) StatusCleared() bool {
  441. _, ok := m.clearedFields[agent.FieldStatus]
  442. return ok
  443. }
  444. // ResetStatus resets all changes to the "status" field.
  445. func (m *AgentMutation) ResetStatus() {
  446. m.status = nil
  447. m.addstatus = nil
  448. delete(m.clearedFields, agent.FieldStatus)
  449. }
  450. // SetBackground sets the "background" field.
  451. func (m *AgentMutation) SetBackground(s string) {
  452. m.background = &s
  453. }
  454. // Background returns the value of the "background" field in the mutation.
  455. func (m *AgentMutation) Background() (r string, exists bool) {
  456. v := m.background
  457. if v == nil {
  458. return
  459. }
  460. return *v, true
  461. }
  462. // OldBackground returns the old "background" field's value of the Agent entity.
  463. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  465. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  466. if !m.op.Is(OpUpdateOne) {
  467. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  468. }
  469. if m.id == nil || m.oldValue == nil {
  470. return v, errors.New("OldBackground requires an ID field in the mutation")
  471. }
  472. oldValue, err := m.oldValue(ctx)
  473. if err != nil {
  474. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  475. }
  476. return oldValue.Background, nil
  477. }
  478. // ClearBackground clears the value of the "background" field.
  479. func (m *AgentMutation) ClearBackground() {
  480. m.background = nil
  481. m.clearedFields[agent.FieldBackground] = struct{}{}
  482. }
  483. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  484. func (m *AgentMutation) BackgroundCleared() bool {
  485. _, ok := m.clearedFields[agent.FieldBackground]
  486. return ok
  487. }
  488. // ResetBackground resets all changes to the "background" field.
  489. func (m *AgentMutation) ResetBackground() {
  490. m.background = nil
  491. delete(m.clearedFields, agent.FieldBackground)
  492. }
  493. // SetExamples sets the "examples" field.
  494. func (m *AgentMutation) SetExamples(s string) {
  495. m.examples = &s
  496. }
  497. // Examples returns the value of the "examples" field in the mutation.
  498. func (m *AgentMutation) Examples() (r string, exists bool) {
  499. v := m.examples
  500. if v == nil {
  501. return
  502. }
  503. return *v, true
  504. }
  505. // OldExamples returns the old "examples" field's value of the Agent entity.
  506. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  508. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  509. if !m.op.Is(OpUpdateOne) {
  510. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  511. }
  512. if m.id == nil || m.oldValue == nil {
  513. return v, errors.New("OldExamples requires an ID field in the mutation")
  514. }
  515. oldValue, err := m.oldValue(ctx)
  516. if err != nil {
  517. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  518. }
  519. return oldValue.Examples, nil
  520. }
  521. // ClearExamples clears the value of the "examples" field.
  522. func (m *AgentMutation) ClearExamples() {
  523. m.examples = nil
  524. m.clearedFields[agent.FieldExamples] = struct{}{}
  525. }
  526. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  527. func (m *AgentMutation) ExamplesCleared() bool {
  528. _, ok := m.clearedFields[agent.FieldExamples]
  529. return ok
  530. }
  531. // ResetExamples resets all changes to the "examples" field.
  532. func (m *AgentMutation) ResetExamples() {
  533. m.examples = nil
  534. delete(m.clearedFields, agent.FieldExamples)
  535. }
  536. // SetOrganizationID sets the "organization_id" field.
  537. func (m *AgentMutation) SetOrganizationID(u uint64) {
  538. m.organization_id = &u
  539. m.addorganization_id = nil
  540. }
  541. // OrganizationID returns the value of the "organization_id" field in the mutation.
  542. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  543. v := m.organization_id
  544. if v == nil {
  545. return
  546. }
  547. return *v, true
  548. }
  549. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  550. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  552. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  553. if !m.op.Is(OpUpdateOne) {
  554. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  555. }
  556. if m.id == nil || m.oldValue == nil {
  557. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  558. }
  559. oldValue, err := m.oldValue(ctx)
  560. if err != nil {
  561. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  562. }
  563. return oldValue.OrganizationID, nil
  564. }
  565. // AddOrganizationID adds u to the "organization_id" field.
  566. func (m *AgentMutation) AddOrganizationID(u int64) {
  567. if m.addorganization_id != nil {
  568. *m.addorganization_id += u
  569. } else {
  570. m.addorganization_id = &u
  571. }
  572. }
  573. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  574. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  575. v := m.addorganization_id
  576. if v == nil {
  577. return
  578. }
  579. return *v, true
  580. }
  581. // ResetOrganizationID resets all changes to the "organization_id" field.
  582. func (m *AgentMutation) ResetOrganizationID() {
  583. m.organization_id = nil
  584. m.addorganization_id = nil
  585. }
  586. // SetDatasetID sets the "dataset_id" field.
  587. func (m *AgentMutation) SetDatasetID(s string) {
  588. m.dataset_id = &s
  589. }
  590. // DatasetID returns the value of the "dataset_id" field in the mutation.
  591. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  592. v := m.dataset_id
  593. if v == nil {
  594. return
  595. }
  596. return *v, true
  597. }
  598. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  599. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  601. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  602. if !m.op.Is(OpUpdateOne) {
  603. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  604. }
  605. if m.id == nil || m.oldValue == nil {
  606. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  607. }
  608. oldValue, err := m.oldValue(ctx)
  609. if err != nil {
  610. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  611. }
  612. return oldValue.DatasetID, nil
  613. }
  614. // ResetDatasetID resets all changes to the "dataset_id" field.
  615. func (m *AgentMutation) ResetDatasetID() {
  616. m.dataset_id = nil
  617. }
  618. // SetCollectionID sets the "collection_id" field.
  619. func (m *AgentMutation) SetCollectionID(s string) {
  620. m.collection_id = &s
  621. }
  622. // CollectionID returns the value of the "collection_id" field in the mutation.
  623. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  624. v := m.collection_id
  625. if v == nil {
  626. return
  627. }
  628. return *v, true
  629. }
  630. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  631. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  633. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  634. if !m.op.Is(OpUpdateOne) {
  635. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  636. }
  637. if m.id == nil || m.oldValue == nil {
  638. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  639. }
  640. oldValue, err := m.oldValue(ctx)
  641. if err != nil {
  642. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  643. }
  644. return oldValue.CollectionID, nil
  645. }
  646. // ResetCollectionID resets all changes to the "collection_id" field.
  647. func (m *AgentMutation) ResetCollectionID() {
  648. m.collection_id = nil
  649. }
  650. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  651. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  652. if m.wx_agent == nil {
  653. m.wx_agent = make(map[uint64]struct{})
  654. }
  655. for i := range ids {
  656. m.wx_agent[ids[i]] = struct{}{}
  657. }
  658. }
  659. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  660. func (m *AgentMutation) ClearWxAgent() {
  661. m.clearedwx_agent = true
  662. }
  663. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  664. func (m *AgentMutation) WxAgentCleared() bool {
  665. return m.clearedwx_agent
  666. }
  667. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  668. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  669. if m.removedwx_agent == nil {
  670. m.removedwx_agent = make(map[uint64]struct{})
  671. }
  672. for i := range ids {
  673. delete(m.wx_agent, ids[i])
  674. m.removedwx_agent[ids[i]] = struct{}{}
  675. }
  676. }
  677. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  678. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  679. for id := range m.removedwx_agent {
  680. ids = append(ids, id)
  681. }
  682. return
  683. }
  684. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  685. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  686. for id := range m.wx_agent {
  687. ids = append(ids, id)
  688. }
  689. return
  690. }
  691. // ResetWxAgent resets all changes to the "wx_agent" edge.
  692. func (m *AgentMutation) ResetWxAgent() {
  693. m.wx_agent = nil
  694. m.clearedwx_agent = false
  695. m.removedwx_agent = nil
  696. }
  697. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  698. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  699. if m.token_agent == nil {
  700. m.token_agent = make(map[uint64]struct{})
  701. }
  702. for i := range ids {
  703. m.token_agent[ids[i]] = struct{}{}
  704. }
  705. }
  706. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  707. func (m *AgentMutation) ClearTokenAgent() {
  708. m.clearedtoken_agent = true
  709. }
  710. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  711. func (m *AgentMutation) TokenAgentCleared() bool {
  712. return m.clearedtoken_agent
  713. }
  714. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  715. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  716. if m.removedtoken_agent == nil {
  717. m.removedtoken_agent = make(map[uint64]struct{})
  718. }
  719. for i := range ids {
  720. delete(m.token_agent, ids[i])
  721. m.removedtoken_agent[ids[i]] = struct{}{}
  722. }
  723. }
  724. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  725. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  726. for id := range m.removedtoken_agent {
  727. ids = append(ids, id)
  728. }
  729. return
  730. }
  731. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  732. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  733. for id := range m.token_agent {
  734. ids = append(ids, id)
  735. }
  736. return
  737. }
  738. // ResetTokenAgent resets all changes to the "token_agent" edge.
  739. func (m *AgentMutation) ResetTokenAgent() {
  740. m.token_agent = nil
  741. m.clearedtoken_agent = false
  742. m.removedtoken_agent = nil
  743. }
  744. // Where appends a list predicates to the AgentMutation builder.
  745. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  746. m.predicates = append(m.predicates, ps...)
  747. }
  748. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  749. // users can use type-assertion to append predicates that do not depend on any generated package.
  750. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  751. p := make([]predicate.Agent, len(ps))
  752. for i := range ps {
  753. p[i] = ps[i]
  754. }
  755. m.Where(p...)
  756. }
  757. // Op returns the operation name.
  758. func (m *AgentMutation) Op() Op {
  759. return m.op
  760. }
  761. // SetOp allows setting the mutation operation.
  762. func (m *AgentMutation) SetOp(op Op) {
  763. m.op = op
  764. }
  765. // Type returns the node type of this mutation (Agent).
  766. func (m *AgentMutation) Type() string {
  767. return m.typ
  768. }
  769. // Fields returns all fields that were changed during this mutation. Note that in
  770. // order to get all numeric fields that were incremented/decremented, call
  771. // AddedFields().
  772. func (m *AgentMutation) Fields() []string {
  773. fields := make([]string, 0, 11)
  774. if m.created_at != nil {
  775. fields = append(fields, agent.FieldCreatedAt)
  776. }
  777. if m.updated_at != nil {
  778. fields = append(fields, agent.FieldUpdatedAt)
  779. }
  780. if m.deleted_at != nil {
  781. fields = append(fields, agent.FieldDeletedAt)
  782. }
  783. if m.name != nil {
  784. fields = append(fields, agent.FieldName)
  785. }
  786. if m.role != nil {
  787. fields = append(fields, agent.FieldRole)
  788. }
  789. if m.status != nil {
  790. fields = append(fields, agent.FieldStatus)
  791. }
  792. if m.background != nil {
  793. fields = append(fields, agent.FieldBackground)
  794. }
  795. if m.examples != nil {
  796. fields = append(fields, agent.FieldExamples)
  797. }
  798. if m.organization_id != nil {
  799. fields = append(fields, agent.FieldOrganizationID)
  800. }
  801. if m.dataset_id != nil {
  802. fields = append(fields, agent.FieldDatasetID)
  803. }
  804. if m.collection_id != nil {
  805. fields = append(fields, agent.FieldCollectionID)
  806. }
  807. return fields
  808. }
  809. // Field returns the value of a field with the given name. The second boolean
  810. // return value indicates that this field was not set, or was not defined in the
  811. // schema.
  812. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  813. switch name {
  814. case agent.FieldCreatedAt:
  815. return m.CreatedAt()
  816. case agent.FieldUpdatedAt:
  817. return m.UpdatedAt()
  818. case agent.FieldDeletedAt:
  819. return m.DeletedAt()
  820. case agent.FieldName:
  821. return m.Name()
  822. case agent.FieldRole:
  823. return m.Role()
  824. case agent.FieldStatus:
  825. return m.Status()
  826. case agent.FieldBackground:
  827. return m.Background()
  828. case agent.FieldExamples:
  829. return m.Examples()
  830. case agent.FieldOrganizationID:
  831. return m.OrganizationID()
  832. case agent.FieldDatasetID:
  833. return m.DatasetID()
  834. case agent.FieldCollectionID:
  835. return m.CollectionID()
  836. }
  837. return nil, false
  838. }
  839. // OldField returns the old value of the field from the database. An error is
  840. // returned if the mutation operation is not UpdateOne, or the query to the
  841. // database failed.
  842. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  843. switch name {
  844. case agent.FieldCreatedAt:
  845. return m.OldCreatedAt(ctx)
  846. case agent.FieldUpdatedAt:
  847. return m.OldUpdatedAt(ctx)
  848. case agent.FieldDeletedAt:
  849. return m.OldDeletedAt(ctx)
  850. case agent.FieldName:
  851. return m.OldName(ctx)
  852. case agent.FieldRole:
  853. return m.OldRole(ctx)
  854. case agent.FieldStatus:
  855. return m.OldStatus(ctx)
  856. case agent.FieldBackground:
  857. return m.OldBackground(ctx)
  858. case agent.FieldExamples:
  859. return m.OldExamples(ctx)
  860. case agent.FieldOrganizationID:
  861. return m.OldOrganizationID(ctx)
  862. case agent.FieldDatasetID:
  863. return m.OldDatasetID(ctx)
  864. case agent.FieldCollectionID:
  865. return m.OldCollectionID(ctx)
  866. }
  867. return nil, fmt.Errorf("unknown Agent field %s", name)
  868. }
  869. // SetField sets the value of a field with the given name. It returns an error if
  870. // the field is not defined in the schema, or if the type mismatched the field
  871. // type.
  872. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. v, ok := value.(time.Time)
  876. if !ok {
  877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  878. }
  879. m.SetCreatedAt(v)
  880. return nil
  881. case agent.FieldUpdatedAt:
  882. v, ok := value.(time.Time)
  883. if !ok {
  884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  885. }
  886. m.SetUpdatedAt(v)
  887. return nil
  888. case agent.FieldDeletedAt:
  889. v, ok := value.(time.Time)
  890. if !ok {
  891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  892. }
  893. m.SetDeletedAt(v)
  894. return nil
  895. case agent.FieldName:
  896. v, ok := value.(string)
  897. if !ok {
  898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  899. }
  900. m.SetName(v)
  901. return nil
  902. case agent.FieldRole:
  903. v, ok := value.(string)
  904. if !ok {
  905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  906. }
  907. m.SetRole(v)
  908. return nil
  909. case agent.FieldStatus:
  910. v, ok := value.(int)
  911. if !ok {
  912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  913. }
  914. m.SetStatus(v)
  915. return nil
  916. case agent.FieldBackground:
  917. v, ok := value.(string)
  918. if !ok {
  919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  920. }
  921. m.SetBackground(v)
  922. return nil
  923. case agent.FieldExamples:
  924. v, ok := value.(string)
  925. if !ok {
  926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  927. }
  928. m.SetExamples(v)
  929. return nil
  930. case agent.FieldOrganizationID:
  931. v, ok := value.(uint64)
  932. if !ok {
  933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  934. }
  935. m.SetOrganizationID(v)
  936. return nil
  937. case agent.FieldDatasetID:
  938. v, ok := value.(string)
  939. if !ok {
  940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  941. }
  942. m.SetDatasetID(v)
  943. return nil
  944. case agent.FieldCollectionID:
  945. v, ok := value.(string)
  946. if !ok {
  947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  948. }
  949. m.SetCollectionID(v)
  950. return nil
  951. }
  952. return fmt.Errorf("unknown Agent field %s", name)
  953. }
  954. // AddedFields returns all numeric fields that were incremented/decremented during
  955. // this mutation.
  956. func (m *AgentMutation) AddedFields() []string {
  957. var fields []string
  958. if m.addstatus != nil {
  959. fields = append(fields, agent.FieldStatus)
  960. }
  961. if m.addorganization_id != nil {
  962. fields = append(fields, agent.FieldOrganizationID)
  963. }
  964. return fields
  965. }
  966. // AddedField returns the numeric value that was incremented/decremented on a field
  967. // with the given name. The second boolean return value indicates that this field
  968. // was not set, or was not defined in the schema.
  969. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  970. switch name {
  971. case agent.FieldStatus:
  972. return m.AddedStatus()
  973. case agent.FieldOrganizationID:
  974. return m.AddedOrganizationID()
  975. }
  976. return nil, false
  977. }
  978. // AddField adds the value to the field with the given name. It returns an error if
  979. // the field is not defined in the schema, or if the type mismatched the field
  980. // type.
  981. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  982. switch name {
  983. case agent.FieldStatus:
  984. v, ok := value.(int)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.AddStatus(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(int64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.AddOrganizationID(v)
  996. return nil
  997. }
  998. return fmt.Errorf("unknown Agent numeric field %s", name)
  999. }
  1000. // ClearedFields returns all nullable fields that were cleared during this
  1001. // mutation.
  1002. func (m *AgentMutation) ClearedFields() []string {
  1003. var fields []string
  1004. if m.FieldCleared(agent.FieldDeletedAt) {
  1005. fields = append(fields, agent.FieldDeletedAt)
  1006. }
  1007. if m.FieldCleared(agent.FieldStatus) {
  1008. fields = append(fields, agent.FieldStatus)
  1009. }
  1010. if m.FieldCleared(agent.FieldBackground) {
  1011. fields = append(fields, agent.FieldBackground)
  1012. }
  1013. if m.FieldCleared(agent.FieldExamples) {
  1014. fields = append(fields, agent.FieldExamples)
  1015. }
  1016. return fields
  1017. }
  1018. // FieldCleared returns a boolean indicating if a field with the given name was
  1019. // cleared in this mutation.
  1020. func (m *AgentMutation) FieldCleared(name string) bool {
  1021. _, ok := m.clearedFields[name]
  1022. return ok
  1023. }
  1024. // ClearField clears the value of the field with the given name. It returns an
  1025. // error if the field is not defined in the schema.
  1026. func (m *AgentMutation) ClearField(name string) error {
  1027. switch name {
  1028. case agent.FieldDeletedAt:
  1029. m.ClearDeletedAt()
  1030. return nil
  1031. case agent.FieldStatus:
  1032. m.ClearStatus()
  1033. return nil
  1034. case agent.FieldBackground:
  1035. m.ClearBackground()
  1036. return nil
  1037. case agent.FieldExamples:
  1038. m.ClearExamples()
  1039. return nil
  1040. }
  1041. return fmt.Errorf("unknown Agent nullable field %s", name)
  1042. }
  1043. // ResetField resets all changes in the mutation for the field with the given name.
  1044. // It returns an error if the field is not defined in the schema.
  1045. func (m *AgentMutation) ResetField(name string) error {
  1046. switch name {
  1047. case agent.FieldCreatedAt:
  1048. m.ResetCreatedAt()
  1049. return nil
  1050. case agent.FieldUpdatedAt:
  1051. m.ResetUpdatedAt()
  1052. return nil
  1053. case agent.FieldDeletedAt:
  1054. m.ResetDeletedAt()
  1055. return nil
  1056. case agent.FieldName:
  1057. m.ResetName()
  1058. return nil
  1059. case agent.FieldRole:
  1060. m.ResetRole()
  1061. return nil
  1062. case agent.FieldStatus:
  1063. m.ResetStatus()
  1064. return nil
  1065. case agent.FieldBackground:
  1066. m.ResetBackground()
  1067. return nil
  1068. case agent.FieldExamples:
  1069. m.ResetExamples()
  1070. return nil
  1071. case agent.FieldOrganizationID:
  1072. m.ResetOrganizationID()
  1073. return nil
  1074. case agent.FieldDatasetID:
  1075. m.ResetDatasetID()
  1076. return nil
  1077. case agent.FieldCollectionID:
  1078. m.ResetCollectionID()
  1079. return nil
  1080. }
  1081. return fmt.Errorf("unknown Agent field %s", name)
  1082. }
  1083. // AddedEdges returns all edge names that were set/added in this mutation.
  1084. func (m *AgentMutation) AddedEdges() []string {
  1085. edges := make([]string, 0, 2)
  1086. if m.wx_agent != nil {
  1087. edges = append(edges, agent.EdgeWxAgent)
  1088. }
  1089. if m.token_agent != nil {
  1090. edges = append(edges, agent.EdgeTokenAgent)
  1091. }
  1092. return edges
  1093. }
  1094. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1095. // name in this mutation.
  1096. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1097. switch name {
  1098. case agent.EdgeWxAgent:
  1099. ids := make([]ent.Value, 0, len(m.wx_agent))
  1100. for id := range m.wx_agent {
  1101. ids = append(ids, id)
  1102. }
  1103. return ids
  1104. case agent.EdgeTokenAgent:
  1105. ids := make([]ent.Value, 0, len(m.token_agent))
  1106. for id := range m.token_agent {
  1107. ids = append(ids, id)
  1108. }
  1109. return ids
  1110. }
  1111. return nil
  1112. }
  1113. // RemovedEdges returns all edge names that were removed in this mutation.
  1114. func (m *AgentMutation) RemovedEdges() []string {
  1115. edges := make([]string, 0, 2)
  1116. if m.removedwx_agent != nil {
  1117. edges = append(edges, agent.EdgeWxAgent)
  1118. }
  1119. if m.removedtoken_agent != nil {
  1120. edges = append(edges, agent.EdgeTokenAgent)
  1121. }
  1122. return edges
  1123. }
  1124. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1125. // the given name in this mutation.
  1126. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1127. switch name {
  1128. case agent.EdgeWxAgent:
  1129. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1130. for id := range m.removedwx_agent {
  1131. ids = append(ids, id)
  1132. }
  1133. return ids
  1134. case agent.EdgeTokenAgent:
  1135. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1136. for id := range m.removedtoken_agent {
  1137. ids = append(ids, id)
  1138. }
  1139. return ids
  1140. }
  1141. return nil
  1142. }
  1143. // ClearedEdges returns all edge names that were cleared in this mutation.
  1144. func (m *AgentMutation) ClearedEdges() []string {
  1145. edges := make([]string, 0, 2)
  1146. if m.clearedwx_agent {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.clearedtoken_agent {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. return edges
  1153. }
  1154. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1155. // was cleared in this mutation.
  1156. func (m *AgentMutation) EdgeCleared(name string) bool {
  1157. switch name {
  1158. case agent.EdgeWxAgent:
  1159. return m.clearedwx_agent
  1160. case agent.EdgeTokenAgent:
  1161. return m.clearedtoken_agent
  1162. }
  1163. return false
  1164. }
  1165. // ClearEdge clears the value of the edge with the given name. It returns an error
  1166. // if that edge is not defined in the schema.
  1167. func (m *AgentMutation) ClearEdge(name string) error {
  1168. switch name {
  1169. }
  1170. return fmt.Errorf("unknown Agent unique edge %s", name)
  1171. }
  1172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1173. // It returns an error if the edge is not defined in the schema.
  1174. func (m *AgentMutation) ResetEdge(name string) error {
  1175. switch name {
  1176. case agent.EdgeWxAgent:
  1177. m.ResetWxAgent()
  1178. return nil
  1179. case agent.EdgeTokenAgent:
  1180. m.ResetTokenAgent()
  1181. return nil
  1182. }
  1183. return fmt.Errorf("unknown Agent edge %s", name)
  1184. }
  1185. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1186. type AgentBaseMutation struct {
  1187. config
  1188. op Op
  1189. typ string
  1190. id *string
  1191. q *string
  1192. a *string
  1193. chunk_index *uint64
  1194. addchunk_index *int64
  1195. indexes *[]string
  1196. appendindexes []string
  1197. dataset_id *string
  1198. collection_id *string
  1199. source_name *string
  1200. can_write *[]bool
  1201. appendcan_write []bool
  1202. is_owner *[]bool
  1203. appendis_owner []bool
  1204. clearedFields map[string]struct{}
  1205. wx_agent map[uint64]struct{}
  1206. removedwx_agent map[uint64]struct{}
  1207. clearedwx_agent bool
  1208. done bool
  1209. oldValue func(context.Context) (*AgentBase, error)
  1210. predicates []predicate.AgentBase
  1211. }
  1212. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1213. // agentbaseOption allows management of the mutation configuration using functional options.
  1214. type agentbaseOption func(*AgentBaseMutation)
  1215. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1216. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1217. m := &AgentBaseMutation{
  1218. config: c,
  1219. op: op,
  1220. typ: TypeAgentBase,
  1221. clearedFields: make(map[string]struct{}),
  1222. }
  1223. for _, opt := range opts {
  1224. opt(m)
  1225. }
  1226. return m
  1227. }
  1228. // withAgentBaseID sets the ID field of the mutation.
  1229. func withAgentBaseID(id string) agentbaseOption {
  1230. return func(m *AgentBaseMutation) {
  1231. var (
  1232. err error
  1233. once sync.Once
  1234. value *AgentBase
  1235. )
  1236. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1237. once.Do(func() {
  1238. if m.done {
  1239. err = errors.New("querying old values post mutation is not allowed")
  1240. } else {
  1241. value, err = m.Client().AgentBase.Get(ctx, id)
  1242. }
  1243. })
  1244. return value, err
  1245. }
  1246. m.id = &id
  1247. }
  1248. }
  1249. // withAgentBase sets the old AgentBase of the mutation.
  1250. func withAgentBase(node *AgentBase) agentbaseOption {
  1251. return func(m *AgentBaseMutation) {
  1252. m.oldValue = func(context.Context) (*AgentBase, error) {
  1253. return node, nil
  1254. }
  1255. m.id = &node.ID
  1256. }
  1257. }
  1258. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1259. // executed in a transaction (ent.Tx), a transactional client is returned.
  1260. func (m AgentBaseMutation) Client() *Client {
  1261. client := &Client{config: m.config}
  1262. client.init()
  1263. return client
  1264. }
  1265. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1266. // it returns an error otherwise.
  1267. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1268. if _, ok := m.driver.(*txDriver); !ok {
  1269. return nil, errors.New("ent: mutation is not running in a transaction")
  1270. }
  1271. tx := &Tx{config: m.config}
  1272. tx.init()
  1273. return tx, nil
  1274. }
  1275. // SetID sets the value of the id field. Note that this
  1276. // operation is only accepted on creation of AgentBase entities.
  1277. func (m *AgentBaseMutation) SetID(id string) {
  1278. m.id = &id
  1279. }
  1280. // ID returns the ID value in the mutation. Note that the ID is only available
  1281. // if it was provided to the builder or after it was returned from the database.
  1282. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1283. if m.id == nil {
  1284. return
  1285. }
  1286. return *m.id, true
  1287. }
  1288. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1289. // That means, if the mutation is applied within a transaction with an isolation level such
  1290. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1291. // or updated by the mutation.
  1292. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1293. switch {
  1294. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1295. id, exists := m.ID()
  1296. if exists {
  1297. return []string{id}, nil
  1298. }
  1299. fallthrough
  1300. case m.op.Is(OpUpdate | OpDelete):
  1301. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1302. default:
  1303. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1304. }
  1305. }
  1306. // SetQ sets the "q" field.
  1307. func (m *AgentBaseMutation) SetQ(s string) {
  1308. m.q = &s
  1309. }
  1310. // Q returns the value of the "q" field in the mutation.
  1311. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1312. v := m.q
  1313. if v == nil {
  1314. return
  1315. }
  1316. return *v, true
  1317. }
  1318. // OldQ returns the old "q" field's value of the AgentBase entity.
  1319. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1321. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1322. if !m.op.Is(OpUpdateOne) {
  1323. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1324. }
  1325. if m.id == nil || m.oldValue == nil {
  1326. return v, errors.New("OldQ requires an ID field in the mutation")
  1327. }
  1328. oldValue, err := m.oldValue(ctx)
  1329. if err != nil {
  1330. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1331. }
  1332. return oldValue.Q, nil
  1333. }
  1334. // ClearQ clears the value of the "q" field.
  1335. func (m *AgentBaseMutation) ClearQ() {
  1336. m.q = nil
  1337. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1338. }
  1339. // QCleared returns if the "q" field was cleared in this mutation.
  1340. func (m *AgentBaseMutation) QCleared() bool {
  1341. _, ok := m.clearedFields[agentbase.FieldQ]
  1342. return ok
  1343. }
  1344. // ResetQ resets all changes to the "q" field.
  1345. func (m *AgentBaseMutation) ResetQ() {
  1346. m.q = nil
  1347. delete(m.clearedFields, agentbase.FieldQ)
  1348. }
  1349. // SetA sets the "a" field.
  1350. func (m *AgentBaseMutation) SetA(s string) {
  1351. m.a = &s
  1352. }
  1353. // A returns the value of the "a" field in the mutation.
  1354. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1355. v := m.a
  1356. if v == nil {
  1357. return
  1358. }
  1359. return *v, true
  1360. }
  1361. // OldA returns the old "a" field's value of the AgentBase entity.
  1362. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1364. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1365. if !m.op.Is(OpUpdateOne) {
  1366. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1367. }
  1368. if m.id == nil || m.oldValue == nil {
  1369. return v, errors.New("OldA requires an ID field in the mutation")
  1370. }
  1371. oldValue, err := m.oldValue(ctx)
  1372. if err != nil {
  1373. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1374. }
  1375. return oldValue.A, nil
  1376. }
  1377. // ClearA clears the value of the "a" field.
  1378. func (m *AgentBaseMutation) ClearA() {
  1379. m.a = nil
  1380. m.clearedFields[agentbase.FieldA] = struct{}{}
  1381. }
  1382. // ACleared returns if the "a" field was cleared in this mutation.
  1383. func (m *AgentBaseMutation) ACleared() bool {
  1384. _, ok := m.clearedFields[agentbase.FieldA]
  1385. return ok
  1386. }
  1387. // ResetA resets all changes to the "a" field.
  1388. func (m *AgentBaseMutation) ResetA() {
  1389. m.a = nil
  1390. delete(m.clearedFields, agentbase.FieldA)
  1391. }
  1392. // SetChunkIndex sets the "chunk_index" field.
  1393. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1394. m.chunk_index = &u
  1395. m.addchunk_index = nil
  1396. }
  1397. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1398. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1399. v := m.chunk_index
  1400. if v == nil {
  1401. return
  1402. }
  1403. return *v, true
  1404. }
  1405. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1406. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1408. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1409. if !m.op.Is(OpUpdateOne) {
  1410. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1411. }
  1412. if m.id == nil || m.oldValue == nil {
  1413. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1414. }
  1415. oldValue, err := m.oldValue(ctx)
  1416. if err != nil {
  1417. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1418. }
  1419. return oldValue.ChunkIndex, nil
  1420. }
  1421. // AddChunkIndex adds u to the "chunk_index" field.
  1422. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1423. if m.addchunk_index != nil {
  1424. *m.addchunk_index += u
  1425. } else {
  1426. m.addchunk_index = &u
  1427. }
  1428. }
  1429. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1430. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1431. v := m.addchunk_index
  1432. if v == nil {
  1433. return
  1434. }
  1435. return *v, true
  1436. }
  1437. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1438. func (m *AgentBaseMutation) ResetChunkIndex() {
  1439. m.chunk_index = nil
  1440. m.addchunk_index = nil
  1441. }
  1442. // SetIndexes sets the "indexes" field.
  1443. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1444. m.indexes = &s
  1445. m.appendindexes = nil
  1446. }
  1447. // Indexes returns the value of the "indexes" field in the mutation.
  1448. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1449. v := m.indexes
  1450. if v == nil {
  1451. return
  1452. }
  1453. return *v, true
  1454. }
  1455. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1456. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1458. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1459. if !m.op.Is(OpUpdateOne) {
  1460. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1461. }
  1462. if m.id == nil || m.oldValue == nil {
  1463. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1464. }
  1465. oldValue, err := m.oldValue(ctx)
  1466. if err != nil {
  1467. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1468. }
  1469. return oldValue.Indexes, nil
  1470. }
  1471. // AppendIndexes adds s to the "indexes" field.
  1472. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1473. m.appendindexes = append(m.appendindexes, s...)
  1474. }
  1475. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1476. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1477. if len(m.appendindexes) == 0 {
  1478. return nil, false
  1479. }
  1480. return m.appendindexes, true
  1481. }
  1482. // ClearIndexes clears the value of the "indexes" field.
  1483. func (m *AgentBaseMutation) ClearIndexes() {
  1484. m.indexes = nil
  1485. m.appendindexes = nil
  1486. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1487. }
  1488. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1489. func (m *AgentBaseMutation) IndexesCleared() bool {
  1490. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1491. return ok
  1492. }
  1493. // ResetIndexes resets all changes to the "indexes" field.
  1494. func (m *AgentBaseMutation) ResetIndexes() {
  1495. m.indexes = nil
  1496. m.appendindexes = nil
  1497. delete(m.clearedFields, agentbase.FieldIndexes)
  1498. }
  1499. // SetDatasetID sets the "dataset_id" field.
  1500. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1501. m.dataset_id = &s
  1502. }
  1503. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1504. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1505. v := m.dataset_id
  1506. if v == nil {
  1507. return
  1508. }
  1509. return *v, true
  1510. }
  1511. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1512. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1514. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1515. if !m.op.Is(OpUpdateOne) {
  1516. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1517. }
  1518. if m.id == nil || m.oldValue == nil {
  1519. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1520. }
  1521. oldValue, err := m.oldValue(ctx)
  1522. if err != nil {
  1523. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1524. }
  1525. return oldValue.DatasetID, nil
  1526. }
  1527. // ClearDatasetID clears the value of the "dataset_id" field.
  1528. func (m *AgentBaseMutation) ClearDatasetID() {
  1529. m.dataset_id = nil
  1530. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1531. }
  1532. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1533. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1534. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1535. return ok
  1536. }
  1537. // ResetDatasetID resets all changes to the "dataset_id" field.
  1538. func (m *AgentBaseMutation) ResetDatasetID() {
  1539. m.dataset_id = nil
  1540. delete(m.clearedFields, agentbase.FieldDatasetID)
  1541. }
  1542. // SetCollectionID sets the "collection_id" field.
  1543. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1544. m.collection_id = &s
  1545. }
  1546. // CollectionID returns the value of the "collection_id" field in the mutation.
  1547. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1548. v := m.collection_id
  1549. if v == nil {
  1550. return
  1551. }
  1552. return *v, true
  1553. }
  1554. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1555. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1557. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1558. if !m.op.Is(OpUpdateOne) {
  1559. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1560. }
  1561. if m.id == nil || m.oldValue == nil {
  1562. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1563. }
  1564. oldValue, err := m.oldValue(ctx)
  1565. if err != nil {
  1566. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1567. }
  1568. return oldValue.CollectionID, nil
  1569. }
  1570. // ClearCollectionID clears the value of the "collection_id" field.
  1571. func (m *AgentBaseMutation) ClearCollectionID() {
  1572. m.collection_id = nil
  1573. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1574. }
  1575. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1576. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1577. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1578. return ok
  1579. }
  1580. // ResetCollectionID resets all changes to the "collection_id" field.
  1581. func (m *AgentBaseMutation) ResetCollectionID() {
  1582. m.collection_id = nil
  1583. delete(m.clearedFields, agentbase.FieldCollectionID)
  1584. }
  1585. // SetSourceName sets the "source_name" field.
  1586. func (m *AgentBaseMutation) SetSourceName(s string) {
  1587. m.source_name = &s
  1588. }
  1589. // SourceName returns the value of the "source_name" field in the mutation.
  1590. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1591. v := m.source_name
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1610. }
  1611. return oldValue.SourceName, nil
  1612. }
  1613. // ClearSourceName clears the value of the "source_name" field.
  1614. func (m *AgentBaseMutation) ClearSourceName() {
  1615. m.source_name = nil
  1616. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1617. }
  1618. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1621. return ok
  1622. }
  1623. // ResetSourceName resets all changes to the "source_name" field.
  1624. func (m *AgentBaseMutation) ResetSourceName() {
  1625. m.source_name = nil
  1626. delete(m.clearedFields, agentbase.FieldSourceName)
  1627. }
  1628. // SetCanWrite sets the "can_write" field.
  1629. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1630. m.can_write = &b
  1631. m.appendcan_write = nil
  1632. }
  1633. // CanWrite returns the value of the "can_write" field in the mutation.
  1634. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1635. v := m.can_write
  1636. if v == nil {
  1637. return
  1638. }
  1639. return *v, true
  1640. }
  1641. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1642. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1644. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1645. if !m.op.Is(OpUpdateOne) {
  1646. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1647. }
  1648. if m.id == nil || m.oldValue == nil {
  1649. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1650. }
  1651. oldValue, err := m.oldValue(ctx)
  1652. if err != nil {
  1653. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1654. }
  1655. return oldValue.CanWrite, nil
  1656. }
  1657. // AppendCanWrite adds b to the "can_write" field.
  1658. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1659. m.appendcan_write = append(m.appendcan_write, b...)
  1660. }
  1661. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1662. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1663. if len(m.appendcan_write) == 0 {
  1664. return nil, false
  1665. }
  1666. return m.appendcan_write, true
  1667. }
  1668. // ClearCanWrite clears the value of the "can_write" field.
  1669. func (m *AgentBaseMutation) ClearCanWrite() {
  1670. m.can_write = nil
  1671. m.appendcan_write = nil
  1672. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1673. }
  1674. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1675. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1676. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1677. return ok
  1678. }
  1679. // ResetCanWrite resets all changes to the "can_write" field.
  1680. func (m *AgentBaseMutation) ResetCanWrite() {
  1681. m.can_write = nil
  1682. m.appendcan_write = nil
  1683. delete(m.clearedFields, agentbase.FieldCanWrite)
  1684. }
  1685. // SetIsOwner sets the "is_owner" field.
  1686. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1687. m.is_owner = &b
  1688. m.appendis_owner = nil
  1689. }
  1690. // IsOwner returns the value of the "is_owner" field in the mutation.
  1691. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1692. v := m.is_owner
  1693. if v == nil {
  1694. return
  1695. }
  1696. return *v, true
  1697. }
  1698. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1699. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1701. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1702. if !m.op.Is(OpUpdateOne) {
  1703. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1704. }
  1705. if m.id == nil || m.oldValue == nil {
  1706. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1707. }
  1708. oldValue, err := m.oldValue(ctx)
  1709. if err != nil {
  1710. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1711. }
  1712. return oldValue.IsOwner, nil
  1713. }
  1714. // AppendIsOwner adds b to the "is_owner" field.
  1715. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1716. m.appendis_owner = append(m.appendis_owner, b...)
  1717. }
  1718. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1719. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1720. if len(m.appendis_owner) == 0 {
  1721. return nil, false
  1722. }
  1723. return m.appendis_owner, true
  1724. }
  1725. // ClearIsOwner clears the value of the "is_owner" field.
  1726. func (m *AgentBaseMutation) ClearIsOwner() {
  1727. m.is_owner = nil
  1728. m.appendis_owner = nil
  1729. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1730. }
  1731. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1732. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1733. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1734. return ok
  1735. }
  1736. // ResetIsOwner resets all changes to the "is_owner" field.
  1737. func (m *AgentBaseMutation) ResetIsOwner() {
  1738. m.is_owner = nil
  1739. m.appendis_owner = nil
  1740. delete(m.clearedFields, agentbase.FieldIsOwner)
  1741. }
  1742. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1743. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1744. if m.wx_agent == nil {
  1745. m.wx_agent = make(map[uint64]struct{})
  1746. }
  1747. for i := range ids {
  1748. m.wx_agent[ids[i]] = struct{}{}
  1749. }
  1750. }
  1751. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1752. func (m *AgentBaseMutation) ClearWxAgent() {
  1753. m.clearedwx_agent = true
  1754. }
  1755. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1756. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1757. return m.clearedwx_agent
  1758. }
  1759. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1760. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1761. if m.removedwx_agent == nil {
  1762. m.removedwx_agent = make(map[uint64]struct{})
  1763. }
  1764. for i := range ids {
  1765. delete(m.wx_agent, ids[i])
  1766. m.removedwx_agent[ids[i]] = struct{}{}
  1767. }
  1768. }
  1769. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1770. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1771. for id := range m.removedwx_agent {
  1772. ids = append(ids, id)
  1773. }
  1774. return
  1775. }
  1776. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1777. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1778. for id := range m.wx_agent {
  1779. ids = append(ids, id)
  1780. }
  1781. return
  1782. }
  1783. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1784. func (m *AgentBaseMutation) ResetWxAgent() {
  1785. m.wx_agent = nil
  1786. m.clearedwx_agent = false
  1787. m.removedwx_agent = nil
  1788. }
  1789. // Where appends a list predicates to the AgentBaseMutation builder.
  1790. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1791. m.predicates = append(m.predicates, ps...)
  1792. }
  1793. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1794. // users can use type-assertion to append predicates that do not depend on any generated package.
  1795. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1796. p := make([]predicate.AgentBase, len(ps))
  1797. for i := range ps {
  1798. p[i] = ps[i]
  1799. }
  1800. m.Where(p...)
  1801. }
  1802. // Op returns the operation name.
  1803. func (m *AgentBaseMutation) Op() Op {
  1804. return m.op
  1805. }
  1806. // SetOp allows setting the mutation operation.
  1807. func (m *AgentBaseMutation) SetOp(op Op) {
  1808. m.op = op
  1809. }
  1810. // Type returns the node type of this mutation (AgentBase).
  1811. func (m *AgentBaseMutation) Type() string {
  1812. return m.typ
  1813. }
  1814. // Fields returns all fields that were changed during this mutation. Note that in
  1815. // order to get all numeric fields that were incremented/decremented, call
  1816. // AddedFields().
  1817. func (m *AgentBaseMutation) Fields() []string {
  1818. fields := make([]string, 0, 9)
  1819. if m.q != nil {
  1820. fields = append(fields, agentbase.FieldQ)
  1821. }
  1822. if m.a != nil {
  1823. fields = append(fields, agentbase.FieldA)
  1824. }
  1825. if m.chunk_index != nil {
  1826. fields = append(fields, agentbase.FieldChunkIndex)
  1827. }
  1828. if m.indexes != nil {
  1829. fields = append(fields, agentbase.FieldIndexes)
  1830. }
  1831. if m.dataset_id != nil {
  1832. fields = append(fields, agentbase.FieldDatasetID)
  1833. }
  1834. if m.collection_id != nil {
  1835. fields = append(fields, agentbase.FieldCollectionID)
  1836. }
  1837. if m.source_name != nil {
  1838. fields = append(fields, agentbase.FieldSourceName)
  1839. }
  1840. if m.can_write != nil {
  1841. fields = append(fields, agentbase.FieldCanWrite)
  1842. }
  1843. if m.is_owner != nil {
  1844. fields = append(fields, agentbase.FieldIsOwner)
  1845. }
  1846. return fields
  1847. }
  1848. // Field returns the value of a field with the given name. The second boolean
  1849. // return value indicates that this field was not set, or was not defined in the
  1850. // schema.
  1851. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1852. switch name {
  1853. case agentbase.FieldQ:
  1854. return m.Q()
  1855. case agentbase.FieldA:
  1856. return m.A()
  1857. case agentbase.FieldChunkIndex:
  1858. return m.ChunkIndex()
  1859. case agentbase.FieldIndexes:
  1860. return m.Indexes()
  1861. case agentbase.FieldDatasetID:
  1862. return m.DatasetID()
  1863. case agentbase.FieldCollectionID:
  1864. return m.CollectionID()
  1865. case agentbase.FieldSourceName:
  1866. return m.SourceName()
  1867. case agentbase.FieldCanWrite:
  1868. return m.CanWrite()
  1869. case agentbase.FieldIsOwner:
  1870. return m.IsOwner()
  1871. }
  1872. return nil, false
  1873. }
  1874. // OldField returns the old value of the field from the database. An error is
  1875. // returned if the mutation operation is not UpdateOne, or the query to the
  1876. // database failed.
  1877. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1878. switch name {
  1879. case agentbase.FieldQ:
  1880. return m.OldQ(ctx)
  1881. case agentbase.FieldA:
  1882. return m.OldA(ctx)
  1883. case agentbase.FieldChunkIndex:
  1884. return m.OldChunkIndex(ctx)
  1885. case agentbase.FieldIndexes:
  1886. return m.OldIndexes(ctx)
  1887. case agentbase.FieldDatasetID:
  1888. return m.OldDatasetID(ctx)
  1889. case agentbase.FieldCollectionID:
  1890. return m.OldCollectionID(ctx)
  1891. case agentbase.FieldSourceName:
  1892. return m.OldSourceName(ctx)
  1893. case agentbase.FieldCanWrite:
  1894. return m.OldCanWrite(ctx)
  1895. case agentbase.FieldIsOwner:
  1896. return m.OldIsOwner(ctx)
  1897. }
  1898. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1899. }
  1900. // SetField sets the value of a field with the given name. It returns an error if
  1901. // the field is not defined in the schema, or if the type mismatched the field
  1902. // type.
  1903. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1904. switch name {
  1905. case agentbase.FieldQ:
  1906. v, ok := value.(string)
  1907. if !ok {
  1908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1909. }
  1910. m.SetQ(v)
  1911. return nil
  1912. case agentbase.FieldA:
  1913. v, ok := value.(string)
  1914. if !ok {
  1915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1916. }
  1917. m.SetA(v)
  1918. return nil
  1919. case agentbase.FieldChunkIndex:
  1920. v, ok := value.(uint64)
  1921. if !ok {
  1922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1923. }
  1924. m.SetChunkIndex(v)
  1925. return nil
  1926. case agentbase.FieldIndexes:
  1927. v, ok := value.([]string)
  1928. if !ok {
  1929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1930. }
  1931. m.SetIndexes(v)
  1932. return nil
  1933. case agentbase.FieldDatasetID:
  1934. v, ok := value.(string)
  1935. if !ok {
  1936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1937. }
  1938. m.SetDatasetID(v)
  1939. return nil
  1940. case agentbase.FieldCollectionID:
  1941. v, ok := value.(string)
  1942. if !ok {
  1943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1944. }
  1945. m.SetCollectionID(v)
  1946. return nil
  1947. case agentbase.FieldSourceName:
  1948. v, ok := value.(string)
  1949. if !ok {
  1950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1951. }
  1952. m.SetSourceName(v)
  1953. return nil
  1954. case agentbase.FieldCanWrite:
  1955. v, ok := value.([]bool)
  1956. if !ok {
  1957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1958. }
  1959. m.SetCanWrite(v)
  1960. return nil
  1961. case agentbase.FieldIsOwner:
  1962. v, ok := value.([]bool)
  1963. if !ok {
  1964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1965. }
  1966. m.SetIsOwner(v)
  1967. return nil
  1968. }
  1969. return fmt.Errorf("unknown AgentBase field %s", name)
  1970. }
  1971. // AddedFields returns all numeric fields that were incremented/decremented during
  1972. // this mutation.
  1973. func (m *AgentBaseMutation) AddedFields() []string {
  1974. var fields []string
  1975. if m.addchunk_index != nil {
  1976. fields = append(fields, agentbase.FieldChunkIndex)
  1977. }
  1978. return fields
  1979. }
  1980. // AddedField returns the numeric value that was incremented/decremented on a field
  1981. // with the given name. The second boolean return value indicates that this field
  1982. // was not set, or was not defined in the schema.
  1983. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1984. switch name {
  1985. case agentbase.FieldChunkIndex:
  1986. return m.AddedChunkIndex()
  1987. }
  1988. return nil, false
  1989. }
  1990. // AddField adds the value to the field with the given name. It returns an error if
  1991. // the field is not defined in the schema, or if the type mismatched the field
  1992. // type.
  1993. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1994. switch name {
  1995. case agentbase.FieldChunkIndex:
  1996. v, ok := value.(int64)
  1997. if !ok {
  1998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1999. }
  2000. m.AddChunkIndex(v)
  2001. return nil
  2002. }
  2003. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2004. }
  2005. // ClearedFields returns all nullable fields that were cleared during this
  2006. // mutation.
  2007. func (m *AgentBaseMutation) ClearedFields() []string {
  2008. var fields []string
  2009. if m.FieldCleared(agentbase.FieldQ) {
  2010. fields = append(fields, agentbase.FieldQ)
  2011. }
  2012. if m.FieldCleared(agentbase.FieldA) {
  2013. fields = append(fields, agentbase.FieldA)
  2014. }
  2015. if m.FieldCleared(agentbase.FieldIndexes) {
  2016. fields = append(fields, agentbase.FieldIndexes)
  2017. }
  2018. if m.FieldCleared(agentbase.FieldDatasetID) {
  2019. fields = append(fields, agentbase.FieldDatasetID)
  2020. }
  2021. if m.FieldCleared(agentbase.FieldCollectionID) {
  2022. fields = append(fields, agentbase.FieldCollectionID)
  2023. }
  2024. if m.FieldCleared(agentbase.FieldSourceName) {
  2025. fields = append(fields, agentbase.FieldSourceName)
  2026. }
  2027. if m.FieldCleared(agentbase.FieldCanWrite) {
  2028. fields = append(fields, agentbase.FieldCanWrite)
  2029. }
  2030. if m.FieldCleared(agentbase.FieldIsOwner) {
  2031. fields = append(fields, agentbase.FieldIsOwner)
  2032. }
  2033. return fields
  2034. }
  2035. // FieldCleared returns a boolean indicating if a field with the given name was
  2036. // cleared in this mutation.
  2037. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2038. _, ok := m.clearedFields[name]
  2039. return ok
  2040. }
  2041. // ClearField clears the value of the field with the given name. It returns an
  2042. // error if the field is not defined in the schema.
  2043. func (m *AgentBaseMutation) ClearField(name string) error {
  2044. switch name {
  2045. case agentbase.FieldQ:
  2046. m.ClearQ()
  2047. return nil
  2048. case agentbase.FieldA:
  2049. m.ClearA()
  2050. return nil
  2051. case agentbase.FieldIndexes:
  2052. m.ClearIndexes()
  2053. return nil
  2054. case agentbase.FieldDatasetID:
  2055. m.ClearDatasetID()
  2056. return nil
  2057. case agentbase.FieldCollectionID:
  2058. m.ClearCollectionID()
  2059. return nil
  2060. case agentbase.FieldSourceName:
  2061. m.ClearSourceName()
  2062. return nil
  2063. case agentbase.FieldCanWrite:
  2064. m.ClearCanWrite()
  2065. return nil
  2066. case agentbase.FieldIsOwner:
  2067. m.ClearIsOwner()
  2068. return nil
  2069. }
  2070. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2071. }
  2072. // ResetField resets all changes in the mutation for the field with the given name.
  2073. // It returns an error if the field is not defined in the schema.
  2074. func (m *AgentBaseMutation) ResetField(name string) error {
  2075. switch name {
  2076. case agentbase.FieldQ:
  2077. m.ResetQ()
  2078. return nil
  2079. case agentbase.FieldA:
  2080. m.ResetA()
  2081. return nil
  2082. case agentbase.FieldChunkIndex:
  2083. m.ResetChunkIndex()
  2084. return nil
  2085. case agentbase.FieldIndexes:
  2086. m.ResetIndexes()
  2087. return nil
  2088. case agentbase.FieldDatasetID:
  2089. m.ResetDatasetID()
  2090. return nil
  2091. case agentbase.FieldCollectionID:
  2092. m.ResetCollectionID()
  2093. return nil
  2094. case agentbase.FieldSourceName:
  2095. m.ResetSourceName()
  2096. return nil
  2097. case agentbase.FieldCanWrite:
  2098. m.ResetCanWrite()
  2099. return nil
  2100. case agentbase.FieldIsOwner:
  2101. m.ResetIsOwner()
  2102. return nil
  2103. }
  2104. return fmt.Errorf("unknown AgentBase field %s", name)
  2105. }
  2106. // AddedEdges returns all edge names that were set/added in this mutation.
  2107. func (m *AgentBaseMutation) AddedEdges() []string {
  2108. edges := make([]string, 0, 1)
  2109. if m.wx_agent != nil {
  2110. edges = append(edges, agentbase.EdgeWxAgent)
  2111. }
  2112. return edges
  2113. }
  2114. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2115. // name in this mutation.
  2116. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2117. switch name {
  2118. case agentbase.EdgeWxAgent:
  2119. ids := make([]ent.Value, 0, len(m.wx_agent))
  2120. for id := range m.wx_agent {
  2121. ids = append(ids, id)
  2122. }
  2123. return ids
  2124. }
  2125. return nil
  2126. }
  2127. // RemovedEdges returns all edge names that were removed in this mutation.
  2128. func (m *AgentBaseMutation) RemovedEdges() []string {
  2129. edges := make([]string, 0, 1)
  2130. if m.removedwx_agent != nil {
  2131. edges = append(edges, agentbase.EdgeWxAgent)
  2132. }
  2133. return edges
  2134. }
  2135. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2136. // the given name in this mutation.
  2137. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2138. switch name {
  2139. case agentbase.EdgeWxAgent:
  2140. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2141. for id := range m.removedwx_agent {
  2142. ids = append(ids, id)
  2143. }
  2144. return ids
  2145. }
  2146. return nil
  2147. }
  2148. // ClearedEdges returns all edge names that were cleared in this mutation.
  2149. func (m *AgentBaseMutation) ClearedEdges() []string {
  2150. edges := make([]string, 0, 1)
  2151. if m.clearedwx_agent {
  2152. edges = append(edges, agentbase.EdgeWxAgent)
  2153. }
  2154. return edges
  2155. }
  2156. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2157. // was cleared in this mutation.
  2158. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2159. switch name {
  2160. case agentbase.EdgeWxAgent:
  2161. return m.clearedwx_agent
  2162. }
  2163. return false
  2164. }
  2165. // ClearEdge clears the value of the edge with the given name. It returns an error
  2166. // if that edge is not defined in the schema.
  2167. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2168. switch name {
  2169. }
  2170. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2171. }
  2172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2173. // It returns an error if the edge is not defined in the schema.
  2174. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2175. switch name {
  2176. case agentbase.EdgeWxAgent:
  2177. m.ResetWxAgent()
  2178. return nil
  2179. }
  2180. return fmt.Errorf("unknown AgentBase edge %s", name)
  2181. }
  2182. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2183. type AliyunAvatarMutation struct {
  2184. config
  2185. op Op
  2186. typ string
  2187. id *uint64
  2188. created_at *time.Time
  2189. updated_at *time.Time
  2190. deleted_at *time.Time
  2191. user_id *uint64
  2192. adduser_id *int64
  2193. biz_id *string
  2194. access_key_id *string
  2195. access_key_secret *string
  2196. app_id *string
  2197. tenant_id *uint64
  2198. addtenant_id *int64
  2199. response *string
  2200. token *string
  2201. session_id *string
  2202. clearedFields map[string]struct{}
  2203. done bool
  2204. oldValue func(context.Context) (*AliyunAvatar, error)
  2205. predicates []predicate.AliyunAvatar
  2206. }
  2207. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2208. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2209. type aliyunavatarOption func(*AliyunAvatarMutation)
  2210. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2211. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2212. m := &AliyunAvatarMutation{
  2213. config: c,
  2214. op: op,
  2215. typ: TypeAliyunAvatar,
  2216. clearedFields: make(map[string]struct{}),
  2217. }
  2218. for _, opt := range opts {
  2219. opt(m)
  2220. }
  2221. return m
  2222. }
  2223. // withAliyunAvatarID sets the ID field of the mutation.
  2224. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2225. return func(m *AliyunAvatarMutation) {
  2226. var (
  2227. err error
  2228. once sync.Once
  2229. value *AliyunAvatar
  2230. )
  2231. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2232. once.Do(func() {
  2233. if m.done {
  2234. err = errors.New("querying old values post mutation is not allowed")
  2235. } else {
  2236. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2237. }
  2238. })
  2239. return value, err
  2240. }
  2241. m.id = &id
  2242. }
  2243. }
  2244. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2245. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2246. return func(m *AliyunAvatarMutation) {
  2247. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2248. return node, nil
  2249. }
  2250. m.id = &node.ID
  2251. }
  2252. }
  2253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2254. // executed in a transaction (ent.Tx), a transactional client is returned.
  2255. func (m AliyunAvatarMutation) Client() *Client {
  2256. client := &Client{config: m.config}
  2257. client.init()
  2258. return client
  2259. }
  2260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2261. // it returns an error otherwise.
  2262. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2263. if _, ok := m.driver.(*txDriver); !ok {
  2264. return nil, errors.New("ent: mutation is not running in a transaction")
  2265. }
  2266. tx := &Tx{config: m.config}
  2267. tx.init()
  2268. return tx, nil
  2269. }
  2270. // SetID sets the value of the id field. Note that this
  2271. // operation is only accepted on creation of AliyunAvatar entities.
  2272. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2273. m.id = &id
  2274. }
  2275. // ID returns the ID value in the mutation. Note that the ID is only available
  2276. // if it was provided to the builder or after it was returned from the database.
  2277. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2278. if m.id == nil {
  2279. return
  2280. }
  2281. return *m.id, true
  2282. }
  2283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2284. // That means, if the mutation is applied within a transaction with an isolation level such
  2285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2286. // or updated by the mutation.
  2287. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2288. switch {
  2289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2290. id, exists := m.ID()
  2291. if exists {
  2292. return []uint64{id}, nil
  2293. }
  2294. fallthrough
  2295. case m.op.Is(OpUpdate | OpDelete):
  2296. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2297. default:
  2298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2299. }
  2300. }
  2301. // SetCreatedAt sets the "created_at" field.
  2302. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2303. m.created_at = &t
  2304. }
  2305. // CreatedAt returns the value of the "created_at" field in the mutation.
  2306. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2307. v := m.created_at
  2308. if v == nil {
  2309. return
  2310. }
  2311. return *v, true
  2312. }
  2313. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2314. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2316. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2317. if !m.op.Is(OpUpdateOne) {
  2318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2319. }
  2320. if m.id == nil || m.oldValue == nil {
  2321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2322. }
  2323. oldValue, err := m.oldValue(ctx)
  2324. if err != nil {
  2325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2326. }
  2327. return oldValue.CreatedAt, nil
  2328. }
  2329. // ResetCreatedAt resets all changes to the "created_at" field.
  2330. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2331. m.created_at = nil
  2332. }
  2333. // SetUpdatedAt sets the "updated_at" field.
  2334. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2335. m.updated_at = &t
  2336. }
  2337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2338. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2339. v := m.updated_at
  2340. if v == nil {
  2341. return
  2342. }
  2343. return *v, true
  2344. }
  2345. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2346. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2348. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2349. if !m.op.Is(OpUpdateOne) {
  2350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2351. }
  2352. if m.id == nil || m.oldValue == nil {
  2353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2354. }
  2355. oldValue, err := m.oldValue(ctx)
  2356. if err != nil {
  2357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2358. }
  2359. return oldValue.UpdatedAt, nil
  2360. }
  2361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2362. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2363. m.updated_at = nil
  2364. }
  2365. // SetDeletedAt sets the "deleted_at" field.
  2366. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2367. m.deleted_at = &t
  2368. }
  2369. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2370. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2371. v := m.deleted_at
  2372. if v == nil {
  2373. return
  2374. }
  2375. return *v, true
  2376. }
  2377. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2378. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2380. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2381. if !m.op.Is(OpUpdateOne) {
  2382. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2383. }
  2384. if m.id == nil || m.oldValue == nil {
  2385. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2386. }
  2387. oldValue, err := m.oldValue(ctx)
  2388. if err != nil {
  2389. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2390. }
  2391. return oldValue.DeletedAt, nil
  2392. }
  2393. // ClearDeletedAt clears the value of the "deleted_at" field.
  2394. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2395. m.deleted_at = nil
  2396. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2397. }
  2398. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2399. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2400. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2401. return ok
  2402. }
  2403. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2404. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2405. m.deleted_at = nil
  2406. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2407. }
  2408. // SetUserID sets the "user_id" field.
  2409. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2410. m.user_id = &u
  2411. m.adduser_id = nil
  2412. }
  2413. // UserID returns the value of the "user_id" field in the mutation.
  2414. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2415. v := m.user_id
  2416. if v == nil {
  2417. return
  2418. }
  2419. return *v, true
  2420. }
  2421. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2422. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2424. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2425. if !m.op.Is(OpUpdateOne) {
  2426. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2427. }
  2428. if m.id == nil || m.oldValue == nil {
  2429. return v, errors.New("OldUserID requires an ID field in the mutation")
  2430. }
  2431. oldValue, err := m.oldValue(ctx)
  2432. if err != nil {
  2433. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2434. }
  2435. return oldValue.UserID, nil
  2436. }
  2437. // AddUserID adds u to the "user_id" field.
  2438. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2439. if m.adduser_id != nil {
  2440. *m.adduser_id += u
  2441. } else {
  2442. m.adduser_id = &u
  2443. }
  2444. }
  2445. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2446. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2447. v := m.adduser_id
  2448. if v == nil {
  2449. return
  2450. }
  2451. return *v, true
  2452. }
  2453. // ResetUserID resets all changes to the "user_id" field.
  2454. func (m *AliyunAvatarMutation) ResetUserID() {
  2455. m.user_id = nil
  2456. m.adduser_id = nil
  2457. }
  2458. // SetBizID sets the "biz_id" field.
  2459. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2460. m.biz_id = &s
  2461. }
  2462. // BizID returns the value of the "biz_id" field in the mutation.
  2463. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2464. v := m.biz_id
  2465. if v == nil {
  2466. return
  2467. }
  2468. return *v, true
  2469. }
  2470. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2471. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2473. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2474. if !m.op.Is(OpUpdateOne) {
  2475. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2476. }
  2477. if m.id == nil || m.oldValue == nil {
  2478. return v, errors.New("OldBizID requires an ID field in the mutation")
  2479. }
  2480. oldValue, err := m.oldValue(ctx)
  2481. if err != nil {
  2482. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2483. }
  2484. return oldValue.BizID, nil
  2485. }
  2486. // ResetBizID resets all changes to the "biz_id" field.
  2487. func (m *AliyunAvatarMutation) ResetBizID() {
  2488. m.biz_id = nil
  2489. }
  2490. // SetAccessKeyID sets the "access_key_id" field.
  2491. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2492. m.access_key_id = &s
  2493. }
  2494. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2495. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2496. v := m.access_key_id
  2497. if v == nil {
  2498. return
  2499. }
  2500. return *v, true
  2501. }
  2502. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2503. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2505. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2506. if !m.op.Is(OpUpdateOne) {
  2507. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2508. }
  2509. if m.id == nil || m.oldValue == nil {
  2510. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2511. }
  2512. oldValue, err := m.oldValue(ctx)
  2513. if err != nil {
  2514. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2515. }
  2516. return oldValue.AccessKeyID, nil
  2517. }
  2518. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2519. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2520. m.access_key_id = nil
  2521. }
  2522. // SetAccessKeySecret sets the "access_key_secret" field.
  2523. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2524. m.access_key_secret = &s
  2525. }
  2526. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2527. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2528. v := m.access_key_secret
  2529. if v == nil {
  2530. return
  2531. }
  2532. return *v, true
  2533. }
  2534. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2535. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2537. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2538. if !m.op.Is(OpUpdateOne) {
  2539. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2540. }
  2541. if m.id == nil || m.oldValue == nil {
  2542. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2543. }
  2544. oldValue, err := m.oldValue(ctx)
  2545. if err != nil {
  2546. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2547. }
  2548. return oldValue.AccessKeySecret, nil
  2549. }
  2550. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2551. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2552. m.access_key_secret = nil
  2553. }
  2554. // SetAppID sets the "app_id" field.
  2555. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2556. m.app_id = &s
  2557. }
  2558. // AppID returns the value of the "app_id" field in the mutation.
  2559. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2560. v := m.app_id
  2561. if v == nil {
  2562. return
  2563. }
  2564. return *v, true
  2565. }
  2566. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2567. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2569. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2570. if !m.op.Is(OpUpdateOne) {
  2571. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2572. }
  2573. if m.id == nil || m.oldValue == nil {
  2574. return v, errors.New("OldAppID requires an ID field in the mutation")
  2575. }
  2576. oldValue, err := m.oldValue(ctx)
  2577. if err != nil {
  2578. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2579. }
  2580. return oldValue.AppID, nil
  2581. }
  2582. // ClearAppID clears the value of the "app_id" field.
  2583. func (m *AliyunAvatarMutation) ClearAppID() {
  2584. m.app_id = nil
  2585. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2586. }
  2587. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2588. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2589. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2590. return ok
  2591. }
  2592. // ResetAppID resets all changes to the "app_id" field.
  2593. func (m *AliyunAvatarMutation) ResetAppID() {
  2594. m.app_id = nil
  2595. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2596. }
  2597. // SetTenantID sets the "tenant_id" field.
  2598. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2599. m.tenant_id = &u
  2600. m.addtenant_id = nil
  2601. }
  2602. // TenantID returns the value of the "tenant_id" field in the mutation.
  2603. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2604. v := m.tenant_id
  2605. if v == nil {
  2606. return
  2607. }
  2608. return *v, true
  2609. }
  2610. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2611. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2613. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2614. if !m.op.Is(OpUpdateOne) {
  2615. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2616. }
  2617. if m.id == nil || m.oldValue == nil {
  2618. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2619. }
  2620. oldValue, err := m.oldValue(ctx)
  2621. if err != nil {
  2622. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2623. }
  2624. return oldValue.TenantID, nil
  2625. }
  2626. // AddTenantID adds u to the "tenant_id" field.
  2627. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2628. if m.addtenant_id != nil {
  2629. *m.addtenant_id += u
  2630. } else {
  2631. m.addtenant_id = &u
  2632. }
  2633. }
  2634. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2635. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2636. v := m.addtenant_id
  2637. if v == nil {
  2638. return
  2639. }
  2640. return *v, true
  2641. }
  2642. // ResetTenantID resets all changes to the "tenant_id" field.
  2643. func (m *AliyunAvatarMutation) ResetTenantID() {
  2644. m.tenant_id = nil
  2645. m.addtenant_id = nil
  2646. }
  2647. // SetResponse sets the "response" field.
  2648. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2649. m.response = &s
  2650. }
  2651. // Response returns the value of the "response" field in the mutation.
  2652. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2653. v := m.response
  2654. if v == nil {
  2655. return
  2656. }
  2657. return *v, true
  2658. }
  2659. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2660. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2662. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2663. if !m.op.Is(OpUpdateOne) {
  2664. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2665. }
  2666. if m.id == nil || m.oldValue == nil {
  2667. return v, errors.New("OldResponse requires an ID field in the mutation")
  2668. }
  2669. oldValue, err := m.oldValue(ctx)
  2670. if err != nil {
  2671. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2672. }
  2673. return oldValue.Response, nil
  2674. }
  2675. // ResetResponse resets all changes to the "response" field.
  2676. func (m *AliyunAvatarMutation) ResetResponse() {
  2677. m.response = nil
  2678. }
  2679. // SetToken sets the "token" field.
  2680. func (m *AliyunAvatarMutation) SetToken(s string) {
  2681. m.token = &s
  2682. }
  2683. // Token returns the value of the "token" field in the mutation.
  2684. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2685. v := m.token
  2686. if v == nil {
  2687. return
  2688. }
  2689. return *v, true
  2690. }
  2691. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2692. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2694. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2695. if !m.op.Is(OpUpdateOne) {
  2696. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2697. }
  2698. if m.id == nil || m.oldValue == nil {
  2699. return v, errors.New("OldToken requires an ID field in the mutation")
  2700. }
  2701. oldValue, err := m.oldValue(ctx)
  2702. if err != nil {
  2703. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2704. }
  2705. return oldValue.Token, nil
  2706. }
  2707. // ResetToken resets all changes to the "token" field.
  2708. func (m *AliyunAvatarMutation) ResetToken() {
  2709. m.token = nil
  2710. }
  2711. // SetSessionID sets the "session_id" field.
  2712. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2713. m.session_id = &s
  2714. }
  2715. // SessionID returns the value of the "session_id" field in the mutation.
  2716. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2717. v := m.session_id
  2718. if v == nil {
  2719. return
  2720. }
  2721. return *v, true
  2722. }
  2723. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2724. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2726. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2727. if !m.op.Is(OpUpdateOne) {
  2728. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2729. }
  2730. if m.id == nil || m.oldValue == nil {
  2731. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2732. }
  2733. oldValue, err := m.oldValue(ctx)
  2734. if err != nil {
  2735. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2736. }
  2737. return oldValue.SessionID, nil
  2738. }
  2739. // ResetSessionID resets all changes to the "session_id" field.
  2740. func (m *AliyunAvatarMutation) ResetSessionID() {
  2741. m.session_id = nil
  2742. }
  2743. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2744. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2745. m.predicates = append(m.predicates, ps...)
  2746. }
  2747. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2748. // users can use type-assertion to append predicates that do not depend on any generated package.
  2749. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2750. p := make([]predicate.AliyunAvatar, len(ps))
  2751. for i := range ps {
  2752. p[i] = ps[i]
  2753. }
  2754. m.Where(p...)
  2755. }
  2756. // Op returns the operation name.
  2757. func (m *AliyunAvatarMutation) Op() Op {
  2758. return m.op
  2759. }
  2760. // SetOp allows setting the mutation operation.
  2761. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2762. m.op = op
  2763. }
  2764. // Type returns the node type of this mutation (AliyunAvatar).
  2765. func (m *AliyunAvatarMutation) Type() string {
  2766. return m.typ
  2767. }
  2768. // Fields returns all fields that were changed during this mutation. Note that in
  2769. // order to get all numeric fields that were incremented/decremented, call
  2770. // AddedFields().
  2771. func (m *AliyunAvatarMutation) Fields() []string {
  2772. fields := make([]string, 0, 12)
  2773. if m.created_at != nil {
  2774. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2775. }
  2776. if m.updated_at != nil {
  2777. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2778. }
  2779. if m.deleted_at != nil {
  2780. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2781. }
  2782. if m.user_id != nil {
  2783. fields = append(fields, aliyunavatar.FieldUserID)
  2784. }
  2785. if m.biz_id != nil {
  2786. fields = append(fields, aliyunavatar.FieldBizID)
  2787. }
  2788. if m.access_key_id != nil {
  2789. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2790. }
  2791. if m.access_key_secret != nil {
  2792. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2793. }
  2794. if m.app_id != nil {
  2795. fields = append(fields, aliyunavatar.FieldAppID)
  2796. }
  2797. if m.tenant_id != nil {
  2798. fields = append(fields, aliyunavatar.FieldTenantID)
  2799. }
  2800. if m.response != nil {
  2801. fields = append(fields, aliyunavatar.FieldResponse)
  2802. }
  2803. if m.token != nil {
  2804. fields = append(fields, aliyunavatar.FieldToken)
  2805. }
  2806. if m.session_id != nil {
  2807. fields = append(fields, aliyunavatar.FieldSessionID)
  2808. }
  2809. return fields
  2810. }
  2811. // Field returns the value of a field with the given name. The second boolean
  2812. // return value indicates that this field was not set, or was not defined in the
  2813. // schema.
  2814. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2815. switch name {
  2816. case aliyunavatar.FieldCreatedAt:
  2817. return m.CreatedAt()
  2818. case aliyunavatar.FieldUpdatedAt:
  2819. return m.UpdatedAt()
  2820. case aliyunavatar.FieldDeletedAt:
  2821. return m.DeletedAt()
  2822. case aliyunavatar.FieldUserID:
  2823. return m.UserID()
  2824. case aliyunavatar.FieldBizID:
  2825. return m.BizID()
  2826. case aliyunavatar.FieldAccessKeyID:
  2827. return m.AccessKeyID()
  2828. case aliyunavatar.FieldAccessKeySecret:
  2829. return m.AccessKeySecret()
  2830. case aliyunavatar.FieldAppID:
  2831. return m.AppID()
  2832. case aliyunavatar.FieldTenantID:
  2833. return m.TenantID()
  2834. case aliyunavatar.FieldResponse:
  2835. return m.Response()
  2836. case aliyunavatar.FieldToken:
  2837. return m.Token()
  2838. case aliyunavatar.FieldSessionID:
  2839. return m.SessionID()
  2840. }
  2841. return nil, false
  2842. }
  2843. // OldField returns the old value of the field from the database. An error is
  2844. // returned if the mutation operation is not UpdateOne, or the query to the
  2845. // database failed.
  2846. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2847. switch name {
  2848. case aliyunavatar.FieldCreatedAt:
  2849. return m.OldCreatedAt(ctx)
  2850. case aliyunavatar.FieldUpdatedAt:
  2851. return m.OldUpdatedAt(ctx)
  2852. case aliyunavatar.FieldDeletedAt:
  2853. return m.OldDeletedAt(ctx)
  2854. case aliyunavatar.FieldUserID:
  2855. return m.OldUserID(ctx)
  2856. case aliyunavatar.FieldBizID:
  2857. return m.OldBizID(ctx)
  2858. case aliyunavatar.FieldAccessKeyID:
  2859. return m.OldAccessKeyID(ctx)
  2860. case aliyunavatar.FieldAccessKeySecret:
  2861. return m.OldAccessKeySecret(ctx)
  2862. case aliyunavatar.FieldAppID:
  2863. return m.OldAppID(ctx)
  2864. case aliyunavatar.FieldTenantID:
  2865. return m.OldTenantID(ctx)
  2866. case aliyunavatar.FieldResponse:
  2867. return m.OldResponse(ctx)
  2868. case aliyunavatar.FieldToken:
  2869. return m.OldToken(ctx)
  2870. case aliyunavatar.FieldSessionID:
  2871. return m.OldSessionID(ctx)
  2872. }
  2873. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2874. }
  2875. // SetField sets the value of a field with the given name. It returns an error if
  2876. // the field is not defined in the schema, or if the type mismatched the field
  2877. // type.
  2878. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2879. switch name {
  2880. case aliyunavatar.FieldCreatedAt:
  2881. v, ok := value.(time.Time)
  2882. if !ok {
  2883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2884. }
  2885. m.SetCreatedAt(v)
  2886. return nil
  2887. case aliyunavatar.FieldUpdatedAt:
  2888. v, ok := value.(time.Time)
  2889. if !ok {
  2890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2891. }
  2892. m.SetUpdatedAt(v)
  2893. return nil
  2894. case aliyunavatar.FieldDeletedAt:
  2895. v, ok := value.(time.Time)
  2896. if !ok {
  2897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2898. }
  2899. m.SetDeletedAt(v)
  2900. return nil
  2901. case aliyunavatar.FieldUserID:
  2902. v, ok := value.(uint64)
  2903. if !ok {
  2904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2905. }
  2906. m.SetUserID(v)
  2907. return nil
  2908. case aliyunavatar.FieldBizID:
  2909. v, ok := value.(string)
  2910. if !ok {
  2911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2912. }
  2913. m.SetBizID(v)
  2914. return nil
  2915. case aliyunavatar.FieldAccessKeyID:
  2916. v, ok := value.(string)
  2917. if !ok {
  2918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2919. }
  2920. m.SetAccessKeyID(v)
  2921. return nil
  2922. case aliyunavatar.FieldAccessKeySecret:
  2923. v, ok := value.(string)
  2924. if !ok {
  2925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2926. }
  2927. m.SetAccessKeySecret(v)
  2928. return nil
  2929. case aliyunavatar.FieldAppID:
  2930. v, ok := value.(string)
  2931. if !ok {
  2932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2933. }
  2934. m.SetAppID(v)
  2935. return nil
  2936. case aliyunavatar.FieldTenantID:
  2937. v, ok := value.(uint64)
  2938. if !ok {
  2939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2940. }
  2941. m.SetTenantID(v)
  2942. return nil
  2943. case aliyunavatar.FieldResponse:
  2944. v, ok := value.(string)
  2945. if !ok {
  2946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2947. }
  2948. m.SetResponse(v)
  2949. return nil
  2950. case aliyunavatar.FieldToken:
  2951. v, ok := value.(string)
  2952. if !ok {
  2953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2954. }
  2955. m.SetToken(v)
  2956. return nil
  2957. case aliyunavatar.FieldSessionID:
  2958. v, ok := value.(string)
  2959. if !ok {
  2960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2961. }
  2962. m.SetSessionID(v)
  2963. return nil
  2964. }
  2965. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2966. }
  2967. // AddedFields returns all numeric fields that were incremented/decremented during
  2968. // this mutation.
  2969. func (m *AliyunAvatarMutation) AddedFields() []string {
  2970. var fields []string
  2971. if m.adduser_id != nil {
  2972. fields = append(fields, aliyunavatar.FieldUserID)
  2973. }
  2974. if m.addtenant_id != nil {
  2975. fields = append(fields, aliyunavatar.FieldTenantID)
  2976. }
  2977. return fields
  2978. }
  2979. // AddedField returns the numeric value that was incremented/decremented on a field
  2980. // with the given name. The second boolean return value indicates that this field
  2981. // was not set, or was not defined in the schema.
  2982. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2983. switch name {
  2984. case aliyunavatar.FieldUserID:
  2985. return m.AddedUserID()
  2986. case aliyunavatar.FieldTenantID:
  2987. return m.AddedTenantID()
  2988. }
  2989. return nil, false
  2990. }
  2991. // AddField adds the value to the field with the given name. It returns an error if
  2992. // the field is not defined in the schema, or if the type mismatched the field
  2993. // type.
  2994. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2995. switch name {
  2996. case aliyunavatar.FieldUserID:
  2997. v, ok := value.(int64)
  2998. if !ok {
  2999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3000. }
  3001. m.AddUserID(v)
  3002. return nil
  3003. case aliyunavatar.FieldTenantID:
  3004. v, ok := value.(int64)
  3005. if !ok {
  3006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3007. }
  3008. m.AddTenantID(v)
  3009. return nil
  3010. }
  3011. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3012. }
  3013. // ClearedFields returns all nullable fields that were cleared during this
  3014. // mutation.
  3015. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3016. var fields []string
  3017. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3018. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3019. }
  3020. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3021. fields = append(fields, aliyunavatar.FieldAppID)
  3022. }
  3023. return fields
  3024. }
  3025. // FieldCleared returns a boolean indicating if a field with the given name was
  3026. // cleared in this mutation.
  3027. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3028. _, ok := m.clearedFields[name]
  3029. return ok
  3030. }
  3031. // ClearField clears the value of the field with the given name. It returns an
  3032. // error if the field is not defined in the schema.
  3033. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3034. switch name {
  3035. case aliyunavatar.FieldDeletedAt:
  3036. m.ClearDeletedAt()
  3037. return nil
  3038. case aliyunavatar.FieldAppID:
  3039. m.ClearAppID()
  3040. return nil
  3041. }
  3042. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3043. }
  3044. // ResetField resets all changes in the mutation for the field with the given name.
  3045. // It returns an error if the field is not defined in the schema.
  3046. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3047. switch name {
  3048. case aliyunavatar.FieldCreatedAt:
  3049. m.ResetCreatedAt()
  3050. return nil
  3051. case aliyunavatar.FieldUpdatedAt:
  3052. m.ResetUpdatedAt()
  3053. return nil
  3054. case aliyunavatar.FieldDeletedAt:
  3055. m.ResetDeletedAt()
  3056. return nil
  3057. case aliyunavatar.FieldUserID:
  3058. m.ResetUserID()
  3059. return nil
  3060. case aliyunavatar.FieldBizID:
  3061. m.ResetBizID()
  3062. return nil
  3063. case aliyunavatar.FieldAccessKeyID:
  3064. m.ResetAccessKeyID()
  3065. return nil
  3066. case aliyunavatar.FieldAccessKeySecret:
  3067. m.ResetAccessKeySecret()
  3068. return nil
  3069. case aliyunavatar.FieldAppID:
  3070. m.ResetAppID()
  3071. return nil
  3072. case aliyunavatar.FieldTenantID:
  3073. m.ResetTenantID()
  3074. return nil
  3075. case aliyunavatar.FieldResponse:
  3076. m.ResetResponse()
  3077. return nil
  3078. case aliyunavatar.FieldToken:
  3079. m.ResetToken()
  3080. return nil
  3081. case aliyunavatar.FieldSessionID:
  3082. m.ResetSessionID()
  3083. return nil
  3084. }
  3085. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3086. }
  3087. // AddedEdges returns all edge names that were set/added in this mutation.
  3088. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3089. edges := make([]string, 0, 0)
  3090. return edges
  3091. }
  3092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3093. // name in this mutation.
  3094. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3095. return nil
  3096. }
  3097. // RemovedEdges returns all edge names that were removed in this mutation.
  3098. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3099. edges := make([]string, 0, 0)
  3100. return edges
  3101. }
  3102. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3103. // the given name in this mutation.
  3104. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3105. return nil
  3106. }
  3107. // ClearedEdges returns all edge names that were cleared in this mutation.
  3108. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3109. edges := make([]string, 0, 0)
  3110. return edges
  3111. }
  3112. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3113. // was cleared in this mutation.
  3114. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3115. return false
  3116. }
  3117. // ClearEdge clears the value of the edge with the given name. It returns an error
  3118. // if that edge is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3120. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3121. }
  3122. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3123. // It returns an error if the edge is not defined in the schema.
  3124. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3125. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3126. }
  3127. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3128. type AllocAgentMutation struct {
  3129. config
  3130. op Op
  3131. typ string
  3132. id *uint64
  3133. created_at *time.Time
  3134. updated_at *time.Time
  3135. deleted_at *time.Time
  3136. user_id *string
  3137. organization_id *uint64
  3138. addorganization_id *int64
  3139. agents *[]uint64
  3140. appendagents []uint64
  3141. status *int
  3142. addstatus *int
  3143. clearedFields map[string]struct{}
  3144. done bool
  3145. oldValue func(context.Context) (*AllocAgent, error)
  3146. predicates []predicate.AllocAgent
  3147. }
  3148. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3149. // allocagentOption allows management of the mutation configuration using functional options.
  3150. type allocagentOption func(*AllocAgentMutation)
  3151. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3152. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3153. m := &AllocAgentMutation{
  3154. config: c,
  3155. op: op,
  3156. typ: TypeAllocAgent,
  3157. clearedFields: make(map[string]struct{}),
  3158. }
  3159. for _, opt := range opts {
  3160. opt(m)
  3161. }
  3162. return m
  3163. }
  3164. // withAllocAgentID sets the ID field of the mutation.
  3165. func withAllocAgentID(id uint64) allocagentOption {
  3166. return func(m *AllocAgentMutation) {
  3167. var (
  3168. err error
  3169. once sync.Once
  3170. value *AllocAgent
  3171. )
  3172. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3173. once.Do(func() {
  3174. if m.done {
  3175. err = errors.New("querying old values post mutation is not allowed")
  3176. } else {
  3177. value, err = m.Client().AllocAgent.Get(ctx, id)
  3178. }
  3179. })
  3180. return value, err
  3181. }
  3182. m.id = &id
  3183. }
  3184. }
  3185. // withAllocAgent sets the old AllocAgent of the mutation.
  3186. func withAllocAgent(node *AllocAgent) allocagentOption {
  3187. return func(m *AllocAgentMutation) {
  3188. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3189. return node, nil
  3190. }
  3191. m.id = &node.ID
  3192. }
  3193. }
  3194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3195. // executed in a transaction (ent.Tx), a transactional client is returned.
  3196. func (m AllocAgentMutation) Client() *Client {
  3197. client := &Client{config: m.config}
  3198. client.init()
  3199. return client
  3200. }
  3201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3202. // it returns an error otherwise.
  3203. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3204. if _, ok := m.driver.(*txDriver); !ok {
  3205. return nil, errors.New("ent: mutation is not running in a transaction")
  3206. }
  3207. tx := &Tx{config: m.config}
  3208. tx.init()
  3209. return tx, nil
  3210. }
  3211. // SetID sets the value of the id field. Note that this
  3212. // operation is only accepted on creation of AllocAgent entities.
  3213. func (m *AllocAgentMutation) SetID(id uint64) {
  3214. m.id = &id
  3215. }
  3216. // ID returns the ID value in the mutation. Note that the ID is only available
  3217. // if it was provided to the builder or after it was returned from the database.
  3218. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3219. if m.id == nil {
  3220. return
  3221. }
  3222. return *m.id, true
  3223. }
  3224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3225. // That means, if the mutation is applied within a transaction with an isolation level such
  3226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3227. // or updated by the mutation.
  3228. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3229. switch {
  3230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3231. id, exists := m.ID()
  3232. if exists {
  3233. return []uint64{id}, nil
  3234. }
  3235. fallthrough
  3236. case m.op.Is(OpUpdate | OpDelete):
  3237. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3238. default:
  3239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3240. }
  3241. }
  3242. // SetCreatedAt sets the "created_at" field.
  3243. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3244. m.created_at = &t
  3245. }
  3246. // CreatedAt returns the value of the "created_at" field in the mutation.
  3247. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3248. v := m.created_at
  3249. if v == nil {
  3250. return
  3251. }
  3252. return *v, true
  3253. }
  3254. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3255. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3257. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3258. if !m.op.Is(OpUpdateOne) {
  3259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3260. }
  3261. if m.id == nil || m.oldValue == nil {
  3262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3263. }
  3264. oldValue, err := m.oldValue(ctx)
  3265. if err != nil {
  3266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3267. }
  3268. return oldValue.CreatedAt, nil
  3269. }
  3270. // ResetCreatedAt resets all changes to the "created_at" field.
  3271. func (m *AllocAgentMutation) ResetCreatedAt() {
  3272. m.created_at = nil
  3273. }
  3274. // SetUpdatedAt sets the "updated_at" field.
  3275. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3276. m.updated_at = &t
  3277. }
  3278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3279. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3280. v := m.updated_at
  3281. if v == nil {
  3282. return
  3283. }
  3284. return *v, true
  3285. }
  3286. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3287. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3289. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3290. if !m.op.Is(OpUpdateOne) {
  3291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3292. }
  3293. if m.id == nil || m.oldValue == nil {
  3294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3295. }
  3296. oldValue, err := m.oldValue(ctx)
  3297. if err != nil {
  3298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3299. }
  3300. return oldValue.UpdatedAt, nil
  3301. }
  3302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3303. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3304. m.updated_at = nil
  3305. }
  3306. // SetDeletedAt sets the "deleted_at" field.
  3307. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3308. m.deleted_at = &t
  3309. }
  3310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3311. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3312. v := m.deleted_at
  3313. if v == nil {
  3314. return
  3315. }
  3316. return *v, true
  3317. }
  3318. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3319. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3321. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3322. if !m.op.Is(OpUpdateOne) {
  3323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3324. }
  3325. if m.id == nil || m.oldValue == nil {
  3326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3327. }
  3328. oldValue, err := m.oldValue(ctx)
  3329. if err != nil {
  3330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3331. }
  3332. return oldValue.DeletedAt, nil
  3333. }
  3334. // ClearDeletedAt clears the value of the "deleted_at" field.
  3335. func (m *AllocAgentMutation) ClearDeletedAt() {
  3336. m.deleted_at = nil
  3337. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3338. }
  3339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3340. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3341. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3342. return ok
  3343. }
  3344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3345. func (m *AllocAgentMutation) ResetDeletedAt() {
  3346. m.deleted_at = nil
  3347. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3348. }
  3349. // SetUserID sets the "user_id" field.
  3350. func (m *AllocAgentMutation) SetUserID(s string) {
  3351. m.user_id = &s
  3352. }
  3353. // UserID returns the value of the "user_id" field in the mutation.
  3354. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3355. v := m.user_id
  3356. if v == nil {
  3357. return
  3358. }
  3359. return *v, true
  3360. }
  3361. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3362. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3364. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3365. if !m.op.Is(OpUpdateOne) {
  3366. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3367. }
  3368. if m.id == nil || m.oldValue == nil {
  3369. return v, errors.New("OldUserID requires an ID field in the mutation")
  3370. }
  3371. oldValue, err := m.oldValue(ctx)
  3372. if err != nil {
  3373. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3374. }
  3375. return oldValue.UserID, nil
  3376. }
  3377. // ClearUserID clears the value of the "user_id" field.
  3378. func (m *AllocAgentMutation) ClearUserID() {
  3379. m.user_id = nil
  3380. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3381. }
  3382. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3383. func (m *AllocAgentMutation) UserIDCleared() bool {
  3384. _, ok := m.clearedFields[allocagent.FieldUserID]
  3385. return ok
  3386. }
  3387. // ResetUserID resets all changes to the "user_id" field.
  3388. func (m *AllocAgentMutation) ResetUserID() {
  3389. m.user_id = nil
  3390. delete(m.clearedFields, allocagent.FieldUserID)
  3391. }
  3392. // SetOrganizationID sets the "organization_id" field.
  3393. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3394. m.organization_id = &u
  3395. m.addorganization_id = nil
  3396. }
  3397. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3398. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3399. v := m.organization_id
  3400. if v == nil {
  3401. return
  3402. }
  3403. return *v, true
  3404. }
  3405. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3406. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3408. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3409. if !m.op.Is(OpUpdateOne) {
  3410. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3411. }
  3412. if m.id == nil || m.oldValue == nil {
  3413. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3414. }
  3415. oldValue, err := m.oldValue(ctx)
  3416. if err != nil {
  3417. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3418. }
  3419. return oldValue.OrganizationID, nil
  3420. }
  3421. // AddOrganizationID adds u to the "organization_id" field.
  3422. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3423. if m.addorganization_id != nil {
  3424. *m.addorganization_id += u
  3425. } else {
  3426. m.addorganization_id = &u
  3427. }
  3428. }
  3429. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3430. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3431. v := m.addorganization_id
  3432. if v == nil {
  3433. return
  3434. }
  3435. return *v, true
  3436. }
  3437. // ClearOrganizationID clears the value of the "organization_id" field.
  3438. func (m *AllocAgentMutation) ClearOrganizationID() {
  3439. m.organization_id = nil
  3440. m.addorganization_id = nil
  3441. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3442. }
  3443. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3444. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3445. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3446. return ok
  3447. }
  3448. // ResetOrganizationID resets all changes to the "organization_id" field.
  3449. func (m *AllocAgentMutation) ResetOrganizationID() {
  3450. m.organization_id = nil
  3451. m.addorganization_id = nil
  3452. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3453. }
  3454. // SetAgents sets the "agents" field.
  3455. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3456. m.agents = &u
  3457. m.appendagents = nil
  3458. }
  3459. // Agents returns the value of the "agents" field in the mutation.
  3460. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3461. v := m.agents
  3462. if v == nil {
  3463. return
  3464. }
  3465. return *v, true
  3466. }
  3467. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3468. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3470. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3471. if !m.op.Is(OpUpdateOne) {
  3472. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3473. }
  3474. if m.id == nil || m.oldValue == nil {
  3475. return v, errors.New("OldAgents requires an ID field in the mutation")
  3476. }
  3477. oldValue, err := m.oldValue(ctx)
  3478. if err != nil {
  3479. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3480. }
  3481. return oldValue.Agents, nil
  3482. }
  3483. // AppendAgents adds u to the "agents" field.
  3484. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3485. m.appendagents = append(m.appendagents, u...)
  3486. }
  3487. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3488. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3489. if len(m.appendagents) == 0 {
  3490. return nil, false
  3491. }
  3492. return m.appendagents, true
  3493. }
  3494. // ResetAgents resets all changes to the "agents" field.
  3495. func (m *AllocAgentMutation) ResetAgents() {
  3496. m.agents = nil
  3497. m.appendagents = nil
  3498. }
  3499. // SetStatus sets the "status" field.
  3500. func (m *AllocAgentMutation) SetStatus(i int) {
  3501. m.status = &i
  3502. m.addstatus = nil
  3503. }
  3504. // Status returns the value of the "status" field in the mutation.
  3505. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3506. v := m.status
  3507. if v == nil {
  3508. return
  3509. }
  3510. return *v, true
  3511. }
  3512. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3513. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3515. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3516. if !m.op.Is(OpUpdateOne) {
  3517. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3518. }
  3519. if m.id == nil || m.oldValue == nil {
  3520. return v, errors.New("OldStatus requires an ID field in the mutation")
  3521. }
  3522. oldValue, err := m.oldValue(ctx)
  3523. if err != nil {
  3524. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3525. }
  3526. return oldValue.Status, nil
  3527. }
  3528. // AddStatus adds i to the "status" field.
  3529. func (m *AllocAgentMutation) AddStatus(i int) {
  3530. if m.addstatus != nil {
  3531. *m.addstatus += i
  3532. } else {
  3533. m.addstatus = &i
  3534. }
  3535. }
  3536. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3537. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3538. v := m.addstatus
  3539. if v == nil {
  3540. return
  3541. }
  3542. return *v, true
  3543. }
  3544. // ClearStatus clears the value of the "status" field.
  3545. func (m *AllocAgentMutation) ClearStatus() {
  3546. m.status = nil
  3547. m.addstatus = nil
  3548. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3549. }
  3550. // StatusCleared returns if the "status" field was cleared in this mutation.
  3551. func (m *AllocAgentMutation) StatusCleared() bool {
  3552. _, ok := m.clearedFields[allocagent.FieldStatus]
  3553. return ok
  3554. }
  3555. // ResetStatus resets all changes to the "status" field.
  3556. func (m *AllocAgentMutation) ResetStatus() {
  3557. m.status = nil
  3558. m.addstatus = nil
  3559. delete(m.clearedFields, allocagent.FieldStatus)
  3560. }
  3561. // Where appends a list predicates to the AllocAgentMutation builder.
  3562. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3563. m.predicates = append(m.predicates, ps...)
  3564. }
  3565. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3566. // users can use type-assertion to append predicates that do not depend on any generated package.
  3567. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3568. p := make([]predicate.AllocAgent, len(ps))
  3569. for i := range ps {
  3570. p[i] = ps[i]
  3571. }
  3572. m.Where(p...)
  3573. }
  3574. // Op returns the operation name.
  3575. func (m *AllocAgentMutation) Op() Op {
  3576. return m.op
  3577. }
  3578. // SetOp allows setting the mutation operation.
  3579. func (m *AllocAgentMutation) SetOp(op Op) {
  3580. m.op = op
  3581. }
  3582. // Type returns the node type of this mutation (AllocAgent).
  3583. func (m *AllocAgentMutation) Type() string {
  3584. return m.typ
  3585. }
  3586. // Fields returns all fields that were changed during this mutation. Note that in
  3587. // order to get all numeric fields that were incremented/decremented, call
  3588. // AddedFields().
  3589. func (m *AllocAgentMutation) Fields() []string {
  3590. fields := make([]string, 0, 7)
  3591. if m.created_at != nil {
  3592. fields = append(fields, allocagent.FieldCreatedAt)
  3593. }
  3594. if m.updated_at != nil {
  3595. fields = append(fields, allocagent.FieldUpdatedAt)
  3596. }
  3597. if m.deleted_at != nil {
  3598. fields = append(fields, allocagent.FieldDeletedAt)
  3599. }
  3600. if m.user_id != nil {
  3601. fields = append(fields, allocagent.FieldUserID)
  3602. }
  3603. if m.organization_id != nil {
  3604. fields = append(fields, allocagent.FieldOrganizationID)
  3605. }
  3606. if m.agents != nil {
  3607. fields = append(fields, allocagent.FieldAgents)
  3608. }
  3609. if m.status != nil {
  3610. fields = append(fields, allocagent.FieldStatus)
  3611. }
  3612. return fields
  3613. }
  3614. // Field returns the value of a field with the given name. The second boolean
  3615. // return value indicates that this field was not set, or was not defined in the
  3616. // schema.
  3617. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3618. switch name {
  3619. case allocagent.FieldCreatedAt:
  3620. return m.CreatedAt()
  3621. case allocagent.FieldUpdatedAt:
  3622. return m.UpdatedAt()
  3623. case allocagent.FieldDeletedAt:
  3624. return m.DeletedAt()
  3625. case allocagent.FieldUserID:
  3626. return m.UserID()
  3627. case allocagent.FieldOrganizationID:
  3628. return m.OrganizationID()
  3629. case allocagent.FieldAgents:
  3630. return m.Agents()
  3631. case allocagent.FieldStatus:
  3632. return m.Status()
  3633. }
  3634. return nil, false
  3635. }
  3636. // OldField returns the old value of the field from the database. An error is
  3637. // returned if the mutation operation is not UpdateOne, or the query to the
  3638. // database failed.
  3639. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3640. switch name {
  3641. case allocagent.FieldCreatedAt:
  3642. return m.OldCreatedAt(ctx)
  3643. case allocagent.FieldUpdatedAt:
  3644. return m.OldUpdatedAt(ctx)
  3645. case allocagent.FieldDeletedAt:
  3646. return m.OldDeletedAt(ctx)
  3647. case allocagent.FieldUserID:
  3648. return m.OldUserID(ctx)
  3649. case allocagent.FieldOrganizationID:
  3650. return m.OldOrganizationID(ctx)
  3651. case allocagent.FieldAgents:
  3652. return m.OldAgents(ctx)
  3653. case allocagent.FieldStatus:
  3654. return m.OldStatus(ctx)
  3655. }
  3656. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3657. }
  3658. // SetField sets the value of a field with the given name. It returns an error if
  3659. // the field is not defined in the schema, or if the type mismatched the field
  3660. // type.
  3661. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3662. switch name {
  3663. case allocagent.FieldCreatedAt:
  3664. v, ok := value.(time.Time)
  3665. if !ok {
  3666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3667. }
  3668. m.SetCreatedAt(v)
  3669. return nil
  3670. case allocagent.FieldUpdatedAt:
  3671. v, ok := value.(time.Time)
  3672. if !ok {
  3673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3674. }
  3675. m.SetUpdatedAt(v)
  3676. return nil
  3677. case allocagent.FieldDeletedAt:
  3678. v, ok := value.(time.Time)
  3679. if !ok {
  3680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3681. }
  3682. m.SetDeletedAt(v)
  3683. return nil
  3684. case allocagent.FieldUserID:
  3685. v, ok := value.(string)
  3686. if !ok {
  3687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3688. }
  3689. m.SetUserID(v)
  3690. return nil
  3691. case allocagent.FieldOrganizationID:
  3692. v, ok := value.(uint64)
  3693. if !ok {
  3694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3695. }
  3696. m.SetOrganizationID(v)
  3697. return nil
  3698. case allocagent.FieldAgents:
  3699. v, ok := value.([]uint64)
  3700. if !ok {
  3701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3702. }
  3703. m.SetAgents(v)
  3704. return nil
  3705. case allocagent.FieldStatus:
  3706. v, ok := value.(int)
  3707. if !ok {
  3708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3709. }
  3710. m.SetStatus(v)
  3711. return nil
  3712. }
  3713. return fmt.Errorf("unknown AllocAgent field %s", name)
  3714. }
  3715. // AddedFields returns all numeric fields that were incremented/decremented during
  3716. // this mutation.
  3717. func (m *AllocAgentMutation) AddedFields() []string {
  3718. var fields []string
  3719. if m.addorganization_id != nil {
  3720. fields = append(fields, allocagent.FieldOrganizationID)
  3721. }
  3722. if m.addstatus != nil {
  3723. fields = append(fields, allocagent.FieldStatus)
  3724. }
  3725. return fields
  3726. }
  3727. // AddedField returns the numeric value that was incremented/decremented on a field
  3728. // with the given name. The second boolean return value indicates that this field
  3729. // was not set, or was not defined in the schema.
  3730. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3731. switch name {
  3732. case allocagent.FieldOrganizationID:
  3733. return m.AddedOrganizationID()
  3734. case allocagent.FieldStatus:
  3735. return m.AddedStatus()
  3736. }
  3737. return nil, false
  3738. }
  3739. // AddField adds the value to the field with the given name. It returns an error if
  3740. // the field is not defined in the schema, or if the type mismatched the field
  3741. // type.
  3742. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3743. switch name {
  3744. case allocagent.FieldOrganizationID:
  3745. v, ok := value.(int64)
  3746. if !ok {
  3747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3748. }
  3749. m.AddOrganizationID(v)
  3750. return nil
  3751. case allocagent.FieldStatus:
  3752. v, ok := value.(int)
  3753. if !ok {
  3754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3755. }
  3756. m.AddStatus(v)
  3757. return nil
  3758. }
  3759. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3760. }
  3761. // ClearedFields returns all nullable fields that were cleared during this
  3762. // mutation.
  3763. func (m *AllocAgentMutation) ClearedFields() []string {
  3764. var fields []string
  3765. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3766. fields = append(fields, allocagent.FieldDeletedAt)
  3767. }
  3768. if m.FieldCleared(allocagent.FieldUserID) {
  3769. fields = append(fields, allocagent.FieldUserID)
  3770. }
  3771. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3772. fields = append(fields, allocagent.FieldOrganizationID)
  3773. }
  3774. if m.FieldCleared(allocagent.FieldStatus) {
  3775. fields = append(fields, allocagent.FieldStatus)
  3776. }
  3777. return fields
  3778. }
  3779. // FieldCleared returns a boolean indicating if a field with the given name was
  3780. // cleared in this mutation.
  3781. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3782. _, ok := m.clearedFields[name]
  3783. return ok
  3784. }
  3785. // ClearField clears the value of the field with the given name. It returns an
  3786. // error if the field is not defined in the schema.
  3787. func (m *AllocAgentMutation) ClearField(name string) error {
  3788. switch name {
  3789. case allocagent.FieldDeletedAt:
  3790. m.ClearDeletedAt()
  3791. return nil
  3792. case allocagent.FieldUserID:
  3793. m.ClearUserID()
  3794. return nil
  3795. case allocagent.FieldOrganizationID:
  3796. m.ClearOrganizationID()
  3797. return nil
  3798. case allocagent.FieldStatus:
  3799. m.ClearStatus()
  3800. return nil
  3801. }
  3802. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3803. }
  3804. // ResetField resets all changes in the mutation for the field with the given name.
  3805. // It returns an error if the field is not defined in the schema.
  3806. func (m *AllocAgentMutation) ResetField(name string) error {
  3807. switch name {
  3808. case allocagent.FieldCreatedAt:
  3809. m.ResetCreatedAt()
  3810. return nil
  3811. case allocagent.FieldUpdatedAt:
  3812. m.ResetUpdatedAt()
  3813. return nil
  3814. case allocagent.FieldDeletedAt:
  3815. m.ResetDeletedAt()
  3816. return nil
  3817. case allocagent.FieldUserID:
  3818. m.ResetUserID()
  3819. return nil
  3820. case allocagent.FieldOrganizationID:
  3821. m.ResetOrganizationID()
  3822. return nil
  3823. case allocagent.FieldAgents:
  3824. m.ResetAgents()
  3825. return nil
  3826. case allocagent.FieldStatus:
  3827. m.ResetStatus()
  3828. return nil
  3829. }
  3830. return fmt.Errorf("unknown AllocAgent field %s", name)
  3831. }
  3832. // AddedEdges returns all edge names that were set/added in this mutation.
  3833. func (m *AllocAgentMutation) AddedEdges() []string {
  3834. edges := make([]string, 0, 0)
  3835. return edges
  3836. }
  3837. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3838. // name in this mutation.
  3839. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3840. return nil
  3841. }
  3842. // RemovedEdges returns all edge names that were removed in this mutation.
  3843. func (m *AllocAgentMutation) RemovedEdges() []string {
  3844. edges := make([]string, 0, 0)
  3845. return edges
  3846. }
  3847. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3848. // the given name in this mutation.
  3849. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3850. return nil
  3851. }
  3852. // ClearedEdges returns all edge names that were cleared in this mutation.
  3853. func (m *AllocAgentMutation) ClearedEdges() []string {
  3854. edges := make([]string, 0, 0)
  3855. return edges
  3856. }
  3857. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3858. // was cleared in this mutation.
  3859. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3860. return false
  3861. }
  3862. // ClearEdge clears the value of the edge with the given name. It returns an error
  3863. // if that edge is not defined in the schema.
  3864. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3865. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3866. }
  3867. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3868. // It returns an error if the edge is not defined in the schema.
  3869. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3870. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3871. }
  3872. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3873. type BatchMsgMutation struct {
  3874. config
  3875. op Op
  3876. typ string
  3877. id *uint64
  3878. created_at *time.Time
  3879. updated_at *time.Time
  3880. deleted_at *time.Time
  3881. status *uint8
  3882. addstatus *int8
  3883. batch_no *string
  3884. task_name *string
  3885. fromwxid *string
  3886. msg *string
  3887. tag *string
  3888. tagids *string
  3889. total *int32
  3890. addtotal *int32
  3891. success *int32
  3892. addsuccess *int32
  3893. fail *int32
  3894. addfail *int32
  3895. start_time *time.Time
  3896. stop_time *time.Time
  3897. send_time *time.Time
  3898. _type *int32
  3899. add_type *int32
  3900. organization_id *uint64
  3901. addorganization_id *int64
  3902. clearedFields map[string]struct{}
  3903. done bool
  3904. oldValue func(context.Context) (*BatchMsg, error)
  3905. predicates []predicate.BatchMsg
  3906. }
  3907. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3908. // batchmsgOption allows management of the mutation configuration using functional options.
  3909. type batchmsgOption func(*BatchMsgMutation)
  3910. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3911. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3912. m := &BatchMsgMutation{
  3913. config: c,
  3914. op: op,
  3915. typ: TypeBatchMsg,
  3916. clearedFields: make(map[string]struct{}),
  3917. }
  3918. for _, opt := range opts {
  3919. opt(m)
  3920. }
  3921. return m
  3922. }
  3923. // withBatchMsgID sets the ID field of the mutation.
  3924. func withBatchMsgID(id uint64) batchmsgOption {
  3925. return func(m *BatchMsgMutation) {
  3926. var (
  3927. err error
  3928. once sync.Once
  3929. value *BatchMsg
  3930. )
  3931. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3932. once.Do(func() {
  3933. if m.done {
  3934. err = errors.New("querying old values post mutation is not allowed")
  3935. } else {
  3936. value, err = m.Client().BatchMsg.Get(ctx, id)
  3937. }
  3938. })
  3939. return value, err
  3940. }
  3941. m.id = &id
  3942. }
  3943. }
  3944. // withBatchMsg sets the old BatchMsg of the mutation.
  3945. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3946. return func(m *BatchMsgMutation) {
  3947. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3948. return node, nil
  3949. }
  3950. m.id = &node.ID
  3951. }
  3952. }
  3953. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3954. // executed in a transaction (ent.Tx), a transactional client is returned.
  3955. func (m BatchMsgMutation) Client() *Client {
  3956. client := &Client{config: m.config}
  3957. client.init()
  3958. return client
  3959. }
  3960. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3961. // it returns an error otherwise.
  3962. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3963. if _, ok := m.driver.(*txDriver); !ok {
  3964. return nil, errors.New("ent: mutation is not running in a transaction")
  3965. }
  3966. tx := &Tx{config: m.config}
  3967. tx.init()
  3968. return tx, nil
  3969. }
  3970. // SetID sets the value of the id field. Note that this
  3971. // operation is only accepted on creation of BatchMsg entities.
  3972. func (m *BatchMsgMutation) SetID(id uint64) {
  3973. m.id = &id
  3974. }
  3975. // ID returns the ID value in the mutation. Note that the ID is only available
  3976. // if it was provided to the builder or after it was returned from the database.
  3977. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3978. if m.id == nil {
  3979. return
  3980. }
  3981. return *m.id, true
  3982. }
  3983. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3984. // That means, if the mutation is applied within a transaction with an isolation level such
  3985. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3986. // or updated by the mutation.
  3987. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3988. switch {
  3989. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3990. id, exists := m.ID()
  3991. if exists {
  3992. return []uint64{id}, nil
  3993. }
  3994. fallthrough
  3995. case m.op.Is(OpUpdate | OpDelete):
  3996. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3997. default:
  3998. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3999. }
  4000. }
  4001. // SetCreatedAt sets the "created_at" field.
  4002. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4003. m.created_at = &t
  4004. }
  4005. // CreatedAt returns the value of the "created_at" field in the mutation.
  4006. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4007. v := m.created_at
  4008. if v == nil {
  4009. return
  4010. }
  4011. return *v, true
  4012. }
  4013. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4014. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4016. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4017. if !m.op.Is(OpUpdateOne) {
  4018. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4019. }
  4020. if m.id == nil || m.oldValue == nil {
  4021. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4022. }
  4023. oldValue, err := m.oldValue(ctx)
  4024. if err != nil {
  4025. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4026. }
  4027. return oldValue.CreatedAt, nil
  4028. }
  4029. // ResetCreatedAt resets all changes to the "created_at" field.
  4030. func (m *BatchMsgMutation) ResetCreatedAt() {
  4031. m.created_at = nil
  4032. }
  4033. // SetUpdatedAt sets the "updated_at" field.
  4034. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4035. m.updated_at = &t
  4036. }
  4037. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4038. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4039. v := m.updated_at
  4040. if v == nil {
  4041. return
  4042. }
  4043. return *v, true
  4044. }
  4045. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4046. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4048. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4049. if !m.op.Is(OpUpdateOne) {
  4050. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4051. }
  4052. if m.id == nil || m.oldValue == nil {
  4053. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4054. }
  4055. oldValue, err := m.oldValue(ctx)
  4056. if err != nil {
  4057. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4058. }
  4059. return oldValue.UpdatedAt, nil
  4060. }
  4061. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4062. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4063. m.updated_at = nil
  4064. }
  4065. // SetDeletedAt sets the "deleted_at" field.
  4066. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4067. m.deleted_at = &t
  4068. }
  4069. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4070. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4071. v := m.deleted_at
  4072. if v == nil {
  4073. return
  4074. }
  4075. return *v, true
  4076. }
  4077. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4078. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4080. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4081. if !m.op.Is(OpUpdateOne) {
  4082. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4083. }
  4084. if m.id == nil || m.oldValue == nil {
  4085. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4086. }
  4087. oldValue, err := m.oldValue(ctx)
  4088. if err != nil {
  4089. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4090. }
  4091. return oldValue.DeletedAt, nil
  4092. }
  4093. // ClearDeletedAt clears the value of the "deleted_at" field.
  4094. func (m *BatchMsgMutation) ClearDeletedAt() {
  4095. m.deleted_at = nil
  4096. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4097. }
  4098. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4099. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4100. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4101. return ok
  4102. }
  4103. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4104. func (m *BatchMsgMutation) ResetDeletedAt() {
  4105. m.deleted_at = nil
  4106. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4107. }
  4108. // SetStatus sets the "status" field.
  4109. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4110. m.status = &u
  4111. m.addstatus = nil
  4112. }
  4113. // Status returns the value of the "status" field in the mutation.
  4114. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4115. v := m.status
  4116. if v == nil {
  4117. return
  4118. }
  4119. return *v, true
  4120. }
  4121. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4122. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4124. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4125. if !m.op.Is(OpUpdateOne) {
  4126. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4127. }
  4128. if m.id == nil || m.oldValue == nil {
  4129. return v, errors.New("OldStatus requires an ID field in the mutation")
  4130. }
  4131. oldValue, err := m.oldValue(ctx)
  4132. if err != nil {
  4133. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4134. }
  4135. return oldValue.Status, nil
  4136. }
  4137. // AddStatus adds u to the "status" field.
  4138. func (m *BatchMsgMutation) AddStatus(u int8) {
  4139. if m.addstatus != nil {
  4140. *m.addstatus += u
  4141. } else {
  4142. m.addstatus = &u
  4143. }
  4144. }
  4145. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4146. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4147. v := m.addstatus
  4148. if v == nil {
  4149. return
  4150. }
  4151. return *v, true
  4152. }
  4153. // ClearStatus clears the value of the "status" field.
  4154. func (m *BatchMsgMutation) ClearStatus() {
  4155. m.status = nil
  4156. m.addstatus = nil
  4157. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4158. }
  4159. // StatusCleared returns if the "status" field was cleared in this mutation.
  4160. func (m *BatchMsgMutation) StatusCleared() bool {
  4161. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4162. return ok
  4163. }
  4164. // ResetStatus resets all changes to the "status" field.
  4165. func (m *BatchMsgMutation) ResetStatus() {
  4166. m.status = nil
  4167. m.addstatus = nil
  4168. delete(m.clearedFields, batchmsg.FieldStatus)
  4169. }
  4170. // SetBatchNo sets the "batch_no" field.
  4171. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4172. m.batch_no = &s
  4173. }
  4174. // BatchNo returns the value of the "batch_no" field in the mutation.
  4175. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4176. v := m.batch_no
  4177. if v == nil {
  4178. return
  4179. }
  4180. return *v, true
  4181. }
  4182. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4183. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4185. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4186. if !m.op.Is(OpUpdateOne) {
  4187. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4188. }
  4189. if m.id == nil || m.oldValue == nil {
  4190. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4191. }
  4192. oldValue, err := m.oldValue(ctx)
  4193. if err != nil {
  4194. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4195. }
  4196. return oldValue.BatchNo, nil
  4197. }
  4198. // ClearBatchNo clears the value of the "batch_no" field.
  4199. func (m *BatchMsgMutation) ClearBatchNo() {
  4200. m.batch_no = nil
  4201. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4202. }
  4203. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4204. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4205. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4206. return ok
  4207. }
  4208. // ResetBatchNo resets all changes to the "batch_no" field.
  4209. func (m *BatchMsgMutation) ResetBatchNo() {
  4210. m.batch_no = nil
  4211. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4212. }
  4213. // SetTaskName sets the "task_name" field.
  4214. func (m *BatchMsgMutation) SetTaskName(s string) {
  4215. m.task_name = &s
  4216. }
  4217. // TaskName returns the value of the "task_name" field in the mutation.
  4218. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4219. v := m.task_name
  4220. if v == nil {
  4221. return
  4222. }
  4223. return *v, true
  4224. }
  4225. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4226. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4228. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4229. if !m.op.Is(OpUpdateOne) {
  4230. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4231. }
  4232. if m.id == nil || m.oldValue == nil {
  4233. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4234. }
  4235. oldValue, err := m.oldValue(ctx)
  4236. if err != nil {
  4237. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4238. }
  4239. return oldValue.TaskName, nil
  4240. }
  4241. // ClearTaskName clears the value of the "task_name" field.
  4242. func (m *BatchMsgMutation) ClearTaskName() {
  4243. m.task_name = nil
  4244. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4245. }
  4246. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4247. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4248. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4249. return ok
  4250. }
  4251. // ResetTaskName resets all changes to the "task_name" field.
  4252. func (m *BatchMsgMutation) ResetTaskName() {
  4253. m.task_name = nil
  4254. delete(m.clearedFields, batchmsg.FieldTaskName)
  4255. }
  4256. // SetFromwxid sets the "fromwxid" field.
  4257. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4258. m.fromwxid = &s
  4259. }
  4260. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4261. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4262. v := m.fromwxid
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4281. }
  4282. return oldValue.Fromwxid, nil
  4283. }
  4284. // ClearFromwxid clears the value of the "fromwxid" field.
  4285. func (m *BatchMsgMutation) ClearFromwxid() {
  4286. m.fromwxid = nil
  4287. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4288. }
  4289. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4290. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4291. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4292. return ok
  4293. }
  4294. // ResetFromwxid resets all changes to the "fromwxid" field.
  4295. func (m *BatchMsgMutation) ResetFromwxid() {
  4296. m.fromwxid = nil
  4297. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4298. }
  4299. // SetMsg sets the "msg" field.
  4300. func (m *BatchMsgMutation) SetMsg(s string) {
  4301. m.msg = &s
  4302. }
  4303. // Msg returns the value of the "msg" field in the mutation.
  4304. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4305. v := m.msg
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldMsg requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4324. }
  4325. return oldValue.Msg, nil
  4326. }
  4327. // ClearMsg clears the value of the "msg" field.
  4328. func (m *BatchMsgMutation) ClearMsg() {
  4329. m.msg = nil
  4330. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4331. }
  4332. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) MsgCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4335. return ok
  4336. }
  4337. // ResetMsg resets all changes to the "msg" field.
  4338. func (m *BatchMsgMutation) ResetMsg() {
  4339. m.msg = nil
  4340. delete(m.clearedFields, batchmsg.FieldMsg)
  4341. }
  4342. // SetTag sets the "tag" field.
  4343. func (m *BatchMsgMutation) SetTag(s string) {
  4344. m.tag = &s
  4345. }
  4346. // Tag returns the value of the "tag" field in the mutation.
  4347. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4348. v := m.tag
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldTag requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4367. }
  4368. return oldValue.Tag, nil
  4369. }
  4370. // ClearTag clears the value of the "tag" field.
  4371. func (m *BatchMsgMutation) ClearTag() {
  4372. m.tag = nil
  4373. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4374. }
  4375. // TagCleared returns if the "tag" field was cleared in this mutation.
  4376. func (m *BatchMsgMutation) TagCleared() bool {
  4377. _, ok := m.clearedFields[batchmsg.FieldTag]
  4378. return ok
  4379. }
  4380. // ResetTag resets all changes to the "tag" field.
  4381. func (m *BatchMsgMutation) ResetTag() {
  4382. m.tag = nil
  4383. delete(m.clearedFields, batchmsg.FieldTag)
  4384. }
  4385. // SetTagids sets the "tagids" field.
  4386. func (m *BatchMsgMutation) SetTagids(s string) {
  4387. m.tagids = &s
  4388. }
  4389. // Tagids returns the value of the "tagids" field in the mutation.
  4390. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4391. v := m.tagids
  4392. if v == nil {
  4393. return
  4394. }
  4395. return *v, true
  4396. }
  4397. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4400. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4401. if !m.op.Is(OpUpdateOne) {
  4402. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4403. }
  4404. if m.id == nil || m.oldValue == nil {
  4405. return v, errors.New("OldTagids requires an ID field in the mutation")
  4406. }
  4407. oldValue, err := m.oldValue(ctx)
  4408. if err != nil {
  4409. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4410. }
  4411. return oldValue.Tagids, nil
  4412. }
  4413. // ClearTagids clears the value of the "tagids" field.
  4414. func (m *BatchMsgMutation) ClearTagids() {
  4415. m.tagids = nil
  4416. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4417. }
  4418. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4419. func (m *BatchMsgMutation) TagidsCleared() bool {
  4420. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4421. return ok
  4422. }
  4423. // ResetTagids resets all changes to the "tagids" field.
  4424. func (m *BatchMsgMutation) ResetTagids() {
  4425. m.tagids = nil
  4426. delete(m.clearedFields, batchmsg.FieldTagids)
  4427. }
  4428. // SetTotal sets the "total" field.
  4429. func (m *BatchMsgMutation) SetTotal(i int32) {
  4430. m.total = &i
  4431. m.addtotal = nil
  4432. }
  4433. // Total returns the value of the "total" field in the mutation.
  4434. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4435. v := m.total
  4436. if v == nil {
  4437. return
  4438. }
  4439. return *v, true
  4440. }
  4441. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4442. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4444. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4445. if !m.op.Is(OpUpdateOne) {
  4446. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4447. }
  4448. if m.id == nil || m.oldValue == nil {
  4449. return v, errors.New("OldTotal requires an ID field in the mutation")
  4450. }
  4451. oldValue, err := m.oldValue(ctx)
  4452. if err != nil {
  4453. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4454. }
  4455. return oldValue.Total, nil
  4456. }
  4457. // AddTotal adds i to the "total" field.
  4458. func (m *BatchMsgMutation) AddTotal(i int32) {
  4459. if m.addtotal != nil {
  4460. *m.addtotal += i
  4461. } else {
  4462. m.addtotal = &i
  4463. }
  4464. }
  4465. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4466. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4467. v := m.addtotal
  4468. if v == nil {
  4469. return
  4470. }
  4471. return *v, true
  4472. }
  4473. // ClearTotal clears the value of the "total" field.
  4474. func (m *BatchMsgMutation) ClearTotal() {
  4475. m.total = nil
  4476. m.addtotal = nil
  4477. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4478. }
  4479. // TotalCleared returns if the "total" field was cleared in this mutation.
  4480. func (m *BatchMsgMutation) TotalCleared() bool {
  4481. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4482. return ok
  4483. }
  4484. // ResetTotal resets all changes to the "total" field.
  4485. func (m *BatchMsgMutation) ResetTotal() {
  4486. m.total = nil
  4487. m.addtotal = nil
  4488. delete(m.clearedFields, batchmsg.FieldTotal)
  4489. }
  4490. // SetSuccess sets the "success" field.
  4491. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4492. m.success = &i
  4493. m.addsuccess = nil
  4494. }
  4495. // Success returns the value of the "success" field in the mutation.
  4496. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4497. v := m.success
  4498. if v == nil {
  4499. return
  4500. }
  4501. return *v, true
  4502. }
  4503. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4504. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4506. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4507. if !m.op.Is(OpUpdateOne) {
  4508. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4509. }
  4510. if m.id == nil || m.oldValue == nil {
  4511. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4512. }
  4513. oldValue, err := m.oldValue(ctx)
  4514. if err != nil {
  4515. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4516. }
  4517. return oldValue.Success, nil
  4518. }
  4519. // AddSuccess adds i to the "success" field.
  4520. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4521. if m.addsuccess != nil {
  4522. *m.addsuccess += i
  4523. } else {
  4524. m.addsuccess = &i
  4525. }
  4526. }
  4527. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4528. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4529. v := m.addsuccess
  4530. if v == nil {
  4531. return
  4532. }
  4533. return *v, true
  4534. }
  4535. // ClearSuccess clears the value of the "success" field.
  4536. func (m *BatchMsgMutation) ClearSuccess() {
  4537. m.success = nil
  4538. m.addsuccess = nil
  4539. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4540. }
  4541. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4542. func (m *BatchMsgMutation) SuccessCleared() bool {
  4543. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4544. return ok
  4545. }
  4546. // ResetSuccess resets all changes to the "success" field.
  4547. func (m *BatchMsgMutation) ResetSuccess() {
  4548. m.success = nil
  4549. m.addsuccess = nil
  4550. delete(m.clearedFields, batchmsg.FieldSuccess)
  4551. }
  4552. // SetFail sets the "fail" field.
  4553. func (m *BatchMsgMutation) SetFail(i int32) {
  4554. m.fail = &i
  4555. m.addfail = nil
  4556. }
  4557. // Fail returns the value of the "fail" field in the mutation.
  4558. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4559. v := m.fail
  4560. if v == nil {
  4561. return
  4562. }
  4563. return *v, true
  4564. }
  4565. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4566. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4568. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4569. if !m.op.Is(OpUpdateOne) {
  4570. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4571. }
  4572. if m.id == nil || m.oldValue == nil {
  4573. return v, errors.New("OldFail requires an ID field in the mutation")
  4574. }
  4575. oldValue, err := m.oldValue(ctx)
  4576. if err != nil {
  4577. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4578. }
  4579. return oldValue.Fail, nil
  4580. }
  4581. // AddFail adds i to the "fail" field.
  4582. func (m *BatchMsgMutation) AddFail(i int32) {
  4583. if m.addfail != nil {
  4584. *m.addfail += i
  4585. } else {
  4586. m.addfail = &i
  4587. }
  4588. }
  4589. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4590. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4591. v := m.addfail
  4592. if v == nil {
  4593. return
  4594. }
  4595. return *v, true
  4596. }
  4597. // ClearFail clears the value of the "fail" field.
  4598. func (m *BatchMsgMutation) ClearFail() {
  4599. m.fail = nil
  4600. m.addfail = nil
  4601. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4602. }
  4603. // FailCleared returns if the "fail" field was cleared in this mutation.
  4604. func (m *BatchMsgMutation) FailCleared() bool {
  4605. _, ok := m.clearedFields[batchmsg.FieldFail]
  4606. return ok
  4607. }
  4608. // ResetFail resets all changes to the "fail" field.
  4609. func (m *BatchMsgMutation) ResetFail() {
  4610. m.fail = nil
  4611. m.addfail = nil
  4612. delete(m.clearedFields, batchmsg.FieldFail)
  4613. }
  4614. // SetStartTime sets the "start_time" field.
  4615. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4616. m.start_time = &t
  4617. }
  4618. // StartTime returns the value of the "start_time" field in the mutation.
  4619. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4620. v := m.start_time
  4621. if v == nil {
  4622. return
  4623. }
  4624. return *v, true
  4625. }
  4626. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4627. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4629. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4630. if !m.op.Is(OpUpdateOne) {
  4631. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4632. }
  4633. if m.id == nil || m.oldValue == nil {
  4634. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4635. }
  4636. oldValue, err := m.oldValue(ctx)
  4637. if err != nil {
  4638. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4639. }
  4640. return oldValue.StartTime, nil
  4641. }
  4642. // ClearStartTime clears the value of the "start_time" field.
  4643. func (m *BatchMsgMutation) ClearStartTime() {
  4644. m.start_time = nil
  4645. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4646. }
  4647. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4648. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4649. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4650. return ok
  4651. }
  4652. // ResetStartTime resets all changes to the "start_time" field.
  4653. func (m *BatchMsgMutation) ResetStartTime() {
  4654. m.start_time = nil
  4655. delete(m.clearedFields, batchmsg.FieldStartTime)
  4656. }
  4657. // SetStopTime sets the "stop_time" field.
  4658. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4659. m.stop_time = &t
  4660. }
  4661. // StopTime returns the value of the "stop_time" field in the mutation.
  4662. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4663. v := m.stop_time
  4664. if v == nil {
  4665. return
  4666. }
  4667. return *v, true
  4668. }
  4669. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4670. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4672. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4673. if !m.op.Is(OpUpdateOne) {
  4674. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4675. }
  4676. if m.id == nil || m.oldValue == nil {
  4677. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4678. }
  4679. oldValue, err := m.oldValue(ctx)
  4680. if err != nil {
  4681. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4682. }
  4683. return oldValue.StopTime, nil
  4684. }
  4685. // ClearStopTime clears the value of the "stop_time" field.
  4686. func (m *BatchMsgMutation) ClearStopTime() {
  4687. m.stop_time = nil
  4688. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4689. }
  4690. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4691. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4692. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4693. return ok
  4694. }
  4695. // ResetStopTime resets all changes to the "stop_time" field.
  4696. func (m *BatchMsgMutation) ResetStopTime() {
  4697. m.stop_time = nil
  4698. delete(m.clearedFields, batchmsg.FieldStopTime)
  4699. }
  4700. // SetSendTime sets the "send_time" field.
  4701. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4702. m.send_time = &t
  4703. }
  4704. // SendTime returns the value of the "send_time" field in the mutation.
  4705. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4706. v := m.send_time
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4725. }
  4726. return oldValue.SendTime, nil
  4727. }
  4728. // ClearSendTime clears the value of the "send_time" field.
  4729. func (m *BatchMsgMutation) ClearSendTime() {
  4730. m.send_time = nil
  4731. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4732. }
  4733. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4734. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4735. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4736. return ok
  4737. }
  4738. // ResetSendTime resets all changes to the "send_time" field.
  4739. func (m *BatchMsgMutation) ResetSendTime() {
  4740. m.send_time = nil
  4741. delete(m.clearedFields, batchmsg.FieldSendTime)
  4742. }
  4743. // SetType sets the "type" field.
  4744. func (m *BatchMsgMutation) SetType(i int32) {
  4745. m._type = &i
  4746. m.add_type = nil
  4747. }
  4748. // GetType returns the value of the "type" field in the mutation.
  4749. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4750. v := m._type
  4751. if v == nil {
  4752. return
  4753. }
  4754. return *v, true
  4755. }
  4756. // OldType returns the old "type" field's value of the BatchMsg entity.
  4757. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4759. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4760. if !m.op.Is(OpUpdateOne) {
  4761. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4762. }
  4763. if m.id == nil || m.oldValue == nil {
  4764. return v, errors.New("OldType requires an ID field in the mutation")
  4765. }
  4766. oldValue, err := m.oldValue(ctx)
  4767. if err != nil {
  4768. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4769. }
  4770. return oldValue.Type, nil
  4771. }
  4772. // AddType adds i to the "type" field.
  4773. func (m *BatchMsgMutation) AddType(i int32) {
  4774. if m.add_type != nil {
  4775. *m.add_type += i
  4776. } else {
  4777. m.add_type = &i
  4778. }
  4779. }
  4780. // AddedType returns the value that was added to the "type" field in this mutation.
  4781. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4782. v := m.add_type
  4783. if v == nil {
  4784. return
  4785. }
  4786. return *v, true
  4787. }
  4788. // ClearType clears the value of the "type" field.
  4789. func (m *BatchMsgMutation) ClearType() {
  4790. m._type = nil
  4791. m.add_type = nil
  4792. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4793. }
  4794. // TypeCleared returns if the "type" field was cleared in this mutation.
  4795. func (m *BatchMsgMutation) TypeCleared() bool {
  4796. _, ok := m.clearedFields[batchmsg.FieldType]
  4797. return ok
  4798. }
  4799. // ResetType resets all changes to the "type" field.
  4800. func (m *BatchMsgMutation) ResetType() {
  4801. m._type = nil
  4802. m.add_type = nil
  4803. delete(m.clearedFields, batchmsg.FieldType)
  4804. }
  4805. // SetOrganizationID sets the "organization_id" field.
  4806. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4807. m.organization_id = &u
  4808. m.addorganization_id = nil
  4809. }
  4810. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4811. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4812. v := m.organization_id
  4813. if v == nil {
  4814. return
  4815. }
  4816. return *v, true
  4817. }
  4818. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4819. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4821. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4822. if !m.op.Is(OpUpdateOne) {
  4823. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4824. }
  4825. if m.id == nil || m.oldValue == nil {
  4826. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4827. }
  4828. oldValue, err := m.oldValue(ctx)
  4829. if err != nil {
  4830. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4831. }
  4832. return oldValue.OrganizationID, nil
  4833. }
  4834. // AddOrganizationID adds u to the "organization_id" field.
  4835. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4836. if m.addorganization_id != nil {
  4837. *m.addorganization_id += u
  4838. } else {
  4839. m.addorganization_id = &u
  4840. }
  4841. }
  4842. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4843. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4844. v := m.addorganization_id
  4845. if v == nil {
  4846. return
  4847. }
  4848. return *v, true
  4849. }
  4850. // ResetOrganizationID resets all changes to the "organization_id" field.
  4851. func (m *BatchMsgMutation) ResetOrganizationID() {
  4852. m.organization_id = nil
  4853. m.addorganization_id = nil
  4854. }
  4855. // Where appends a list predicates to the BatchMsgMutation builder.
  4856. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4857. m.predicates = append(m.predicates, ps...)
  4858. }
  4859. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4860. // users can use type-assertion to append predicates that do not depend on any generated package.
  4861. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4862. p := make([]predicate.BatchMsg, len(ps))
  4863. for i := range ps {
  4864. p[i] = ps[i]
  4865. }
  4866. m.Where(p...)
  4867. }
  4868. // Op returns the operation name.
  4869. func (m *BatchMsgMutation) Op() Op {
  4870. return m.op
  4871. }
  4872. // SetOp allows setting the mutation operation.
  4873. func (m *BatchMsgMutation) SetOp(op Op) {
  4874. m.op = op
  4875. }
  4876. // Type returns the node type of this mutation (BatchMsg).
  4877. func (m *BatchMsgMutation) Type() string {
  4878. return m.typ
  4879. }
  4880. // Fields returns all fields that were changed during this mutation. Note that in
  4881. // order to get all numeric fields that were incremented/decremented, call
  4882. // AddedFields().
  4883. func (m *BatchMsgMutation) Fields() []string {
  4884. fields := make([]string, 0, 18)
  4885. if m.created_at != nil {
  4886. fields = append(fields, batchmsg.FieldCreatedAt)
  4887. }
  4888. if m.updated_at != nil {
  4889. fields = append(fields, batchmsg.FieldUpdatedAt)
  4890. }
  4891. if m.deleted_at != nil {
  4892. fields = append(fields, batchmsg.FieldDeletedAt)
  4893. }
  4894. if m.status != nil {
  4895. fields = append(fields, batchmsg.FieldStatus)
  4896. }
  4897. if m.batch_no != nil {
  4898. fields = append(fields, batchmsg.FieldBatchNo)
  4899. }
  4900. if m.task_name != nil {
  4901. fields = append(fields, batchmsg.FieldTaskName)
  4902. }
  4903. if m.fromwxid != nil {
  4904. fields = append(fields, batchmsg.FieldFromwxid)
  4905. }
  4906. if m.msg != nil {
  4907. fields = append(fields, batchmsg.FieldMsg)
  4908. }
  4909. if m.tag != nil {
  4910. fields = append(fields, batchmsg.FieldTag)
  4911. }
  4912. if m.tagids != nil {
  4913. fields = append(fields, batchmsg.FieldTagids)
  4914. }
  4915. if m.total != nil {
  4916. fields = append(fields, batchmsg.FieldTotal)
  4917. }
  4918. if m.success != nil {
  4919. fields = append(fields, batchmsg.FieldSuccess)
  4920. }
  4921. if m.fail != nil {
  4922. fields = append(fields, batchmsg.FieldFail)
  4923. }
  4924. if m.start_time != nil {
  4925. fields = append(fields, batchmsg.FieldStartTime)
  4926. }
  4927. if m.stop_time != nil {
  4928. fields = append(fields, batchmsg.FieldStopTime)
  4929. }
  4930. if m.send_time != nil {
  4931. fields = append(fields, batchmsg.FieldSendTime)
  4932. }
  4933. if m._type != nil {
  4934. fields = append(fields, batchmsg.FieldType)
  4935. }
  4936. if m.organization_id != nil {
  4937. fields = append(fields, batchmsg.FieldOrganizationID)
  4938. }
  4939. return fields
  4940. }
  4941. // Field returns the value of a field with the given name. The second boolean
  4942. // return value indicates that this field was not set, or was not defined in the
  4943. // schema.
  4944. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4945. switch name {
  4946. case batchmsg.FieldCreatedAt:
  4947. return m.CreatedAt()
  4948. case batchmsg.FieldUpdatedAt:
  4949. return m.UpdatedAt()
  4950. case batchmsg.FieldDeletedAt:
  4951. return m.DeletedAt()
  4952. case batchmsg.FieldStatus:
  4953. return m.Status()
  4954. case batchmsg.FieldBatchNo:
  4955. return m.BatchNo()
  4956. case batchmsg.FieldTaskName:
  4957. return m.TaskName()
  4958. case batchmsg.FieldFromwxid:
  4959. return m.Fromwxid()
  4960. case batchmsg.FieldMsg:
  4961. return m.Msg()
  4962. case batchmsg.FieldTag:
  4963. return m.Tag()
  4964. case batchmsg.FieldTagids:
  4965. return m.Tagids()
  4966. case batchmsg.FieldTotal:
  4967. return m.Total()
  4968. case batchmsg.FieldSuccess:
  4969. return m.Success()
  4970. case batchmsg.FieldFail:
  4971. return m.Fail()
  4972. case batchmsg.FieldStartTime:
  4973. return m.StartTime()
  4974. case batchmsg.FieldStopTime:
  4975. return m.StopTime()
  4976. case batchmsg.FieldSendTime:
  4977. return m.SendTime()
  4978. case batchmsg.FieldType:
  4979. return m.GetType()
  4980. case batchmsg.FieldOrganizationID:
  4981. return m.OrganizationID()
  4982. }
  4983. return nil, false
  4984. }
  4985. // OldField returns the old value of the field from the database. An error is
  4986. // returned if the mutation operation is not UpdateOne, or the query to the
  4987. // database failed.
  4988. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4989. switch name {
  4990. case batchmsg.FieldCreatedAt:
  4991. return m.OldCreatedAt(ctx)
  4992. case batchmsg.FieldUpdatedAt:
  4993. return m.OldUpdatedAt(ctx)
  4994. case batchmsg.FieldDeletedAt:
  4995. return m.OldDeletedAt(ctx)
  4996. case batchmsg.FieldStatus:
  4997. return m.OldStatus(ctx)
  4998. case batchmsg.FieldBatchNo:
  4999. return m.OldBatchNo(ctx)
  5000. case batchmsg.FieldTaskName:
  5001. return m.OldTaskName(ctx)
  5002. case batchmsg.FieldFromwxid:
  5003. return m.OldFromwxid(ctx)
  5004. case batchmsg.FieldMsg:
  5005. return m.OldMsg(ctx)
  5006. case batchmsg.FieldTag:
  5007. return m.OldTag(ctx)
  5008. case batchmsg.FieldTagids:
  5009. return m.OldTagids(ctx)
  5010. case batchmsg.FieldTotal:
  5011. return m.OldTotal(ctx)
  5012. case batchmsg.FieldSuccess:
  5013. return m.OldSuccess(ctx)
  5014. case batchmsg.FieldFail:
  5015. return m.OldFail(ctx)
  5016. case batchmsg.FieldStartTime:
  5017. return m.OldStartTime(ctx)
  5018. case batchmsg.FieldStopTime:
  5019. return m.OldStopTime(ctx)
  5020. case batchmsg.FieldSendTime:
  5021. return m.OldSendTime(ctx)
  5022. case batchmsg.FieldType:
  5023. return m.OldType(ctx)
  5024. case batchmsg.FieldOrganizationID:
  5025. return m.OldOrganizationID(ctx)
  5026. }
  5027. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5028. }
  5029. // SetField sets the value of a field with the given name. It returns an error if
  5030. // the field is not defined in the schema, or if the type mismatched the field
  5031. // type.
  5032. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5033. switch name {
  5034. case batchmsg.FieldCreatedAt:
  5035. v, ok := value.(time.Time)
  5036. if !ok {
  5037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5038. }
  5039. m.SetCreatedAt(v)
  5040. return nil
  5041. case batchmsg.FieldUpdatedAt:
  5042. v, ok := value.(time.Time)
  5043. if !ok {
  5044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5045. }
  5046. m.SetUpdatedAt(v)
  5047. return nil
  5048. case batchmsg.FieldDeletedAt:
  5049. v, ok := value.(time.Time)
  5050. if !ok {
  5051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5052. }
  5053. m.SetDeletedAt(v)
  5054. return nil
  5055. case batchmsg.FieldStatus:
  5056. v, ok := value.(uint8)
  5057. if !ok {
  5058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5059. }
  5060. m.SetStatus(v)
  5061. return nil
  5062. case batchmsg.FieldBatchNo:
  5063. v, ok := value.(string)
  5064. if !ok {
  5065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5066. }
  5067. m.SetBatchNo(v)
  5068. return nil
  5069. case batchmsg.FieldTaskName:
  5070. v, ok := value.(string)
  5071. if !ok {
  5072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5073. }
  5074. m.SetTaskName(v)
  5075. return nil
  5076. case batchmsg.FieldFromwxid:
  5077. v, ok := value.(string)
  5078. if !ok {
  5079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5080. }
  5081. m.SetFromwxid(v)
  5082. return nil
  5083. case batchmsg.FieldMsg:
  5084. v, ok := value.(string)
  5085. if !ok {
  5086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5087. }
  5088. m.SetMsg(v)
  5089. return nil
  5090. case batchmsg.FieldTag:
  5091. v, ok := value.(string)
  5092. if !ok {
  5093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5094. }
  5095. m.SetTag(v)
  5096. return nil
  5097. case batchmsg.FieldTagids:
  5098. v, ok := value.(string)
  5099. if !ok {
  5100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5101. }
  5102. m.SetTagids(v)
  5103. return nil
  5104. case batchmsg.FieldTotal:
  5105. v, ok := value.(int32)
  5106. if !ok {
  5107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5108. }
  5109. m.SetTotal(v)
  5110. return nil
  5111. case batchmsg.FieldSuccess:
  5112. v, ok := value.(int32)
  5113. if !ok {
  5114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5115. }
  5116. m.SetSuccess(v)
  5117. return nil
  5118. case batchmsg.FieldFail:
  5119. v, ok := value.(int32)
  5120. if !ok {
  5121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5122. }
  5123. m.SetFail(v)
  5124. return nil
  5125. case batchmsg.FieldStartTime:
  5126. v, ok := value.(time.Time)
  5127. if !ok {
  5128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5129. }
  5130. m.SetStartTime(v)
  5131. return nil
  5132. case batchmsg.FieldStopTime:
  5133. v, ok := value.(time.Time)
  5134. if !ok {
  5135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5136. }
  5137. m.SetStopTime(v)
  5138. return nil
  5139. case batchmsg.FieldSendTime:
  5140. v, ok := value.(time.Time)
  5141. if !ok {
  5142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5143. }
  5144. m.SetSendTime(v)
  5145. return nil
  5146. case batchmsg.FieldType:
  5147. v, ok := value.(int32)
  5148. if !ok {
  5149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5150. }
  5151. m.SetType(v)
  5152. return nil
  5153. case batchmsg.FieldOrganizationID:
  5154. v, ok := value.(uint64)
  5155. if !ok {
  5156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5157. }
  5158. m.SetOrganizationID(v)
  5159. return nil
  5160. }
  5161. return fmt.Errorf("unknown BatchMsg field %s", name)
  5162. }
  5163. // AddedFields returns all numeric fields that were incremented/decremented during
  5164. // this mutation.
  5165. func (m *BatchMsgMutation) AddedFields() []string {
  5166. var fields []string
  5167. if m.addstatus != nil {
  5168. fields = append(fields, batchmsg.FieldStatus)
  5169. }
  5170. if m.addtotal != nil {
  5171. fields = append(fields, batchmsg.FieldTotal)
  5172. }
  5173. if m.addsuccess != nil {
  5174. fields = append(fields, batchmsg.FieldSuccess)
  5175. }
  5176. if m.addfail != nil {
  5177. fields = append(fields, batchmsg.FieldFail)
  5178. }
  5179. if m.add_type != nil {
  5180. fields = append(fields, batchmsg.FieldType)
  5181. }
  5182. if m.addorganization_id != nil {
  5183. fields = append(fields, batchmsg.FieldOrganizationID)
  5184. }
  5185. return fields
  5186. }
  5187. // AddedField returns the numeric value that was incremented/decremented on a field
  5188. // with the given name. The second boolean return value indicates that this field
  5189. // was not set, or was not defined in the schema.
  5190. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5191. switch name {
  5192. case batchmsg.FieldStatus:
  5193. return m.AddedStatus()
  5194. case batchmsg.FieldTotal:
  5195. return m.AddedTotal()
  5196. case batchmsg.FieldSuccess:
  5197. return m.AddedSuccess()
  5198. case batchmsg.FieldFail:
  5199. return m.AddedFail()
  5200. case batchmsg.FieldType:
  5201. return m.AddedType()
  5202. case batchmsg.FieldOrganizationID:
  5203. return m.AddedOrganizationID()
  5204. }
  5205. return nil, false
  5206. }
  5207. // AddField adds the value to the field with the given name. It returns an error if
  5208. // the field is not defined in the schema, or if the type mismatched the field
  5209. // type.
  5210. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5211. switch name {
  5212. case batchmsg.FieldStatus:
  5213. v, ok := value.(int8)
  5214. if !ok {
  5215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5216. }
  5217. m.AddStatus(v)
  5218. return nil
  5219. case batchmsg.FieldTotal:
  5220. v, ok := value.(int32)
  5221. if !ok {
  5222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5223. }
  5224. m.AddTotal(v)
  5225. return nil
  5226. case batchmsg.FieldSuccess:
  5227. v, ok := value.(int32)
  5228. if !ok {
  5229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5230. }
  5231. m.AddSuccess(v)
  5232. return nil
  5233. case batchmsg.FieldFail:
  5234. v, ok := value.(int32)
  5235. if !ok {
  5236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5237. }
  5238. m.AddFail(v)
  5239. return nil
  5240. case batchmsg.FieldType:
  5241. v, ok := value.(int32)
  5242. if !ok {
  5243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5244. }
  5245. m.AddType(v)
  5246. return nil
  5247. case batchmsg.FieldOrganizationID:
  5248. v, ok := value.(int64)
  5249. if !ok {
  5250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5251. }
  5252. m.AddOrganizationID(v)
  5253. return nil
  5254. }
  5255. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5256. }
  5257. // ClearedFields returns all nullable fields that were cleared during this
  5258. // mutation.
  5259. func (m *BatchMsgMutation) ClearedFields() []string {
  5260. var fields []string
  5261. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5262. fields = append(fields, batchmsg.FieldDeletedAt)
  5263. }
  5264. if m.FieldCleared(batchmsg.FieldStatus) {
  5265. fields = append(fields, batchmsg.FieldStatus)
  5266. }
  5267. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5268. fields = append(fields, batchmsg.FieldBatchNo)
  5269. }
  5270. if m.FieldCleared(batchmsg.FieldTaskName) {
  5271. fields = append(fields, batchmsg.FieldTaskName)
  5272. }
  5273. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5274. fields = append(fields, batchmsg.FieldFromwxid)
  5275. }
  5276. if m.FieldCleared(batchmsg.FieldMsg) {
  5277. fields = append(fields, batchmsg.FieldMsg)
  5278. }
  5279. if m.FieldCleared(batchmsg.FieldTag) {
  5280. fields = append(fields, batchmsg.FieldTag)
  5281. }
  5282. if m.FieldCleared(batchmsg.FieldTagids) {
  5283. fields = append(fields, batchmsg.FieldTagids)
  5284. }
  5285. if m.FieldCleared(batchmsg.FieldTotal) {
  5286. fields = append(fields, batchmsg.FieldTotal)
  5287. }
  5288. if m.FieldCleared(batchmsg.FieldSuccess) {
  5289. fields = append(fields, batchmsg.FieldSuccess)
  5290. }
  5291. if m.FieldCleared(batchmsg.FieldFail) {
  5292. fields = append(fields, batchmsg.FieldFail)
  5293. }
  5294. if m.FieldCleared(batchmsg.FieldStartTime) {
  5295. fields = append(fields, batchmsg.FieldStartTime)
  5296. }
  5297. if m.FieldCleared(batchmsg.FieldStopTime) {
  5298. fields = append(fields, batchmsg.FieldStopTime)
  5299. }
  5300. if m.FieldCleared(batchmsg.FieldSendTime) {
  5301. fields = append(fields, batchmsg.FieldSendTime)
  5302. }
  5303. if m.FieldCleared(batchmsg.FieldType) {
  5304. fields = append(fields, batchmsg.FieldType)
  5305. }
  5306. return fields
  5307. }
  5308. // FieldCleared returns a boolean indicating if a field with the given name was
  5309. // cleared in this mutation.
  5310. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5311. _, ok := m.clearedFields[name]
  5312. return ok
  5313. }
  5314. // ClearField clears the value of the field with the given name. It returns an
  5315. // error if the field is not defined in the schema.
  5316. func (m *BatchMsgMutation) ClearField(name string) error {
  5317. switch name {
  5318. case batchmsg.FieldDeletedAt:
  5319. m.ClearDeletedAt()
  5320. return nil
  5321. case batchmsg.FieldStatus:
  5322. m.ClearStatus()
  5323. return nil
  5324. case batchmsg.FieldBatchNo:
  5325. m.ClearBatchNo()
  5326. return nil
  5327. case batchmsg.FieldTaskName:
  5328. m.ClearTaskName()
  5329. return nil
  5330. case batchmsg.FieldFromwxid:
  5331. m.ClearFromwxid()
  5332. return nil
  5333. case batchmsg.FieldMsg:
  5334. m.ClearMsg()
  5335. return nil
  5336. case batchmsg.FieldTag:
  5337. m.ClearTag()
  5338. return nil
  5339. case batchmsg.FieldTagids:
  5340. m.ClearTagids()
  5341. return nil
  5342. case batchmsg.FieldTotal:
  5343. m.ClearTotal()
  5344. return nil
  5345. case batchmsg.FieldSuccess:
  5346. m.ClearSuccess()
  5347. return nil
  5348. case batchmsg.FieldFail:
  5349. m.ClearFail()
  5350. return nil
  5351. case batchmsg.FieldStartTime:
  5352. m.ClearStartTime()
  5353. return nil
  5354. case batchmsg.FieldStopTime:
  5355. m.ClearStopTime()
  5356. return nil
  5357. case batchmsg.FieldSendTime:
  5358. m.ClearSendTime()
  5359. return nil
  5360. case batchmsg.FieldType:
  5361. m.ClearType()
  5362. return nil
  5363. }
  5364. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5365. }
  5366. // ResetField resets all changes in the mutation for the field with the given name.
  5367. // It returns an error if the field is not defined in the schema.
  5368. func (m *BatchMsgMutation) ResetField(name string) error {
  5369. switch name {
  5370. case batchmsg.FieldCreatedAt:
  5371. m.ResetCreatedAt()
  5372. return nil
  5373. case batchmsg.FieldUpdatedAt:
  5374. m.ResetUpdatedAt()
  5375. return nil
  5376. case batchmsg.FieldDeletedAt:
  5377. m.ResetDeletedAt()
  5378. return nil
  5379. case batchmsg.FieldStatus:
  5380. m.ResetStatus()
  5381. return nil
  5382. case batchmsg.FieldBatchNo:
  5383. m.ResetBatchNo()
  5384. return nil
  5385. case batchmsg.FieldTaskName:
  5386. m.ResetTaskName()
  5387. return nil
  5388. case batchmsg.FieldFromwxid:
  5389. m.ResetFromwxid()
  5390. return nil
  5391. case batchmsg.FieldMsg:
  5392. m.ResetMsg()
  5393. return nil
  5394. case batchmsg.FieldTag:
  5395. m.ResetTag()
  5396. return nil
  5397. case batchmsg.FieldTagids:
  5398. m.ResetTagids()
  5399. return nil
  5400. case batchmsg.FieldTotal:
  5401. m.ResetTotal()
  5402. return nil
  5403. case batchmsg.FieldSuccess:
  5404. m.ResetSuccess()
  5405. return nil
  5406. case batchmsg.FieldFail:
  5407. m.ResetFail()
  5408. return nil
  5409. case batchmsg.FieldStartTime:
  5410. m.ResetStartTime()
  5411. return nil
  5412. case batchmsg.FieldStopTime:
  5413. m.ResetStopTime()
  5414. return nil
  5415. case batchmsg.FieldSendTime:
  5416. m.ResetSendTime()
  5417. return nil
  5418. case batchmsg.FieldType:
  5419. m.ResetType()
  5420. return nil
  5421. case batchmsg.FieldOrganizationID:
  5422. m.ResetOrganizationID()
  5423. return nil
  5424. }
  5425. return fmt.Errorf("unknown BatchMsg field %s", name)
  5426. }
  5427. // AddedEdges returns all edge names that were set/added in this mutation.
  5428. func (m *BatchMsgMutation) AddedEdges() []string {
  5429. edges := make([]string, 0, 0)
  5430. return edges
  5431. }
  5432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5433. // name in this mutation.
  5434. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5435. return nil
  5436. }
  5437. // RemovedEdges returns all edge names that were removed in this mutation.
  5438. func (m *BatchMsgMutation) RemovedEdges() []string {
  5439. edges := make([]string, 0, 0)
  5440. return edges
  5441. }
  5442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5443. // the given name in this mutation.
  5444. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5445. return nil
  5446. }
  5447. // ClearedEdges returns all edge names that were cleared in this mutation.
  5448. func (m *BatchMsgMutation) ClearedEdges() []string {
  5449. edges := make([]string, 0, 0)
  5450. return edges
  5451. }
  5452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5453. // was cleared in this mutation.
  5454. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5455. return false
  5456. }
  5457. // ClearEdge clears the value of the edge with the given name. It returns an error
  5458. // if that edge is not defined in the schema.
  5459. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5460. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5461. }
  5462. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5463. // It returns an error if the edge is not defined in the schema.
  5464. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5465. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5466. }
  5467. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5468. type CategoryMutation struct {
  5469. config
  5470. op Op
  5471. typ string
  5472. id *uint64
  5473. created_at *time.Time
  5474. updated_at *time.Time
  5475. deleted_at *time.Time
  5476. name *string
  5477. organization_id *uint64
  5478. addorganization_id *int64
  5479. clearedFields map[string]struct{}
  5480. done bool
  5481. oldValue func(context.Context) (*Category, error)
  5482. predicates []predicate.Category
  5483. }
  5484. var _ ent.Mutation = (*CategoryMutation)(nil)
  5485. // categoryOption allows management of the mutation configuration using functional options.
  5486. type categoryOption func(*CategoryMutation)
  5487. // newCategoryMutation creates new mutation for the Category entity.
  5488. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5489. m := &CategoryMutation{
  5490. config: c,
  5491. op: op,
  5492. typ: TypeCategory,
  5493. clearedFields: make(map[string]struct{}),
  5494. }
  5495. for _, opt := range opts {
  5496. opt(m)
  5497. }
  5498. return m
  5499. }
  5500. // withCategoryID sets the ID field of the mutation.
  5501. func withCategoryID(id uint64) categoryOption {
  5502. return func(m *CategoryMutation) {
  5503. var (
  5504. err error
  5505. once sync.Once
  5506. value *Category
  5507. )
  5508. m.oldValue = func(ctx context.Context) (*Category, error) {
  5509. once.Do(func() {
  5510. if m.done {
  5511. err = errors.New("querying old values post mutation is not allowed")
  5512. } else {
  5513. value, err = m.Client().Category.Get(ctx, id)
  5514. }
  5515. })
  5516. return value, err
  5517. }
  5518. m.id = &id
  5519. }
  5520. }
  5521. // withCategory sets the old Category of the mutation.
  5522. func withCategory(node *Category) categoryOption {
  5523. return func(m *CategoryMutation) {
  5524. m.oldValue = func(context.Context) (*Category, error) {
  5525. return node, nil
  5526. }
  5527. m.id = &node.ID
  5528. }
  5529. }
  5530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5531. // executed in a transaction (ent.Tx), a transactional client is returned.
  5532. func (m CategoryMutation) Client() *Client {
  5533. client := &Client{config: m.config}
  5534. client.init()
  5535. return client
  5536. }
  5537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5538. // it returns an error otherwise.
  5539. func (m CategoryMutation) Tx() (*Tx, error) {
  5540. if _, ok := m.driver.(*txDriver); !ok {
  5541. return nil, errors.New("ent: mutation is not running in a transaction")
  5542. }
  5543. tx := &Tx{config: m.config}
  5544. tx.init()
  5545. return tx, nil
  5546. }
  5547. // SetID sets the value of the id field. Note that this
  5548. // operation is only accepted on creation of Category entities.
  5549. func (m *CategoryMutation) SetID(id uint64) {
  5550. m.id = &id
  5551. }
  5552. // ID returns the ID value in the mutation. Note that the ID is only available
  5553. // if it was provided to the builder or after it was returned from the database.
  5554. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5555. if m.id == nil {
  5556. return
  5557. }
  5558. return *m.id, true
  5559. }
  5560. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5561. // That means, if the mutation is applied within a transaction with an isolation level such
  5562. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5563. // or updated by the mutation.
  5564. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5565. switch {
  5566. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5567. id, exists := m.ID()
  5568. if exists {
  5569. return []uint64{id}, nil
  5570. }
  5571. fallthrough
  5572. case m.op.Is(OpUpdate | OpDelete):
  5573. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5574. default:
  5575. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5576. }
  5577. }
  5578. // SetCreatedAt sets the "created_at" field.
  5579. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5580. m.created_at = &t
  5581. }
  5582. // CreatedAt returns the value of the "created_at" field in the mutation.
  5583. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5584. v := m.created_at
  5585. if v == nil {
  5586. return
  5587. }
  5588. return *v, true
  5589. }
  5590. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5591. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5593. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5594. if !m.op.Is(OpUpdateOne) {
  5595. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5596. }
  5597. if m.id == nil || m.oldValue == nil {
  5598. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5599. }
  5600. oldValue, err := m.oldValue(ctx)
  5601. if err != nil {
  5602. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5603. }
  5604. return oldValue.CreatedAt, nil
  5605. }
  5606. // ResetCreatedAt resets all changes to the "created_at" field.
  5607. func (m *CategoryMutation) ResetCreatedAt() {
  5608. m.created_at = nil
  5609. }
  5610. // SetUpdatedAt sets the "updated_at" field.
  5611. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5612. m.updated_at = &t
  5613. }
  5614. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5615. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5616. v := m.updated_at
  5617. if v == nil {
  5618. return
  5619. }
  5620. return *v, true
  5621. }
  5622. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5623. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5625. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5626. if !m.op.Is(OpUpdateOne) {
  5627. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5628. }
  5629. if m.id == nil || m.oldValue == nil {
  5630. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5631. }
  5632. oldValue, err := m.oldValue(ctx)
  5633. if err != nil {
  5634. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5635. }
  5636. return oldValue.UpdatedAt, nil
  5637. }
  5638. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5639. func (m *CategoryMutation) ResetUpdatedAt() {
  5640. m.updated_at = nil
  5641. }
  5642. // SetDeletedAt sets the "deleted_at" field.
  5643. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5644. m.deleted_at = &t
  5645. }
  5646. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5647. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5648. v := m.deleted_at
  5649. if v == nil {
  5650. return
  5651. }
  5652. return *v, true
  5653. }
  5654. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5655. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5657. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5658. if !m.op.Is(OpUpdateOne) {
  5659. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5660. }
  5661. if m.id == nil || m.oldValue == nil {
  5662. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5663. }
  5664. oldValue, err := m.oldValue(ctx)
  5665. if err != nil {
  5666. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5667. }
  5668. return oldValue.DeletedAt, nil
  5669. }
  5670. // ClearDeletedAt clears the value of the "deleted_at" field.
  5671. func (m *CategoryMutation) ClearDeletedAt() {
  5672. m.deleted_at = nil
  5673. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5674. }
  5675. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5676. func (m *CategoryMutation) DeletedAtCleared() bool {
  5677. _, ok := m.clearedFields[category.FieldDeletedAt]
  5678. return ok
  5679. }
  5680. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5681. func (m *CategoryMutation) ResetDeletedAt() {
  5682. m.deleted_at = nil
  5683. delete(m.clearedFields, category.FieldDeletedAt)
  5684. }
  5685. // SetName sets the "name" field.
  5686. func (m *CategoryMutation) SetName(s string) {
  5687. m.name = &s
  5688. }
  5689. // Name returns the value of the "name" field in the mutation.
  5690. func (m *CategoryMutation) Name() (r string, exists bool) {
  5691. v := m.name
  5692. if v == nil {
  5693. return
  5694. }
  5695. return *v, true
  5696. }
  5697. // OldName returns the old "name" field's value of the Category entity.
  5698. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5700. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5701. if !m.op.Is(OpUpdateOne) {
  5702. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5703. }
  5704. if m.id == nil || m.oldValue == nil {
  5705. return v, errors.New("OldName requires an ID field in the mutation")
  5706. }
  5707. oldValue, err := m.oldValue(ctx)
  5708. if err != nil {
  5709. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5710. }
  5711. return oldValue.Name, nil
  5712. }
  5713. // ResetName resets all changes to the "name" field.
  5714. func (m *CategoryMutation) ResetName() {
  5715. m.name = nil
  5716. }
  5717. // SetOrganizationID sets the "organization_id" field.
  5718. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5719. m.organization_id = &u
  5720. m.addorganization_id = nil
  5721. }
  5722. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5723. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5724. v := m.organization_id
  5725. if v == nil {
  5726. return
  5727. }
  5728. return *v, true
  5729. }
  5730. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5731. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5733. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5734. if !m.op.Is(OpUpdateOne) {
  5735. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5736. }
  5737. if m.id == nil || m.oldValue == nil {
  5738. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5739. }
  5740. oldValue, err := m.oldValue(ctx)
  5741. if err != nil {
  5742. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5743. }
  5744. return oldValue.OrganizationID, nil
  5745. }
  5746. // AddOrganizationID adds u to the "organization_id" field.
  5747. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5748. if m.addorganization_id != nil {
  5749. *m.addorganization_id += u
  5750. } else {
  5751. m.addorganization_id = &u
  5752. }
  5753. }
  5754. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5755. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5756. v := m.addorganization_id
  5757. if v == nil {
  5758. return
  5759. }
  5760. return *v, true
  5761. }
  5762. // ResetOrganizationID resets all changes to the "organization_id" field.
  5763. func (m *CategoryMutation) ResetOrganizationID() {
  5764. m.organization_id = nil
  5765. m.addorganization_id = nil
  5766. }
  5767. // Where appends a list predicates to the CategoryMutation builder.
  5768. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5769. m.predicates = append(m.predicates, ps...)
  5770. }
  5771. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5772. // users can use type-assertion to append predicates that do not depend on any generated package.
  5773. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5774. p := make([]predicate.Category, len(ps))
  5775. for i := range ps {
  5776. p[i] = ps[i]
  5777. }
  5778. m.Where(p...)
  5779. }
  5780. // Op returns the operation name.
  5781. func (m *CategoryMutation) Op() Op {
  5782. return m.op
  5783. }
  5784. // SetOp allows setting the mutation operation.
  5785. func (m *CategoryMutation) SetOp(op Op) {
  5786. m.op = op
  5787. }
  5788. // Type returns the node type of this mutation (Category).
  5789. func (m *CategoryMutation) Type() string {
  5790. return m.typ
  5791. }
  5792. // Fields returns all fields that were changed during this mutation. Note that in
  5793. // order to get all numeric fields that were incremented/decremented, call
  5794. // AddedFields().
  5795. func (m *CategoryMutation) Fields() []string {
  5796. fields := make([]string, 0, 5)
  5797. if m.created_at != nil {
  5798. fields = append(fields, category.FieldCreatedAt)
  5799. }
  5800. if m.updated_at != nil {
  5801. fields = append(fields, category.FieldUpdatedAt)
  5802. }
  5803. if m.deleted_at != nil {
  5804. fields = append(fields, category.FieldDeletedAt)
  5805. }
  5806. if m.name != nil {
  5807. fields = append(fields, category.FieldName)
  5808. }
  5809. if m.organization_id != nil {
  5810. fields = append(fields, category.FieldOrganizationID)
  5811. }
  5812. return fields
  5813. }
  5814. // Field returns the value of a field with the given name. The second boolean
  5815. // return value indicates that this field was not set, or was not defined in the
  5816. // schema.
  5817. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5818. switch name {
  5819. case category.FieldCreatedAt:
  5820. return m.CreatedAt()
  5821. case category.FieldUpdatedAt:
  5822. return m.UpdatedAt()
  5823. case category.FieldDeletedAt:
  5824. return m.DeletedAt()
  5825. case category.FieldName:
  5826. return m.Name()
  5827. case category.FieldOrganizationID:
  5828. return m.OrganizationID()
  5829. }
  5830. return nil, false
  5831. }
  5832. // OldField returns the old value of the field from the database. An error is
  5833. // returned if the mutation operation is not UpdateOne, or the query to the
  5834. // database failed.
  5835. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5836. switch name {
  5837. case category.FieldCreatedAt:
  5838. return m.OldCreatedAt(ctx)
  5839. case category.FieldUpdatedAt:
  5840. return m.OldUpdatedAt(ctx)
  5841. case category.FieldDeletedAt:
  5842. return m.OldDeletedAt(ctx)
  5843. case category.FieldName:
  5844. return m.OldName(ctx)
  5845. case category.FieldOrganizationID:
  5846. return m.OldOrganizationID(ctx)
  5847. }
  5848. return nil, fmt.Errorf("unknown Category field %s", name)
  5849. }
  5850. // SetField sets the value of a field with the given name. It returns an error if
  5851. // the field is not defined in the schema, or if the type mismatched the field
  5852. // type.
  5853. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5854. switch name {
  5855. case category.FieldCreatedAt:
  5856. v, ok := value.(time.Time)
  5857. if !ok {
  5858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5859. }
  5860. m.SetCreatedAt(v)
  5861. return nil
  5862. case category.FieldUpdatedAt:
  5863. v, ok := value.(time.Time)
  5864. if !ok {
  5865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5866. }
  5867. m.SetUpdatedAt(v)
  5868. return nil
  5869. case category.FieldDeletedAt:
  5870. v, ok := value.(time.Time)
  5871. if !ok {
  5872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5873. }
  5874. m.SetDeletedAt(v)
  5875. return nil
  5876. case category.FieldName:
  5877. v, ok := value.(string)
  5878. if !ok {
  5879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5880. }
  5881. m.SetName(v)
  5882. return nil
  5883. case category.FieldOrganizationID:
  5884. v, ok := value.(uint64)
  5885. if !ok {
  5886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5887. }
  5888. m.SetOrganizationID(v)
  5889. return nil
  5890. }
  5891. return fmt.Errorf("unknown Category field %s", name)
  5892. }
  5893. // AddedFields returns all numeric fields that were incremented/decremented during
  5894. // this mutation.
  5895. func (m *CategoryMutation) AddedFields() []string {
  5896. var fields []string
  5897. if m.addorganization_id != nil {
  5898. fields = append(fields, category.FieldOrganizationID)
  5899. }
  5900. return fields
  5901. }
  5902. // AddedField returns the numeric value that was incremented/decremented on a field
  5903. // with the given name. The second boolean return value indicates that this field
  5904. // was not set, or was not defined in the schema.
  5905. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5906. switch name {
  5907. case category.FieldOrganizationID:
  5908. return m.AddedOrganizationID()
  5909. }
  5910. return nil, false
  5911. }
  5912. // AddField adds the value to the field with the given name. It returns an error if
  5913. // the field is not defined in the schema, or if the type mismatched the field
  5914. // type.
  5915. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5916. switch name {
  5917. case category.FieldOrganizationID:
  5918. v, ok := value.(int64)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.AddOrganizationID(v)
  5923. return nil
  5924. }
  5925. return fmt.Errorf("unknown Category numeric field %s", name)
  5926. }
  5927. // ClearedFields returns all nullable fields that were cleared during this
  5928. // mutation.
  5929. func (m *CategoryMutation) ClearedFields() []string {
  5930. var fields []string
  5931. if m.FieldCleared(category.FieldDeletedAt) {
  5932. fields = append(fields, category.FieldDeletedAt)
  5933. }
  5934. return fields
  5935. }
  5936. // FieldCleared returns a boolean indicating if a field with the given name was
  5937. // cleared in this mutation.
  5938. func (m *CategoryMutation) FieldCleared(name string) bool {
  5939. _, ok := m.clearedFields[name]
  5940. return ok
  5941. }
  5942. // ClearField clears the value of the field with the given name. It returns an
  5943. // error if the field is not defined in the schema.
  5944. func (m *CategoryMutation) ClearField(name string) error {
  5945. switch name {
  5946. case category.FieldDeletedAt:
  5947. m.ClearDeletedAt()
  5948. return nil
  5949. }
  5950. return fmt.Errorf("unknown Category nullable field %s", name)
  5951. }
  5952. // ResetField resets all changes in the mutation for the field with the given name.
  5953. // It returns an error if the field is not defined in the schema.
  5954. func (m *CategoryMutation) ResetField(name string) error {
  5955. switch name {
  5956. case category.FieldCreatedAt:
  5957. m.ResetCreatedAt()
  5958. return nil
  5959. case category.FieldUpdatedAt:
  5960. m.ResetUpdatedAt()
  5961. return nil
  5962. case category.FieldDeletedAt:
  5963. m.ResetDeletedAt()
  5964. return nil
  5965. case category.FieldName:
  5966. m.ResetName()
  5967. return nil
  5968. case category.FieldOrganizationID:
  5969. m.ResetOrganizationID()
  5970. return nil
  5971. }
  5972. return fmt.Errorf("unknown Category field %s", name)
  5973. }
  5974. // AddedEdges returns all edge names that were set/added in this mutation.
  5975. func (m *CategoryMutation) AddedEdges() []string {
  5976. edges := make([]string, 0, 0)
  5977. return edges
  5978. }
  5979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5980. // name in this mutation.
  5981. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5982. return nil
  5983. }
  5984. // RemovedEdges returns all edge names that were removed in this mutation.
  5985. func (m *CategoryMutation) RemovedEdges() []string {
  5986. edges := make([]string, 0, 0)
  5987. return edges
  5988. }
  5989. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5990. // the given name in this mutation.
  5991. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5992. return nil
  5993. }
  5994. // ClearedEdges returns all edge names that were cleared in this mutation.
  5995. func (m *CategoryMutation) ClearedEdges() []string {
  5996. edges := make([]string, 0, 0)
  5997. return edges
  5998. }
  5999. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6000. // was cleared in this mutation.
  6001. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6002. return false
  6003. }
  6004. // ClearEdge clears the value of the edge with the given name. It returns an error
  6005. // if that edge is not defined in the schema.
  6006. func (m *CategoryMutation) ClearEdge(name string) error {
  6007. return fmt.Errorf("unknown Category unique edge %s", name)
  6008. }
  6009. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6010. // It returns an error if the edge is not defined in the schema.
  6011. func (m *CategoryMutation) ResetEdge(name string) error {
  6012. return fmt.Errorf("unknown Category edge %s", name)
  6013. }
  6014. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6015. type ChatRecordsMutation struct {
  6016. config
  6017. op Op
  6018. typ string
  6019. id *uint64
  6020. created_at *time.Time
  6021. updated_at *time.Time
  6022. deleted_at *time.Time
  6023. content *string
  6024. content_type *uint8
  6025. addcontent_type *int8
  6026. session_id *uint64
  6027. addsession_id *int64
  6028. user_id *uint64
  6029. adduser_id *int64
  6030. bot_id *uint64
  6031. addbot_id *int64
  6032. bot_type *uint8
  6033. addbot_type *int8
  6034. clearedFields map[string]struct{}
  6035. done bool
  6036. oldValue func(context.Context) (*ChatRecords, error)
  6037. predicates []predicate.ChatRecords
  6038. }
  6039. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6040. // chatrecordsOption allows management of the mutation configuration using functional options.
  6041. type chatrecordsOption func(*ChatRecordsMutation)
  6042. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6043. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6044. m := &ChatRecordsMutation{
  6045. config: c,
  6046. op: op,
  6047. typ: TypeChatRecords,
  6048. clearedFields: make(map[string]struct{}),
  6049. }
  6050. for _, opt := range opts {
  6051. opt(m)
  6052. }
  6053. return m
  6054. }
  6055. // withChatRecordsID sets the ID field of the mutation.
  6056. func withChatRecordsID(id uint64) chatrecordsOption {
  6057. return func(m *ChatRecordsMutation) {
  6058. var (
  6059. err error
  6060. once sync.Once
  6061. value *ChatRecords
  6062. )
  6063. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6064. once.Do(func() {
  6065. if m.done {
  6066. err = errors.New("querying old values post mutation is not allowed")
  6067. } else {
  6068. value, err = m.Client().ChatRecords.Get(ctx, id)
  6069. }
  6070. })
  6071. return value, err
  6072. }
  6073. m.id = &id
  6074. }
  6075. }
  6076. // withChatRecords sets the old ChatRecords of the mutation.
  6077. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6078. return func(m *ChatRecordsMutation) {
  6079. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6080. return node, nil
  6081. }
  6082. m.id = &node.ID
  6083. }
  6084. }
  6085. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6086. // executed in a transaction (ent.Tx), a transactional client is returned.
  6087. func (m ChatRecordsMutation) Client() *Client {
  6088. client := &Client{config: m.config}
  6089. client.init()
  6090. return client
  6091. }
  6092. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6093. // it returns an error otherwise.
  6094. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6095. if _, ok := m.driver.(*txDriver); !ok {
  6096. return nil, errors.New("ent: mutation is not running in a transaction")
  6097. }
  6098. tx := &Tx{config: m.config}
  6099. tx.init()
  6100. return tx, nil
  6101. }
  6102. // SetID sets the value of the id field. Note that this
  6103. // operation is only accepted on creation of ChatRecords entities.
  6104. func (m *ChatRecordsMutation) SetID(id uint64) {
  6105. m.id = &id
  6106. }
  6107. // ID returns the ID value in the mutation. Note that the ID is only available
  6108. // if it was provided to the builder or after it was returned from the database.
  6109. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6110. if m.id == nil {
  6111. return
  6112. }
  6113. return *m.id, true
  6114. }
  6115. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6116. // That means, if the mutation is applied within a transaction with an isolation level such
  6117. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6118. // or updated by the mutation.
  6119. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6120. switch {
  6121. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6122. id, exists := m.ID()
  6123. if exists {
  6124. return []uint64{id}, nil
  6125. }
  6126. fallthrough
  6127. case m.op.Is(OpUpdate | OpDelete):
  6128. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6129. default:
  6130. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6131. }
  6132. }
  6133. // SetCreatedAt sets the "created_at" field.
  6134. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6135. m.created_at = &t
  6136. }
  6137. // CreatedAt returns the value of the "created_at" field in the mutation.
  6138. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6139. v := m.created_at
  6140. if v == nil {
  6141. return
  6142. }
  6143. return *v, true
  6144. }
  6145. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6146. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6148. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6149. if !m.op.Is(OpUpdateOne) {
  6150. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6151. }
  6152. if m.id == nil || m.oldValue == nil {
  6153. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6154. }
  6155. oldValue, err := m.oldValue(ctx)
  6156. if err != nil {
  6157. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6158. }
  6159. return oldValue.CreatedAt, nil
  6160. }
  6161. // ResetCreatedAt resets all changes to the "created_at" field.
  6162. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6163. m.created_at = nil
  6164. }
  6165. // SetUpdatedAt sets the "updated_at" field.
  6166. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6167. m.updated_at = &t
  6168. }
  6169. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6170. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6171. v := m.updated_at
  6172. if v == nil {
  6173. return
  6174. }
  6175. return *v, true
  6176. }
  6177. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6178. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6180. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6181. if !m.op.Is(OpUpdateOne) {
  6182. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6183. }
  6184. if m.id == nil || m.oldValue == nil {
  6185. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6186. }
  6187. oldValue, err := m.oldValue(ctx)
  6188. if err != nil {
  6189. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6190. }
  6191. return oldValue.UpdatedAt, nil
  6192. }
  6193. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6194. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6195. m.updated_at = nil
  6196. }
  6197. // SetDeletedAt sets the "deleted_at" field.
  6198. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6199. m.deleted_at = &t
  6200. }
  6201. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6202. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6203. v := m.deleted_at
  6204. if v == nil {
  6205. return
  6206. }
  6207. return *v, true
  6208. }
  6209. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6210. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6212. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6213. if !m.op.Is(OpUpdateOne) {
  6214. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6215. }
  6216. if m.id == nil || m.oldValue == nil {
  6217. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6218. }
  6219. oldValue, err := m.oldValue(ctx)
  6220. if err != nil {
  6221. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6222. }
  6223. return oldValue.DeletedAt, nil
  6224. }
  6225. // ClearDeletedAt clears the value of the "deleted_at" field.
  6226. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6227. m.deleted_at = nil
  6228. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6229. }
  6230. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6231. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6232. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6233. return ok
  6234. }
  6235. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6236. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6237. m.deleted_at = nil
  6238. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6239. }
  6240. // SetContent sets the "content" field.
  6241. func (m *ChatRecordsMutation) SetContent(s string) {
  6242. m.content = &s
  6243. }
  6244. // Content returns the value of the "content" field in the mutation.
  6245. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6246. v := m.content
  6247. if v == nil {
  6248. return
  6249. }
  6250. return *v, true
  6251. }
  6252. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6253. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6255. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6256. if !m.op.Is(OpUpdateOne) {
  6257. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6258. }
  6259. if m.id == nil || m.oldValue == nil {
  6260. return v, errors.New("OldContent requires an ID field in the mutation")
  6261. }
  6262. oldValue, err := m.oldValue(ctx)
  6263. if err != nil {
  6264. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6265. }
  6266. return oldValue.Content, nil
  6267. }
  6268. // ResetContent resets all changes to the "content" field.
  6269. func (m *ChatRecordsMutation) ResetContent() {
  6270. m.content = nil
  6271. }
  6272. // SetContentType sets the "content_type" field.
  6273. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6274. m.content_type = &u
  6275. m.addcontent_type = nil
  6276. }
  6277. // ContentType returns the value of the "content_type" field in the mutation.
  6278. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6279. v := m.content_type
  6280. if v == nil {
  6281. return
  6282. }
  6283. return *v, true
  6284. }
  6285. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6286. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6288. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6289. if !m.op.Is(OpUpdateOne) {
  6290. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6291. }
  6292. if m.id == nil || m.oldValue == nil {
  6293. return v, errors.New("OldContentType requires an ID field in the mutation")
  6294. }
  6295. oldValue, err := m.oldValue(ctx)
  6296. if err != nil {
  6297. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6298. }
  6299. return oldValue.ContentType, nil
  6300. }
  6301. // AddContentType adds u to the "content_type" field.
  6302. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6303. if m.addcontent_type != nil {
  6304. *m.addcontent_type += u
  6305. } else {
  6306. m.addcontent_type = &u
  6307. }
  6308. }
  6309. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6310. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6311. v := m.addcontent_type
  6312. if v == nil {
  6313. return
  6314. }
  6315. return *v, true
  6316. }
  6317. // ResetContentType resets all changes to the "content_type" field.
  6318. func (m *ChatRecordsMutation) ResetContentType() {
  6319. m.content_type = nil
  6320. m.addcontent_type = nil
  6321. }
  6322. // SetSessionID sets the "session_id" field.
  6323. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6324. m.session_id = &u
  6325. m.addsession_id = nil
  6326. }
  6327. // SessionID returns the value of the "session_id" field in the mutation.
  6328. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6329. v := m.session_id
  6330. if v == nil {
  6331. return
  6332. }
  6333. return *v, true
  6334. }
  6335. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6336. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6338. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6339. if !m.op.Is(OpUpdateOne) {
  6340. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6341. }
  6342. if m.id == nil || m.oldValue == nil {
  6343. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6344. }
  6345. oldValue, err := m.oldValue(ctx)
  6346. if err != nil {
  6347. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6348. }
  6349. return oldValue.SessionID, nil
  6350. }
  6351. // AddSessionID adds u to the "session_id" field.
  6352. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6353. if m.addsession_id != nil {
  6354. *m.addsession_id += u
  6355. } else {
  6356. m.addsession_id = &u
  6357. }
  6358. }
  6359. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6360. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6361. v := m.addsession_id
  6362. if v == nil {
  6363. return
  6364. }
  6365. return *v, true
  6366. }
  6367. // ResetSessionID resets all changes to the "session_id" field.
  6368. func (m *ChatRecordsMutation) ResetSessionID() {
  6369. m.session_id = nil
  6370. m.addsession_id = nil
  6371. }
  6372. // SetUserID sets the "user_id" field.
  6373. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6374. m.user_id = &u
  6375. m.adduser_id = nil
  6376. }
  6377. // UserID returns the value of the "user_id" field in the mutation.
  6378. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6379. v := m.user_id
  6380. if v == nil {
  6381. return
  6382. }
  6383. return *v, true
  6384. }
  6385. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6386. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6388. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6389. if !m.op.Is(OpUpdateOne) {
  6390. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6391. }
  6392. if m.id == nil || m.oldValue == nil {
  6393. return v, errors.New("OldUserID requires an ID field in the mutation")
  6394. }
  6395. oldValue, err := m.oldValue(ctx)
  6396. if err != nil {
  6397. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6398. }
  6399. return oldValue.UserID, nil
  6400. }
  6401. // AddUserID adds u to the "user_id" field.
  6402. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6403. if m.adduser_id != nil {
  6404. *m.adduser_id += u
  6405. } else {
  6406. m.adduser_id = &u
  6407. }
  6408. }
  6409. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6410. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6411. v := m.adduser_id
  6412. if v == nil {
  6413. return
  6414. }
  6415. return *v, true
  6416. }
  6417. // ResetUserID resets all changes to the "user_id" field.
  6418. func (m *ChatRecordsMutation) ResetUserID() {
  6419. m.user_id = nil
  6420. m.adduser_id = nil
  6421. }
  6422. // SetBotID sets the "bot_id" field.
  6423. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6424. m.bot_id = &u
  6425. m.addbot_id = nil
  6426. }
  6427. // BotID returns the value of the "bot_id" field in the mutation.
  6428. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6429. v := m.bot_id
  6430. if v == nil {
  6431. return
  6432. }
  6433. return *v, true
  6434. }
  6435. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6436. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6438. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6439. if !m.op.Is(OpUpdateOne) {
  6440. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6441. }
  6442. if m.id == nil || m.oldValue == nil {
  6443. return v, errors.New("OldBotID requires an ID field in the mutation")
  6444. }
  6445. oldValue, err := m.oldValue(ctx)
  6446. if err != nil {
  6447. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6448. }
  6449. return oldValue.BotID, nil
  6450. }
  6451. // AddBotID adds u to the "bot_id" field.
  6452. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6453. if m.addbot_id != nil {
  6454. *m.addbot_id += u
  6455. } else {
  6456. m.addbot_id = &u
  6457. }
  6458. }
  6459. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6460. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6461. v := m.addbot_id
  6462. if v == nil {
  6463. return
  6464. }
  6465. return *v, true
  6466. }
  6467. // ResetBotID resets all changes to the "bot_id" field.
  6468. func (m *ChatRecordsMutation) ResetBotID() {
  6469. m.bot_id = nil
  6470. m.addbot_id = nil
  6471. }
  6472. // SetBotType sets the "bot_type" field.
  6473. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6474. m.bot_type = &u
  6475. m.addbot_type = nil
  6476. }
  6477. // BotType returns the value of the "bot_type" field in the mutation.
  6478. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6479. v := m.bot_type
  6480. if v == nil {
  6481. return
  6482. }
  6483. return *v, true
  6484. }
  6485. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6486. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6488. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6489. if !m.op.Is(OpUpdateOne) {
  6490. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6491. }
  6492. if m.id == nil || m.oldValue == nil {
  6493. return v, errors.New("OldBotType requires an ID field in the mutation")
  6494. }
  6495. oldValue, err := m.oldValue(ctx)
  6496. if err != nil {
  6497. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6498. }
  6499. return oldValue.BotType, nil
  6500. }
  6501. // AddBotType adds u to the "bot_type" field.
  6502. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6503. if m.addbot_type != nil {
  6504. *m.addbot_type += u
  6505. } else {
  6506. m.addbot_type = &u
  6507. }
  6508. }
  6509. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6510. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6511. v := m.addbot_type
  6512. if v == nil {
  6513. return
  6514. }
  6515. return *v, true
  6516. }
  6517. // ResetBotType resets all changes to the "bot_type" field.
  6518. func (m *ChatRecordsMutation) ResetBotType() {
  6519. m.bot_type = nil
  6520. m.addbot_type = nil
  6521. }
  6522. // Where appends a list predicates to the ChatRecordsMutation builder.
  6523. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6524. m.predicates = append(m.predicates, ps...)
  6525. }
  6526. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6527. // users can use type-assertion to append predicates that do not depend on any generated package.
  6528. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6529. p := make([]predicate.ChatRecords, len(ps))
  6530. for i := range ps {
  6531. p[i] = ps[i]
  6532. }
  6533. m.Where(p...)
  6534. }
  6535. // Op returns the operation name.
  6536. func (m *ChatRecordsMutation) Op() Op {
  6537. return m.op
  6538. }
  6539. // SetOp allows setting the mutation operation.
  6540. func (m *ChatRecordsMutation) SetOp(op Op) {
  6541. m.op = op
  6542. }
  6543. // Type returns the node type of this mutation (ChatRecords).
  6544. func (m *ChatRecordsMutation) Type() string {
  6545. return m.typ
  6546. }
  6547. // Fields returns all fields that were changed during this mutation. Note that in
  6548. // order to get all numeric fields that were incremented/decremented, call
  6549. // AddedFields().
  6550. func (m *ChatRecordsMutation) Fields() []string {
  6551. fields := make([]string, 0, 9)
  6552. if m.created_at != nil {
  6553. fields = append(fields, chatrecords.FieldCreatedAt)
  6554. }
  6555. if m.updated_at != nil {
  6556. fields = append(fields, chatrecords.FieldUpdatedAt)
  6557. }
  6558. if m.deleted_at != nil {
  6559. fields = append(fields, chatrecords.FieldDeletedAt)
  6560. }
  6561. if m.content != nil {
  6562. fields = append(fields, chatrecords.FieldContent)
  6563. }
  6564. if m.content_type != nil {
  6565. fields = append(fields, chatrecords.FieldContentType)
  6566. }
  6567. if m.session_id != nil {
  6568. fields = append(fields, chatrecords.FieldSessionID)
  6569. }
  6570. if m.user_id != nil {
  6571. fields = append(fields, chatrecords.FieldUserID)
  6572. }
  6573. if m.bot_id != nil {
  6574. fields = append(fields, chatrecords.FieldBotID)
  6575. }
  6576. if m.bot_type != nil {
  6577. fields = append(fields, chatrecords.FieldBotType)
  6578. }
  6579. return fields
  6580. }
  6581. // Field returns the value of a field with the given name. The second boolean
  6582. // return value indicates that this field was not set, or was not defined in the
  6583. // schema.
  6584. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6585. switch name {
  6586. case chatrecords.FieldCreatedAt:
  6587. return m.CreatedAt()
  6588. case chatrecords.FieldUpdatedAt:
  6589. return m.UpdatedAt()
  6590. case chatrecords.FieldDeletedAt:
  6591. return m.DeletedAt()
  6592. case chatrecords.FieldContent:
  6593. return m.Content()
  6594. case chatrecords.FieldContentType:
  6595. return m.ContentType()
  6596. case chatrecords.FieldSessionID:
  6597. return m.SessionID()
  6598. case chatrecords.FieldUserID:
  6599. return m.UserID()
  6600. case chatrecords.FieldBotID:
  6601. return m.BotID()
  6602. case chatrecords.FieldBotType:
  6603. return m.BotType()
  6604. }
  6605. return nil, false
  6606. }
  6607. // OldField returns the old value of the field from the database. An error is
  6608. // returned if the mutation operation is not UpdateOne, or the query to the
  6609. // database failed.
  6610. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6611. switch name {
  6612. case chatrecords.FieldCreatedAt:
  6613. return m.OldCreatedAt(ctx)
  6614. case chatrecords.FieldUpdatedAt:
  6615. return m.OldUpdatedAt(ctx)
  6616. case chatrecords.FieldDeletedAt:
  6617. return m.OldDeletedAt(ctx)
  6618. case chatrecords.FieldContent:
  6619. return m.OldContent(ctx)
  6620. case chatrecords.FieldContentType:
  6621. return m.OldContentType(ctx)
  6622. case chatrecords.FieldSessionID:
  6623. return m.OldSessionID(ctx)
  6624. case chatrecords.FieldUserID:
  6625. return m.OldUserID(ctx)
  6626. case chatrecords.FieldBotID:
  6627. return m.OldBotID(ctx)
  6628. case chatrecords.FieldBotType:
  6629. return m.OldBotType(ctx)
  6630. }
  6631. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6632. }
  6633. // SetField sets the value of a field with the given name. It returns an error if
  6634. // the field is not defined in the schema, or if the type mismatched the field
  6635. // type.
  6636. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6637. switch name {
  6638. case chatrecords.FieldCreatedAt:
  6639. v, ok := value.(time.Time)
  6640. if !ok {
  6641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6642. }
  6643. m.SetCreatedAt(v)
  6644. return nil
  6645. case chatrecords.FieldUpdatedAt:
  6646. v, ok := value.(time.Time)
  6647. if !ok {
  6648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6649. }
  6650. m.SetUpdatedAt(v)
  6651. return nil
  6652. case chatrecords.FieldDeletedAt:
  6653. v, ok := value.(time.Time)
  6654. if !ok {
  6655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6656. }
  6657. m.SetDeletedAt(v)
  6658. return nil
  6659. case chatrecords.FieldContent:
  6660. v, ok := value.(string)
  6661. if !ok {
  6662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6663. }
  6664. m.SetContent(v)
  6665. return nil
  6666. case chatrecords.FieldContentType:
  6667. v, ok := value.(uint8)
  6668. if !ok {
  6669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6670. }
  6671. m.SetContentType(v)
  6672. return nil
  6673. case chatrecords.FieldSessionID:
  6674. v, ok := value.(uint64)
  6675. if !ok {
  6676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6677. }
  6678. m.SetSessionID(v)
  6679. return nil
  6680. case chatrecords.FieldUserID:
  6681. v, ok := value.(uint64)
  6682. if !ok {
  6683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6684. }
  6685. m.SetUserID(v)
  6686. return nil
  6687. case chatrecords.FieldBotID:
  6688. v, ok := value.(uint64)
  6689. if !ok {
  6690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6691. }
  6692. m.SetBotID(v)
  6693. return nil
  6694. case chatrecords.FieldBotType:
  6695. v, ok := value.(uint8)
  6696. if !ok {
  6697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6698. }
  6699. m.SetBotType(v)
  6700. return nil
  6701. }
  6702. return fmt.Errorf("unknown ChatRecords field %s", name)
  6703. }
  6704. // AddedFields returns all numeric fields that were incremented/decremented during
  6705. // this mutation.
  6706. func (m *ChatRecordsMutation) AddedFields() []string {
  6707. var fields []string
  6708. if m.addcontent_type != nil {
  6709. fields = append(fields, chatrecords.FieldContentType)
  6710. }
  6711. if m.addsession_id != nil {
  6712. fields = append(fields, chatrecords.FieldSessionID)
  6713. }
  6714. if m.adduser_id != nil {
  6715. fields = append(fields, chatrecords.FieldUserID)
  6716. }
  6717. if m.addbot_id != nil {
  6718. fields = append(fields, chatrecords.FieldBotID)
  6719. }
  6720. if m.addbot_type != nil {
  6721. fields = append(fields, chatrecords.FieldBotType)
  6722. }
  6723. return fields
  6724. }
  6725. // AddedField returns the numeric value that was incremented/decremented on a field
  6726. // with the given name. The second boolean return value indicates that this field
  6727. // was not set, or was not defined in the schema.
  6728. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6729. switch name {
  6730. case chatrecords.FieldContentType:
  6731. return m.AddedContentType()
  6732. case chatrecords.FieldSessionID:
  6733. return m.AddedSessionID()
  6734. case chatrecords.FieldUserID:
  6735. return m.AddedUserID()
  6736. case chatrecords.FieldBotID:
  6737. return m.AddedBotID()
  6738. case chatrecords.FieldBotType:
  6739. return m.AddedBotType()
  6740. }
  6741. return nil, false
  6742. }
  6743. // AddField adds the value to the field with the given name. It returns an error if
  6744. // the field is not defined in the schema, or if the type mismatched the field
  6745. // type.
  6746. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6747. switch name {
  6748. case chatrecords.FieldContentType:
  6749. v, ok := value.(int8)
  6750. if !ok {
  6751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6752. }
  6753. m.AddContentType(v)
  6754. return nil
  6755. case chatrecords.FieldSessionID:
  6756. v, ok := value.(int64)
  6757. if !ok {
  6758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6759. }
  6760. m.AddSessionID(v)
  6761. return nil
  6762. case chatrecords.FieldUserID:
  6763. v, ok := value.(int64)
  6764. if !ok {
  6765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6766. }
  6767. m.AddUserID(v)
  6768. return nil
  6769. case chatrecords.FieldBotID:
  6770. v, ok := value.(int64)
  6771. if !ok {
  6772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6773. }
  6774. m.AddBotID(v)
  6775. return nil
  6776. case chatrecords.FieldBotType:
  6777. v, ok := value.(int8)
  6778. if !ok {
  6779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6780. }
  6781. m.AddBotType(v)
  6782. return nil
  6783. }
  6784. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6785. }
  6786. // ClearedFields returns all nullable fields that were cleared during this
  6787. // mutation.
  6788. func (m *ChatRecordsMutation) ClearedFields() []string {
  6789. var fields []string
  6790. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6791. fields = append(fields, chatrecords.FieldDeletedAt)
  6792. }
  6793. return fields
  6794. }
  6795. // FieldCleared returns a boolean indicating if a field with the given name was
  6796. // cleared in this mutation.
  6797. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6798. _, ok := m.clearedFields[name]
  6799. return ok
  6800. }
  6801. // ClearField clears the value of the field with the given name. It returns an
  6802. // error if the field is not defined in the schema.
  6803. func (m *ChatRecordsMutation) ClearField(name string) error {
  6804. switch name {
  6805. case chatrecords.FieldDeletedAt:
  6806. m.ClearDeletedAt()
  6807. return nil
  6808. }
  6809. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6810. }
  6811. // ResetField resets all changes in the mutation for the field with the given name.
  6812. // It returns an error if the field is not defined in the schema.
  6813. func (m *ChatRecordsMutation) ResetField(name string) error {
  6814. switch name {
  6815. case chatrecords.FieldCreatedAt:
  6816. m.ResetCreatedAt()
  6817. return nil
  6818. case chatrecords.FieldUpdatedAt:
  6819. m.ResetUpdatedAt()
  6820. return nil
  6821. case chatrecords.FieldDeletedAt:
  6822. m.ResetDeletedAt()
  6823. return nil
  6824. case chatrecords.FieldContent:
  6825. m.ResetContent()
  6826. return nil
  6827. case chatrecords.FieldContentType:
  6828. m.ResetContentType()
  6829. return nil
  6830. case chatrecords.FieldSessionID:
  6831. m.ResetSessionID()
  6832. return nil
  6833. case chatrecords.FieldUserID:
  6834. m.ResetUserID()
  6835. return nil
  6836. case chatrecords.FieldBotID:
  6837. m.ResetBotID()
  6838. return nil
  6839. case chatrecords.FieldBotType:
  6840. m.ResetBotType()
  6841. return nil
  6842. }
  6843. return fmt.Errorf("unknown ChatRecords field %s", name)
  6844. }
  6845. // AddedEdges returns all edge names that were set/added in this mutation.
  6846. func (m *ChatRecordsMutation) AddedEdges() []string {
  6847. edges := make([]string, 0, 0)
  6848. return edges
  6849. }
  6850. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6851. // name in this mutation.
  6852. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6853. return nil
  6854. }
  6855. // RemovedEdges returns all edge names that were removed in this mutation.
  6856. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6857. edges := make([]string, 0, 0)
  6858. return edges
  6859. }
  6860. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6861. // the given name in this mutation.
  6862. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6863. return nil
  6864. }
  6865. // ClearedEdges returns all edge names that were cleared in this mutation.
  6866. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6867. edges := make([]string, 0, 0)
  6868. return edges
  6869. }
  6870. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6871. // was cleared in this mutation.
  6872. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6873. return false
  6874. }
  6875. // ClearEdge clears the value of the edge with the given name. It returns an error
  6876. // if that edge is not defined in the schema.
  6877. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6878. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6879. }
  6880. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6881. // It returns an error if the edge is not defined in the schema.
  6882. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6883. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6884. }
  6885. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6886. type ChatSessionMutation struct {
  6887. config
  6888. op Op
  6889. typ string
  6890. id *uint64
  6891. created_at *time.Time
  6892. updated_at *time.Time
  6893. deleted_at *time.Time
  6894. name *string
  6895. user_id *uint64
  6896. adduser_id *int64
  6897. bot_id *uint64
  6898. addbot_id *int64
  6899. bot_type *uint8
  6900. addbot_type *int8
  6901. clearedFields map[string]struct{}
  6902. done bool
  6903. oldValue func(context.Context) (*ChatSession, error)
  6904. predicates []predicate.ChatSession
  6905. }
  6906. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6907. // chatsessionOption allows management of the mutation configuration using functional options.
  6908. type chatsessionOption func(*ChatSessionMutation)
  6909. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6910. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6911. m := &ChatSessionMutation{
  6912. config: c,
  6913. op: op,
  6914. typ: TypeChatSession,
  6915. clearedFields: make(map[string]struct{}),
  6916. }
  6917. for _, opt := range opts {
  6918. opt(m)
  6919. }
  6920. return m
  6921. }
  6922. // withChatSessionID sets the ID field of the mutation.
  6923. func withChatSessionID(id uint64) chatsessionOption {
  6924. return func(m *ChatSessionMutation) {
  6925. var (
  6926. err error
  6927. once sync.Once
  6928. value *ChatSession
  6929. )
  6930. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6931. once.Do(func() {
  6932. if m.done {
  6933. err = errors.New("querying old values post mutation is not allowed")
  6934. } else {
  6935. value, err = m.Client().ChatSession.Get(ctx, id)
  6936. }
  6937. })
  6938. return value, err
  6939. }
  6940. m.id = &id
  6941. }
  6942. }
  6943. // withChatSession sets the old ChatSession of the mutation.
  6944. func withChatSession(node *ChatSession) chatsessionOption {
  6945. return func(m *ChatSessionMutation) {
  6946. m.oldValue = func(context.Context) (*ChatSession, error) {
  6947. return node, nil
  6948. }
  6949. m.id = &node.ID
  6950. }
  6951. }
  6952. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6953. // executed in a transaction (ent.Tx), a transactional client is returned.
  6954. func (m ChatSessionMutation) Client() *Client {
  6955. client := &Client{config: m.config}
  6956. client.init()
  6957. return client
  6958. }
  6959. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6960. // it returns an error otherwise.
  6961. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6962. if _, ok := m.driver.(*txDriver); !ok {
  6963. return nil, errors.New("ent: mutation is not running in a transaction")
  6964. }
  6965. tx := &Tx{config: m.config}
  6966. tx.init()
  6967. return tx, nil
  6968. }
  6969. // SetID sets the value of the id field. Note that this
  6970. // operation is only accepted on creation of ChatSession entities.
  6971. func (m *ChatSessionMutation) SetID(id uint64) {
  6972. m.id = &id
  6973. }
  6974. // ID returns the ID value in the mutation. Note that the ID is only available
  6975. // if it was provided to the builder or after it was returned from the database.
  6976. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6977. if m.id == nil {
  6978. return
  6979. }
  6980. return *m.id, true
  6981. }
  6982. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6983. // That means, if the mutation is applied within a transaction with an isolation level such
  6984. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6985. // or updated by the mutation.
  6986. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6987. switch {
  6988. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6989. id, exists := m.ID()
  6990. if exists {
  6991. return []uint64{id}, nil
  6992. }
  6993. fallthrough
  6994. case m.op.Is(OpUpdate | OpDelete):
  6995. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6996. default:
  6997. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6998. }
  6999. }
  7000. // SetCreatedAt sets the "created_at" field.
  7001. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7002. m.created_at = &t
  7003. }
  7004. // CreatedAt returns the value of the "created_at" field in the mutation.
  7005. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7006. v := m.created_at
  7007. if v == nil {
  7008. return
  7009. }
  7010. return *v, true
  7011. }
  7012. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7013. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7015. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7016. if !m.op.Is(OpUpdateOne) {
  7017. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7018. }
  7019. if m.id == nil || m.oldValue == nil {
  7020. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7021. }
  7022. oldValue, err := m.oldValue(ctx)
  7023. if err != nil {
  7024. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7025. }
  7026. return oldValue.CreatedAt, nil
  7027. }
  7028. // ResetCreatedAt resets all changes to the "created_at" field.
  7029. func (m *ChatSessionMutation) ResetCreatedAt() {
  7030. m.created_at = nil
  7031. }
  7032. // SetUpdatedAt sets the "updated_at" field.
  7033. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7034. m.updated_at = &t
  7035. }
  7036. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7037. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7038. v := m.updated_at
  7039. if v == nil {
  7040. return
  7041. }
  7042. return *v, true
  7043. }
  7044. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7045. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7047. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7048. if !m.op.Is(OpUpdateOne) {
  7049. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7050. }
  7051. if m.id == nil || m.oldValue == nil {
  7052. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7053. }
  7054. oldValue, err := m.oldValue(ctx)
  7055. if err != nil {
  7056. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7057. }
  7058. return oldValue.UpdatedAt, nil
  7059. }
  7060. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7061. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7062. m.updated_at = nil
  7063. }
  7064. // SetDeletedAt sets the "deleted_at" field.
  7065. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7066. m.deleted_at = &t
  7067. }
  7068. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7069. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7070. v := m.deleted_at
  7071. if v == nil {
  7072. return
  7073. }
  7074. return *v, true
  7075. }
  7076. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7077. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7079. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7080. if !m.op.Is(OpUpdateOne) {
  7081. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7082. }
  7083. if m.id == nil || m.oldValue == nil {
  7084. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7085. }
  7086. oldValue, err := m.oldValue(ctx)
  7087. if err != nil {
  7088. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7089. }
  7090. return oldValue.DeletedAt, nil
  7091. }
  7092. // ClearDeletedAt clears the value of the "deleted_at" field.
  7093. func (m *ChatSessionMutation) ClearDeletedAt() {
  7094. m.deleted_at = nil
  7095. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7096. }
  7097. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7098. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7099. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7100. return ok
  7101. }
  7102. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7103. func (m *ChatSessionMutation) ResetDeletedAt() {
  7104. m.deleted_at = nil
  7105. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7106. }
  7107. // SetName sets the "name" field.
  7108. func (m *ChatSessionMutation) SetName(s string) {
  7109. m.name = &s
  7110. }
  7111. // Name returns the value of the "name" field in the mutation.
  7112. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7113. v := m.name
  7114. if v == nil {
  7115. return
  7116. }
  7117. return *v, true
  7118. }
  7119. // OldName returns the old "name" field's value of the ChatSession entity.
  7120. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7122. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7123. if !m.op.Is(OpUpdateOne) {
  7124. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7125. }
  7126. if m.id == nil || m.oldValue == nil {
  7127. return v, errors.New("OldName requires an ID field in the mutation")
  7128. }
  7129. oldValue, err := m.oldValue(ctx)
  7130. if err != nil {
  7131. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7132. }
  7133. return oldValue.Name, nil
  7134. }
  7135. // ResetName resets all changes to the "name" field.
  7136. func (m *ChatSessionMutation) ResetName() {
  7137. m.name = nil
  7138. }
  7139. // SetUserID sets the "user_id" field.
  7140. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7141. m.user_id = &u
  7142. m.adduser_id = nil
  7143. }
  7144. // UserID returns the value of the "user_id" field in the mutation.
  7145. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7146. v := m.user_id
  7147. if v == nil {
  7148. return
  7149. }
  7150. return *v, true
  7151. }
  7152. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7153. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7155. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7156. if !m.op.Is(OpUpdateOne) {
  7157. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7158. }
  7159. if m.id == nil || m.oldValue == nil {
  7160. return v, errors.New("OldUserID requires an ID field in the mutation")
  7161. }
  7162. oldValue, err := m.oldValue(ctx)
  7163. if err != nil {
  7164. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7165. }
  7166. return oldValue.UserID, nil
  7167. }
  7168. // AddUserID adds u to the "user_id" field.
  7169. func (m *ChatSessionMutation) AddUserID(u int64) {
  7170. if m.adduser_id != nil {
  7171. *m.adduser_id += u
  7172. } else {
  7173. m.adduser_id = &u
  7174. }
  7175. }
  7176. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7177. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7178. v := m.adduser_id
  7179. if v == nil {
  7180. return
  7181. }
  7182. return *v, true
  7183. }
  7184. // ResetUserID resets all changes to the "user_id" field.
  7185. func (m *ChatSessionMutation) ResetUserID() {
  7186. m.user_id = nil
  7187. m.adduser_id = nil
  7188. }
  7189. // SetBotID sets the "bot_id" field.
  7190. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7191. m.bot_id = &u
  7192. m.addbot_id = nil
  7193. }
  7194. // BotID returns the value of the "bot_id" field in the mutation.
  7195. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7196. v := m.bot_id
  7197. if v == nil {
  7198. return
  7199. }
  7200. return *v, true
  7201. }
  7202. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7203. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7205. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7206. if !m.op.Is(OpUpdateOne) {
  7207. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7208. }
  7209. if m.id == nil || m.oldValue == nil {
  7210. return v, errors.New("OldBotID requires an ID field in the mutation")
  7211. }
  7212. oldValue, err := m.oldValue(ctx)
  7213. if err != nil {
  7214. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7215. }
  7216. return oldValue.BotID, nil
  7217. }
  7218. // AddBotID adds u to the "bot_id" field.
  7219. func (m *ChatSessionMutation) AddBotID(u int64) {
  7220. if m.addbot_id != nil {
  7221. *m.addbot_id += u
  7222. } else {
  7223. m.addbot_id = &u
  7224. }
  7225. }
  7226. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7227. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7228. v := m.addbot_id
  7229. if v == nil {
  7230. return
  7231. }
  7232. return *v, true
  7233. }
  7234. // ResetBotID resets all changes to the "bot_id" field.
  7235. func (m *ChatSessionMutation) ResetBotID() {
  7236. m.bot_id = nil
  7237. m.addbot_id = nil
  7238. }
  7239. // SetBotType sets the "bot_type" field.
  7240. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7241. m.bot_type = &u
  7242. m.addbot_type = nil
  7243. }
  7244. // BotType returns the value of the "bot_type" field in the mutation.
  7245. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7246. v := m.bot_type
  7247. if v == nil {
  7248. return
  7249. }
  7250. return *v, true
  7251. }
  7252. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7253. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7255. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7256. if !m.op.Is(OpUpdateOne) {
  7257. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7258. }
  7259. if m.id == nil || m.oldValue == nil {
  7260. return v, errors.New("OldBotType requires an ID field in the mutation")
  7261. }
  7262. oldValue, err := m.oldValue(ctx)
  7263. if err != nil {
  7264. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7265. }
  7266. return oldValue.BotType, nil
  7267. }
  7268. // AddBotType adds u to the "bot_type" field.
  7269. func (m *ChatSessionMutation) AddBotType(u int8) {
  7270. if m.addbot_type != nil {
  7271. *m.addbot_type += u
  7272. } else {
  7273. m.addbot_type = &u
  7274. }
  7275. }
  7276. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7277. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7278. v := m.addbot_type
  7279. if v == nil {
  7280. return
  7281. }
  7282. return *v, true
  7283. }
  7284. // ResetBotType resets all changes to the "bot_type" field.
  7285. func (m *ChatSessionMutation) ResetBotType() {
  7286. m.bot_type = nil
  7287. m.addbot_type = nil
  7288. }
  7289. // Where appends a list predicates to the ChatSessionMutation builder.
  7290. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7291. m.predicates = append(m.predicates, ps...)
  7292. }
  7293. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7294. // users can use type-assertion to append predicates that do not depend on any generated package.
  7295. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7296. p := make([]predicate.ChatSession, len(ps))
  7297. for i := range ps {
  7298. p[i] = ps[i]
  7299. }
  7300. m.Where(p...)
  7301. }
  7302. // Op returns the operation name.
  7303. func (m *ChatSessionMutation) Op() Op {
  7304. return m.op
  7305. }
  7306. // SetOp allows setting the mutation operation.
  7307. func (m *ChatSessionMutation) SetOp(op Op) {
  7308. m.op = op
  7309. }
  7310. // Type returns the node type of this mutation (ChatSession).
  7311. func (m *ChatSessionMutation) Type() string {
  7312. return m.typ
  7313. }
  7314. // Fields returns all fields that were changed during this mutation. Note that in
  7315. // order to get all numeric fields that were incremented/decremented, call
  7316. // AddedFields().
  7317. func (m *ChatSessionMutation) Fields() []string {
  7318. fields := make([]string, 0, 7)
  7319. if m.created_at != nil {
  7320. fields = append(fields, chatsession.FieldCreatedAt)
  7321. }
  7322. if m.updated_at != nil {
  7323. fields = append(fields, chatsession.FieldUpdatedAt)
  7324. }
  7325. if m.deleted_at != nil {
  7326. fields = append(fields, chatsession.FieldDeletedAt)
  7327. }
  7328. if m.name != nil {
  7329. fields = append(fields, chatsession.FieldName)
  7330. }
  7331. if m.user_id != nil {
  7332. fields = append(fields, chatsession.FieldUserID)
  7333. }
  7334. if m.bot_id != nil {
  7335. fields = append(fields, chatsession.FieldBotID)
  7336. }
  7337. if m.bot_type != nil {
  7338. fields = append(fields, chatsession.FieldBotType)
  7339. }
  7340. return fields
  7341. }
  7342. // Field returns the value of a field with the given name. The second boolean
  7343. // return value indicates that this field was not set, or was not defined in the
  7344. // schema.
  7345. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7346. switch name {
  7347. case chatsession.FieldCreatedAt:
  7348. return m.CreatedAt()
  7349. case chatsession.FieldUpdatedAt:
  7350. return m.UpdatedAt()
  7351. case chatsession.FieldDeletedAt:
  7352. return m.DeletedAt()
  7353. case chatsession.FieldName:
  7354. return m.Name()
  7355. case chatsession.FieldUserID:
  7356. return m.UserID()
  7357. case chatsession.FieldBotID:
  7358. return m.BotID()
  7359. case chatsession.FieldBotType:
  7360. return m.BotType()
  7361. }
  7362. return nil, false
  7363. }
  7364. // OldField returns the old value of the field from the database. An error is
  7365. // returned if the mutation operation is not UpdateOne, or the query to the
  7366. // database failed.
  7367. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7368. switch name {
  7369. case chatsession.FieldCreatedAt:
  7370. return m.OldCreatedAt(ctx)
  7371. case chatsession.FieldUpdatedAt:
  7372. return m.OldUpdatedAt(ctx)
  7373. case chatsession.FieldDeletedAt:
  7374. return m.OldDeletedAt(ctx)
  7375. case chatsession.FieldName:
  7376. return m.OldName(ctx)
  7377. case chatsession.FieldUserID:
  7378. return m.OldUserID(ctx)
  7379. case chatsession.FieldBotID:
  7380. return m.OldBotID(ctx)
  7381. case chatsession.FieldBotType:
  7382. return m.OldBotType(ctx)
  7383. }
  7384. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7385. }
  7386. // SetField sets the value of a field with the given name. It returns an error if
  7387. // the field is not defined in the schema, or if the type mismatched the field
  7388. // type.
  7389. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7390. switch name {
  7391. case chatsession.FieldCreatedAt:
  7392. v, ok := value.(time.Time)
  7393. if !ok {
  7394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7395. }
  7396. m.SetCreatedAt(v)
  7397. return nil
  7398. case chatsession.FieldUpdatedAt:
  7399. v, ok := value.(time.Time)
  7400. if !ok {
  7401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7402. }
  7403. m.SetUpdatedAt(v)
  7404. return nil
  7405. case chatsession.FieldDeletedAt:
  7406. v, ok := value.(time.Time)
  7407. if !ok {
  7408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7409. }
  7410. m.SetDeletedAt(v)
  7411. return nil
  7412. case chatsession.FieldName:
  7413. v, ok := value.(string)
  7414. if !ok {
  7415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7416. }
  7417. m.SetName(v)
  7418. return nil
  7419. case chatsession.FieldUserID:
  7420. v, ok := value.(uint64)
  7421. if !ok {
  7422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7423. }
  7424. m.SetUserID(v)
  7425. return nil
  7426. case chatsession.FieldBotID:
  7427. v, ok := value.(uint64)
  7428. if !ok {
  7429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7430. }
  7431. m.SetBotID(v)
  7432. return nil
  7433. case chatsession.FieldBotType:
  7434. v, ok := value.(uint8)
  7435. if !ok {
  7436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7437. }
  7438. m.SetBotType(v)
  7439. return nil
  7440. }
  7441. return fmt.Errorf("unknown ChatSession field %s", name)
  7442. }
  7443. // AddedFields returns all numeric fields that were incremented/decremented during
  7444. // this mutation.
  7445. func (m *ChatSessionMutation) AddedFields() []string {
  7446. var fields []string
  7447. if m.adduser_id != nil {
  7448. fields = append(fields, chatsession.FieldUserID)
  7449. }
  7450. if m.addbot_id != nil {
  7451. fields = append(fields, chatsession.FieldBotID)
  7452. }
  7453. if m.addbot_type != nil {
  7454. fields = append(fields, chatsession.FieldBotType)
  7455. }
  7456. return fields
  7457. }
  7458. // AddedField returns the numeric value that was incremented/decremented on a field
  7459. // with the given name. The second boolean return value indicates that this field
  7460. // was not set, or was not defined in the schema.
  7461. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7462. switch name {
  7463. case chatsession.FieldUserID:
  7464. return m.AddedUserID()
  7465. case chatsession.FieldBotID:
  7466. return m.AddedBotID()
  7467. case chatsession.FieldBotType:
  7468. return m.AddedBotType()
  7469. }
  7470. return nil, false
  7471. }
  7472. // AddField adds the value to the field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7476. switch name {
  7477. case chatsession.FieldUserID:
  7478. v, ok := value.(int64)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.AddUserID(v)
  7483. return nil
  7484. case chatsession.FieldBotID:
  7485. v, ok := value.(int64)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.AddBotID(v)
  7490. return nil
  7491. case chatsession.FieldBotType:
  7492. v, ok := value.(int8)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.AddBotType(v)
  7497. return nil
  7498. }
  7499. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7500. }
  7501. // ClearedFields returns all nullable fields that were cleared during this
  7502. // mutation.
  7503. func (m *ChatSessionMutation) ClearedFields() []string {
  7504. var fields []string
  7505. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7506. fields = append(fields, chatsession.FieldDeletedAt)
  7507. }
  7508. return fields
  7509. }
  7510. // FieldCleared returns a boolean indicating if a field with the given name was
  7511. // cleared in this mutation.
  7512. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7513. _, ok := m.clearedFields[name]
  7514. return ok
  7515. }
  7516. // ClearField clears the value of the field with the given name. It returns an
  7517. // error if the field is not defined in the schema.
  7518. func (m *ChatSessionMutation) ClearField(name string) error {
  7519. switch name {
  7520. case chatsession.FieldDeletedAt:
  7521. m.ClearDeletedAt()
  7522. return nil
  7523. }
  7524. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7525. }
  7526. // ResetField resets all changes in the mutation for the field with the given name.
  7527. // It returns an error if the field is not defined in the schema.
  7528. func (m *ChatSessionMutation) ResetField(name string) error {
  7529. switch name {
  7530. case chatsession.FieldCreatedAt:
  7531. m.ResetCreatedAt()
  7532. return nil
  7533. case chatsession.FieldUpdatedAt:
  7534. m.ResetUpdatedAt()
  7535. return nil
  7536. case chatsession.FieldDeletedAt:
  7537. m.ResetDeletedAt()
  7538. return nil
  7539. case chatsession.FieldName:
  7540. m.ResetName()
  7541. return nil
  7542. case chatsession.FieldUserID:
  7543. m.ResetUserID()
  7544. return nil
  7545. case chatsession.FieldBotID:
  7546. m.ResetBotID()
  7547. return nil
  7548. case chatsession.FieldBotType:
  7549. m.ResetBotType()
  7550. return nil
  7551. }
  7552. return fmt.Errorf("unknown ChatSession field %s", name)
  7553. }
  7554. // AddedEdges returns all edge names that were set/added in this mutation.
  7555. func (m *ChatSessionMutation) AddedEdges() []string {
  7556. edges := make([]string, 0, 0)
  7557. return edges
  7558. }
  7559. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7560. // name in this mutation.
  7561. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7562. return nil
  7563. }
  7564. // RemovedEdges returns all edge names that were removed in this mutation.
  7565. func (m *ChatSessionMutation) RemovedEdges() []string {
  7566. edges := make([]string, 0, 0)
  7567. return edges
  7568. }
  7569. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7570. // the given name in this mutation.
  7571. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7572. return nil
  7573. }
  7574. // ClearedEdges returns all edge names that were cleared in this mutation.
  7575. func (m *ChatSessionMutation) ClearedEdges() []string {
  7576. edges := make([]string, 0, 0)
  7577. return edges
  7578. }
  7579. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7580. // was cleared in this mutation.
  7581. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7582. return false
  7583. }
  7584. // ClearEdge clears the value of the edge with the given name. It returns an error
  7585. // if that edge is not defined in the schema.
  7586. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7587. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7588. }
  7589. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7590. // It returns an error if the edge is not defined in the schema.
  7591. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7592. return fmt.Errorf("unknown ChatSession edge %s", name)
  7593. }
  7594. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7595. type ContactMutation struct {
  7596. config
  7597. op Op
  7598. typ string
  7599. id *uint64
  7600. created_at *time.Time
  7601. updated_at *time.Time
  7602. status *uint8
  7603. addstatus *int8
  7604. deleted_at *time.Time
  7605. wx_wxid *string
  7606. _type *int
  7607. add_type *int
  7608. wxid *string
  7609. account *string
  7610. nickname *string
  7611. markname *string
  7612. headimg *string
  7613. sex *int
  7614. addsex *int
  7615. starrole *string
  7616. dontseeit *int
  7617. adddontseeit *int
  7618. dontseeme *int
  7619. adddontseeme *int
  7620. lag *string
  7621. gid *string
  7622. gname *string
  7623. v3 *string
  7624. organization_id *uint64
  7625. addorganization_id *int64
  7626. clearedFields map[string]struct{}
  7627. contact_relationships map[uint64]struct{}
  7628. removedcontact_relationships map[uint64]struct{}
  7629. clearedcontact_relationships bool
  7630. contact_messages map[uint64]struct{}
  7631. removedcontact_messages map[uint64]struct{}
  7632. clearedcontact_messages bool
  7633. done bool
  7634. oldValue func(context.Context) (*Contact, error)
  7635. predicates []predicate.Contact
  7636. }
  7637. var _ ent.Mutation = (*ContactMutation)(nil)
  7638. // contactOption allows management of the mutation configuration using functional options.
  7639. type contactOption func(*ContactMutation)
  7640. // newContactMutation creates new mutation for the Contact entity.
  7641. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7642. m := &ContactMutation{
  7643. config: c,
  7644. op: op,
  7645. typ: TypeContact,
  7646. clearedFields: make(map[string]struct{}),
  7647. }
  7648. for _, opt := range opts {
  7649. opt(m)
  7650. }
  7651. return m
  7652. }
  7653. // withContactID sets the ID field of the mutation.
  7654. func withContactID(id uint64) contactOption {
  7655. return func(m *ContactMutation) {
  7656. var (
  7657. err error
  7658. once sync.Once
  7659. value *Contact
  7660. )
  7661. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7662. once.Do(func() {
  7663. if m.done {
  7664. err = errors.New("querying old values post mutation is not allowed")
  7665. } else {
  7666. value, err = m.Client().Contact.Get(ctx, id)
  7667. }
  7668. })
  7669. return value, err
  7670. }
  7671. m.id = &id
  7672. }
  7673. }
  7674. // withContact sets the old Contact of the mutation.
  7675. func withContact(node *Contact) contactOption {
  7676. return func(m *ContactMutation) {
  7677. m.oldValue = func(context.Context) (*Contact, error) {
  7678. return node, nil
  7679. }
  7680. m.id = &node.ID
  7681. }
  7682. }
  7683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7684. // executed in a transaction (ent.Tx), a transactional client is returned.
  7685. func (m ContactMutation) Client() *Client {
  7686. client := &Client{config: m.config}
  7687. client.init()
  7688. return client
  7689. }
  7690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7691. // it returns an error otherwise.
  7692. func (m ContactMutation) Tx() (*Tx, error) {
  7693. if _, ok := m.driver.(*txDriver); !ok {
  7694. return nil, errors.New("ent: mutation is not running in a transaction")
  7695. }
  7696. tx := &Tx{config: m.config}
  7697. tx.init()
  7698. return tx, nil
  7699. }
  7700. // SetID sets the value of the id field. Note that this
  7701. // operation is only accepted on creation of Contact entities.
  7702. func (m *ContactMutation) SetID(id uint64) {
  7703. m.id = &id
  7704. }
  7705. // ID returns the ID value in the mutation. Note that the ID is only available
  7706. // if it was provided to the builder or after it was returned from the database.
  7707. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7708. if m.id == nil {
  7709. return
  7710. }
  7711. return *m.id, true
  7712. }
  7713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7714. // That means, if the mutation is applied within a transaction with an isolation level such
  7715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7716. // or updated by the mutation.
  7717. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7718. switch {
  7719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7720. id, exists := m.ID()
  7721. if exists {
  7722. return []uint64{id}, nil
  7723. }
  7724. fallthrough
  7725. case m.op.Is(OpUpdate | OpDelete):
  7726. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7727. default:
  7728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7729. }
  7730. }
  7731. // SetCreatedAt sets the "created_at" field.
  7732. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7733. m.created_at = &t
  7734. }
  7735. // CreatedAt returns the value of the "created_at" field in the mutation.
  7736. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7737. v := m.created_at
  7738. if v == nil {
  7739. return
  7740. }
  7741. return *v, true
  7742. }
  7743. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7744. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7746. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7747. if !m.op.Is(OpUpdateOne) {
  7748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7749. }
  7750. if m.id == nil || m.oldValue == nil {
  7751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7752. }
  7753. oldValue, err := m.oldValue(ctx)
  7754. if err != nil {
  7755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7756. }
  7757. return oldValue.CreatedAt, nil
  7758. }
  7759. // ResetCreatedAt resets all changes to the "created_at" field.
  7760. func (m *ContactMutation) ResetCreatedAt() {
  7761. m.created_at = nil
  7762. }
  7763. // SetUpdatedAt sets the "updated_at" field.
  7764. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7765. m.updated_at = &t
  7766. }
  7767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7768. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7769. v := m.updated_at
  7770. if v == nil {
  7771. return
  7772. }
  7773. return *v, true
  7774. }
  7775. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7776. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7778. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7779. if !m.op.Is(OpUpdateOne) {
  7780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7781. }
  7782. if m.id == nil || m.oldValue == nil {
  7783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7784. }
  7785. oldValue, err := m.oldValue(ctx)
  7786. if err != nil {
  7787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7788. }
  7789. return oldValue.UpdatedAt, nil
  7790. }
  7791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7792. func (m *ContactMutation) ResetUpdatedAt() {
  7793. m.updated_at = nil
  7794. }
  7795. // SetStatus sets the "status" field.
  7796. func (m *ContactMutation) SetStatus(u uint8) {
  7797. m.status = &u
  7798. m.addstatus = nil
  7799. }
  7800. // Status returns the value of the "status" field in the mutation.
  7801. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7802. v := m.status
  7803. if v == nil {
  7804. return
  7805. }
  7806. return *v, true
  7807. }
  7808. // OldStatus returns the old "status" field's value of the Contact entity.
  7809. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7811. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7812. if !m.op.Is(OpUpdateOne) {
  7813. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7814. }
  7815. if m.id == nil || m.oldValue == nil {
  7816. return v, errors.New("OldStatus requires an ID field in the mutation")
  7817. }
  7818. oldValue, err := m.oldValue(ctx)
  7819. if err != nil {
  7820. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7821. }
  7822. return oldValue.Status, nil
  7823. }
  7824. // AddStatus adds u to the "status" field.
  7825. func (m *ContactMutation) AddStatus(u int8) {
  7826. if m.addstatus != nil {
  7827. *m.addstatus += u
  7828. } else {
  7829. m.addstatus = &u
  7830. }
  7831. }
  7832. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7833. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7834. v := m.addstatus
  7835. if v == nil {
  7836. return
  7837. }
  7838. return *v, true
  7839. }
  7840. // ClearStatus clears the value of the "status" field.
  7841. func (m *ContactMutation) ClearStatus() {
  7842. m.status = nil
  7843. m.addstatus = nil
  7844. m.clearedFields[contact.FieldStatus] = struct{}{}
  7845. }
  7846. // StatusCleared returns if the "status" field was cleared in this mutation.
  7847. func (m *ContactMutation) StatusCleared() bool {
  7848. _, ok := m.clearedFields[contact.FieldStatus]
  7849. return ok
  7850. }
  7851. // ResetStatus resets all changes to the "status" field.
  7852. func (m *ContactMutation) ResetStatus() {
  7853. m.status = nil
  7854. m.addstatus = nil
  7855. delete(m.clearedFields, contact.FieldStatus)
  7856. }
  7857. // SetDeletedAt sets the "deleted_at" field.
  7858. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7859. m.deleted_at = &t
  7860. }
  7861. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7862. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7863. v := m.deleted_at
  7864. if v == nil {
  7865. return
  7866. }
  7867. return *v, true
  7868. }
  7869. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7870. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7872. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7873. if !m.op.Is(OpUpdateOne) {
  7874. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7875. }
  7876. if m.id == nil || m.oldValue == nil {
  7877. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7878. }
  7879. oldValue, err := m.oldValue(ctx)
  7880. if err != nil {
  7881. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7882. }
  7883. return oldValue.DeletedAt, nil
  7884. }
  7885. // ClearDeletedAt clears the value of the "deleted_at" field.
  7886. func (m *ContactMutation) ClearDeletedAt() {
  7887. m.deleted_at = nil
  7888. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7889. }
  7890. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7891. func (m *ContactMutation) DeletedAtCleared() bool {
  7892. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7893. return ok
  7894. }
  7895. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7896. func (m *ContactMutation) ResetDeletedAt() {
  7897. m.deleted_at = nil
  7898. delete(m.clearedFields, contact.FieldDeletedAt)
  7899. }
  7900. // SetWxWxid sets the "wx_wxid" field.
  7901. func (m *ContactMutation) SetWxWxid(s string) {
  7902. m.wx_wxid = &s
  7903. }
  7904. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7905. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7906. v := m.wx_wxid
  7907. if v == nil {
  7908. return
  7909. }
  7910. return *v, true
  7911. }
  7912. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7913. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7915. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7916. if !m.op.Is(OpUpdateOne) {
  7917. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7918. }
  7919. if m.id == nil || m.oldValue == nil {
  7920. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7921. }
  7922. oldValue, err := m.oldValue(ctx)
  7923. if err != nil {
  7924. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7925. }
  7926. return oldValue.WxWxid, nil
  7927. }
  7928. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7929. func (m *ContactMutation) ResetWxWxid() {
  7930. m.wx_wxid = nil
  7931. }
  7932. // SetType sets the "type" field.
  7933. func (m *ContactMutation) SetType(i int) {
  7934. m._type = &i
  7935. m.add_type = nil
  7936. }
  7937. // GetType returns the value of the "type" field in the mutation.
  7938. func (m *ContactMutation) GetType() (r int, exists bool) {
  7939. v := m._type
  7940. if v == nil {
  7941. return
  7942. }
  7943. return *v, true
  7944. }
  7945. // OldType returns the old "type" field's value of the Contact entity.
  7946. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7948. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7949. if !m.op.Is(OpUpdateOne) {
  7950. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7951. }
  7952. if m.id == nil || m.oldValue == nil {
  7953. return v, errors.New("OldType requires an ID field in the mutation")
  7954. }
  7955. oldValue, err := m.oldValue(ctx)
  7956. if err != nil {
  7957. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7958. }
  7959. return oldValue.Type, nil
  7960. }
  7961. // AddType adds i to the "type" field.
  7962. func (m *ContactMutation) AddType(i int) {
  7963. if m.add_type != nil {
  7964. *m.add_type += i
  7965. } else {
  7966. m.add_type = &i
  7967. }
  7968. }
  7969. // AddedType returns the value that was added to the "type" field in this mutation.
  7970. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7971. v := m.add_type
  7972. if v == nil {
  7973. return
  7974. }
  7975. return *v, true
  7976. }
  7977. // ClearType clears the value of the "type" field.
  7978. func (m *ContactMutation) ClearType() {
  7979. m._type = nil
  7980. m.add_type = nil
  7981. m.clearedFields[contact.FieldType] = struct{}{}
  7982. }
  7983. // TypeCleared returns if the "type" field was cleared in this mutation.
  7984. func (m *ContactMutation) TypeCleared() bool {
  7985. _, ok := m.clearedFields[contact.FieldType]
  7986. return ok
  7987. }
  7988. // ResetType resets all changes to the "type" field.
  7989. func (m *ContactMutation) ResetType() {
  7990. m._type = nil
  7991. m.add_type = nil
  7992. delete(m.clearedFields, contact.FieldType)
  7993. }
  7994. // SetWxid sets the "wxid" field.
  7995. func (m *ContactMutation) SetWxid(s string) {
  7996. m.wxid = &s
  7997. }
  7998. // Wxid returns the value of the "wxid" field in the mutation.
  7999. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8000. v := m.wxid
  8001. if v == nil {
  8002. return
  8003. }
  8004. return *v, true
  8005. }
  8006. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8007. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8009. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8010. if !m.op.Is(OpUpdateOne) {
  8011. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8012. }
  8013. if m.id == nil || m.oldValue == nil {
  8014. return v, errors.New("OldWxid requires an ID field in the mutation")
  8015. }
  8016. oldValue, err := m.oldValue(ctx)
  8017. if err != nil {
  8018. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8019. }
  8020. return oldValue.Wxid, nil
  8021. }
  8022. // ResetWxid resets all changes to the "wxid" field.
  8023. func (m *ContactMutation) ResetWxid() {
  8024. m.wxid = nil
  8025. }
  8026. // SetAccount sets the "account" field.
  8027. func (m *ContactMutation) SetAccount(s string) {
  8028. m.account = &s
  8029. }
  8030. // Account returns the value of the "account" field in the mutation.
  8031. func (m *ContactMutation) Account() (r string, exists bool) {
  8032. v := m.account
  8033. if v == nil {
  8034. return
  8035. }
  8036. return *v, true
  8037. }
  8038. // OldAccount returns the old "account" field's value of the Contact entity.
  8039. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8041. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8042. if !m.op.Is(OpUpdateOne) {
  8043. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8044. }
  8045. if m.id == nil || m.oldValue == nil {
  8046. return v, errors.New("OldAccount requires an ID field in the mutation")
  8047. }
  8048. oldValue, err := m.oldValue(ctx)
  8049. if err != nil {
  8050. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8051. }
  8052. return oldValue.Account, nil
  8053. }
  8054. // ResetAccount resets all changes to the "account" field.
  8055. func (m *ContactMutation) ResetAccount() {
  8056. m.account = nil
  8057. }
  8058. // SetNickname sets the "nickname" field.
  8059. func (m *ContactMutation) SetNickname(s string) {
  8060. m.nickname = &s
  8061. }
  8062. // Nickname returns the value of the "nickname" field in the mutation.
  8063. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8064. v := m.nickname
  8065. if v == nil {
  8066. return
  8067. }
  8068. return *v, true
  8069. }
  8070. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8071. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8073. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8074. if !m.op.Is(OpUpdateOne) {
  8075. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8076. }
  8077. if m.id == nil || m.oldValue == nil {
  8078. return v, errors.New("OldNickname requires an ID field in the mutation")
  8079. }
  8080. oldValue, err := m.oldValue(ctx)
  8081. if err != nil {
  8082. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8083. }
  8084. return oldValue.Nickname, nil
  8085. }
  8086. // ResetNickname resets all changes to the "nickname" field.
  8087. func (m *ContactMutation) ResetNickname() {
  8088. m.nickname = nil
  8089. }
  8090. // SetMarkname sets the "markname" field.
  8091. func (m *ContactMutation) SetMarkname(s string) {
  8092. m.markname = &s
  8093. }
  8094. // Markname returns the value of the "markname" field in the mutation.
  8095. func (m *ContactMutation) Markname() (r string, exists bool) {
  8096. v := m.markname
  8097. if v == nil {
  8098. return
  8099. }
  8100. return *v, true
  8101. }
  8102. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8105. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8106. if !m.op.Is(OpUpdateOne) {
  8107. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8108. }
  8109. if m.id == nil || m.oldValue == nil {
  8110. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8111. }
  8112. oldValue, err := m.oldValue(ctx)
  8113. if err != nil {
  8114. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8115. }
  8116. return oldValue.Markname, nil
  8117. }
  8118. // ResetMarkname resets all changes to the "markname" field.
  8119. func (m *ContactMutation) ResetMarkname() {
  8120. m.markname = nil
  8121. }
  8122. // SetHeadimg sets the "headimg" field.
  8123. func (m *ContactMutation) SetHeadimg(s string) {
  8124. m.headimg = &s
  8125. }
  8126. // Headimg returns the value of the "headimg" field in the mutation.
  8127. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8128. v := m.headimg
  8129. if v == nil {
  8130. return
  8131. }
  8132. return *v, true
  8133. }
  8134. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8135. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8137. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8138. if !m.op.Is(OpUpdateOne) {
  8139. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8140. }
  8141. if m.id == nil || m.oldValue == nil {
  8142. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8143. }
  8144. oldValue, err := m.oldValue(ctx)
  8145. if err != nil {
  8146. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8147. }
  8148. return oldValue.Headimg, nil
  8149. }
  8150. // ResetHeadimg resets all changes to the "headimg" field.
  8151. func (m *ContactMutation) ResetHeadimg() {
  8152. m.headimg = nil
  8153. }
  8154. // SetSex sets the "sex" field.
  8155. func (m *ContactMutation) SetSex(i int) {
  8156. m.sex = &i
  8157. m.addsex = nil
  8158. }
  8159. // Sex returns the value of the "sex" field in the mutation.
  8160. func (m *ContactMutation) Sex() (r int, exists bool) {
  8161. v := m.sex
  8162. if v == nil {
  8163. return
  8164. }
  8165. return *v, true
  8166. }
  8167. // OldSex returns the old "sex" field's value of the Contact entity.
  8168. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8170. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8171. if !m.op.Is(OpUpdateOne) {
  8172. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8173. }
  8174. if m.id == nil || m.oldValue == nil {
  8175. return v, errors.New("OldSex requires an ID field in the mutation")
  8176. }
  8177. oldValue, err := m.oldValue(ctx)
  8178. if err != nil {
  8179. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8180. }
  8181. return oldValue.Sex, nil
  8182. }
  8183. // AddSex adds i to the "sex" field.
  8184. func (m *ContactMutation) AddSex(i int) {
  8185. if m.addsex != nil {
  8186. *m.addsex += i
  8187. } else {
  8188. m.addsex = &i
  8189. }
  8190. }
  8191. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8192. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8193. v := m.addsex
  8194. if v == nil {
  8195. return
  8196. }
  8197. return *v, true
  8198. }
  8199. // ResetSex resets all changes to the "sex" field.
  8200. func (m *ContactMutation) ResetSex() {
  8201. m.sex = nil
  8202. m.addsex = nil
  8203. }
  8204. // SetStarrole sets the "starrole" field.
  8205. func (m *ContactMutation) SetStarrole(s string) {
  8206. m.starrole = &s
  8207. }
  8208. // Starrole returns the value of the "starrole" field in the mutation.
  8209. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8210. v := m.starrole
  8211. if v == nil {
  8212. return
  8213. }
  8214. return *v, true
  8215. }
  8216. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8217. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8219. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8220. if !m.op.Is(OpUpdateOne) {
  8221. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8222. }
  8223. if m.id == nil || m.oldValue == nil {
  8224. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8225. }
  8226. oldValue, err := m.oldValue(ctx)
  8227. if err != nil {
  8228. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8229. }
  8230. return oldValue.Starrole, nil
  8231. }
  8232. // ResetStarrole resets all changes to the "starrole" field.
  8233. func (m *ContactMutation) ResetStarrole() {
  8234. m.starrole = nil
  8235. }
  8236. // SetDontseeit sets the "dontseeit" field.
  8237. func (m *ContactMutation) SetDontseeit(i int) {
  8238. m.dontseeit = &i
  8239. m.adddontseeit = nil
  8240. }
  8241. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8242. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8243. v := m.dontseeit
  8244. if v == nil {
  8245. return
  8246. }
  8247. return *v, true
  8248. }
  8249. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8250. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8252. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8253. if !m.op.Is(OpUpdateOne) {
  8254. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8255. }
  8256. if m.id == nil || m.oldValue == nil {
  8257. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8258. }
  8259. oldValue, err := m.oldValue(ctx)
  8260. if err != nil {
  8261. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8262. }
  8263. return oldValue.Dontseeit, nil
  8264. }
  8265. // AddDontseeit adds i to the "dontseeit" field.
  8266. func (m *ContactMutation) AddDontseeit(i int) {
  8267. if m.adddontseeit != nil {
  8268. *m.adddontseeit += i
  8269. } else {
  8270. m.adddontseeit = &i
  8271. }
  8272. }
  8273. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8274. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8275. v := m.adddontseeit
  8276. if v == nil {
  8277. return
  8278. }
  8279. return *v, true
  8280. }
  8281. // ResetDontseeit resets all changes to the "dontseeit" field.
  8282. func (m *ContactMutation) ResetDontseeit() {
  8283. m.dontseeit = nil
  8284. m.adddontseeit = nil
  8285. }
  8286. // SetDontseeme sets the "dontseeme" field.
  8287. func (m *ContactMutation) SetDontseeme(i int) {
  8288. m.dontseeme = &i
  8289. m.adddontseeme = nil
  8290. }
  8291. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8292. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8293. v := m.dontseeme
  8294. if v == nil {
  8295. return
  8296. }
  8297. return *v, true
  8298. }
  8299. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8300. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8302. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8303. if !m.op.Is(OpUpdateOne) {
  8304. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8305. }
  8306. if m.id == nil || m.oldValue == nil {
  8307. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8308. }
  8309. oldValue, err := m.oldValue(ctx)
  8310. if err != nil {
  8311. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8312. }
  8313. return oldValue.Dontseeme, nil
  8314. }
  8315. // AddDontseeme adds i to the "dontseeme" field.
  8316. func (m *ContactMutation) AddDontseeme(i int) {
  8317. if m.adddontseeme != nil {
  8318. *m.adddontseeme += i
  8319. } else {
  8320. m.adddontseeme = &i
  8321. }
  8322. }
  8323. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8324. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8325. v := m.adddontseeme
  8326. if v == nil {
  8327. return
  8328. }
  8329. return *v, true
  8330. }
  8331. // ResetDontseeme resets all changes to the "dontseeme" field.
  8332. func (m *ContactMutation) ResetDontseeme() {
  8333. m.dontseeme = nil
  8334. m.adddontseeme = nil
  8335. }
  8336. // SetLag sets the "lag" field.
  8337. func (m *ContactMutation) SetLag(s string) {
  8338. m.lag = &s
  8339. }
  8340. // Lag returns the value of the "lag" field in the mutation.
  8341. func (m *ContactMutation) Lag() (r string, exists bool) {
  8342. v := m.lag
  8343. if v == nil {
  8344. return
  8345. }
  8346. return *v, true
  8347. }
  8348. // OldLag returns the old "lag" field's value of the Contact entity.
  8349. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8351. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8352. if !m.op.Is(OpUpdateOne) {
  8353. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8354. }
  8355. if m.id == nil || m.oldValue == nil {
  8356. return v, errors.New("OldLag requires an ID field in the mutation")
  8357. }
  8358. oldValue, err := m.oldValue(ctx)
  8359. if err != nil {
  8360. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8361. }
  8362. return oldValue.Lag, nil
  8363. }
  8364. // ResetLag resets all changes to the "lag" field.
  8365. func (m *ContactMutation) ResetLag() {
  8366. m.lag = nil
  8367. }
  8368. // SetGid sets the "gid" field.
  8369. func (m *ContactMutation) SetGid(s string) {
  8370. m.gid = &s
  8371. }
  8372. // Gid returns the value of the "gid" field in the mutation.
  8373. func (m *ContactMutation) Gid() (r string, exists bool) {
  8374. v := m.gid
  8375. if v == nil {
  8376. return
  8377. }
  8378. return *v, true
  8379. }
  8380. // OldGid returns the old "gid" field's value of the Contact entity.
  8381. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8383. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8384. if !m.op.Is(OpUpdateOne) {
  8385. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8386. }
  8387. if m.id == nil || m.oldValue == nil {
  8388. return v, errors.New("OldGid requires an ID field in the mutation")
  8389. }
  8390. oldValue, err := m.oldValue(ctx)
  8391. if err != nil {
  8392. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8393. }
  8394. return oldValue.Gid, nil
  8395. }
  8396. // ResetGid resets all changes to the "gid" field.
  8397. func (m *ContactMutation) ResetGid() {
  8398. m.gid = nil
  8399. }
  8400. // SetGname sets the "gname" field.
  8401. func (m *ContactMutation) SetGname(s string) {
  8402. m.gname = &s
  8403. }
  8404. // Gname returns the value of the "gname" field in the mutation.
  8405. func (m *ContactMutation) Gname() (r string, exists bool) {
  8406. v := m.gname
  8407. if v == nil {
  8408. return
  8409. }
  8410. return *v, true
  8411. }
  8412. // OldGname returns the old "gname" field's value of the Contact entity.
  8413. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8415. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8416. if !m.op.Is(OpUpdateOne) {
  8417. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8418. }
  8419. if m.id == nil || m.oldValue == nil {
  8420. return v, errors.New("OldGname requires an ID field in the mutation")
  8421. }
  8422. oldValue, err := m.oldValue(ctx)
  8423. if err != nil {
  8424. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8425. }
  8426. return oldValue.Gname, nil
  8427. }
  8428. // ResetGname resets all changes to the "gname" field.
  8429. func (m *ContactMutation) ResetGname() {
  8430. m.gname = nil
  8431. }
  8432. // SetV3 sets the "v3" field.
  8433. func (m *ContactMutation) SetV3(s string) {
  8434. m.v3 = &s
  8435. }
  8436. // V3 returns the value of the "v3" field in the mutation.
  8437. func (m *ContactMutation) V3() (r string, exists bool) {
  8438. v := m.v3
  8439. if v == nil {
  8440. return
  8441. }
  8442. return *v, true
  8443. }
  8444. // OldV3 returns the old "v3" field's value of the Contact entity.
  8445. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8447. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8448. if !m.op.Is(OpUpdateOne) {
  8449. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8450. }
  8451. if m.id == nil || m.oldValue == nil {
  8452. return v, errors.New("OldV3 requires an ID field in the mutation")
  8453. }
  8454. oldValue, err := m.oldValue(ctx)
  8455. if err != nil {
  8456. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8457. }
  8458. return oldValue.V3, nil
  8459. }
  8460. // ResetV3 resets all changes to the "v3" field.
  8461. func (m *ContactMutation) ResetV3() {
  8462. m.v3 = nil
  8463. }
  8464. // SetOrganizationID sets the "organization_id" field.
  8465. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8466. m.organization_id = &u
  8467. m.addorganization_id = nil
  8468. }
  8469. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8470. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8471. v := m.organization_id
  8472. if v == nil {
  8473. return
  8474. }
  8475. return *v, true
  8476. }
  8477. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8478. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8480. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8481. if !m.op.Is(OpUpdateOne) {
  8482. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8483. }
  8484. if m.id == nil || m.oldValue == nil {
  8485. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8486. }
  8487. oldValue, err := m.oldValue(ctx)
  8488. if err != nil {
  8489. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8490. }
  8491. return oldValue.OrganizationID, nil
  8492. }
  8493. // AddOrganizationID adds u to the "organization_id" field.
  8494. func (m *ContactMutation) AddOrganizationID(u int64) {
  8495. if m.addorganization_id != nil {
  8496. *m.addorganization_id += u
  8497. } else {
  8498. m.addorganization_id = &u
  8499. }
  8500. }
  8501. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8502. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8503. v := m.addorganization_id
  8504. if v == nil {
  8505. return
  8506. }
  8507. return *v, true
  8508. }
  8509. // ClearOrganizationID clears the value of the "organization_id" field.
  8510. func (m *ContactMutation) ClearOrganizationID() {
  8511. m.organization_id = nil
  8512. m.addorganization_id = nil
  8513. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8514. }
  8515. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8516. func (m *ContactMutation) OrganizationIDCleared() bool {
  8517. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8518. return ok
  8519. }
  8520. // ResetOrganizationID resets all changes to the "organization_id" field.
  8521. func (m *ContactMutation) ResetOrganizationID() {
  8522. m.organization_id = nil
  8523. m.addorganization_id = nil
  8524. delete(m.clearedFields, contact.FieldOrganizationID)
  8525. }
  8526. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8527. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8528. if m.contact_relationships == nil {
  8529. m.contact_relationships = make(map[uint64]struct{})
  8530. }
  8531. for i := range ids {
  8532. m.contact_relationships[ids[i]] = struct{}{}
  8533. }
  8534. }
  8535. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8536. func (m *ContactMutation) ClearContactRelationships() {
  8537. m.clearedcontact_relationships = true
  8538. }
  8539. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8540. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8541. return m.clearedcontact_relationships
  8542. }
  8543. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8544. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8545. if m.removedcontact_relationships == nil {
  8546. m.removedcontact_relationships = make(map[uint64]struct{})
  8547. }
  8548. for i := range ids {
  8549. delete(m.contact_relationships, ids[i])
  8550. m.removedcontact_relationships[ids[i]] = struct{}{}
  8551. }
  8552. }
  8553. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8554. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8555. for id := range m.removedcontact_relationships {
  8556. ids = append(ids, id)
  8557. }
  8558. return
  8559. }
  8560. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8561. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8562. for id := range m.contact_relationships {
  8563. ids = append(ids, id)
  8564. }
  8565. return
  8566. }
  8567. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8568. func (m *ContactMutation) ResetContactRelationships() {
  8569. m.contact_relationships = nil
  8570. m.clearedcontact_relationships = false
  8571. m.removedcontact_relationships = nil
  8572. }
  8573. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8574. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8575. if m.contact_messages == nil {
  8576. m.contact_messages = make(map[uint64]struct{})
  8577. }
  8578. for i := range ids {
  8579. m.contact_messages[ids[i]] = struct{}{}
  8580. }
  8581. }
  8582. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8583. func (m *ContactMutation) ClearContactMessages() {
  8584. m.clearedcontact_messages = true
  8585. }
  8586. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8587. func (m *ContactMutation) ContactMessagesCleared() bool {
  8588. return m.clearedcontact_messages
  8589. }
  8590. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8591. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8592. if m.removedcontact_messages == nil {
  8593. m.removedcontact_messages = make(map[uint64]struct{})
  8594. }
  8595. for i := range ids {
  8596. delete(m.contact_messages, ids[i])
  8597. m.removedcontact_messages[ids[i]] = struct{}{}
  8598. }
  8599. }
  8600. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8601. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8602. for id := range m.removedcontact_messages {
  8603. ids = append(ids, id)
  8604. }
  8605. return
  8606. }
  8607. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8608. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8609. for id := range m.contact_messages {
  8610. ids = append(ids, id)
  8611. }
  8612. return
  8613. }
  8614. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8615. func (m *ContactMutation) ResetContactMessages() {
  8616. m.contact_messages = nil
  8617. m.clearedcontact_messages = false
  8618. m.removedcontact_messages = nil
  8619. }
  8620. // Where appends a list predicates to the ContactMutation builder.
  8621. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8622. m.predicates = append(m.predicates, ps...)
  8623. }
  8624. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8625. // users can use type-assertion to append predicates that do not depend on any generated package.
  8626. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8627. p := make([]predicate.Contact, len(ps))
  8628. for i := range ps {
  8629. p[i] = ps[i]
  8630. }
  8631. m.Where(p...)
  8632. }
  8633. // Op returns the operation name.
  8634. func (m *ContactMutation) Op() Op {
  8635. return m.op
  8636. }
  8637. // SetOp allows setting the mutation operation.
  8638. func (m *ContactMutation) SetOp(op Op) {
  8639. m.op = op
  8640. }
  8641. // Type returns the node type of this mutation (Contact).
  8642. func (m *ContactMutation) Type() string {
  8643. return m.typ
  8644. }
  8645. // Fields returns all fields that were changed during this mutation. Note that in
  8646. // order to get all numeric fields that were incremented/decremented, call
  8647. // AddedFields().
  8648. func (m *ContactMutation) Fields() []string {
  8649. fields := make([]string, 0, 20)
  8650. if m.created_at != nil {
  8651. fields = append(fields, contact.FieldCreatedAt)
  8652. }
  8653. if m.updated_at != nil {
  8654. fields = append(fields, contact.FieldUpdatedAt)
  8655. }
  8656. if m.status != nil {
  8657. fields = append(fields, contact.FieldStatus)
  8658. }
  8659. if m.deleted_at != nil {
  8660. fields = append(fields, contact.FieldDeletedAt)
  8661. }
  8662. if m.wx_wxid != nil {
  8663. fields = append(fields, contact.FieldWxWxid)
  8664. }
  8665. if m._type != nil {
  8666. fields = append(fields, contact.FieldType)
  8667. }
  8668. if m.wxid != nil {
  8669. fields = append(fields, contact.FieldWxid)
  8670. }
  8671. if m.account != nil {
  8672. fields = append(fields, contact.FieldAccount)
  8673. }
  8674. if m.nickname != nil {
  8675. fields = append(fields, contact.FieldNickname)
  8676. }
  8677. if m.markname != nil {
  8678. fields = append(fields, contact.FieldMarkname)
  8679. }
  8680. if m.headimg != nil {
  8681. fields = append(fields, contact.FieldHeadimg)
  8682. }
  8683. if m.sex != nil {
  8684. fields = append(fields, contact.FieldSex)
  8685. }
  8686. if m.starrole != nil {
  8687. fields = append(fields, contact.FieldStarrole)
  8688. }
  8689. if m.dontseeit != nil {
  8690. fields = append(fields, contact.FieldDontseeit)
  8691. }
  8692. if m.dontseeme != nil {
  8693. fields = append(fields, contact.FieldDontseeme)
  8694. }
  8695. if m.lag != nil {
  8696. fields = append(fields, contact.FieldLag)
  8697. }
  8698. if m.gid != nil {
  8699. fields = append(fields, contact.FieldGid)
  8700. }
  8701. if m.gname != nil {
  8702. fields = append(fields, contact.FieldGname)
  8703. }
  8704. if m.v3 != nil {
  8705. fields = append(fields, contact.FieldV3)
  8706. }
  8707. if m.organization_id != nil {
  8708. fields = append(fields, contact.FieldOrganizationID)
  8709. }
  8710. return fields
  8711. }
  8712. // Field returns the value of a field with the given name. The second boolean
  8713. // return value indicates that this field was not set, or was not defined in the
  8714. // schema.
  8715. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8716. switch name {
  8717. case contact.FieldCreatedAt:
  8718. return m.CreatedAt()
  8719. case contact.FieldUpdatedAt:
  8720. return m.UpdatedAt()
  8721. case contact.FieldStatus:
  8722. return m.Status()
  8723. case contact.FieldDeletedAt:
  8724. return m.DeletedAt()
  8725. case contact.FieldWxWxid:
  8726. return m.WxWxid()
  8727. case contact.FieldType:
  8728. return m.GetType()
  8729. case contact.FieldWxid:
  8730. return m.Wxid()
  8731. case contact.FieldAccount:
  8732. return m.Account()
  8733. case contact.FieldNickname:
  8734. return m.Nickname()
  8735. case contact.FieldMarkname:
  8736. return m.Markname()
  8737. case contact.FieldHeadimg:
  8738. return m.Headimg()
  8739. case contact.FieldSex:
  8740. return m.Sex()
  8741. case contact.FieldStarrole:
  8742. return m.Starrole()
  8743. case contact.FieldDontseeit:
  8744. return m.Dontseeit()
  8745. case contact.FieldDontseeme:
  8746. return m.Dontseeme()
  8747. case contact.FieldLag:
  8748. return m.Lag()
  8749. case contact.FieldGid:
  8750. return m.Gid()
  8751. case contact.FieldGname:
  8752. return m.Gname()
  8753. case contact.FieldV3:
  8754. return m.V3()
  8755. case contact.FieldOrganizationID:
  8756. return m.OrganizationID()
  8757. }
  8758. return nil, false
  8759. }
  8760. // OldField returns the old value of the field from the database. An error is
  8761. // returned if the mutation operation is not UpdateOne, or the query to the
  8762. // database failed.
  8763. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8764. switch name {
  8765. case contact.FieldCreatedAt:
  8766. return m.OldCreatedAt(ctx)
  8767. case contact.FieldUpdatedAt:
  8768. return m.OldUpdatedAt(ctx)
  8769. case contact.FieldStatus:
  8770. return m.OldStatus(ctx)
  8771. case contact.FieldDeletedAt:
  8772. return m.OldDeletedAt(ctx)
  8773. case contact.FieldWxWxid:
  8774. return m.OldWxWxid(ctx)
  8775. case contact.FieldType:
  8776. return m.OldType(ctx)
  8777. case contact.FieldWxid:
  8778. return m.OldWxid(ctx)
  8779. case contact.FieldAccount:
  8780. return m.OldAccount(ctx)
  8781. case contact.FieldNickname:
  8782. return m.OldNickname(ctx)
  8783. case contact.FieldMarkname:
  8784. return m.OldMarkname(ctx)
  8785. case contact.FieldHeadimg:
  8786. return m.OldHeadimg(ctx)
  8787. case contact.FieldSex:
  8788. return m.OldSex(ctx)
  8789. case contact.FieldStarrole:
  8790. return m.OldStarrole(ctx)
  8791. case contact.FieldDontseeit:
  8792. return m.OldDontseeit(ctx)
  8793. case contact.FieldDontseeme:
  8794. return m.OldDontseeme(ctx)
  8795. case contact.FieldLag:
  8796. return m.OldLag(ctx)
  8797. case contact.FieldGid:
  8798. return m.OldGid(ctx)
  8799. case contact.FieldGname:
  8800. return m.OldGname(ctx)
  8801. case contact.FieldV3:
  8802. return m.OldV3(ctx)
  8803. case contact.FieldOrganizationID:
  8804. return m.OldOrganizationID(ctx)
  8805. }
  8806. return nil, fmt.Errorf("unknown Contact field %s", name)
  8807. }
  8808. // SetField sets the value of a field with the given name. It returns an error if
  8809. // the field is not defined in the schema, or if the type mismatched the field
  8810. // type.
  8811. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8812. switch name {
  8813. case contact.FieldCreatedAt:
  8814. v, ok := value.(time.Time)
  8815. if !ok {
  8816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8817. }
  8818. m.SetCreatedAt(v)
  8819. return nil
  8820. case contact.FieldUpdatedAt:
  8821. v, ok := value.(time.Time)
  8822. if !ok {
  8823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8824. }
  8825. m.SetUpdatedAt(v)
  8826. return nil
  8827. case contact.FieldStatus:
  8828. v, ok := value.(uint8)
  8829. if !ok {
  8830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8831. }
  8832. m.SetStatus(v)
  8833. return nil
  8834. case contact.FieldDeletedAt:
  8835. v, ok := value.(time.Time)
  8836. if !ok {
  8837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8838. }
  8839. m.SetDeletedAt(v)
  8840. return nil
  8841. case contact.FieldWxWxid:
  8842. v, ok := value.(string)
  8843. if !ok {
  8844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8845. }
  8846. m.SetWxWxid(v)
  8847. return nil
  8848. case contact.FieldType:
  8849. v, ok := value.(int)
  8850. if !ok {
  8851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8852. }
  8853. m.SetType(v)
  8854. return nil
  8855. case contact.FieldWxid:
  8856. v, ok := value.(string)
  8857. if !ok {
  8858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8859. }
  8860. m.SetWxid(v)
  8861. return nil
  8862. case contact.FieldAccount:
  8863. v, ok := value.(string)
  8864. if !ok {
  8865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8866. }
  8867. m.SetAccount(v)
  8868. return nil
  8869. case contact.FieldNickname:
  8870. v, ok := value.(string)
  8871. if !ok {
  8872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8873. }
  8874. m.SetNickname(v)
  8875. return nil
  8876. case contact.FieldMarkname:
  8877. v, ok := value.(string)
  8878. if !ok {
  8879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8880. }
  8881. m.SetMarkname(v)
  8882. return nil
  8883. case contact.FieldHeadimg:
  8884. v, ok := value.(string)
  8885. if !ok {
  8886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8887. }
  8888. m.SetHeadimg(v)
  8889. return nil
  8890. case contact.FieldSex:
  8891. v, ok := value.(int)
  8892. if !ok {
  8893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8894. }
  8895. m.SetSex(v)
  8896. return nil
  8897. case contact.FieldStarrole:
  8898. v, ok := value.(string)
  8899. if !ok {
  8900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8901. }
  8902. m.SetStarrole(v)
  8903. return nil
  8904. case contact.FieldDontseeit:
  8905. v, ok := value.(int)
  8906. if !ok {
  8907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8908. }
  8909. m.SetDontseeit(v)
  8910. return nil
  8911. case contact.FieldDontseeme:
  8912. v, ok := value.(int)
  8913. if !ok {
  8914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8915. }
  8916. m.SetDontseeme(v)
  8917. return nil
  8918. case contact.FieldLag:
  8919. v, ok := value.(string)
  8920. if !ok {
  8921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8922. }
  8923. m.SetLag(v)
  8924. return nil
  8925. case contact.FieldGid:
  8926. v, ok := value.(string)
  8927. if !ok {
  8928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8929. }
  8930. m.SetGid(v)
  8931. return nil
  8932. case contact.FieldGname:
  8933. v, ok := value.(string)
  8934. if !ok {
  8935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8936. }
  8937. m.SetGname(v)
  8938. return nil
  8939. case contact.FieldV3:
  8940. v, ok := value.(string)
  8941. if !ok {
  8942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8943. }
  8944. m.SetV3(v)
  8945. return nil
  8946. case contact.FieldOrganizationID:
  8947. v, ok := value.(uint64)
  8948. if !ok {
  8949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8950. }
  8951. m.SetOrganizationID(v)
  8952. return nil
  8953. }
  8954. return fmt.Errorf("unknown Contact field %s", name)
  8955. }
  8956. // AddedFields returns all numeric fields that were incremented/decremented during
  8957. // this mutation.
  8958. func (m *ContactMutation) AddedFields() []string {
  8959. var fields []string
  8960. if m.addstatus != nil {
  8961. fields = append(fields, contact.FieldStatus)
  8962. }
  8963. if m.add_type != nil {
  8964. fields = append(fields, contact.FieldType)
  8965. }
  8966. if m.addsex != nil {
  8967. fields = append(fields, contact.FieldSex)
  8968. }
  8969. if m.adddontseeit != nil {
  8970. fields = append(fields, contact.FieldDontseeit)
  8971. }
  8972. if m.adddontseeme != nil {
  8973. fields = append(fields, contact.FieldDontseeme)
  8974. }
  8975. if m.addorganization_id != nil {
  8976. fields = append(fields, contact.FieldOrganizationID)
  8977. }
  8978. return fields
  8979. }
  8980. // AddedField returns the numeric value that was incremented/decremented on a field
  8981. // with the given name. The second boolean return value indicates that this field
  8982. // was not set, or was not defined in the schema.
  8983. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8984. switch name {
  8985. case contact.FieldStatus:
  8986. return m.AddedStatus()
  8987. case contact.FieldType:
  8988. return m.AddedType()
  8989. case contact.FieldSex:
  8990. return m.AddedSex()
  8991. case contact.FieldDontseeit:
  8992. return m.AddedDontseeit()
  8993. case contact.FieldDontseeme:
  8994. return m.AddedDontseeme()
  8995. case contact.FieldOrganizationID:
  8996. return m.AddedOrganizationID()
  8997. }
  8998. return nil, false
  8999. }
  9000. // AddField adds the value to the field with the given name. It returns an error if
  9001. // the field is not defined in the schema, or if the type mismatched the field
  9002. // type.
  9003. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9004. switch name {
  9005. case contact.FieldStatus:
  9006. v, ok := value.(int8)
  9007. if !ok {
  9008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9009. }
  9010. m.AddStatus(v)
  9011. return nil
  9012. case contact.FieldType:
  9013. v, ok := value.(int)
  9014. if !ok {
  9015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9016. }
  9017. m.AddType(v)
  9018. return nil
  9019. case contact.FieldSex:
  9020. v, ok := value.(int)
  9021. if !ok {
  9022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9023. }
  9024. m.AddSex(v)
  9025. return nil
  9026. case contact.FieldDontseeit:
  9027. v, ok := value.(int)
  9028. if !ok {
  9029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9030. }
  9031. m.AddDontseeit(v)
  9032. return nil
  9033. case contact.FieldDontseeme:
  9034. v, ok := value.(int)
  9035. if !ok {
  9036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9037. }
  9038. m.AddDontseeme(v)
  9039. return nil
  9040. case contact.FieldOrganizationID:
  9041. v, ok := value.(int64)
  9042. if !ok {
  9043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9044. }
  9045. m.AddOrganizationID(v)
  9046. return nil
  9047. }
  9048. return fmt.Errorf("unknown Contact numeric field %s", name)
  9049. }
  9050. // ClearedFields returns all nullable fields that were cleared during this
  9051. // mutation.
  9052. func (m *ContactMutation) ClearedFields() []string {
  9053. var fields []string
  9054. if m.FieldCleared(contact.FieldStatus) {
  9055. fields = append(fields, contact.FieldStatus)
  9056. }
  9057. if m.FieldCleared(contact.FieldDeletedAt) {
  9058. fields = append(fields, contact.FieldDeletedAt)
  9059. }
  9060. if m.FieldCleared(contact.FieldType) {
  9061. fields = append(fields, contact.FieldType)
  9062. }
  9063. if m.FieldCleared(contact.FieldOrganizationID) {
  9064. fields = append(fields, contact.FieldOrganizationID)
  9065. }
  9066. return fields
  9067. }
  9068. // FieldCleared returns a boolean indicating if a field with the given name was
  9069. // cleared in this mutation.
  9070. func (m *ContactMutation) FieldCleared(name string) bool {
  9071. _, ok := m.clearedFields[name]
  9072. return ok
  9073. }
  9074. // ClearField clears the value of the field with the given name. It returns an
  9075. // error if the field is not defined in the schema.
  9076. func (m *ContactMutation) ClearField(name string) error {
  9077. switch name {
  9078. case contact.FieldStatus:
  9079. m.ClearStatus()
  9080. return nil
  9081. case contact.FieldDeletedAt:
  9082. m.ClearDeletedAt()
  9083. return nil
  9084. case contact.FieldType:
  9085. m.ClearType()
  9086. return nil
  9087. case contact.FieldOrganizationID:
  9088. m.ClearOrganizationID()
  9089. return nil
  9090. }
  9091. return fmt.Errorf("unknown Contact nullable field %s", name)
  9092. }
  9093. // ResetField resets all changes in the mutation for the field with the given name.
  9094. // It returns an error if the field is not defined in the schema.
  9095. func (m *ContactMutation) ResetField(name string) error {
  9096. switch name {
  9097. case contact.FieldCreatedAt:
  9098. m.ResetCreatedAt()
  9099. return nil
  9100. case contact.FieldUpdatedAt:
  9101. m.ResetUpdatedAt()
  9102. return nil
  9103. case contact.FieldStatus:
  9104. m.ResetStatus()
  9105. return nil
  9106. case contact.FieldDeletedAt:
  9107. m.ResetDeletedAt()
  9108. return nil
  9109. case contact.FieldWxWxid:
  9110. m.ResetWxWxid()
  9111. return nil
  9112. case contact.FieldType:
  9113. m.ResetType()
  9114. return nil
  9115. case contact.FieldWxid:
  9116. m.ResetWxid()
  9117. return nil
  9118. case contact.FieldAccount:
  9119. m.ResetAccount()
  9120. return nil
  9121. case contact.FieldNickname:
  9122. m.ResetNickname()
  9123. return nil
  9124. case contact.FieldMarkname:
  9125. m.ResetMarkname()
  9126. return nil
  9127. case contact.FieldHeadimg:
  9128. m.ResetHeadimg()
  9129. return nil
  9130. case contact.FieldSex:
  9131. m.ResetSex()
  9132. return nil
  9133. case contact.FieldStarrole:
  9134. m.ResetStarrole()
  9135. return nil
  9136. case contact.FieldDontseeit:
  9137. m.ResetDontseeit()
  9138. return nil
  9139. case contact.FieldDontseeme:
  9140. m.ResetDontseeme()
  9141. return nil
  9142. case contact.FieldLag:
  9143. m.ResetLag()
  9144. return nil
  9145. case contact.FieldGid:
  9146. m.ResetGid()
  9147. return nil
  9148. case contact.FieldGname:
  9149. m.ResetGname()
  9150. return nil
  9151. case contact.FieldV3:
  9152. m.ResetV3()
  9153. return nil
  9154. case contact.FieldOrganizationID:
  9155. m.ResetOrganizationID()
  9156. return nil
  9157. }
  9158. return fmt.Errorf("unknown Contact field %s", name)
  9159. }
  9160. // AddedEdges returns all edge names that were set/added in this mutation.
  9161. func (m *ContactMutation) AddedEdges() []string {
  9162. edges := make([]string, 0, 2)
  9163. if m.contact_relationships != nil {
  9164. edges = append(edges, contact.EdgeContactRelationships)
  9165. }
  9166. if m.contact_messages != nil {
  9167. edges = append(edges, contact.EdgeContactMessages)
  9168. }
  9169. return edges
  9170. }
  9171. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9172. // name in this mutation.
  9173. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9174. switch name {
  9175. case contact.EdgeContactRelationships:
  9176. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9177. for id := range m.contact_relationships {
  9178. ids = append(ids, id)
  9179. }
  9180. return ids
  9181. case contact.EdgeContactMessages:
  9182. ids := make([]ent.Value, 0, len(m.contact_messages))
  9183. for id := range m.contact_messages {
  9184. ids = append(ids, id)
  9185. }
  9186. return ids
  9187. }
  9188. return nil
  9189. }
  9190. // RemovedEdges returns all edge names that were removed in this mutation.
  9191. func (m *ContactMutation) RemovedEdges() []string {
  9192. edges := make([]string, 0, 2)
  9193. if m.removedcontact_relationships != nil {
  9194. edges = append(edges, contact.EdgeContactRelationships)
  9195. }
  9196. if m.removedcontact_messages != nil {
  9197. edges = append(edges, contact.EdgeContactMessages)
  9198. }
  9199. return edges
  9200. }
  9201. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9202. // the given name in this mutation.
  9203. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9204. switch name {
  9205. case contact.EdgeContactRelationships:
  9206. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9207. for id := range m.removedcontact_relationships {
  9208. ids = append(ids, id)
  9209. }
  9210. return ids
  9211. case contact.EdgeContactMessages:
  9212. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9213. for id := range m.removedcontact_messages {
  9214. ids = append(ids, id)
  9215. }
  9216. return ids
  9217. }
  9218. return nil
  9219. }
  9220. // ClearedEdges returns all edge names that were cleared in this mutation.
  9221. func (m *ContactMutation) ClearedEdges() []string {
  9222. edges := make([]string, 0, 2)
  9223. if m.clearedcontact_relationships {
  9224. edges = append(edges, contact.EdgeContactRelationships)
  9225. }
  9226. if m.clearedcontact_messages {
  9227. edges = append(edges, contact.EdgeContactMessages)
  9228. }
  9229. return edges
  9230. }
  9231. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9232. // was cleared in this mutation.
  9233. func (m *ContactMutation) EdgeCleared(name string) bool {
  9234. switch name {
  9235. case contact.EdgeContactRelationships:
  9236. return m.clearedcontact_relationships
  9237. case contact.EdgeContactMessages:
  9238. return m.clearedcontact_messages
  9239. }
  9240. return false
  9241. }
  9242. // ClearEdge clears the value of the edge with the given name. It returns an error
  9243. // if that edge is not defined in the schema.
  9244. func (m *ContactMutation) ClearEdge(name string) error {
  9245. switch name {
  9246. }
  9247. return fmt.Errorf("unknown Contact unique edge %s", name)
  9248. }
  9249. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9250. // It returns an error if the edge is not defined in the schema.
  9251. func (m *ContactMutation) ResetEdge(name string) error {
  9252. switch name {
  9253. case contact.EdgeContactRelationships:
  9254. m.ResetContactRelationships()
  9255. return nil
  9256. case contact.EdgeContactMessages:
  9257. m.ResetContactMessages()
  9258. return nil
  9259. }
  9260. return fmt.Errorf("unknown Contact edge %s", name)
  9261. }
  9262. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  9263. type EmployeeMutation struct {
  9264. config
  9265. op Op
  9266. typ string
  9267. id *uint64
  9268. created_at *time.Time
  9269. updated_at *time.Time
  9270. deleted_at *time.Time
  9271. title *string
  9272. avatar *string
  9273. tags *string
  9274. hire_count *int
  9275. addhire_count *int
  9276. service_count *int
  9277. addservice_count *int
  9278. achievement_count *int
  9279. addachievement_count *int
  9280. intro *string
  9281. estimate *string
  9282. skill *string
  9283. ability_type *string
  9284. scene *string
  9285. switch_in *string
  9286. video_url *string
  9287. organization_id *uint64
  9288. addorganization_id *int64
  9289. category_id *uint64
  9290. addcategory_id *int64
  9291. api_base *string
  9292. api_key *string
  9293. ai_info *string
  9294. is_vip *int
  9295. addis_vip *int
  9296. chat_url *string
  9297. clearedFields map[string]struct{}
  9298. em_work_experiences map[uint64]struct{}
  9299. removedem_work_experiences map[uint64]struct{}
  9300. clearedem_work_experiences bool
  9301. em_tutorial map[uint64]struct{}
  9302. removedem_tutorial map[uint64]struct{}
  9303. clearedem_tutorial bool
  9304. done bool
  9305. oldValue func(context.Context) (*Employee, error)
  9306. predicates []predicate.Employee
  9307. }
  9308. var _ ent.Mutation = (*EmployeeMutation)(nil)
  9309. // employeeOption allows management of the mutation configuration using functional options.
  9310. type employeeOption func(*EmployeeMutation)
  9311. // newEmployeeMutation creates new mutation for the Employee entity.
  9312. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  9313. m := &EmployeeMutation{
  9314. config: c,
  9315. op: op,
  9316. typ: TypeEmployee,
  9317. clearedFields: make(map[string]struct{}),
  9318. }
  9319. for _, opt := range opts {
  9320. opt(m)
  9321. }
  9322. return m
  9323. }
  9324. // withEmployeeID sets the ID field of the mutation.
  9325. func withEmployeeID(id uint64) employeeOption {
  9326. return func(m *EmployeeMutation) {
  9327. var (
  9328. err error
  9329. once sync.Once
  9330. value *Employee
  9331. )
  9332. m.oldValue = func(ctx context.Context) (*Employee, error) {
  9333. once.Do(func() {
  9334. if m.done {
  9335. err = errors.New("querying old values post mutation is not allowed")
  9336. } else {
  9337. value, err = m.Client().Employee.Get(ctx, id)
  9338. }
  9339. })
  9340. return value, err
  9341. }
  9342. m.id = &id
  9343. }
  9344. }
  9345. // withEmployee sets the old Employee of the mutation.
  9346. func withEmployee(node *Employee) employeeOption {
  9347. return func(m *EmployeeMutation) {
  9348. m.oldValue = func(context.Context) (*Employee, error) {
  9349. return node, nil
  9350. }
  9351. m.id = &node.ID
  9352. }
  9353. }
  9354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9355. // executed in a transaction (ent.Tx), a transactional client is returned.
  9356. func (m EmployeeMutation) Client() *Client {
  9357. client := &Client{config: m.config}
  9358. client.init()
  9359. return client
  9360. }
  9361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9362. // it returns an error otherwise.
  9363. func (m EmployeeMutation) Tx() (*Tx, error) {
  9364. if _, ok := m.driver.(*txDriver); !ok {
  9365. return nil, errors.New("ent: mutation is not running in a transaction")
  9366. }
  9367. tx := &Tx{config: m.config}
  9368. tx.init()
  9369. return tx, nil
  9370. }
  9371. // SetID sets the value of the id field. Note that this
  9372. // operation is only accepted on creation of Employee entities.
  9373. func (m *EmployeeMutation) SetID(id uint64) {
  9374. m.id = &id
  9375. }
  9376. // ID returns the ID value in the mutation. Note that the ID is only available
  9377. // if it was provided to the builder or after it was returned from the database.
  9378. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  9379. if m.id == nil {
  9380. return
  9381. }
  9382. return *m.id, true
  9383. }
  9384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9385. // That means, if the mutation is applied within a transaction with an isolation level such
  9386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9387. // or updated by the mutation.
  9388. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9389. switch {
  9390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9391. id, exists := m.ID()
  9392. if exists {
  9393. return []uint64{id}, nil
  9394. }
  9395. fallthrough
  9396. case m.op.Is(OpUpdate | OpDelete):
  9397. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  9398. default:
  9399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9400. }
  9401. }
  9402. // SetCreatedAt sets the "created_at" field.
  9403. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  9404. m.created_at = &t
  9405. }
  9406. // CreatedAt returns the value of the "created_at" field in the mutation.
  9407. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  9408. v := m.created_at
  9409. if v == nil {
  9410. return
  9411. }
  9412. return *v, true
  9413. }
  9414. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  9415. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9417. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9418. if !m.op.Is(OpUpdateOne) {
  9419. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9420. }
  9421. if m.id == nil || m.oldValue == nil {
  9422. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9423. }
  9424. oldValue, err := m.oldValue(ctx)
  9425. if err != nil {
  9426. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9427. }
  9428. return oldValue.CreatedAt, nil
  9429. }
  9430. // ResetCreatedAt resets all changes to the "created_at" field.
  9431. func (m *EmployeeMutation) ResetCreatedAt() {
  9432. m.created_at = nil
  9433. }
  9434. // SetUpdatedAt sets the "updated_at" field.
  9435. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  9436. m.updated_at = &t
  9437. }
  9438. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9439. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  9440. v := m.updated_at
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  9447. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9459. }
  9460. return oldValue.UpdatedAt, nil
  9461. }
  9462. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9463. func (m *EmployeeMutation) ResetUpdatedAt() {
  9464. m.updated_at = nil
  9465. }
  9466. // SetDeletedAt sets the "deleted_at" field.
  9467. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  9468. m.deleted_at = &t
  9469. }
  9470. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9471. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  9472. v := m.deleted_at
  9473. if v == nil {
  9474. return
  9475. }
  9476. return *v, true
  9477. }
  9478. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  9479. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9481. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9482. if !m.op.Is(OpUpdateOne) {
  9483. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9484. }
  9485. if m.id == nil || m.oldValue == nil {
  9486. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9487. }
  9488. oldValue, err := m.oldValue(ctx)
  9489. if err != nil {
  9490. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9491. }
  9492. return oldValue.DeletedAt, nil
  9493. }
  9494. // ClearDeletedAt clears the value of the "deleted_at" field.
  9495. func (m *EmployeeMutation) ClearDeletedAt() {
  9496. m.deleted_at = nil
  9497. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  9498. }
  9499. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9500. func (m *EmployeeMutation) DeletedAtCleared() bool {
  9501. _, ok := m.clearedFields[employee.FieldDeletedAt]
  9502. return ok
  9503. }
  9504. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9505. func (m *EmployeeMutation) ResetDeletedAt() {
  9506. m.deleted_at = nil
  9507. delete(m.clearedFields, employee.FieldDeletedAt)
  9508. }
  9509. // SetTitle sets the "title" field.
  9510. func (m *EmployeeMutation) SetTitle(s string) {
  9511. m.title = &s
  9512. }
  9513. // Title returns the value of the "title" field in the mutation.
  9514. func (m *EmployeeMutation) Title() (r string, exists bool) {
  9515. v := m.title
  9516. if v == nil {
  9517. return
  9518. }
  9519. return *v, true
  9520. }
  9521. // OldTitle returns the old "title" field's value of the Employee entity.
  9522. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9524. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  9525. if !m.op.Is(OpUpdateOne) {
  9526. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9527. }
  9528. if m.id == nil || m.oldValue == nil {
  9529. return v, errors.New("OldTitle requires an ID field in the mutation")
  9530. }
  9531. oldValue, err := m.oldValue(ctx)
  9532. if err != nil {
  9533. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9534. }
  9535. return oldValue.Title, nil
  9536. }
  9537. // ResetTitle resets all changes to the "title" field.
  9538. func (m *EmployeeMutation) ResetTitle() {
  9539. m.title = nil
  9540. }
  9541. // SetAvatar sets the "avatar" field.
  9542. func (m *EmployeeMutation) SetAvatar(s string) {
  9543. m.avatar = &s
  9544. }
  9545. // Avatar returns the value of the "avatar" field in the mutation.
  9546. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  9547. v := m.avatar
  9548. if v == nil {
  9549. return
  9550. }
  9551. return *v, true
  9552. }
  9553. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  9554. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9556. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  9557. if !m.op.Is(OpUpdateOne) {
  9558. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  9559. }
  9560. if m.id == nil || m.oldValue == nil {
  9561. return v, errors.New("OldAvatar requires an ID field in the mutation")
  9562. }
  9563. oldValue, err := m.oldValue(ctx)
  9564. if err != nil {
  9565. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  9566. }
  9567. return oldValue.Avatar, nil
  9568. }
  9569. // ResetAvatar resets all changes to the "avatar" field.
  9570. func (m *EmployeeMutation) ResetAvatar() {
  9571. m.avatar = nil
  9572. }
  9573. // SetTags sets the "tags" field.
  9574. func (m *EmployeeMutation) SetTags(s string) {
  9575. m.tags = &s
  9576. }
  9577. // Tags returns the value of the "tags" field in the mutation.
  9578. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  9579. v := m.tags
  9580. if v == nil {
  9581. return
  9582. }
  9583. return *v, true
  9584. }
  9585. // OldTags returns the old "tags" field's value of the Employee entity.
  9586. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9588. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  9589. if !m.op.Is(OpUpdateOne) {
  9590. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  9591. }
  9592. if m.id == nil || m.oldValue == nil {
  9593. return v, errors.New("OldTags requires an ID field in the mutation")
  9594. }
  9595. oldValue, err := m.oldValue(ctx)
  9596. if err != nil {
  9597. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  9598. }
  9599. return oldValue.Tags, nil
  9600. }
  9601. // ResetTags resets all changes to the "tags" field.
  9602. func (m *EmployeeMutation) ResetTags() {
  9603. m.tags = nil
  9604. }
  9605. // SetHireCount sets the "hire_count" field.
  9606. func (m *EmployeeMutation) SetHireCount(i int) {
  9607. m.hire_count = &i
  9608. m.addhire_count = nil
  9609. }
  9610. // HireCount returns the value of the "hire_count" field in the mutation.
  9611. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  9612. v := m.hire_count
  9613. if v == nil {
  9614. return
  9615. }
  9616. return *v, true
  9617. }
  9618. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  9619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9621. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  9622. if !m.op.Is(OpUpdateOne) {
  9623. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  9624. }
  9625. if m.id == nil || m.oldValue == nil {
  9626. return v, errors.New("OldHireCount requires an ID field in the mutation")
  9627. }
  9628. oldValue, err := m.oldValue(ctx)
  9629. if err != nil {
  9630. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  9631. }
  9632. return oldValue.HireCount, nil
  9633. }
  9634. // AddHireCount adds i to the "hire_count" field.
  9635. func (m *EmployeeMutation) AddHireCount(i int) {
  9636. if m.addhire_count != nil {
  9637. *m.addhire_count += i
  9638. } else {
  9639. m.addhire_count = &i
  9640. }
  9641. }
  9642. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  9643. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  9644. v := m.addhire_count
  9645. if v == nil {
  9646. return
  9647. }
  9648. return *v, true
  9649. }
  9650. // ResetHireCount resets all changes to the "hire_count" field.
  9651. func (m *EmployeeMutation) ResetHireCount() {
  9652. m.hire_count = nil
  9653. m.addhire_count = nil
  9654. }
  9655. // SetServiceCount sets the "service_count" field.
  9656. func (m *EmployeeMutation) SetServiceCount(i int) {
  9657. m.service_count = &i
  9658. m.addservice_count = nil
  9659. }
  9660. // ServiceCount returns the value of the "service_count" field in the mutation.
  9661. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  9662. v := m.service_count
  9663. if v == nil {
  9664. return
  9665. }
  9666. return *v, true
  9667. }
  9668. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  9669. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9671. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  9672. if !m.op.Is(OpUpdateOne) {
  9673. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  9674. }
  9675. if m.id == nil || m.oldValue == nil {
  9676. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  9677. }
  9678. oldValue, err := m.oldValue(ctx)
  9679. if err != nil {
  9680. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  9681. }
  9682. return oldValue.ServiceCount, nil
  9683. }
  9684. // AddServiceCount adds i to the "service_count" field.
  9685. func (m *EmployeeMutation) AddServiceCount(i int) {
  9686. if m.addservice_count != nil {
  9687. *m.addservice_count += i
  9688. } else {
  9689. m.addservice_count = &i
  9690. }
  9691. }
  9692. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  9693. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  9694. v := m.addservice_count
  9695. if v == nil {
  9696. return
  9697. }
  9698. return *v, true
  9699. }
  9700. // ResetServiceCount resets all changes to the "service_count" field.
  9701. func (m *EmployeeMutation) ResetServiceCount() {
  9702. m.service_count = nil
  9703. m.addservice_count = nil
  9704. }
  9705. // SetAchievementCount sets the "achievement_count" field.
  9706. func (m *EmployeeMutation) SetAchievementCount(i int) {
  9707. m.achievement_count = &i
  9708. m.addachievement_count = nil
  9709. }
  9710. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  9711. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  9712. v := m.achievement_count
  9713. if v == nil {
  9714. return
  9715. }
  9716. return *v, true
  9717. }
  9718. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  9719. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9721. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  9722. if !m.op.Is(OpUpdateOne) {
  9723. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  9724. }
  9725. if m.id == nil || m.oldValue == nil {
  9726. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  9727. }
  9728. oldValue, err := m.oldValue(ctx)
  9729. if err != nil {
  9730. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  9731. }
  9732. return oldValue.AchievementCount, nil
  9733. }
  9734. // AddAchievementCount adds i to the "achievement_count" field.
  9735. func (m *EmployeeMutation) AddAchievementCount(i int) {
  9736. if m.addachievement_count != nil {
  9737. *m.addachievement_count += i
  9738. } else {
  9739. m.addachievement_count = &i
  9740. }
  9741. }
  9742. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  9743. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  9744. v := m.addachievement_count
  9745. if v == nil {
  9746. return
  9747. }
  9748. return *v, true
  9749. }
  9750. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9751. func (m *EmployeeMutation) ResetAchievementCount() {
  9752. m.achievement_count = nil
  9753. m.addachievement_count = nil
  9754. }
  9755. // SetIntro sets the "intro" field.
  9756. func (m *EmployeeMutation) SetIntro(s string) {
  9757. m.intro = &s
  9758. }
  9759. // Intro returns the value of the "intro" field in the mutation.
  9760. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9761. v := m.intro
  9762. if v == nil {
  9763. return
  9764. }
  9765. return *v, true
  9766. }
  9767. // OldIntro returns the old "intro" field's value of the Employee entity.
  9768. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9770. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9771. if !m.op.Is(OpUpdateOne) {
  9772. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9773. }
  9774. if m.id == nil || m.oldValue == nil {
  9775. return v, errors.New("OldIntro requires an ID field in the mutation")
  9776. }
  9777. oldValue, err := m.oldValue(ctx)
  9778. if err != nil {
  9779. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9780. }
  9781. return oldValue.Intro, nil
  9782. }
  9783. // ResetIntro resets all changes to the "intro" field.
  9784. func (m *EmployeeMutation) ResetIntro() {
  9785. m.intro = nil
  9786. }
  9787. // SetEstimate sets the "estimate" field.
  9788. func (m *EmployeeMutation) SetEstimate(s string) {
  9789. m.estimate = &s
  9790. }
  9791. // Estimate returns the value of the "estimate" field in the mutation.
  9792. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9793. v := m.estimate
  9794. if v == nil {
  9795. return
  9796. }
  9797. return *v, true
  9798. }
  9799. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9800. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9802. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9803. if !m.op.Is(OpUpdateOne) {
  9804. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9805. }
  9806. if m.id == nil || m.oldValue == nil {
  9807. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9808. }
  9809. oldValue, err := m.oldValue(ctx)
  9810. if err != nil {
  9811. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9812. }
  9813. return oldValue.Estimate, nil
  9814. }
  9815. // ResetEstimate resets all changes to the "estimate" field.
  9816. func (m *EmployeeMutation) ResetEstimate() {
  9817. m.estimate = nil
  9818. }
  9819. // SetSkill sets the "skill" field.
  9820. func (m *EmployeeMutation) SetSkill(s string) {
  9821. m.skill = &s
  9822. }
  9823. // Skill returns the value of the "skill" field in the mutation.
  9824. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9825. v := m.skill
  9826. if v == nil {
  9827. return
  9828. }
  9829. return *v, true
  9830. }
  9831. // OldSkill returns the old "skill" field's value of the Employee entity.
  9832. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9834. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9835. if !m.op.Is(OpUpdateOne) {
  9836. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9837. }
  9838. if m.id == nil || m.oldValue == nil {
  9839. return v, errors.New("OldSkill requires an ID field in the mutation")
  9840. }
  9841. oldValue, err := m.oldValue(ctx)
  9842. if err != nil {
  9843. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9844. }
  9845. return oldValue.Skill, nil
  9846. }
  9847. // ResetSkill resets all changes to the "skill" field.
  9848. func (m *EmployeeMutation) ResetSkill() {
  9849. m.skill = nil
  9850. }
  9851. // SetAbilityType sets the "ability_type" field.
  9852. func (m *EmployeeMutation) SetAbilityType(s string) {
  9853. m.ability_type = &s
  9854. }
  9855. // AbilityType returns the value of the "ability_type" field in the mutation.
  9856. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9857. v := m.ability_type
  9858. if v == nil {
  9859. return
  9860. }
  9861. return *v, true
  9862. }
  9863. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9864. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9866. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9867. if !m.op.Is(OpUpdateOne) {
  9868. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9869. }
  9870. if m.id == nil || m.oldValue == nil {
  9871. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9872. }
  9873. oldValue, err := m.oldValue(ctx)
  9874. if err != nil {
  9875. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9876. }
  9877. return oldValue.AbilityType, nil
  9878. }
  9879. // ResetAbilityType resets all changes to the "ability_type" field.
  9880. func (m *EmployeeMutation) ResetAbilityType() {
  9881. m.ability_type = nil
  9882. }
  9883. // SetScene sets the "scene" field.
  9884. func (m *EmployeeMutation) SetScene(s string) {
  9885. m.scene = &s
  9886. }
  9887. // Scene returns the value of the "scene" field in the mutation.
  9888. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9889. v := m.scene
  9890. if v == nil {
  9891. return
  9892. }
  9893. return *v, true
  9894. }
  9895. // OldScene returns the old "scene" field's value of the Employee entity.
  9896. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9898. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9899. if !m.op.Is(OpUpdateOne) {
  9900. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9901. }
  9902. if m.id == nil || m.oldValue == nil {
  9903. return v, errors.New("OldScene requires an ID field in the mutation")
  9904. }
  9905. oldValue, err := m.oldValue(ctx)
  9906. if err != nil {
  9907. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9908. }
  9909. return oldValue.Scene, nil
  9910. }
  9911. // ResetScene resets all changes to the "scene" field.
  9912. func (m *EmployeeMutation) ResetScene() {
  9913. m.scene = nil
  9914. }
  9915. // SetSwitchIn sets the "switch_in" field.
  9916. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9917. m.switch_in = &s
  9918. }
  9919. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9920. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9921. v := m.switch_in
  9922. if v == nil {
  9923. return
  9924. }
  9925. return *v, true
  9926. }
  9927. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9928. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9930. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9931. if !m.op.Is(OpUpdateOne) {
  9932. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9933. }
  9934. if m.id == nil || m.oldValue == nil {
  9935. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9936. }
  9937. oldValue, err := m.oldValue(ctx)
  9938. if err != nil {
  9939. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9940. }
  9941. return oldValue.SwitchIn, nil
  9942. }
  9943. // ResetSwitchIn resets all changes to the "switch_in" field.
  9944. func (m *EmployeeMutation) ResetSwitchIn() {
  9945. m.switch_in = nil
  9946. }
  9947. // SetVideoURL sets the "video_url" field.
  9948. func (m *EmployeeMutation) SetVideoURL(s string) {
  9949. m.video_url = &s
  9950. }
  9951. // VideoURL returns the value of the "video_url" field in the mutation.
  9952. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9953. v := m.video_url
  9954. if v == nil {
  9955. return
  9956. }
  9957. return *v, true
  9958. }
  9959. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9960. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9962. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9963. if !m.op.Is(OpUpdateOne) {
  9964. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9965. }
  9966. if m.id == nil || m.oldValue == nil {
  9967. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9968. }
  9969. oldValue, err := m.oldValue(ctx)
  9970. if err != nil {
  9971. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9972. }
  9973. return oldValue.VideoURL, nil
  9974. }
  9975. // ResetVideoURL resets all changes to the "video_url" field.
  9976. func (m *EmployeeMutation) ResetVideoURL() {
  9977. m.video_url = nil
  9978. }
  9979. // SetOrganizationID sets the "organization_id" field.
  9980. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9981. m.organization_id = &u
  9982. m.addorganization_id = nil
  9983. }
  9984. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9985. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9986. v := m.organization_id
  9987. if v == nil {
  9988. return
  9989. }
  9990. return *v, true
  9991. }
  9992. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9993. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9995. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9996. if !m.op.Is(OpUpdateOne) {
  9997. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9998. }
  9999. if m.id == nil || m.oldValue == nil {
  10000. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10001. }
  10002. oldValue, err := m.oldValue(ctx)
  10003. if err != nil {
  10004. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10005. }
  10006. return oldValue.OrganizationID, nil
  10007. }
  10008. // AddOrganizationID adds u to the "organization_id" field.
  10009. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  10010. if m.addorganization_id != nil {
  10011. *m.addorganization_id += u
  10012. } else {
  10013. m.addorganization_id = &u
  10014. }
  10015. }
  10016. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10017. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  10018. v := m.addorganization_id
  10019. if v == nil {
  10020. return
  10021. }
  10022. return *v, true
  10023. }
  10024. // ResetOrganizationID resets all changes to the "organization_id" field.
  10025. func (m *EmployeeMutation) ResetOrganizationID() {
  10026. m.organization_id = nil
  10027. m.addorganization_id = nil
  10028. }
  10029. // SetCategoryID sets the "category_id" field.
  10030. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  10031. m.category_id = &u
  10032. m.addcategory_id = nil
  10033. }
  10034. // CategoryID returns the value of the "category_id" field in the mutation.
  10035. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  10036. v := m.category_id
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  10043. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  10055. }
  10056. return oldValue.CategoryID, nil
  10057. }
  10058. // AddCategoryID adds u to the "category_id" field.
  10059. func (m *EmployeeMutation) AddCategoryID(u int64) {
  10060. if m.addcategory_id != nil {
  10061. *m.addcategory_id += u
  10062. } else {
  10063. m.addcategory_id = &u
  10064. }
  10065. }
  10066. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  10067. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  10068. v := m.addcategory_id
  10069. if v == nil {
  10070. return
  10071. }
  10072. return *v, true
  10073. }
  10074. // ResetCategoryID resets all changes to the "category_id" field.
  10075. func (m *EmployeeMutation) ResetCategoryID() {
  10076. m.category_id = nil
  10077. m.addcategory_id = nil
  10078. }
  10079. // SetAPIBase sets the "api_base" field.
  10080. func (m *EmployeeMutation) SetAPIBase(s string) {
  10081. m.api_base = &s
  10082. }
  10083. // APIBase returns the value of the "api_base" field in the mutation.
  10084. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  10085. v := m.api_base
  10086. if v == nil {
  10087. return
  10088. }
  10089. return *v, true
  10090. }
  10091. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  10092. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10094. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  10095. if !m.op.Is(OpUpdateOne) {
  10096. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  10097. }
  10098. if m.id == nil || m.oldValue == nil {
  10099. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  10100. }
  10101. oldValue, err := m.oldValue(ctx)
  10102. if err != nil {
  10103. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  10104. }
  10105. return oldValue.APIBase, nil
  10106. }
  10107. // ResetAPIBase resets all changes to the "api_base" field.
  10108. func (m *EmployeeMutation) ResetAPIBase() {
  10109. m.api_base = nil
  10110. }
  10111. // SetAPIKey sets the "api_key" field.
  10112. func (m *EmployeeMutation) SetAPIKey(s string) {
  10113. m.api_key = &s
  10114. }
  10115. // APIKey returns the value of the "api_key" field in the mutation.
  10116. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  10117. v := m.api_key
  10118. if v == nil {
  10119. return
  10120. }
  10121. return *v, true
  10122. }
  10123. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  10124. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10126. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  10127. if !m.op.Is(OpUpdateOne) {
  10128. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  10129. }
  10130. if m.id == nil || m.oldValue == nil {
  10131. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  10132. }
  10133. oldValue, err := m.oldValue(ctx)
  10134. if err != nil {
  10135. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  10136. }
  10137. return oldValue.APIKey, nil
  10138. }
  10139. // ResetAPIKey resets all changes to the "api_key" field.
  10140. func (m *EmployeeMutation) ResetAPIKey() {
  10141. m.api_key = nil
  10142. }
  10143. // SetAiInfo sets the "ai_info" field.
  10144. func (m *EmployeeMutation) SetAiInfo(s string) {
  10145. m.ai_info = &s
  10146. }
  10147. // AiInfo returns the value of the "ai_info" field in the mutation.
  10148. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  10149. v := m.ai_info
  10150. if v == nil {
  10151. return
  10152. }
  10153. return *v, true
  10154. }
  10155. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  10156. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10158. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  10159. if !m.op.Is(OpUpdateOne) {
  10160. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  10161. }
  10162. if m.id == nil || m.oldValue == nil {
  10163. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  10164. }
  10165. oldValue, err := m.oldValue(ctx)
  10166. if err != nil {
  10167. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  10168. }
  10169. return oldValue.AiInfo, nil
  10170. }
  10171. // ClearAiInfo clears the value of the "ai_info" field.
  10172. func (m *EmployeeMutation) ClearAiInfo() {
  10173. m.ai_info = nil
  10174. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  10175. }
  10176. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  10177. func (m *EmployeeMutation) AiInfoCleared() bool {
  10178. _, ok := m.clearedFields[employee.FieldAiInfo]
  10179. return ok
  10180. }
  10181. // ResetAiInfo resets all changes to the "ai_info" field.
  10182. func (m *EmployeeMutation) ResetAiInfo() {
  10183. m.ai_info = nil
  10184. delete(m.clearedFields, employee.FieldAiInfo)
  10185. }
  10186. // SetIsVip sets the "is_vip" field.
  10187. func (m *EmployeeMutation) SetIsVip(i int) {
  10188. m.is_vip = &i
  10189. m.addis_vip = nil
  10190. }
  10191. // IsVip returns the value of the "is_vip" field in the mutation.
  10192. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  10193. v := m.is_vip
  10194. if v == nil {
  10195. return
  10196. }
  10197. return *v, true
  10198. }
  10199. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  10200. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10202. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  10203. if !m.op.Is(OpUpdateOne) {
  10204. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  10205. }
  10206. if m.id == nil || m.oldValue == nil {
  10207. return v, errors.New("OldIsVip requires an ID field in the mutation")
  10208. }
  10209. oldValue, err := m.oldValue(ctx)
  10210. if err != nil {
  10211. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  10212. }
  10213. return oldValue.IsVip, nil
  10214. }
  10215. // AddIsVip adds i to the "is_vip" field.
  10216. func (m *EmployeeMutation) AddIsVip(i int) {
  10217. if m.addis_vip != nil {
  10218. *m.addis_vip += i
  10219. } else {
  10220. m.addis_vip = &i
  10221. }
  10222. }
  10223. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  10224. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  10225. v := m.addis_vip
  10226. if v == nil {
  10227. return
  10228. }
  10229. return *v, true
  10230. }
  10231. // ResetIsVip resets all changes to the "is_vip" field.
  10232. func (m *EmployeeMutation) ResetIsVip() {
  10233. m.is_vip = nil
  10234. m.addis_vip = nil
  10235. }
  10236. // SetChatURL sets the "chat_url" field.
  10237. func (m *EmployeeMutation) SetChatURL(s string) {
  10238. m.chat_url = &s
  10239. }
  10240. // ChatURL returns the value of the "chat_url" field in the mutation.
  10241. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  10242. v := m.chat_url
  10243. if v == nil {
  10244. return
  10245. }
  10246. return *v, true
  10247. }
  10248. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  10249. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10251. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  10252. if !m.op.Is(OpUpdateOne) {
  10253. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  10254. }
  10255. if m.id == nil || m.oldValue == nil {
  10256. return v, errors.New("OldChatURL requires an ID field in the mutation")
  10257. }
  10258. oldValue, err := m.oldValue(ctx)
  10259. if err != nil {
  10260. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  10261. }
  10262. return oldValue.ChatURL, nil
  10263. }
  10264. // ResetChatURL resets all changes to the "chat_url" field.
  10265. func (m *EmployeeMutation) ResetChatURL() {
  10266. m.chat_url = nil
  10267. }
  10268. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  10269. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  10270. if m.em_work_experiences == nil {
  10271. m.em_work_experiences = make(map[uint64]struct{})
  10272. }
  10273. for i := range ids {
  10274. m.em_work_experiences[ids[i]] = struct{}{}
  10275. }
  10276. }
  10277. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  10278. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  10279. m.clearedem_work_experiences = true
  10280. }
  10281. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  10282. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  10283. return m.clearedem_work_experiences
  10284. }
  10285. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  10286. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  10287. if m.removedem_work_experiences == nil {
  10288. m.removedem_work_experiences = make(map[uint64]struct{})
  10289. }
  10290. for i := range ids {
  10291. delete(m.em_work_experiences, ids[i])
  10292. m.removedem_work_experiences[ids[i]] = struct{}{}
  10293. }
  10294. }
  10295. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  10296. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  10297. for id := range m.removedem_work_experiences {
  10298. ids = append(ids, id)
  10299. }
  10300. return
  10301. }
  10302. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  10303. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  10304. for id := range m.em_work_experiences {
  10305. ids = append(ids, id)
  10306. }
  10307. return
  10308. }
  10309. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  10310. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  10311. m.em_work_experiences = nil
  10312. m.clearedem_work_experiences = false
  10313. m.removedem_work_experiences = nil
  10314. }
  10315. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  10316. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  10317. if m.em_tutorial == nil {
  10318. m.em_tutorial = make(map[uint64]struct{})
  10319. }
  10320. for i := range ids {
  10321. m.em_tutorial[ids[i]] = struct{}{}
  10322. }
  10323. }
  10324. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  10325. func (m *EmployeeMutation) ClearEmTutorial() {
  10326. m.clearedem_tutorial = true
  10327. }
  10328. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  10329. func (m *EmployeeMutation) EmTutorialCleared() bool {
  10330. return m.clearedem_tutorial
  10331. }
  10332. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  10333. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  10334. if m.removedem_tutorial == nil {
  10335. m.removedem_tutorial = make(map[uint64]struct{})
  10336. }
  10337. for i := range ids {
  10338. delete(m.em_tutorial, ids[i])
  10339. m.removedem_tutorial[ids[i]] = struct{}{}
  10340. }
  10341. }
  10342. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  10343. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  10344. for id := range m.removedem_tutorial {
  10345. ids = append(ids, id)
  10346. }
  10347. return
  10348. }
  10349. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  10350. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  10351. for id := range m.em_tutorial {
  10352. ids = append(ids, id)
  10353. }
  10354. return
  10355. }
  10356. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  10357. func (m *EmployeeMutation) ResetEmTutorial() {
  10358. m.em_tutorial = nil
  10359. m.clearedem_tutorial = false
  10360. m.removedem_tutorial = nil
  10361. }
  10362. // Where appends a list predicates to the EmployeeMutation builder.
  10363. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  10364. m.predicates = append(m.predicates, ps...)
  10365. }
  10366. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  10367. // users can use type-assertion to append predicates that do not depend on any generated package.
  10368. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  10369. p := make([]predicate.Employee, len(ps))
  10370. for i := range ps {
  10371. p[i] = ps[i]
  10372. }
  10373. m.Where(p...)
  10374. }
  10375. // Op returns the operation name.
  10376. func (m *EmployeeMutation) Op() Op {
  10377. return m.op
  10378. }
  10379. // SetOp allows setting the mutation operation.
  10380. func (m *EmployeeMutation) SetOp(op Op) {
  10381. m.op = op
  10382. }
  10383. // Type returns the node type of this mutation (Employee).
  10384. func (m *EmployeeMutation) Type() string {
  10385. return m.typ
  10386. }
  10387. // Fields returns all fields that were changed during this mutation. Note that in
  10388. // order to get all numeric fields that were incremented/decremented, call
  10389. // AddedFields().
  10390. func (m *EmployeeMutation) Fields() []string {
  10391. fields := make([]string, 0, 23)
  10392. if m.created_at != nil {
  10393. fields = append(fields, employee.FieldCreatedAt)
  10394. }
  10395. if m.updated_at != nil {
  10396. fields = append(fields, employee.FieldUpdatedAt)
  10397. }
  10398. if m.deleted_at != nil {
  10399. fields = append(fields, employee.FieldDeletedAt)
  10400. }
  10401. if m.title != nil {
  10402. fields = append(fields, employee.FieldTitle)
  10403. }
  10404. if m.avatar != nil {
  10405. fields = append(fields, employee.FieldAvatar)
  10406. }
  10407. if m.tags != nil {
  10408. fields = append(fields, employee.FieldTags)
  10409. }
  10410. if m.hire_count != nil {
  10411. fields = append(fields, employee.FieldHireCount)
  10412. }
  10413. if m.service_count != nil {
  10414. fields = append(fields, employee.FieldServiceCount)
  10415. }
  10416. if m.achievement_count != nil {
  10417. fields = append(fields, employee.FieldAchievementCount)
  10418. }
  10419. if m.intro != nil {
  10420. fields = append(fields, employee.FieldIntro)
  10421. }
  10422. if m.estimate != nil {
  10423. fields = append(fields, employee.FieldEstimate)
  10424. }
  10425. if m.skill != nil {
  10426. fields = append(fields, employee.FieldSkill)
  10427. }
  10428. if m.ability_type != nil {
  10429. fields = append(fields, employee.FieldAbilityType)
  10430. }
  10431. if m.scene != nil {
  10432. fields = append(fields, employee.FieldScene)
  10433. }
  10434. if m.switch_in != nil {
  10435. fields = append(fields, employee.FieldSwitchIn)
  10436. }
  10437. if m.video_url != nil {
  10438. fields = append(fields, employee.FieldVideoURL)
  10439. }
  10440. if m.organization_id != nil {
  10441. fields = append(fields, employee.FieldOrganizationID)
  10442. }
  10443. if m.category_id != nil {
  10444. fields = append(fields, employee.FieldCategoryID)
  10445. }
  10446. if m.api_base != nil {
  10447. fields = append(fields, employee.FieldAPIBase)
  10448. }
  10449. if m.api_key != nil {
  10450. fields = append(fields, employee.FieldAPIKey)
  10451. }
  10452. if m.ai_info != nil {
  10453. fields = append(fields, employee.FieldAiInfo)
  10454. }
  10455. if m.is_vip != nil {
  10456. fields = append(fields, employee.FieldIsVip)
  10457. }
  10458. if m.chat_url != nil {
  10459. fields = append(fields, employee.FieldChatURL)
  10460. }
  10461. return fields
  10462. }
  10463. // Field returns the value of a field with the given name. The second boolean
  10464. // return value indicates that this field was not set, or was not defined in the
  10465. // schema.
  10466. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  10467. switch name {
  10468. case employee.FieldCreatedAt:
  10469. return m.CreatedAt()
  10470. case employee.FieldUpdatedAt:
  10471. return m.UpdatedAt()
  10472. case employee.FieldDeletedAt:
  10473. return m.DeletedAt()
  10474. case employee.FieldTitle:
  10475. return m.Title()
  10476. case employee.FieldAvatar:
  10477. return m.Avatar()
  10478. case employee.FieldTags:
  10479. return m.Tags()
  10480. case employee.FieldHireCount:
  10481. return m.HireCount()
  10482. case employee.FieldServiceCount:
  10483. return m.ServiceCount()
  10484. case employee.FieldAchievementCount:
  10485. return m.AchievementCount()
  10486. case employee.FieldIntro:
  10487. return m.Intro()
  10488. case employee.FieldEstimate:
  10489. return m.Estimate()
  10490. case employee.FieldSkill:
  10491. return m.Skill()
  10492. case employee.FieldAbilityType:
  10493. return m.AbilityType()
  10494. case employee.FieldScene:
  10495. return m.Scene()
  10496. case employee.FieldSwitchIn:
  10497. return m.SwitchIn()
  10498. case employee.FieldVideoURL:
  10499. return m.VideoURL()
  10500. case employee.FieldOrganizationID:
  10501. return m.OrganizationID()
  10502. case employee.FieldCategoryID:
  10503. return m.CategoryID()
  10504. case employee.FieldAPIBase:
  10505. return m.APIBase()
  10506. case employee.FieldAPIKey:
  10507. return m.APIKey()
  10508. case employee.FieldAiInfo:
  10509. return m.AiInfo()
  10510. case employee.FieldIsVip:
  10511. return m.IsVip()
  10512. case employee.FieldChatURL:
  10513. return m.ChatURL()
  10514. }
  10515. return nil, false
  10516. }
  10517. // OldField returns the old value of the field from the database. An error is
  10518. // returned if the mutation operation is not UpdateOne, or the query to the
  10519. // database failed.
  10520. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10521. switch name {
  10522. case employee.FieldCreatedAt:
  10523. return m.OldCreatedAt(ctx)
  10524. case employee.FieldUpdatedAt:
  10525. return m.OldUpdatedAt(ctx)
  10526. case employee.FieldDeletedAt:
  10527. return m.OldDeletedAt(ctx)
  10528. case employee.FieldTitle:
  10529. return m.OldTitle(ctx)
  10530. case employee.FieldAvatar:
  10531. return m.OldAvatar(ctx)
  10532. case employee.FieldTags:
  10533. return m.OldTags(ctx)
  10534. case employee.FieldHireCount:
  10535. return m.OldHireCount(ctx)
  10536. case employee.FieldServiceCount:
  10537. return m.OldServiceCount(ctx)
  10538. case employee.FieldAchievementCount:
  10539. return m.OldAchievementCount(ctx)
  10540. case employee.FieldIntro:
  10541. return m.OldIntro(ctx)
  10542. case employee.FieldEstimate:
  10543. return m.OldEstimate(ctx)
  10544. case employee.FieldSkill:
  10545. return m.OldSkill(ctx)
  10546. case employee.FieldAbilityType:
  10547. return m.OldAbilityType(ctx)
  10548. case employee.FieldScene:
  10549. return m.OldScene(ctx)
  10550. case employee.FieldSwitchIn:
  10551. return m.OldSwitchIn(ctx)
  10552. case employee.FieldVideoURL:
  10553. return m.OldVideoURL(ctx)
  10554. case employee.FieldOrganizationID:
  10555. return m.OldOrganizationID(ctx)
  10556. case employee.FieldCategoryID:
  10557. return m.OldCategoryID(ctx)
  10558. case employee.FieldAPIBase:
  10559. return m.OldAPIBase(ctx)
  10560. case employee.FieldAPIKey:
  10561. return m.OldAPIKey(ctx)
  10562. case employee.FieldAiInfo:
  10563. return m.OldAiInfo(ctx)
  10564. case employee.FieldIsVip:
  10565. return m.OldIsVip(ctx)
  10566. case employee.FieldChatURL:
  10567. return m.OldChatURL(ctx)
  10568. }
  10569. return nil, fmt.Errorf("unknown Employee field %s", name)
  10570. }
  10571. // SetField sets the value of a field with the given name. It returns an error if
  10572. // the field is not defined in the schema, or if the type mismatched the field
  10573. // type.
  10574. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  10575. switch name {
  10576. case employee.FieldCreatedAt:
  10577. v, ok := value.(time.Time)
  10578. if !ok {
  10579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10580. }
  10581. m.SetCreatedAt(v)
  10582. return nil
  10583. case employee.FieldUpdatedAt:
  10584. v, ok := value.(time.Time)
  10585. if !ok {
  10586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10587. }
  10588. m.SetUpdatedAt(v)
  10589. return nil
  10590. case employee.FieldDeletedAt:
  10591. v, ok := value.(time.Time)
  10592. if !ok {
  10593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10594. }
  10595. m.SetDeletedAt(v)
  10596. return nil
  10597. case employee.FieldTitle:
  10598. v, ok := value.(string)
  10599. if !ok {
  10600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10601. }
  10602. m.SetTitle(v)
  10603. return nil
  10604. case employee.FieldAvatar:
  10605. v, ok := value.(string)
  10606. if !ok {
  10607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10608. }
  10609. m.SetAvatar(v)
  10610. return nil
  10611. case employee.FieldTags:
  10612. v, ok := value.(string)
  10613. if !ok {
  10614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10615. }
  10616. m.SetTags(v)
  10617. return nil
  10618. case employee.FieldHireCount:
  10619. v, ok := value.(int)
  10620. if !ok {
  10621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10622. }
  10623. m.SetHireCount(v)
  10624. return nil
  10625. case employee.FieldServiceCount:
  10626. v, ok := value.(int)
  10627. if !ok {
  10628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10629. }
  10630. m.SetServiceCount(v)
  10631. return nil
  10632. case employee.FieldAchievementCount:
  10633. v, ok := value.(int)
  10634. if !ok {
  10635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10636. }
  10637. m.SetAchievementCount(v)
  10638. return nil
  10639. case employee.FieldIntro:
  10640. v, ok := value.(string)
  10641. if !ok {
  10642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10643. }
  10644. m.SetIntro(v)
  10645. return nil
  10646. case employee.FieldEstimate:
  10647. v, ok := value.(string)
  10648. if !ok {
  10649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10650. }
  10651. m.SetEstimate(v)
  10652. return nil
  10653. case employee.FieldSkill:
  10654. v, ok := value.(string)
  10655. if !ok {
  10656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10657. }
  10658. m.SetSkill(v)
  10659. return nil
  10660. case employee.FieldAbilityType:
  10661. v, ok := value.(string)
  10662. if !ok {
  10663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10664. }
  10665. m.SetAbilityType(v)
  10666. return nil
  10667. case employee.FieldScene:
  10668. v, ok := value.(string)
  10669. if !ok {
  10670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10671. }
  10672. m.SetScene(v)
  10673. return nil
  10674. case employee.FieldSwitchIn:
  10675. v, ok := value.(string)
  10676. if !ok {
  10677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10678. }
  10679. m.SetSwitchIn(v)
  10680. return nil
  10681. case employee.FieldVideoURL:
  10682. v, ok := value.(string)
  10683. if !ok {
  10684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10685. }
  10686. m.SetVideoURL(v)
  10687. return nil
  10688. case employee.FieldOrganizationID:
  10689. v, ok := value.(uint64)
  10690. if !ok {
  10691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10692. }
  10693. m.SetOrganizationID(v)
  10694. return nil
  10695. case employee.FieldCategoryID:
  10696. v, ok := value.(uint64)
  10697. if !ok {
  10698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10699. }
  10700. m.SetCategoryID(v)
  10701. return nil
  10702. case employee.FieldAPIBase:
  10703. v, ok := value.(string)
  10704. if !ok {
  10705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10706. }
  10707. m.SetAPIBase(v)
  10708. return nil
  10709. case employee.FieldAPIKey:
  10710. v, ok := value.(string)
  10711. if !ok {
  10712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10713. }
  10714. m.SetAPIKey(v)
  10715. return nil
  10716. case employee.FieldAiInfo:
  10717. v, ok := value.(string)
  10718. if !ok {
  10719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10720. }
  10721. m.SetAiInfo(v)
  10722. return nil
  10723. case employee.FieldIsVip:
  10724. v, ok := value.(int)
  10725. if !ok {
  10726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10727. }
  10728. m.SetIsVip(v)
  10729. return nil
  10730. case employee.FieldChatURL:
  10731. v, ok := value.(string)
  10732. if !ok {
  10733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10734. }
  10735. m.SetChatURL(v)
  10736. return nil
  10737. }
  10738. return fmt.Errorf("unknown Employee field %s", name)
  10739. }
  10740. // AddedFields returns all numeric fields that were incremented/decremented during
  10741. // this mutation.
  10742. func (m *EmployeeMutation) AddedFields() []string {
  10743. var fields []string
  10744. if m.addhire_count != nil {
  10745. fields = append(fields, employee.FieldHireCount)
  10746. }
  10747. if m.addservice_count != nil {
  10748. fields = append(fields, employee.FieldServiceCount)
  10749. }
  10750. if m.addachievement_count != nil {
  10751. fields = append(fields, employee.FieldAchievementCount)
  10752. }
  10753. if m.addorganization_id != nil {
  10754. fields = append(fields, employee.FieldOrganizationID)
  10755. }
  10756. if m.addcategory_id != nil {
  10757. fields = append(fields, employee.FieldCategoryID)
  10758. }
  10759. if m.addis_vip != nil {
  10760. fields = append(fields, employee.FieldIsVip)
  10761. }
  10762. return fields
  10763. }
  10764. // AddedField returns the numeric value that was incremented/decremented on a field
  10765. // with the given name. The second boolean return value indicates that this field
  10766. // was not set, or was not defined in the schema.
  10767. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10768. switch name {
  10769. case employee.FieldHireCount:
  10770. return m.AddedHireCount()
  10771. case employee.FieldServiceCount:
  10772. return m.AddedServiceCount()
  10773. case employee.FieldAchievementCount:
  10774. return m.AddedAchievementCount()
  10775. case employee.FieldOrganizationID:
  10776. return m.AddedOrganizationID()
  10777. case employee.FieldCategoryID:
  10778. return m.AddedCategoryID()
  10779. case employee.FieldIsVip:
  10780. return m.AddedIsVip()
  10781. }
  10782. return nil, false
  10783. }
  10784. // AddField adds the value to the field with the given name. It returns an error if
  10785. // the field is not defined in the schema, or if the type mismatched the field
  10786. // type.
  10787. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10788. switch name {
  10789. case employee.FieldHireCount:
  10790. v, ok := value.(int)
  10791. if !ok {
  10792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10793. }
  10794. m.AddHireCount(v)
  10795. return nil
  10796. case employee.FieldServiceCount:
  10797. v, ok := value.(int)
  10798. if !ok {
  10799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10800. }
  10801. m.AddServiceCount(v)
  10802. return nil
  10803. case employee.FieldAchievementCount:
  10804. v, ok := value.(int)
  10805. if !ok {
  10806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10807. }
  10808. m.AddAchievementCount(v)
  10809. return nil
  10810. case employee.FieldOrganizationID:
  10811. v, ok := value.(int64)
  10812. if !ok {
  10813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10814. }
  10815. m.AddOrganizationID(v)
  10816. return nil
  10817. case employee.FieldCategoryID:
  10818. v, ok := value.(int64)
  10819. if !ok {
  10820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10821. }
  10822. m.AddCategoryID(v)
  10823. return nil
  10824. case employee.FieldIsVip:
  10825. v, ok := value.(int)
  10826. if !ok {
  10827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10828. }
  10829. m.AddIsVip(v)
  10830. return nil
  10831. }
  10832. return fmt.Errorf("unknown Employee numeric field %s", name)
  10833. }
  10834. // ClearedFields returns all nullable fields that were cleared during this
  10835. // mutation.
  10836. func (m *EmployeeMutation) ClearedFields() []string {
  10837. var fields []string
  10838. if m.FieldCleared(employee.FieldDeletedAt) {
  10839. fields = append(fields, employee.FieldDeletedAt)
  10840. }
  10841. if m.FieldCleared(employee.FieldAiInfo) {
  10842. fields = append(fields, employee.FieldAiInfo)
  10843. }
  10844. return fields
  10845. }
  10846. // FieldCleared returns a boolean indicating if a field with the given name was
  10847. // cleared in this mutation.
  10848. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10849. _, ok := m.clearedFields[name]
  10850. return ok
  10851. }
  10852. // ClearField clears the value of the field with the given name. It returns an
  10853. // error if the field is not defined in the schema.
  10854. func (m *EmployeeMutation) ClearField(name string) error {
  10855. switch name {
  10856. case employee.FieldDeletedAt:
  10857. m.ClearDeletedAt()
  10858. return nil
  10859. case employee.FieldAiInfo:
  10860. m.ClearAiInfo()
  10861. return nil
  10862. }
  10863. return fmt.Errorf("unknown Employee nullable field %s", name)
  10864. }
  10865. // ResetField resets all changes in the mutation for the field with the given name.
  10866. // It returns an error if the field is not defined in the schema.
  10867. func (m *EmployeeMutation) ResetField(name string) error {
  10868. switch name {
  10869. case employee.FieldCreatedAt:
  10870. m.ResetCreatedAt()
  10871. return nil
  10872. case employee.FieldUpdatedAt:
  10873. m.ResetUpdatedAt()
  10874. return nil
  10875. case employee.FieldDeletedAt:
  10876. m.ResetDeletedAt()
  10877. return nil
  10878. case employee.FieldTitle:
  10879. m.ResetTitle()
  10880. return nil
  10881. case employee.FieldAvatar:
  10882. m.ResetAvatar()
  10883. return nil
  10884. case employee.FieldTags:
  10885. m.ResetTags()
  10886. return nil
  10887. case employee.FieldHireCount:
  10888. m.ResetHireCount()
  10889. return nil
  10890. case employee.FieldServiceCount:
  10891. m.ResetServiceCount()
  10892. return nil
  10893. case employee.FieldAchievementCount:
  10894. m.ResetAchievementCount()
  10895. return nil
  10896. case employee.FieldIntro:
  10897. m.ResetIntro()
  10898. return nil
  10899. case employee.FieldEstimate:
  10900. m.ResetEstimate()
  10901. return nil
  10902. case employee.FieldSkill:
  10903. m.ResetSkill()
  10904. return nil
  10905. case employee.FieldAbilityType:
  10906. m.ResetAbilityType()
  10907. return nil
  10908. case employee.FieldScene:
  10909. m.ResetScene()
  10910. return nil
  10911. case employee.FieldSwitchIn:
  10912. m.ResetSwitchIn()
  10913. return nil
  10914. case employee.FieldVideoURL:
  10915. m.ResetVideoURL()
  10916. return nil
  10917. case employee.FieldOrganizationID:
  10918. m.ResetOrganizationID()
  10919. return nil
  10920. case employee.FieldCategoryID:
  10921. m.ResetCategoryID()
  10922. return nil
  10923. case employee.FieldAPIBase:
  10924. m.ResetAPIBase()
  10925. return nil
  10926. case employee.FieldAPIKey:
  10927. m.ResetAPIKey()
  10928. return nil
  10929. case employee.FieldAiInfo:
  10930. m.ResetAiInfo()
  10931. return nil
  10932. case employee.FieldIsVip:
  10933. m.ResetIsVip()
  10934. return nil
  10935. case employee.FieldChatURL:
  10936. m.ResetChatURL()
  10937. return nil
  10938. }
  10939. return fmt.Errorf("unknown Employee field %s", name)
  10940. }
  10941. // AddedEdges returns all edge names that were set/added in this mutation.
  10942. func (m *EmployeeMutation) AddedEdges() []string {
  10943. edges := make([]string, 0, 2)
  10944. if m.em_work_experiences != nil {
  10945. edges = append(edges, employee.EdgeEmWorkExperiences)
  10946. }
  10947. if m.em_tutorial != nil {
  10948. edges = append(edges, employee.EdgeEmTutorial)
  10949. }
  10950. return edges
  10951. }
  10952. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10953. // name in this mutation.
  10954. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10955. switch name {
  10956. case employee.EdgeEmWorkExperiences:
  10957. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10958. for id := range m.em_work_experiences {
  10959. ids = append(ids, id)
  10960. }
  10961. return ids
  10962. case employee.EdgeEmTutorial:
  10963. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10964. for id := range m.em_tutorial {
  10965. ids = append(ids, id)
  10966. }
  10967. return ids
  10968. }
  10969. return nil
  10970. }
  10971. // RemovedEdges returns all edge names that were removed in this mutation.
  10972. func (m *EmployeeMutation) RemovedEdges() []string {
  10973. edges := make([]string, 0, 2)
  10974. if m.removedem_work_experiences != nil {
  10975. edges = append(edges, employee.EdgeEmWorkExperiences)
  10976. }
  10977. if m.removedem_tutorial != nil {
  10978. edges = append(edges, employee.EdgeEmTutorial)
  10979. }
  10980. return edges
  10981. }
  10982. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10983. // the given name in this mutation.
  10984. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10985. switch name {
  10986. case employee.EdgeEmWorkExperiences:
  10987. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10988. for id := range m.removedem_work_experiences {
  10989. ids = append(ids, id)
  10990. }
  10991. return ids
  10992. case employee.EdgeEmTutorial:
  10993. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10994. for id := range m.removedem_tutorial {
  10995. ids = append(ids, id)
  10996. }
  10997. return ids
  10998. }
  10999. return nil
  11000. }
  11001. // ClearedEdges returns all edge names that were cleared in this mutation.
  11002. func (m *EmployeeMutation) ClearedEdges() []string {
  11003. edges := make([]string, 0, 2)
  11004. if m.clearedem_work_experiences {
  11005. edges = append(edges, employee.EdgeEmWorkExperiences)
  11006. }
  11007. if m.clearedem_tutorial {
  11008. edges = append(edges, employee.EdgeEmTutorial)
  11009. }
  11010. return edges
  11011. }
  11012. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11013. // was cleared in this mutation.
  11014. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  11015. switch name {
  11016. case employee.EdgeEmWorkExperiences:
  11017. return m.clearedem_work_experiences
  11018. case employee.EdgeEmTutorial:
  11019. return m.clearedem_tutorial
  11020. }
  11021. return false
  11022. }
  11023. // ClearEdge clears the value of the edge with the given name. It returns an error
  11024. // if that edge is not defined in the schema.
  11025. func (m *EmployeeMutation) ClearEdge(name string) error {
  11026. switch name {
  11027. }
  11028. return fmt.Errorf("unknown Employee unique edge %s", name)
  11029. }
  11030. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11031. // It returns an error if the edge is not defined in the schema.
  11032. func (m *EmployeeMutation) ResetEdge(name string) error {
  11033. switch name {
  11034. case employee.EdgeEmWorkExperiences:
  11035. m.ResetEmWorkExperiences()
  11036. return nil
  11037. case employee.EdgeEmTutorial:
  11038. m.ResetEmTutorial()
  11039. return nil
  11040. }
  11041. return fmt.Errorf("unknown Employee edge %s", name)
  11042. }
  11043. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  11044. type EmployeeConfigMutation struct {
  11045. config
  11046. op Op
  11047. typ string
  11048. id *uint64
  11049. created_at *time.Time
  11050. updated_at *time.Time
  11051. deleted_at *time.Time
  11052. stype *string
  11053. title *string
  11054. photo *string
  11055. organization_id *uint64
  11056. addorganization_id *int64
  11057. clearedFields map[string]struct{}
  11058. done bool
  11059. oldValue func(context.Context) (*EmployeeConfig, error)
  11060. predicates []predicate.EmployeeConfig
  11061. }
  11062. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  11063. // employeeconfigOption allows management of the mutation configuration using functional options.
  11064. type employeeconfigOption func(*EmployeeConfigMutation)
  11065. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  11066. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  11067. m := &EmployeeConfigMutation{
  11068. config: c,
  11069. op: op,
  11070. typ: TypeEmployeeConfig,
  11071. clearedFields: make(map[string]struct{}),
  11072. }
  11073. for _, opt := range opts {
  11074. opt(m)
  11075. }
  11076. return m
  11077. }
  11078. // withEmployeeConfigID sets the ID field of the mutation.
  11079. func withEmployeeConfigID(id uint64) employeeconfigOption {
  11080. return func(m *EmployeeConfigMutation) {
  11081. var (
  11082. err error
  11083. once sync.Once
  11084. value *EmployeeConfig
  11085. )
  11086. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  11087. once.Do(func() {
  11088. if m.done {
  11089. err = errors.New("querying old values post mutation is not allowed")
  11090. } else {
  11091. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  11092. }
  11093. })
  11094. return value, err
  11095. }
  11096. m.id = &id
  11097. }
  11098. }
  11099. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  11100. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  11101. return func(m *EmployeeConfigMutation) {
  11102. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  11103. return node, nil
  11104. }
  11105. m.id = &node.ID
  11106. }
  11107. }
  11108. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11109. // executed in a transaction (ent.Tx), a transactional client is returned.
  11110. func (m EmployeeConfigMutation) Client() *Client {
  11111. client := &Client{config: m.config}
  11112. client.init()
  11113. return client
  11114. }
  11115. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11116. // it returns an error otherwise.
  11117. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  11118. if _, ok := m.driver.(*txDriver); !ok {
  11119. return nil, errors.New("ent: mutation is not running in a transaction")
  11120. }
  11121. tx := &Tx{config: m.config}
  11122. tx.init()
  11123. return tx, nil
  11124. }
  11125. // SetID sets the value of the id field. Note that this
  11126. // operation is only accepted on creation of EmployeeConfig entities.
  11127. func (m *EmployeeConfigMutation) SetID(id uint64) {
  11128. m.id = &id
  11129. }
  11130. // ID returns the ID value in the mutation. Note that the ID is only available
  11131. // if it was provided to the builder or after it was returned from the database.
  11132. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  11133. if m.id == nil {
  11134. return
  11135. }
  11136. return *m.id, true
  11137. }
  11138. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11139. // That means, if the mutation is applied within a transaction with an isolation level such
  11140. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11141. // or updated by the mutation.
  11142. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  11143. switch {
  11144. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11145. id, exists := m.ID()
  11146. if exists {
  11147. return []uint64{id}, nil
  11148. }
  11149. fallthrough
  11150. case m.op.Is(OpUpdate | OpDelete):
  11151. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  11152. default:
  11153. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11154. }
  11155. }
  11156. // SetCreatedAt sets the "created_at" field.
  11157. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  11158. m.created_at = &t
  11159. }
  11160. // CreatedAt returns the value of the "created_at" field in the mutation.
  11161. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  11162. v := m.created_at
  11163. if v == nil {
  11164. return
  11165. }
  11166. return *v, true
  11167. }
  11168. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  11169. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11171. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11172. if !m.op.Is(OpUpdateOne) {
  11173. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11174. }
  11175. if m.id == nil || m.oldValue == nil {
  11176. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11177. }
  11178. oldValue, err := m.oldValue(ctx)
  11179. if err != nil {
  11180. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11181. }
  11182. return oldValue.CreatedAt, nil
  11183. }
  11184. // ResetCreatedAt resets all changes to the "created_at" field.
  11185. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  11186. m.created_at = nil
  11187. }
  11188. // SetUpdatedAt sets the "updated_at" field.
  11189. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  11190. m.updated_at = &t
  11191. }
  11192. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11193. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  11194. v := m.updated_at
  11195. if v == nil {
  11196. return
  11197. }
  11198. return *v, true
  11199. }
  11200. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  11201. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11203. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11204. if !m.op.Is(OpUpdateOne) {
  11205. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11206. }
  11207. if m.id == nil || m.oldValue == nil {
  11208. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11209. }
  11210. oldValue, err := m.oldValue(ctx)
  11211. if err != nil {
  11212. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11213. }
  11214. return oldValue.UpdatedAt, nil
  11215. }
  11216. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11217. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  11218. m.updated_at = nil
  11219. }
  11220. // SetDeletedAt sets the "deleted_at" field.
  11221. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  11222. m.deleted_at = &t
  11223. }
  11224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11225. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  11226. v := m.deleted_at
  11227. if v == nil {
  11228. return
  11229. }
  11230. return *v, true
  11231. }
  11232. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  11233. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11235. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11236. if !m.op.Is(OpUpdateOne) {
  11237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11238. }
  11239. if m.id == nil || m.oldValue == nil {
  11240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11241. }
  11242. oldValue, err := m.oldValue(ctx)
  11243. if err != nil {
  11244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11245. }
  11246. return oldValue.DeletedAt, nil
  11247. }
  11248. // ClearDeletedAt clears the value of the "deleted_at" field.
  11249. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  11250. m.deleted_at = nil
  11251. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  11252. }
  11253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11254. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  11255. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  11256. return ok
  11257. }
  11258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11259. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  11260. m.deleted_at = nil
  11261. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  11262. }
  11263. // SetStype sets the "stype" field.
  11264. func (m *EmployeeConfigMutation) SetStype(s string) {
  11265. m.stype = &s
  11266. }
  11267. // Stype returns the value of the "stype" field in the mutation.
  11268. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  11269. v := m.stype
  11270. if v == nil {
  11271. return
  11272. }
  11273. return *v, true
  11274. }
  11275. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  11276. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11278. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  11279. if !m.op.Is(OpUpdateOne) {
  11280. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  11281. }
  11282. if m.id == nil || m.oldValue == nil {
  11283. return v, errors.New("OldStype requires an ID field in the mutation")
  11284. }
  11285. oldValue, err := m.oldValue(ctx)
  11286. if err != nil {
  11287. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  11288. }
  11289. return oldValue.Stype, nil
  11290. }
  11291. // ResetStype resets all changes to the "stype" field.
  11292. func (m *EmployeeConfigMutation) ResetStype() {
  11293. m.stype = nil
  11294. }
  11295. // SetTitle sets the "title" field.
  11296. func (m *EmployeeConfigMutation) SetTitle(s string) {
  11297. m.title = &s
  11298. }
  11299. // Title returns the value of the "title" field in the mutation.
  11300. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  11301. v := m.title
  11302. if v == nil {
  11303. return
  11304. }
  11305. return *v, true
  11306. }
  11307. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  11308. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11310. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  11311. if !m.op.Is(OpUpdateOne) {
  11312. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11313. }
  11314. if m.id == nil || m.oldValue == nil {
  11315. return v, errors.New("OldTitle requires an ID field in the mutation")
  11316. }
  11317. oldValue, err := m.oldValue(ctx)
  11318. if err != nil {
  11319. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11320. }
  11321. return oldValue.Title, nil
  11322. }
  11323. // ResetTitle resets all changes to the "title" field.
  11324. func (m *EmployeeConfigMutation) ResetTitle() {
  11325. m.title = nil
  11326. }
  11327. // SetPhoto sets the "photo" field.
  11328. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  11329. m.photo = &s
  11330. }
  11331. // Photo returns the value of the "photo" field in the mutation.
  11332. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  11333. v := m.photo
  11334. if v == nil {
  11335. return
  11336. }
  11337. return *v, true
  11338. }
  11339. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  11340. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11342. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  11343. if !m.op.Is(OpUpdateOne) {
  11344. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  11345. }
  11346. if m.id == nil || m.oldValue == nil {
  11347. return v, errors.New("OldPhoto requires an ID field in the mutation")
  11348. }
  11349. oldValue, err := m.oldValue(ctx)
  11350. if err != nil {
  11351. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  11352. }
  11353. return oldValue.Photo, nil
  11354. }
  11355. // ResetPhoto resets all changes to the "photo" field.
  11356. func (m *EmployeeConfigMutation) ResetPhoto() {
  11357. m.photo = nil
  11358. }
  11359. // SetOrganizationID sets the "organization_id" field.
  11360. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  11361. m.organization_id = &u
  11362. m.addorganization_id = nil
  11363. }
  11364. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11365. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  11366. v := m.organization_id
  11367. if v == nil {
  11368. return
  11369. }
  11370. return *v, true
  11371. }
  11372. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  11373. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11375. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11376. if !m.op.Is(OpUpdateOne) {
  11377. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11378. }
  11379. if m.id == nil || m.oldValue == nil {
  11380. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11381. }
  11382. oldValue, err := m.oldValue(ctx)
  11383. if err != nil {
  11384. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11385. }
  11386. return oldValue.OrganizationID, nil
  11387. }
  11388. // AddOrganizationID adds u to the "organization_id" field.
  11389. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  11390. if m.addorganization_id != nil {
  11391. *m.addorganization_id += u
  11392. } else {
  11393. m.addorganization_id = &u
  11394. }
  11395. }
  11396. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11397. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  11398. v := m.addorganization_id
  11399. if v == nil {
  11400. return
  11401. }
  11402. return *v, true
  11403. }
  11404. // ClearOrganizationID clears the value of the "organization_id" field.
  11405. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  11406. m.organization_id = nil
  11407. m.addorganization_id = nil
  11408. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  11409. }
  11410. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11411. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  11412. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  11413. return ok
  11414. }
  11415. // ResetOrganizationID resets all changes to the "organization_id" field.
  11416. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  11417. m.organization_id = nil
  11418. m.addorganization_id = nil
  11419. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  11420. }
  11421. // Where appends a list predicates to the EmployeeConfigMutation builder.
  11422. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  11423. m.predicates = append(m.predicates, ps...)
  11424. }
  11425. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  11426. // users can use type-assertion to append predicates that do not depend on any generated package.
  11427. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  11428. p := make([]predicate.EmployeeConfig, len(ps))
  11429. for i := range ps {
  11430. p[i] = ps[i]
  11431. }
  11432. m.Where(p...)
  11433. }
  11434. // Op returns the operation name.
  11435. func (m *EmployeeConfigMutation) Op() Op {
  11436. return m.op
  11437. }
  11438. // SetOp allows setting the mutation operation.
  11439. func (m *EmployeeConfigMutation) SetOp(op Op) {
  11440. m.op = op
  11441. }
  11442. // Type returns the node type of this mutation (EmployeeConfig).
  11443. func (m *EmployeeConfigMutation) Type() string {
  11444. return m.typ
  11445. }
  11446. // Fields returns all fields that were changed during this mutation. Note that in
  11447. // order to get all numeric fields that were incremented/decremented, call
  11448. // AddedFields().
  11449. func (m *EmployeeConfigMutation) Fields() []string {
  11450. fields := make([]string, 0, 7)
  11451. if m.created_at != nil {
  11452. fields = append(fields, employeeconfig.FieldCreatedAt)
  11453. }
  11454. if m.updated_at != nil {
  11455. fields = append(fields, employeeconfig.FieldUpdatedAt)
  11456. }
  11457. if m.deleted_at != nil {
  11458. fields = append(fields, employeeconfig.FieldDeletedAt)
  11459. }
  11460. if m.stype != nil {
  11461. fields = append(fields, employeeconfig.FieldStype)
  11462. }
  11463. if m.title != nil {
  11464. fields = append(fields, employeeconfig.FieldTitle)
  11465. }
  11466. if m.photo != nil {
  11467. fields = append(fields, employeeconfig.FieldPhoto)
  11468. }
  11469. if m.organization_id != nil {
  11470. fields = append(fields, employeeconfig.FieldOrganizationID)
  11471. }
  11472. return fields
  11473. }
  11474. // Field returns the value of a field with the given name. The second boolean
  11475. // return value indicates that this field was not set, or was not defined in the
  11476. // schema.
  11477. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  11478. switch name {
  11479. case employeeconfig.FieldCreatedAt:
  11480. return m.CreatedAt()
  11481. case employeeconfig.FieldUpdatedAt:
  11482. return m.UpdatedAt()
  11483. case employeeconfig.FieldDeletedAt:
  11484. return m.DeletedAt()
  11485. case employeeconfig.FieldStype:
  11486. return m.Stype()
  11487. case employeeconfig.FieldTitle:
  11488. return m.Title()
  11489. case employeeconfig.FieldPhoto:
  11490. return m.Photo()
  11491. case employeeconfig.FieldOrganizationID:
  11492. return m.OrganizationID()
  11493. }
  11494. return nil, false
  11495. }
  11496. // OldField returns the old value of the field from the database. An error is
  11497. // returned if the mutation operation is not UpdateOne, or the query to the
  11498. // database failed.
  11499. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11500. switch name {
  11501. case employeeconfig.FieldCreatedAt:
  11502. return m.OldCreatedAt(ctx)
  11503. case employeeconfig.FieldUpdatedAt:
  11504. return m.OldUpdatedAt(ctx)
  11505. case employeeconfig.FieldDeletedAt:
  11506. return m.OldDeletedAt(ctx)
  11507. case employeeconfig.FieldStype:
  11508. return m.OldStype(ctx)
  11509. case employeeconfig.FieldTitle:
  11510. return m.OldTitle(ctx)
  11511. case employeeconfig.FieldPhoto:
  11512. return m.OldPhoto(ctx)
  11513. case employeeconfig.FieldOrganizationID:
  11514. return m.OldOrganizationID(ctx)
  11515. }
  11516. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  11517. }
  11518. // SetField sets the value of a field with the given name. It returns an error if
  11519. // the field is not defined in the schema, or if the type mismatched the field
  11520. // type.
  11521. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  11522. switch name {
  11523. case employeeconfig.FieldCreatedAt:
  11524. v, ok := value.(time.Time)
  11525. if !ok {
  11526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11527. }
  11528. m.SetCreatedAt(v)
  11529. return nil
  11530. case employeeconfig.FieldUpdatedAt:
  11531. v, ok := value.(time.Time)
  11532. if !ok {
  11533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11534. }
  11535. m.SetUpdatedAt(v)
  11536. return nil
  11537. case employeeconfig.FieldDeletedAt:
  11538. v, ok := value.(time.Time)
  11539. if !ok {
  11540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11541. }
  11542. m.SetDeletedAt(v)
  11543. return nil
  11544. case employeeconfig.FieldStype:
  11545. v, ok := value.(string)
  11546. if !ok {
  11547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11548. }
  11549. m.SetStype(v)
  11550. return nil
  11551. case employeeconfig.FieldTitle:
  11552. v, ok := value.(string)
  11553. if !ok {
  11554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11555. }
  11556. m.SetTitle(v)
  11557. return nil
  11558. case employeeconfig.FieldPhoto:
  11559. v, ok := value.(string)
  11560. if !ok {
  11561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11562. }
  11563. m.SetPhoto(v)
  11564. return nil
  11565. case employeeconfig.FieldOrganizationID:
  11566. v, ok := value.(uint64)
  11567. if !ok {
  11568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11569. }
  11570. m.SetOrganizationID(v)
  11571. return nil
  11572. }
  11573. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11574. }
  11575. // AddedFields returns all numeric fields that were incremented/decremented during
  11576. // this mutation.
  11577. func (m *EmployeeConfigMutation) AddedFields() []string {
  11578. var fields []string
  11579. if m.addorganization_id != nil {
  11580. fields = append(fields, employeeconfig.FieldOrganizationID)
  11581. }
  11582. return fields
  11583. }
  11584. // AddedField returns the numeric value that was incremented/decremented on a field
  11585. // with the given name. The second boolean return value indicates that this field
  11586. // was not set, or was not defined in the schema.
  11587. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  11588. switch name {
  11589. case employeeconfig.FieldOrganizationID:
  11590. return m.AddedOrganizationID()
  11591. }
  11592. return nil, false
  11593. }
  11594. // AddField adds the value to the field with the given name. It returns an error if
  11595. // the field is not defined in the schema, or if the type mismatched the field
  11596. // type.
  11597. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  11598. switch name {
  11599. case employeeconfig.FieldOrganizationID:
  11600. v, ok := value.(int64)
  11601. if !ok {
  11602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11603. }
  11604. m.AddOrganizationID(v)
  11605. return nil
  11606. }
  11607. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  11608. }
  11609. // ClearedFields returns all nullable fields that were cleared during this
  11610. // mutation.
  11611. func (m *EmployeeConfigMutation) ClearedFields() []string {
  11612. var fields []string
  11613. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  11614. fields = append(fields, employeeconfig.FieldDeletedAt)
  11615. }
  11616. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  11617. fields = append(fields, employeeconfig.FieldOrganizationID)
  11618. }
  11619. return fields
  11620. }
  11621. // FieldCleared returns a boolean indicating if a field with the given name was
  11622. // cleared in this mutation.
  11623. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  11624. _, ok := m.clearedFields[name]
  11625. return ok
  11626. }
  11627. // ClearField clears the value of the field with the given name. It returns an
  11628. // error if the field is not defined in the schema.
  11629. func (m *EmployeeConfigMutation) ClearField(name string) error {
  11630. switch name {
  11631. case employeeconfig.FieldDeletedAt:
  11632. m.ClearDeletedAt()
  11633. return nil
  11634. case employeeconfig.FieldOrganizationID:
  11635. m.ClearOrganizationID()
  11636. return nil
  11637. }
  11638. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  11639. }
  11640. // ResetField resets all changes in the mutation for the field with the given name.
  11641. // It returns an error if the field is not defined in the schema.
  11642. func (m *EmployeeConfigMutation) ResetField(name string) error {
  11643. switch name {
  11644. case employeeconfig.FieldCreatedAt:
  11645. m.ResetCreatedAt()
  11646. return nil
  11647. case employeeconfig.FieldUpdatedAt:
  11648. m.ResetUpdatedAt()
  11649. return nil
  11650. case employeeconfig.FieldDeletedAt:
  11651. m.ResetDeletedAt()
  11652. return nil
  11653. case employeeconfig.FieldStype:
  11654. m.ResetStype()
  11655. return nil
  11656. case employeeconfig.FieldTitle:
  11657. m.ResetTitle()
  11658. return nil
  11659. case employeeconfig.FieldPhoto:
  11660. m.ResetPhoto()
  11661. return nil
  11662. case employeeconfig.FieldOrganizationID:
  11663. m.ResetOrganizationID()
  11664. return nil
  11665. }
  11666. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11667. }
  11668. // AddedEdges returns all edge names that were set/added in this mutation.
  11669. func (m *EmployeeConfigMutation) AddedEdges() []string {
  11670. edges := make([]string, 0, 0)
  11671. return edges
  11672. }
  11673. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11674. // name in this mutation.
  11675. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  11676. return nil
  11677. }
  11678. // RemovedEdges returns all edge names that were removed in this mutation.
  11679. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  11680. edges := make([]string, 0, 0)
  11681. return edges
  11682. }
  11683. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11684. // the given name in this mutation.
  11685. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  11686. return nil
  11687. }
  11688. // ClearedEdges returns all edge names that were cleared in this mutation.
  11689. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  11690. edges := make([]string, 0, 0)
  11691. return edges
  11692. }
  11693. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11694. // was cleared in this mutation.
  11695. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  11696. return false
  11697. }
  11698. // ClearEdge clears the value of the edge with the given name. It returns an error
  11699. // if that edge is not defined in the schema.
  11700. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  11701. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  11702. }
  11703. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11704. // It returns an error if the edge is not defined in the schema.
  11705. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  11706. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  11707. }
  11708. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  11709. type LabelMutation struct {
  11710. config
  11711. op Op
  11712. typ string
  11713. id *uint64
  11714. created_at *time.Time
  11715. updated_at *time.Time
  11716. status *uint8
  11717. addstatus *int8
  11718. _type *int
  11719. add_type *int
  11720. name *string
  11721. from *int
  11722. addfrom *int
  11723. mode *int
  11724. addmode *int
  11725. conditions *string
  11726. organization_id *uint64
  11727. addorganization_id *int64
  11728. clearedFields map[string]struct{}
  11729. label_relationships map[uint64]struct{}
  11730. removedlabel_relationships map[uint64]struct{}
  11731. clearedlabel_relationships bool
  11732. done bool
  11733. oldValue func(context.Context) (*Label, error)
  11734. predicates []predicate.Label
  11735. }
  11736. var _ ent.Mutation = (*LabelMutation)(nil)
  11737. // labelOption allows management of the mutation configuration using functional options.
  11738. type labelOption func(*LabelMutation)
  11739. // newLabelMutation creates new mutation for the Label entity.
  11740. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  11741. m := &LabelMutation{
  11742. config: c,
  11743. op: op,
  11744. typ: TypeLabel,
  11745. clearedFields: make(map[string]struct{}),
  11746. }
  11747. for _, opt := range opts {
  11748. opt(m)
  11749. }
  11750. return m
  11751. }
  11752. // withLabelID sets the ID field of the mutation.
  11753. func withLabelID(id uint64) labelOption {
  11754. return func(m *LabelMutation) {
  11755. var (
  11756. err error
  11757. once sync.Once
  11758. value *Label
  11759. )
  11760. m.oldValue = func(ctx context.Context) (*Label, error) {
  11761. once.Do(func() {
  11762. if m.done {
  11763. err = errors.New("querying old values post mutation is not allowed")
  11764. } else {
  11765. value, err = m.Client().Label.Get(ctx, id)
  11766. }
  11767. })
  11768. return value, err
  11769. }
  11770. m.id = &id
  11771. }
  11772. }
  11773. // withLabel sets the old Label of the mutation.
  11774. func withLabel(node *Label) labelOption {
  11775. return func(m *LabelMutation) {
  11776. m.oldValue = func(context.Context) (*Label, error) {
  11777. return node, nil
  11778. }
  11779. m.id = &node.ID
  11780. }
  11781. }
  11782. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11783. // executed in a transaction (ent.Tx), a transactional client is returned.
  11784. func (m LabelMutation) Client() *Client {
  11785. client := &Client{config: m.config}
  11786. client.init()
  11787. return client
  11788. }
  11789. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11790. // it returns an error otherwise.
  11791. func (m LabelMutation) Tx() (*Tx, error) {
  11792. if _, ok := m.driver.(*txDriver); !ok {
  11793. return nil, errors.New("ent: mutation is not running in a transaction")
  11794. }
  11795. tx := &Tx{config: m.config}
  11796. tx.init()
  11797. return tx, nil
  11798. }
  11799. // SetID sets the value of the id field. Note that this
  11800. // operation is only accepted on creation of Label entities.
  11801. func (m *LabelMutation) SetID(id uint64) {
  11802. m.id = &id
  11803. }
  11804. // ID returns the ID value in the mutation. Note that the ID is only available
  11805. // if it was provided to the builder or after it was returned from the database.
  11806. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11807. if m.id == nil {
  11808. return
  11809. }
  11810. return *m.id, true
  11811. }
  11812. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11813. // That means, if the mutation is applied within a transaction with an isolation level such
  11814. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11815. // or updated by the mutation.
  11816. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11817. switch {
  11818. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11819. id, exists := m.ID()
  11820. if exists {
  11821. return []uint64{id}, nil
  11822. }
  11823. fallthrough
  11824. case m.op.Is(OpUpdate | OpDelete):
  11825. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11826. default:
  11827. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11828. }
  11829. }
  11830. // SetCreatedAt sets the "created_at" field.
  11831. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11832. m.created_at = &t
  11833. }
  11834. // CreatedAt returns the value of the "created_at" field in the mutation.
  11835. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11836. v := m.created_at
  11837. if v == nil {
  11838. return
  11839. }
  11840. return *v, true
  11841. }
  11842. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11843. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11845. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11846. if !m.op.Is(OpUpdateOne) {
  11847. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11848. }
  11849. if m.id == nil || m.oldValue == nil {
  11850. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11851. }
  11852. oldValue, err := m.oldValue(ctx)
  11853. if err != nil {
  11854. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11855. }
  11856. return oldValue.CreatedAt, nil
  11857. }
  11858. // ResetCreatedAt resets all changes to the "created_at" field.
  11859. func (m *LabelMutation) ResetCreatedAt() {
  11860. m.created_at = nil
  11861. }
  11862. // SetUpdatedAt sets the "updated_at" field.
  11863. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11864. m.updated_at = &t
  11865. }
  11866. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11867. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11868. v := m.updated_at
  11869. if v == nil {
  11870. return
  11871. }
  11872. return *v, true
  11873. }
  11874. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11875. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11877. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11878. if !m.op.Is(OpUpdateOne) {
  11879. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11880. }
  11881. if m.id == nil || m.oldValue == nil {
  11882. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11883. }
  11884. oldValue, err := m.oldValue(ctx)
  11885. if err != nil {
  11886. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11887. }
  11888. return oldValue.UpdatedAt, nil
  11889. }
  11890. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11891. func (m *LabelMutation) ResetUpdatedAt() {
  11892. m.updated_at = nil
  11893. }
  11894. // SetStatus sets the "status" field.
  11895. func (m *LabelMutation) SetStatus(u uint8) {
  11896. m.status = &u
  11897. m.addstatus = nil
  11898. }
  11899. // Status returns the value of the "status" field in the mutation.
  11900. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11901. v := m.status
  11902. if v == nil {
  11903. return
  11904. }
  11905. return *v, true
  11906. }
  11907. // OldStatus returns the old "status" field's value of the Label entity.
  11908. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11910. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11911. if !m.op.Is(OpUpdateOne) {
  11912. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11913. }
  11914. if m.id == nil || m.oldValue == nil {
  11915. return v, errors.New("OldStatus requires an ID field in the mutation")
  11916. }
  11917. oldValue, err := m.oldValue(ctx)
  11918. if err != nil {
  11919. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11920. }
  11921. return oldValue.Status, nil
  11922. }
  11923. // AddStatus adds u to the "status" field.
  11924. func (m *LabelMutation) AddStatus(u int8) {
  11925. if m.addstatus != nil {
  11926. *m.addstatus += u
  11927. } else {
  11928. m.addstatus = &u
  11929. }
  11930. }
  11931. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11932. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11933. v := m.addstatus
  11934. if v == nil {
  11935. return
  11936. }
  11937. return *v, true
  11938. }
  11939. // ClearStatus clears the value of the "status" field.
  11940. func (m *LabelMutation) ClearStatus() {
  11941. m.status = nil
  11942. m.addstatus = nil
  11943. m.clearedFields[label.FieldStatus] = struct{}{}
  11944. }
  11945. // StatusCleared returns if the "status" field was cleared in this mutation.
  11946. func (m *LabelMutation) StatusCleared() bool {
  11947. _, ok := m.clearedFields[label.FieldStatus]
  11948. return ok
  11949. }
  11950. // ResetStatus resets all changes to the "status" field.
  11951. func (m *LabelMutation) ResetStatus() {
  11952. m.status = nil
  11953. m.addstatus = nil
  11954. delete(m.clearedFields, label.FieldStatus)
  11955. }
  11956. // SetType sets the "type" field.
  11957. func (m *LabelMutation) SetType(i int) {
  11958. m._type = &i
  11959. m.add_type = nil
  11960. }
  11961. // GetType returns the value of the "type" field in the mutation.
  11962. func (m *LabelMutation) GetType() (r int, exists bool) {
  11963. v := m._type
  11964. if v == nil {
  11965. return
  11966. }
  11967. return *v, true
  11968. }
  11969. // OldType returns the old "type" field's value of the Label entity.
  11970. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11972. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11973. if !m.op.Is(OpUpdateOne) {
  11974. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11975. }
  11976. if m.id == nil || m.oldValue == nil {
  11977. return v, errors.New("OldType requires an ID field in the mutation")
  11978. }
  11979. oldValue, err := m.oldValue(ctx)
  11980. if err != nil {
  11981. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11982. }
  11983. return oldValue.Type, nil
  11984. }
  11985. // AddType adds i to the "type" field.
  11986. func (m *LabelMutation) AddType(i int) {
  11987. if m.add_type != nil {
  11988. *m.add_type += i
  11989. } else {
  11990. m.add_type = &i
  11991. }
  11992. }
  11993. // AddedType returns the value that was added to the "type" field in this mutation.
  11994. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11995. v := m.add_type
  11996. if v == nil {
  11997. return
  11998. }
  11999. return *v, true
  12000. }
  12001. // ResetType resets all changes to the "type" field.
  12002. func (m *LabelMutation) ResetType() {
  12003. m._type = nil
  12004. m.add_type = nil
  12005. }
  12006. // SetName sets the "name" field.
  12007. func (m *LabelMutation) SetName(s string) {
  12008. m.name = &s
  12009. }
  12010. // Name returns the value of the "name" field in the mutation.
  12011. func (m *LabelMutation) Name() (r string, exists bool) {
  12012. v := m.name
  12013. if v == nil {
  12014. return
  12015. }
  12016. return *v, true
  12017. }
  12018. // OldName returns the old "name" field's value of the Label entity.
  12019. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12021. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  12022. if !m.op.Is(OpUpdateOne) {
  12023. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12024. }
  12025. if m.id == nil || m.oldValue == nil {
  12026. return v, errors.New("OldName requires an ID field in the mutation")
  12027. }
  12028. oldValue, err := m.oldValue(ctx)
  12029. if err != nil {
  12030. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12031. }
  12032. return oldValue.Name, nil
  12033. }
  12034. // ResetName resets all changes to the "name" field.
  12035. func (m *LabelMutation) ResetName() {
  12036. m.name = nil
  12037. }
  12038. // SetFrom sets the "from" field.
  12039. func (m *LabelMutation) SetFrom(i int) {
  12040. m.from = &i
  12041. m.addfrom = nil
  12042. }
  12043. // From returns the value of the "from" field in the mutation.
  12044. func (m *LabelMutation) From() (r int, exists bool) {
  12045. v := m.from
  12046. if v == nil {
  12047. return
  12048. }
  12049. return *v, true
  12050. }
  12051. // OldFrom returns the old "from" field's value of the Label entity.
  12052. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12054. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  12055. if !m.op.Is(OpUpdateOne) {
  12056. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  12057. }
  12058. if m.id == nil || m.oldValue == nil {
  12059. return v, errors.New("OldFrom requires an ID field in the mutation")
  12060. }
  12061. oldValue, err := m.oldValue(ctx)
  12062. if err != nil {
  12063. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  12064. }
  12065. return oldValue.From, nil
  12066. }
  12067. // AddFrom adds i to the "from" field.
  12068. func (m *LabelMutation) AddFrom(i int) {
  12069. if m.addfrom != nil {
  12070. *m.addfrom += i
  12071. } else {
  12072. m.addfrom = &i
  12073. }
  12074. }
  12075. // AddedFrom returns the value that was added to the "from" field in this mutation.
  12076. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  12077. v := m.addfrom
  12078. if v == nil {
  12079. return
  12080. }
  12081. return *v, true
  12082. }
  12083. // ResetFrom resets all changes to the "from" field.
  12084. func (m *LabelMutation) ResetFrom() {
  12085. m.from = nil
  12086. m.addfrom = nil
  12087. }
  12088. // SetMode sets the "mode" field.
  12089. func (m *LabelMutation) SetMode(i int) {
  12090. m.mode = &i
  12091. m.addmode = nil
  12092. }
  12093. // Mode returns the value of the "mode" field in the mutation.
  12094. func (m *LabelMutation) Mode() (r int, exists bool) {
  12095. v := m.mode
  12096. if v == nil {
  12097. return
  12098. }
  12099. return *v, true
  12100. }
  12101. // OldMode returns the old "mode" field's value of the Label entity.
  12102. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12104. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  12105. if !m.op.Is(OpUpdateOne) {
  12106. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  12107. }
  12108. if m.id == nil || m.oldValue == nil {
  12109. return v, errors.New("OldMode requires an ID field in the mutation")
  12110. }
  12111. oldValue, err := m.oldValue(ctx)
  12112. if err != nil {
  12113. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  12114. }
  12115. return oldValue.Mode, nil
  12116. }
  12117. // AddMode adds i to the "mode" field.
  12118. func (m *LabelMutation) AddMode(i int) {
  12119. if m.addmode != nil {
  12120. *m.addmode += i
  12121. } else {
  12122. m.addmode = &i
  12123. }
  12124. }
  12125. // AddedMode returns the value that was added to the "mode" field in this mutation.
  12126. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  12127. v := m.addmode
  12128. if v == nil {
  12129. return
  12130. }
  12131. return *v, true
  12132. }
  12133. // ResetMode resets all changes to the "mode" field.
  12134. func (m *LabelMutation) ResetMode() {
  12135. m.mode = nil
  12136. m.addmode = nil
  12137. }
  12138. // SetConditions sets the "conditions" field.
  12139. func (m *LabelMutation) SetConditions(s string) {
  12140. m.conditions = &s
  12141. }
  12142. // Conditions returns the value of the "conditions" field in the mutation.
  12143. func (m *LabelMutation) Conditions() (r string, exists bool) {
  12144. v := m.conditions
  12145. if v == nil {
  12146. return
  12147. }
  12148. return *v, true
  12149. }
  12150. // OldConditions returns the old "conditions" field's value of the Label entity.
  12151. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12153. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  12154. if !m.op.Is(OpUpdateOne) {
  12155. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  12156. }
  12157. if m.id == nil || m.oldValue == nil {
  12158. return v, errors.New("OldConditions requires an ID field in the mutation")
  12159. }
  12160. oldValue, err := m.oldValue(ctx)
  12161. if err != nil {
  12162. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  12163. }
  12164. return oldValue.Conditions, nil
  12165. }
  12166. // ClearConditions clears the value of the "conditions" field.
  12167. func (m *LabelMutation) ClearConditions() {
  12168. m.conditions = nil
  12169. m.clearedFields[label.FieldConditions] = struct{}{}
  12170. }
  12171. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  12172. func (m *LabelMutation) ConditionsCleared() bool {
  12173. _, ok := m.clearedFields[label.FieldConditions]
  12174. return ok
  12175. }
  12176. // ResetConditions resets all changes to the "conditions" field.
  12177. func (m *LabelMutation) ResetConditions() {
  12178. m.conditions = nil
  12179. delete(m.clearedFields, label.FieldConditions)
  12180. }
  12181. // SetOrganizationID sets the "organization_id" field.
  12182. func (m *LabelMutation) SetOrganizationID(u uint64) {
  12183. m.organization_id = &u
  12184. m.addorganization_id = nil
  12185. }
  12186. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12187. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  12188. v := m.organization_id
  12189. if v == nil {
  12190. return
  12191. }
  12192. return *v, true
  12193. }
  12194. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  12195. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12197. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12198. if !m.op.Is(OpUpdateOne) {
  12199. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12200. }
  12201. if m.id == nil || m.oldValue == nil {
  12202. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12203. }
  12204. oldValue, err := m.oldValue(ctx)
  12205. if err != nil {
  12206. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12207. }
  12208. return oldValue.OrganizationID, nil
  12209. }
  12210. // AddOrganizationID adds u to the "organization_id" field.
  12211. func (m *LabelMutation) AddOrganizationID(u int64) {
  12212. if m.addorganization_id != nil {
  12213. *m.addorganization_id += u
  12214. } else {
  12215. m.addorganization_id = &u
  12216. }
  12217. }
  12218. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12219. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  12220. v := m.addorganization_id
  12221. if v == nil {
  12222. return
  12223. }
  12224. return *v, true
  12225. }
  12226. // ClearOrganizationID clears the value of the "organization_id" field.
  12227. func (m *LabelMutation) ClearOrganizationID() {
  12228. m.organization_id = nil
  12229. m.addorganization_id = nil
  12230. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  12231. }
  12232. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12233. func (m *LabelMutation) OrganizationIDCleared() bool {
  12234. _, ok := m.clearedFields[label.FieldOrganizationID]
  12235. return ok
  12236. }
  12237. // ResetOrganizationID resets all changes to the "organization_id" field.
  12238. func (m *LabelMutation) ResetOrganizationID() {
  12239. m.organization_id = nil
  12240. m.addorganization_id = nil
  12241. delete(m.clearedFields, label.FieldOrganizationID)
  12242. }
  12243. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  12244. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  12245. if m.label_relationships == nil {
  12246. m.label_relationships = make(map[uint64]struct{})
  12247. }
  12248. for i := range ids {
  12249. m.label_relationships[ids[i]] = struct{}{}
  12250. }
  12251. }
  12252. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  12253. func (m *LabelMutation) ClearLabelRelationships() {
  12254. m.clearedlabel_relationships = true
  12255. }
  12256. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  12257. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  12258. return m.clearedlabel_relationships
  12259. }
  12260. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  12261. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  12262. if m.removedlabel_relationships == nil {
  12263. m.removedlabel_relationships = make(map[uint64]struct{})
  12264. }
  12265. for i := range ids {
  12266. delete(m.label_relationships, ids[i])
  12267. m.removedlabel_relationships[ids[i]] = struct{}{}
  12268. }
  12269. }
  12270. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  12271. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  12272. for id := range m.removedlabel_relationships {
  12273. ids = append(ids, id)
  12274. }
  12275. return
  12276. }
  12277. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  12278. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  12279. for id := range m.label_relationships {
  12280. ids = append(ids, id)
  12281. }
  12282. return
  12283. }
  12284. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  12285. func (m *LabelMutation) ResetLabelRelationships() {
  12286. m.label_relationships = nil
  12287. m.clearedlabel_relationships = false
  12288. m.removedlabel_relationships = nil
  12289. }
  12290. // Where appends a list predicates to the LabelMutation builder.
  12291. func (m *LabelMutation) Where(ps ...predicate.Label) {
  12292. m.predicates = append(m.predicates, ps...)
  12293. }
  12294. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  12295. // users can use type-assertion to append predicates that do not depend on any generated package.
  12296. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  12297. p := make([]predicate.Label, len(ps))
  12298. for i := range ps {
  12299. p[i] = ps[i]
  12300. }
  12301. m.Where(p...)
  12302. }
  12303. // Op returns the operation name.
  12304. func (m *LabelMutation) Op() Op {
  12305. return m.op
  12306. }
  12307. // SetOp allows setting the mutation operation.
  12308. func (m *LabelMutation) SetOp(op Op) {
  12309. m.op = op
  12310. }
  12311. // Type returns the node type of this mutation (Label).
  12312. func (m *LabelMutation) Type() string {
  12313. return m.typ
  12314. }
  12315. // Fields returns all fields that were changed during this mutation. Note that in
  12316. // order to get all numeric fields that were incremented/decremented, call
  12317. // AddedFields().
  12318. func (m *LabelMutation) Fields() []string {
  12319. fields := make([]string, 0, 9)
  12320. if m.created_at != nil {
  12321. fields = append(fields, label.FieldCreatedAt)
  12322. }
  12323. if m.updated_at != nil {
  12324. fields = append(fields, label.FieldUpdatedAt)
  12325. }
  12326. if m.status != nil {
  12327. fields = append(fields, label.FieldStatus)
  12328. }
  12329. if m._type != nil {
  12330. fields = append(fields, label.FieldType)
  12331. }
  12332. if m.name != nil {
  12333. fields = append(fields, label.FieldName)
  12334. }
  12335. if m.from != nil {
  12336. fields = append(fields, label.FieldFrom)
  12337. }
  12338. if m.mode != nil {
  12339. fields = append(fields, label.FieldMode)
  12340. }
  12341. if m.conditions != nil {
  12342. fields = append(fields, label.FieldConditions)
  12343. }
  12344. if m.organization_id != nil {
  12345. fields = append(fields, label.FieldOrganizationID)
  12346. }
  12347. return fields
  12348. }
  12349. // Field returns the value of a field with the given name. The second boolean
  12350. // return value indicates that this field was not set, or was not defined in the
  12351. // schema.
  12352. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  12353. switch name {
  12354. case label.FieldCreatedAt:
  12355. return m.CreatedAt()
  12356. case label.FieldUpdatedAt:
  12357. return m.UpdatedAt()
  12358. case label.FieldStatus:
  12359. return m.Status()
  12360. case label.FieldType:
  12361. return m.GetType()
  12362. case label.FieldName:
  12363. return m.Name()
  12364. case label.FieldFrom:
  12365. return m.From()
  12366. case label.FieldMode:
  12367. return m.Mode()
  12368. case label.FieldConditions:
  12369. return m.Conditions()
  12370. case label.FieldOrganizationID:
  12371. return m.OrganizationID()
  12372. }
  12373. return nil, false
  12374. }
  12375. // OldField returns the old value of the field from the database. An error is
  12376. // returned if the mutation operation is not UpdateOne, or the query to the
  12377. // database failed.
  12378. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12379. switch name {
  12380. case label.FieldCreatedAt:
  12381. return m.OldCreatedAt(ctx)
  12382. case label.FieldUpdatedAt:
  12383. return m.OldUpdatedAt(ctx)
  12384. case label.FieldStatus:
  12385. return m.OldStatus(ctx)
  12386. case label.FieldType:
  12387. return m.OldType(ctx)
  12388. case label.FieldName:
  12389. return m.OldName(ctx)
  12390. case label.FieldFrom:
  12391. return m.OldFrom(ctx)
  12392. case label.FieldMode:
  12393. return m.OldMode(ctx)
  12394. case label.FieldConditions:
  12395. return m.OldConditions(ctx)
  12396. case label.FieldOrganizationID:
  12397. return m.OldOrganizationID(ctx)
  12398. }
  12399. return nil, fmt.Errorf("unknown Label field %s", name)
  12400. }
  12401. // SetField sets the value of a field with the given name. It returns an error if
  12402. // the field is not defined in the schema, or if the type mismatched the field
  12403. // type.
  12404. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  12405. switch name {
  12406. case label.FieldCreatedAt:
  12407. v, ok := value.(time.Time)
  12408. if !ok {
  12409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12410. }
  12411. m.SetCreatedAt(v)
  12412. return nil
  12413. case label.FieldUpdatedAt:
  12414. v, ok := value.(time.Time)
  12415. if !ok {
  12416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12417. }
  12418. m.SetUpdatedAt(v)
  12419. return nil
  12420. case label.FieldStatus:
  12421. v, ok := value.(uint8)
  12422. if !ok {
  12423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12424. }
  12425. m.SetStatus(v)
  12426. return nil
  12427. case label.FieldType:
  12428. v, ok := value.(int)
  12429. if !ok {
  12430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12431. }
  12432. m.SetType(v)
  12433. return nil
  12434. case label.FieldName:
  12435. v, ok := value.(string)
  12436. if !ok {
  12437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12438. }
  12439. m.SetName(v)
  12440. return nil
  12441. case label.FieldFrom:
  12442. v, ok := value.(int)
  12443. if !ok {
  12444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12445. }
  12446. m.SetFrom(v)
  12447. return nil
  12448. case label.FieldMode:
  12449. v, ok := value.(int)
  12450. if !ok {
  12451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12452. }
  12453. m.SetMode(v)
  12454. return nil
  12455. case label.FieldConditions:
  12456. v, ok := value.(string)
  12457. if !ok {
  12458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12459. }
  12460. m.SetConditions(v)
  12461. return nil
  12462. case label.FieldOrganizationID:
  12463. v, ok := value.(uint64)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetOrganizationID(v)
  12468. return nil
  12469. }
  12470. return fmt.Errorf("unknown Label field %s", name)
  12471. }
  12472. // AddedFields returns all numeric fields that were incremented/decremented during
  12473. // this mutation.
  12474. func (m *LabelMutation) AddedFields() []string {
  12475. var fields []string
  12476. if m.addstatus != nil {
  12477. fields = append(fields, label.FieldStatus)
  12478. }
  12479. if m.add_type != nil {
  12480. fields = append(fields, label.FieldType)
  12481. }
  12482. if m.addfrom != nil {
  12483. fields = append(fields, label.FieldFrom)
  12484. }
  12485. if m.addmode != nil {
  12486. fields = append(fields, label.FieldMode)
  12487. }
  12488. if m.addorganization_id != nil {
  12489. fields = append(fields, label.FieldOrganizationID)
  12490. }
  12491. return fields
  12492. }
  12493. // AddedField returns the numeric value that was incremented/decremented on a field
  12494. // with the given name. The second boolean return value indicates that this field
  12495. // was not set, or was not defined in the schema.
  12496. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  12497. switch name {
  12498. case label.FieldStatus:
  12499. return m.AddedStatus()
  12500. case label.FieldType:
  12501. return m.AddedType()
  12502. case label.FieldFrom:
  12503. return m.AddedFrom()
  12504. case label.FieldMode:
  12505. return m.AddedMode()
  12506. case label.FieldOrganizationID:
  12507. return m.AddedOrganizationID()
  12508. }
  12509. return nil, false
  12510. }
  12511. // AddField adds the value to the field with the given name. It returns an error if
  12512. // the field is not defined in the schema, or if the type mismatched the field
  12513. // type.
  12514. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  12515. switch name {
  12516. case label.FieldStatus:
  12517. v, ok := value.(int8)
  12518. if !ok {
  12519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12520. }
  12521. m.AddStatus(v)
  12522. return nil
  12523. case label.FieldType:
  12524. v, ok := value.(int)
  12525. if !ok {
  12526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12527. }
  12528. m.AddType(v)
  12529. return nil
  12530. case label.FieldFrom:
  12531. v, ok := value.(int)
  12532. if !ok {
  12533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12534. }
  12535. m.AddFrom(v)
  12536. return nil
  12537. case label.FieldMode:
  12538. v, ok := value.(int)
  12539. if !ok {
  12540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12541. }
  12542. m.AddMode(v)
  12543. return nil
  12544. case label.FieldOrganizationID:
  12545. v, ok := value.(int64)
  12546. if !ok {
  12547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12548. }
  12549. m.AddOrganizationID(v)
  12550. return nil
  12551. }
  12552. return fmt.Errorf("unknown Label numeric field %s", name)
  12553. }
  12554. // ClearedFields returns all nullable fields that were cleared during this
  12555. // mutation.
  12556. func (m *LabelMutation) ClearedFields() []string {
  12557. var fields []string
  12558. if m.FieldCleared(label.FieldStatus) {
  12559. fields = append(fields, label.FieldStatus)
  12560. }
  12561. if m.FieldCleared(label.FieldConditions) {
  12562. fields = append(fields, label.FieldConditions)
  12563. }
  12564. if m.FieldCleared(label.FieldOrganizationID) {
  12565. fields = append(fields, label.FieldOrganizationID)
  12566. }
  12567. return fields
  12568. }
  12569. // FieldCleared returns a boolean indicating if a field with the given name was
  12570. // cleared in this mutation.
  12571. func (m *LabelMutation) FieldCleared(name string) bool {
  12572. _, ok := m.clearedFields[name]
  12573. return ok
  12574. }
  12575. // ClearField clears the value of the field with the given name. It returns an
  12576. // error if the field is not defined in the schema.
  12577. func (m *LabelMutation) ClearField(name string) error {
  12578. switch name {
  12579. case label.FieldStatus:
  12580. m.ClearStatus()
  12581. return nil
  12582. case label.FieldConditions:
  12583. m.ClearConditions()
  12584. return nil
  12585. case label.FieldOrganizationID:
  12586. m.ClearOrganizationID()
  12587. return nil
  12588. }
  12589. return fmt.Errorf("unknown Label nullable field %s", name)
  12590. }
  12591. // ResetField resets all changes in the mutation for the field with the given name.
  12592. // It returns an error if the field is not defined in the schema.
  12593. func (m *LabelMutation) ResetField(name string) error {
  12594. switch name {
  12595. case label.FieldCreatedAt:
  12596. m.ResetCreatedAt()
  12597. return nil
  12598. case label.FieldUpdatedAt:
  12599. m.ResetUpdatedAt()
  12600. return nil
  12601. case label.FieldStatus:
  12602. m.ResetStatus()
  12603. return nil
  12604. case label.FieldType:
  12605. m.ResetType()
  12606. return nil
  12607. case label.FieldName:
  12608. m.ResetName()
  12609. return nil
  12610. case label.FieldFrom:
  12611. m.ResetFrom()
  12612. return nil
  12613. case label.FieldMode:
  12614. m.ResetMode()
  12615. return nil
  12616. case label.FieldConditions:
  12617. m.ResetConditions()
  12618. return nil
  12619. case label.FieldOrganizationID:
  12620. m.ResetOrganizationID()
  12621. return nil
  12622. }
  12623. return fmt.Errorf("unknown Label field %s", name)
  12624. }
  12625. // AddedEdges returns all edge names that were set/added in this mutation.
  12626. func (m *LabelMutation) AddedEdges() []string {
  12627. edges := make([]string, 0, 1)
  12628. if m.label_relationships != nil {
  12629. edges = append(edges, label.EdgeLabelRelationships)
  12630. }
  12631. return edges
  12632. }
  12633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12634. // name in this mutation.
  12635. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  12636. switch name {
  12637. case label.EdgeLabelRelationships:
  12638. ids := make([]ent.Value, 0, len(m.label_relationships))
  12639. for id := range m.label_relationships {
  12640. ids = append(ids, id)
  12641. }
  12642. return ids
  12643. }
  12644. return nil
  12645. }
  12646. // RemovedEdges returns all edge names that were removed in this mutation.
  12647. func (m *LabelMutation) RemovedEdges() []string {
  12648. edges := make([]string, 0, 1)
  12649. if m.removedlabel_relationships != nil {
  12650. edges = append(edges, label.EdgeLabelRelationships)
  12651. }
  12652. return edges
  12653. }
  12654. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12655. // the given name in this mutation.
  12656. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  12657. switch name {
  12658. case label.EdgeLabelRelationships:
  12659. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  12660. for id := range m.removedlabel_relationships {
  12661. ids = append(ids, id)
  12662. }
  12663. return ids
  12664. }
  12665. return nil
  12666. }
  12667. // ClearedEdges returns all edge names that were cleared in this mutation.
  12668. func (m *LabelMutation) ClearedEdges() []string {
  12669. edges := make([]string, 0, 1)
  12670. if m.clearedlabel_relationships {
  12671. edges = append(edges, label.EdgeLabelRelationships)
  12672. }
  12673. return edges
  12674. }
  12675. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12676. // was cleared in this mutation.
  12677. func (m *LabelMutation) EdgeCleared(name string) bool {
  12678. switch name {
  12679. case label.EdgeLabelRelationships:
  12680. return m.clearedlabel_relationships
  12681. }
  12682. return false
  12683. }
  12684. // ClearEdge clears the value of the edge with the given name. It returns an error
  12685. // if that edge is not defined in the schema.
  12686. func (m *LabelMutation) ClearEdge(name string) error {
  12687. switch name {
  12688. }
  12689. return fmt.Errorf("unknown Label unique edge %s", name)
  12690. }
  12691. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12692. // It returns an error if the edge is not defined in the schema.
  12693. func (m *LabelMutation) ResetEdge(name string) error {
  12694. switch name {
  12695. case label.EdgeLabelRelationships:
  12696. m.ResetLabelRelationships()
  12697. return nil
  12698. }
  12699. return fmt.Errorf("unknown Label edge %s", name)
  12700. }
  12701. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  12702. type LabelRelationshipMutation struct {
  12703. config
  12704. op Op
  12705. typ string
  12706. id *uint64
  12707. created_at *time.Time
  12708. updated_at *time.Time
  12709. status *uint8
  12710. addstatus *int8
  12711. deleted_at *time.Time
  12712. organization_id *uint64
  12713. addorganization_id *int64
  12714. clearedFields map[string]struct{}
  12715. contacts *uint64
  12716. clearedcontacts bool
  12717. labels *uint64
  12718. clearedlabels bool
  12719. done bool
  12720. oldValue func(context.Context) (*LabelRelationship, error)
  12721. predicates []predicate.LabelRelationship
  12722. }
  12723. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  12724. // labelrelationshipOption allows management of the mutation configuration using functional options.
  12725. type labelrelationshipOption func(*LabelRelationshipMutation)
  12726. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  12727. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  12728. m := &LabelRelationshipMutation{
  12729. config: c,
  12730. op: op,
  12731. typ: TypeLabelRelationship,
  12732. clearedFields: make(map[string]struct{}),
  12733. }
  12734. for _, opt := range opts {
  12735. opt(m)
  12736. }
  12737. return m
  12738. }
  12739. // withLabelRelationshipID sets the ID field of the mutation.
  12740. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  12741. return func(m *LabelRelationshipMutation) {
  12742. var (
  12743. err error
  12744. once sync.Once
  12745. value *LabelRelationship
  12746. )
  12747. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  12748. once.Do(func() {
  12749. if m.done {
  12750. err = errors.New("querying old values post mutation is not allowed")
  12751. } else {
  12752. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12753. }
  12754. })
  12755. return value, err
  12756. }
  12757. m.id = &id
  12758. }
  12759. }
  12760. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12761. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12762. return func(m *LabelRelationshipMutation) {
  12763. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12764. return node, nil
  12765. }
  12766. m.id = &node.ID
  12767. }
  12768. }
  12769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12770. // executed in a transaction (ent.Tx), a transactional client is returned.
  12771. func (m LabelRelationshipMutation) Client() *Client {
  12772. client := &Client{config: m.config}
  12773. client.init()
  12774. return client
  12775. }
  12776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12777. // it returns an error otherwise.
  12778. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12779. if _, ok := m.driver.(*txDriver); !ok {
  12780. return nil, errors.New("ent: mutation is not running in a transaction")
  12781. }
  12782. tx := &Tx{config: m.config}
  12783. tx.init()
  12784. return tx, nil
  12785. }
  12786. // SetID sets the value of the id field. Note that this
  12787. // operation is only accepted on creation of LabelRelationship entities.
  12788. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12789. m.id = &id
  12790. }
  12791. // ID returns the ID value in the mutation. Note that the ID is only available
  12792. // if it was provided to the builder or after it was returned from the database.
  12793. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12794. if m.id == nil {
  12795. return
  12796. }
  12797. return *m.id, true
  12798. }
  12799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12800. // That means, if the mutation is applied within a transaction with an isolation level such
  12801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12802. // or updated by the mutation.
  12803. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12804. switch {
  12805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12806. id, exists := m.ID()
  12807. if exists {
  12808. return []uint64{id}, nil
  12809. }
  12810. fallthrough
  12811. case m.op.Is(OpUpdate | OpDelete):
  12812. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12813. default:
  12814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12815. }
  12816. }
  12817. // SetCreatedAt sets the "created_at" field.
  12818. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12819. m.created_at = &t
  12820. }
  12821. // CreatedAt returns the value of the "created_at" field in the mutation.
  12822. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12823. v := m.created_at
  12824. if v == nil {
  12825. return
  12826. }
  12827. return *v, true
  12828. }
  12829. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12830. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12832. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12833. if !m.op.Is(OpUpdateOne) {
  12834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12835. }
  12836. if m.id == nil || m.oldValue == nil {
  12837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12838. }
  12839. oldValue, err := m.oldValue(ctx)
  12840. if err != nil {
  12841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12842. }
  12843. return oldValue.CreatedAt, nil
  12844. }
  12845. // ResetCreatedAt resets all changes to the "created_at" field.
  12846. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12847. m.created_at = nil
  12848. }
  12849. // SetUpdatedAt sets the "updated_at" field.
  12850. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12851. m.updated_at = &t
  12852. }
  12853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12854. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12855. v := m.updated_at
  12856. if v == nil {
  12857. return
  12858. }
  12859. return *v, true
  12860. }
  12861. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12862. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12864. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12865. if !m.op.Is(OpUpdateOne) {
  12866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12867. }
  12868. if m.id == nil || m.oldValue == nil {
  12869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12870. }
  12871. oldValue, err := m.oldValue(ctx)
  12872. if err != nil {
  12873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12874. }
  12875. return oldValue.UpdatedAt, nil
  12876. }
  12877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12878. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12879. m.updated_at = nil
  12880. }
  12881. // SetStatus sets the "status" field.
  12882. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12883. m.status = &u
  12884. m.addstatus = nil
  12885. }
  12886. // Status returns the value of the "status" field in the mutation.
  12887. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12888. v := m.status
  12889. if v == nil {
  12890. return
  12891. }
  12892. return *v, true
  12893. }
  12894. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12895. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12897. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12898. if !m.op.Is(OpUpdateOne) {
  12899. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12900. }
  12901. if m.id == nil || m.oldValue == nil {
  12902. return v, errors.New("OldStatus requires an ID field in the mutation")
  12903. }
  12904. oldValue, err := m.oldValue(ctx)
  12905. if err != nil {
  12906. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12907. }
  12908. return oldValue.Status, nil
  12909. }
  12910. // AddStatus adds u to the "status" field.
  12911. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12912. if m.addstatus != nil {
  12913. *m.addstatus += u
  12914. } else {
  12915. m.addstatus = &u
  12916. }
  12917. }
  12918. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12919. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12920. v := m.addstatus
  12921. if v == nil {
  12922. return
  12923. }
  12924. return *v, true
  12925. }
  12926. // ClearStatus clears the value of the "status" field.
  12927. func (m *LabelRelationshipMutation) ClearStatus() {
  12928. m.status = nil
  12929. m.addstatus = nil
  12930. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12931. }
  12932. // StatusCleared returns if the "status" field was cleared in this mutation.
  12933. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12934. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12935. return ok
  12936. }
  12937. // ResetStatus resets all changes to the "status" field.
  12938. func (m *LabelRelationshipMutation) ResetStatus() {
  12939. m.status = nil
  12940. m.addstatus = nil
  12941. delete(m.clearedFields, labelrelationship.FieldStatus)
  12942. }
  12943. // SetDeletedAt sets the "deleted_at" field.
  12944. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12945. m.deleted_at = &t
  12946. }
  12947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12948. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12949. v := m.deleted_at
  12950. if v == nil {
  12951. return
  12952. }
  12953. return *v, true
  12954. }
  12955. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12956. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12958. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12959. if !m.op.Is(OpUpdateOne) {
  12960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12961. }
  12962. if m.id == nil || m.oldValue == nil {
  12963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12964. }
  12965. oldValue, err := m.oldValue(ctx)
  12966. if err != nil {
  12967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12968. }
  12969. return oldValue.DeletedAt, nil
  12970. }
  12971. // ClearDeletedAt clears the value of the "deleted_at" field.
  12972. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12973. m.deleted_at = nil
  12974. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12975. }
  12976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12977. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12978. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12979. return ok
  12980. }
  12981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12982. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12983. m.deleted_at = nil
  12984. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12985. }
  12986. // SetLabelID sets the "label_id" field.
  12987. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12988. m.labels = &u
  12989. }
  12990. // LabelID returns the value of the "label_id" field in the mutation.
  12991. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12992. v := m.labels
  12993. if v == nil {
  12994. return
  12995. }
  12996. return *v, true
  12997. }
  12998. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12999. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13001. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  13002. if !m.op.Is(OpUpdateOne) {
  13003. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  13004. }
  13005. if m.id == nil || m.oldValue == nil {
  13006. return v, errors.New("OldLabelID requires an ID field in the mutation")
  13007. }
  13008. oldValue, err := m.oldValue(ctx)
  13009. if err != nil {
  13010. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  13011. }
  13012. return oldValue.LabelID, nil
  13013. }
  13014. // ResetLabelID resets all changes to the "label_id" field.
  13015. func (m *LabelRelationshipMutation) ResetLabelID() {
  13016. m.labels = nil
  13017. }
  13018. // SetContactID sets the "contact_id" field.
  13019. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  13020. m.contacts = &u
  13021. }
  13022. // ContactID returns the value of the "contact_id" field in the mutation.
  13023. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  13024. v := m.contacts
  13025. if v == nil {
  13026. return
  13027. }
  13028. return *v, true
  13029. }
  13030. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  13031. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13033. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13034. if !m.op.Is(OpUpdateOne) {
  13035. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13036. }
  13037. if m.id == nil || m.oldValue == nil {
  13038. return v, errors.New("OldContactID requires an ID field in the mutation")
  13039. }
  13040. oldValue, err := m.oldValue(ctx)
  13041. if err != nil {
  13042. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13043. }
  13044. return oldValue.ContactID, nil
  13045. }
  13046. // ResetContactID resets all changes to the "contact_id" field.
  13047. func (m *LabelRelationshipMutation) ResetContactID() {
  13048. m.contacts = nil
  13049. }
  13050. // SetOrganizationID sets the "organization_id" field.
  13051. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  13052. m.organization_id = &u
  13053. m.addorganization_id = nil
  13054. }
  13055. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13056. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  13057. v := m.organization_id
  13058. if v == nil {
  13059. return
  13060. }
  13061. return *v, true
  13062. }
  13063. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  13064. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13066. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13067. if !m.op.Is(OpUpdateOne) {
  13068. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13069. }
  13070. if m.id == nil || m.oldValue == nil {
  13071. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13072. }
  13073. oldValue, err := m.oldValue(ctx)
  13074. if err != nil {
  13075. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13076. }
  13077. return oldValue.OrganizationID, nil
  13078. }
  13079. // AddOrganizationID adds u to the "organization_id" field.
  13080. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  13081. if m.addorganization_id != nil {
  13082. *m.addorganization_id += u
  13083. } else {
  13084. m.addorganization_id = &u
  13085. }
  13086. }
  13087. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13088. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  13089. v := m.addorganization_id
  13090. if v == nil {
  13091. return
  13092. }
  13093. return *v, true
  13094. }
  13095. // ClearOrganizationID clears the value of the "organization_id" field.
  13096. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  13097. m.organization_id = nil
  13098. m.addorganization_id = nil
  13099. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  13100. }
  13101. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13102. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  13103. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  13104. return ok
  13105. }
  13106. // ResetOrganizationID resets all changes to the "organization_id" field.
  13107. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  13108. m.organization_id = nil
  13109. m.addorganization_id = nil
  13110. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  13111. }
  13112. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  13113. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  13114. m.contacts = &id
  13115. }
  13116. // ClearContacts clears the "contacts" edge to the Contact entity.
  13117. func (m *LabelRelationshipMutation) ClearContacts() {
  13118. m.clearedcontacts = true
  13119. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  13120. }
  13121. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  13122. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  13123. return m.clearedcontacts
  13124. }
  13125. // ContactsID returns the "contacts" edge ID in the mutation.
  13126. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  13127. if m.contacts != nil {
  13128. return *m.contacts, true
  13129. }
  13130. return
  13131. }
  13132. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  13133. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13134. // ContactsID instead. It exists only for internal usage by the builders.
  13135. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  13136. if id := m.contacts; id != nil {
  13137. ids = append(ids, *id)
  13138. }
  13139. return
  13140. }
  13141. // ResetContacts resets all changes to the "contacts" edge.
  13142. func (m *LabelRelationshipMutation) ResetContacts() {
  13143. m.contacts = nil
  13144. m.clearedcontacts = false
  13145. }
  13146. // SetLabelsID sets the "labels" edge to the Label entity by id.
  13147. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  13148. m.labels = &id
  13149. }
  13150. // ClearLabels clears the "labels" edge to the Label entity.
  13151. func (m *LabelRelationshipMutation) ClearLabels() {
  13152. m.clearedlabels = true
  13153. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  13154. }
  13155. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  13156. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  13157. return m.clearedlabels
  13158. }
  13159. // LabelsID returns the "labels" edge ID in the mutation.
  13160. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  13161. if m.labels != nil {
  13162. return *m.labels, true
  13163. }
  13164. return
  13165. }
  13166. // LabelsIDs returns the "labels" edge IDs in the mutation.
  13167. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13168. // LabelsID instead. It exists only for internal usage by the builders.
  13169. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  13170. if id := m.labels; id != nil {
  13171. ids = append(ids, *id)
  13172. }
  13173. return
  13174. }
  13175. // ResetLabels resets all changes to the "labels" edge.
  13176. func (m *LabelRelationshipMutation) ResetLabels() {
  13177. m.labels = nil
  13178. m.clearedlabels = false
  13179. }
  13180. // Where appends a list predicates to the LabelRelationshipMutation builder.
  13181. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  13182. m.predicates = append(m.predicates, ps...)
  13183. }
  13184. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  13185. // users can use type-assertion to append predicates that do not depend on any generated package.
  13186. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  13187. p := make([]predicate.LabelRelationship, len(ps))
  13188. for i := range ps {
  13189. p[i] = ps[i]
  13190. }
  13191. m.Where(p...)
  13192. }
  13193. // Op returns the operation name.
  13194. func (m *LabelRelationshipMutation) Op() Op {
  13195. return m.op
  13196. }
  13197. // SetOp allows setting the mutation operation.
  13198. func (m *LabelRelationshipMutation) SetOp(op Op) {
  13199. m.op = op
  13200. }
  13201. // Type returns the node type of this mutation (LabelRelationship).
  13202. func (m *LabelRelationshipMutation) Type() string {
  13203. return m.typ
  13204. }
  13205. // Fields returns all fields that were changed during this mutation. Note that in
  13206. // order to get all numeric fields that were incremented/decremented, call
  13207. // AddedFields().
  13208. func (m *LabelRelationshipMutation) Fields() []string {
  13209. fields := make([]string, 0, 7)
  13210. if m.created_at != nil {
  13211. fields = append(fields, labelrelationship.FieldCreatedAt)
  13212. }
  13213. if m.updated_at != nil {
  13214. fields = append(fields, labelrelationship.FieldUpdatedAt)
  13215. }
  13216. if m.status != nil {
  13217. fields = append(fields, labelrelationship.FieldStatus)
  13218. }
  13219. if m.deleted_at != nil {
  13220. fields = append(fields, labelrelationship.FieldDeletedAt)
  13221. }
  13222. if m.labels != nil {
  13223. fields = append(fields, labelrelationship.FieldLabelID)
  13224. }
  13225. if m.contacts != nil {
  13226. fields = append(fields, labelrelationship.FieldContactID)
  13227. }
  13228. if m.organization_id != nil {
  13229. fields = append(fields, labelrelationship.FieldOrganizationID)
  13230. }
  13231. return fields
  13232. }
  13233. // Field returns the value of a field with the given name. The second boolean
  13234. // return value indicates that this field was not set, or was not defined in the
  13235. // schema.
  13236. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  13237. switch name {
  13238. case labelrelationship.FieldCreatedAt:
  13239. return m.CreatedAt()
  13240. case labelrelationship.FieldUpdatedAt:
  13241. return m.UpdatedAt()
  13242. case labelrelationship.FieldStatus:
  13243. return m.Status()
  13244. case labelrelationship.FieldDeletedAt:
  13245. return m.DeletedAt()
  13246. case labelrelationship.FieldLabelID:
  13247. return m.LabelID()
  13248. case labelrelationship.FieldContactID:
  13249. return m.ContactID()
  13250. case labelrelationship.FieldOrganizationID:
  13251. return m.OrganizationID()
  13252. }
  13253. return nil, false
  13254. }
  13255. // OldField returns the old value of the field from the database. An error is
  13256. // returned if the mutation operation is not UpdateOne, or the query to the
  13257. // database failed.
  13258. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13259. switch name {
  13260. case labelrelationship.FieldCreatedAt:
  13261. return m.OldCreatedAt(ctx)
  13262. case labelrelationship.FieldUpdatedAt:
  13263. return m.OldUpdatedAt(ctx)
  13264. case labelrelationship.FieldStatus:
  13265. return m.OldStatus(ctx)
  13266. case labelrelationship.FieldDeletedAt:
  13267. return m.OldDeletedAt(ctx)
  13268. case labelrelationship.FieldLabelID:
  13269. return m.OldLabelID(ctx)
  13270. case labelrelationship.FieldContactID:
  13271. return m.OldContactID(ctx)
  13272. case labelrelationship.FieldOrganizationID:
  13273. return m.OldOrganizationID(ctx)
  13274. }
  13275. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  13276. }
  13277. // SetField sets the value of a field with the given name. It returns an error if
  13278. // the field is not defined in the schema, or if the type mismatched the field
  13279. // type.
  13280. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  13281. switch name {
  13282. case labelrelationship.FieldCreatedAt:
  13283. v, ok := value.(time.Time)
  13284. if !ok {
  13285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13286. }
  13287. m.SetCreatedAt(v)
  13288. return nil
  13289. case labelrelationship.FieldUpdatedAt:
  13290. v, ok := value.(time.Time)
  13291. if !ok {
  13292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13293. }
  13294. m.SetUpdatedAt(v)
  13295. return nil
  13296. case labelrelationship.FieldStatus:
  13297. v, ok := value.(uint8)
  13298. if !ok {
  13299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13300. }
  13301. m.SetStatus(v)
  13302. return nil
  13303. case labelrelationship.FieldDeletedAt:
  13304. v, ok := value.(time.Time)
  13305. if !ok {
  13306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13307. }
  13308. m.SetDeletedAt(v)
  13309. return nil
  13310. case labelrelationship.FieldLabelID:
  13311. v, ok := value.(uint64)
  13312. if !ok {
  13313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13314. }
  13315. m.SetLabelID(v)
  13316. return nil
  13317. case labelrelationship.FieldContactID:
  13318. v, ok := value.(uint64)
  13319. if !ok {
  13320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13321. }
  13322. m.SetContactID(v)
  13323. return nil
  13324. case labelrelationship.FieldOrganizationID:
  13325. v, ok := value.(uint64)
  13326. if !ok {
  13327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13328. }
  13329. m.SetOrganizationID(v)
  13330. return nil
  13331. }
  13332. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13333. }
  13334. // AddedFields returns all numeric fields that were incremented/decremented during
  13335. // this mutation.
  13336. func (m *LabelRelationshipMutation) AddedFields() []string {
  13337. var fields []string
  13338. if m.addstatus != nil {
  13339. fields = append(fields, labelrelationship.FieldStatus)
  13340. }
  13341. if m.addorganization_id != nil {
  13342. fields = append(fields, labelrelationship.FieldOrganizationID)
  13343. }
  13344. return fields
  13345. }
  13346. // AddedField returns the numeric value that was incremented/decremented on a field
  13347. // with the given name. The second boolean return value indicates that this field
  13348. // was not set, or was not defined in the schema.
  13349. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  13350. switch name {
  13351. case labelrelationship.FieldStatus:
  13352. return m.AddedStatus()
  13353. case labelrelationship.FieldOrganizationID:
  13354. return m.AddedOrganizationID()
  13355. }
  13356. return nil, false
  13357. }
  13358. // AddField adds the value to the field with the given name. It returns an error if
  13359. // the field is not defined in the schema, or if the type mismatched the field
  13360. // type.
  13361. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  13362. switch name {
  13363. case labelrelationship.FieldStatus:
  13364. v, ok := value.(int8)
  13365. if !ok {
  13366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13367. }
  13368. m.AddStatus(v)
  13369. return nil
  13370. case labelrelationship.FieldOrganizationID:
  13371. v, ok := value.(int64)
  13372. if !ok {
  13373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13374. }
  13375. m.AddOrganizationID(v)
  13376. return nil
  13377. }
  13378. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  13379. }
  13380. // ClearedFields returns all nullable fields that were cleared during this
  13381. // mutation.
  13382. func (m *LabelRelationshipMutation) ClearedFields() []string {
  13383. var fields []string
  13384. if m.FieldCleared(labelrelationship.FieldStatus) {
  13385. fields = append(fields, labelrelationship.FieldStatus)
  13386. }
  13387. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  13388. fields = append(fields, labelrelationship.FieldDeletedAt)
  13389. }
  13390. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  13391. fields = append(fields, labelrelationship.FieldOrganizationID)
  13392. }
  13393. return fields
  13394. }
  13395. // FieldCleared returns a boolean indicating if a field with the given name was
  13396. // cleared in this mutation.
  13397. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  13398. _, ok := m.clearedFields[name]
  13399. return ok
  13400. }
  13401. // ClearField clears the value of the field with the given name. It returns an
  13402. // error if the field is not defined in the schema.
  13403. func (m *LabelRelationshipMutation) ClearField(name string) error {
  13404. switch name {
  13405. case labelrelationship.FieldStatus:
  13406. m.ClearStatus()
  13407. return nil
  13408. case labelrelationship.FieldDeletedAt:
  13409. m.ClearDeletedAt()
  13410. return nil
  13411. case labelrelationship.FieldOrganizationID:
  13412. m.ClearOrganizationID()
  13413. return nil
  13414. }
  13415. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  13416. }
  13417. // ResetField resets all changes in the mutation for the field with the given name.
  13418. // It returns an error if the field is not defined in the schema.
  13419. func (m *LabelRelationshipMutation) ResetField(name string) error {
  13420. switch name {
  13421. case labelrelationship.FieldCreatedAt:
  13422. m.ResetCreatedAt()
  13423. return nil
  13424. case labelrelationship.FieldUpdatedAt:
  13425. m.ResetUpdatedAt()
  13426. return nil
  13427. case labelrelationship.FieldStatus:
  13428. m.ResetStatus()
  13429. return nil
  13430. case labelrelationship.FieldDeletedAt:
  13431. m.ResetDeletedAt()
  13432. return nil
  13433. case labelrelationship.FieldLabelID:
  13434. m.ResetLabelID()
  13435. return nil
  13436. case labelrelationship.FieldContactID:
  13437. m.ResetContactID()
  13438. return nil
  13439. case labelrelationship.FieldOrganizationID:
  13440. m.ResetOrganizationID()
  13441. return nil
  13442. }
  13443. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13444. }
  13445. // AddedEdges returns all edge names that were set/added in this mutation.
  13446. func (m *LabelRelationshipMutation) AddedEdges() []string {
  13447. edges := make([]string, 0, 2)
  13448. if m.contacts != nil {
  13449. edges = append(edges, labelrelationship.EdgeContacts)
  13450. }
  13451. if m.labels != nil {
  13452. edges = append(edges, labelrelationship.EdgeLabels)
  13453. }
  13454. return edges
  13455. }
  13456. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13457. // name in this mutation.
  13458. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  13459. switch name {
  13460. case labelrelationship.EdgeContacts:
  13461. if id := m.contacts; id != nil {
  13462. return []ent.Value{*id}
  13463. }
  13464. case labelrelationship.EdgeLabels:
  13465. if id := m.labels; id != nil {
  13466. return []ent.Value{*id}
  13467. }
  13468. }
  13469. return nil
  13470. }
  13471. // RemovedEdges returns all edge names that were removed in this mutation.
  13472. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  13473. edges := make([]string, 0, 2)
  13474. return edges
  13475. }
  13476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13477. // the given name in this mutation.
  13478. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  13479. return nil
  13480. }
  13481. // ClearedEdges returns all edge names that were cleared in this mutation.
  13482. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  13483. edges := make([]string, 0, 2)
  13484. if m.clearedcontacts {
  13485. edges = append(edges, labelrelationship.EdgeContacts)
  13486. }
  13487. if m.clearedlabels {
  13488. edges = append(edges, labelrelationship.EdgeLabels)
  13489. }
  13490. return edges
  13491. }
  13492. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13493. // was cleared in this mutation.
  13494. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  13495. switch name {
  13496. case labelrelationship.EdgeContacts:
  13497. return m.clearedcontacts
  13498. case labelrelationship.EdgeLabels:
  13499. return m.clearedlabels
  13500. }
  13501. return false
  13502. }
  13503. // ClearEdge clears the value of the edge with the given name. It returns an error
  13504. // if that edge is not defined in the schema.
  13505. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  13506. switch name {
  13507. case labelrelationship.EdgeContacts:
  13508. m.ClearContacts()
  13509. return nil
  13510. case labelrelationship.EdgeLabels:
  13511. m.ClearLabels()
  13512. return nil
  13513. }
  13514. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  13515. }
  13516. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13517. // It returns an error if the edge is not defined in the schema.
  13518. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  13519. switch name {
  13520. case labelrelationship.EdgeContacts:
  13521. m.ResetContacts()
  13522. return nil
  13523. case labelrelationship.EdgeLabels:
  13524. m.ResetLabels()
  13525. return nil
  13526. }
  13527. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  13528. }
  13529. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  13530. type LabelTaggingMutation struct {
  13531. config
  13532. op Op
  13533. typ string
  13534. id *uint64
  13535. created_at *time.Time
  13536. updated_at *time.Time
  13537. status *uint8
  13538. addstatus *int8
  13539. deleted_at *time.Time
  13540. organization_id *uint64
  13541. addorganization_id *int64
  13542. _type *int
  13543. add_type *int
  13544. conditions *[]string
  13545. appendconditions []string
  13546. action_label_add *[]uint64
  13547. appendaction_label_add []uint64
  13548. action_label_del *[]uint64
  13549. appendaction_label_del []uint64
  13550. clearedFields map[string]struct{}
  13551. done bool
  13552. oldValue func(context.Context) (*LabelTagging, error)
  13553. predicates []predicate.LabelTagging
  13554. }
  13555. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  13556. // labeltaggingOption allows management of the mutation configuration using functional options.
  13557. type labeltaggingOption func(*LabelTaggingMutation)
  13558. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  13559. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  13560. m := &LabelTaggingMutation{
  13561. config: c,
  13562. op: op,
  13563. typ: TypeLabelTagging,
  13564. clearedFields: make(map[string]struct{}),
  13565. }
  13566. for _, opt := range opts {
  13567. opt(m)
  13568. }
  13569. return m
  13570. }
  13571. // withLabelTaggingID sets the ID field of the mutation.
  13572. func withLabelTaggingID(id uint64) labeltaggingOption {
  13573. return func(m *LabelTaggingMutation) {
  13574. var (
  13575. err error
  13576. once sync.Once
  13577. value *LabelTagging
  13578. )
  13579. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  13580. once.Do(func() {
  13581. if m.done {
  13582. err = errors.New("querying old values post mutation is not allowed")
  13583. } else {
  13584. value, err = m.Client().LabelTagging.Get(ctx, id)
  13585. }
  13586. })
  13587. return value, err
  13588. }
  13589. m.id = &id
  13590. }
  13591. }
  13592. // withLabelTagging sets the old LabelTagging of the mutation.
  13593. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  13594. return func(m *LabelTaggingMutation) {
  13595. m.oldValue = func(context.Context) (*LabelTagging, error) {
  13596. return node, nil
  13597. }
  13598. m.id = &node.ID
  13599. }
  13600. }
  13601. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13602. // executed in a transaction (ent.Tx), a transactional client is returned.
  13603. func (m LabelTaggingMutation) Client() *Client {
  13604. client := &Client{config: m.config}
  13605. client.init()
  13606. return client
  13607. }
  13608. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13609. // it returns an error otherwise.
  13610. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  13611. if _, ok := m.driver.(*txDriver); !ok {
  13612. return nil, errors.New("ent: mutation is not running in a transaction")
  13613. }
  13614. tx := &Tx{config: m.config}
  13615. tx.init()
  13616. return tx, nil
  13617. }
  13618. // SetID sets the value of the id field. Note that this
  13619. // operation is only accepted on creation of LabelTagging entities.
  13620. func (m *LabelTaggingMutation) SetID(id uint64) {
  13621. m.id = &id
  13622. }
  13623. // ID returns the ID value in the mutation. Note that the ID is only available
  13624. // if it was provided to the builder or after it was returned from the database.
  13625. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  13626. if m.id == nil {
  13627. return
  13628. }
  13629. return *m.id, true
  13630. }
  13631. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13632. // That means, if the mutation is applied within a transaction with an isolation level such
  13633. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13634. // or updated by the mutation.
  13635. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  13636. switch {
  13637. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13638. id, exists := m.ID()
  13639. if exists {
  13640. return []uint64{id}, nil
  13641. }
  13642. fallthrough
  13643. case m.op.Is(OpUpdate | OpDelete):
  13644. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  13645. default:
  13646. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13647. }
  13648. }
  13649. // SetCreatedAt sets the "created_at" field.
  13650. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  13651. m.created_at = &t
  13652. }
  13653. // CreatedAt returns the value of the "created_at" field in the mutation.
  13654. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  13655. v := m.created_at
  13656. if v == nil {
  13657. return
  13658. }
  13659. return *v, true
  13660. }
  13661. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  13662. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13664. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13665. if !m.op.Is(OpUpdateOne) {
  13666. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13667. }
  13668. if m.id == nil || m.oldValue == nil {
  13669. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13670. }
  13671. oldValue, err := m.oldValue(ctx)
  13672. if err != nil {
  13673. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13674. }
  13675. return oldValue.CreatedAt, nil
  13676. }
  13677. // ResetCreatedAt resets all changes to the "created_at" field.
  13678. func (m *LabelTaggingMutation) ResetCreatedAt() {
  13679. m.created_at = nil
  13680. }
  13681. // SetUpdatedAt sets the "updated_at" field.
  13682. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  13683. m.updated_at = &t
  13684. }
  13685. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13686. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  13687. v := m.updated_at
  13688. if v == nil {
  13689. return
  13690. }
  13691. return *v, true
  13692. }
  13693. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  13694. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13696. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13697. if !m.op.Is(OpUpdateOne) {
  13698. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13699. }
  13700. if m.id == nil || m.oldValue == nil {
  13701. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13702. }
  13703. oldValue, err := m.oldValue(ctx)
  13704. if err != nil {
  13705. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13706. }
  13707. return oldValue.UpdatedAt, nil
  13708. }
  13709. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13710. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  13711. m.updated_at = nil
  13712. }
  13713. // SetStatus sets the "status" field.
  13714. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  13715. m.status = &u
  13716. m.addstatus = nil
  13717. }
  13718. // Status returns the value of the "status" field in the mutation.
  13719. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  13720. v := m.status
  13721. if v == nil {
  13722. return
  13723. }
  13724. return *v, true
  13725. }
  13726. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  13727. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13729. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13730. if !m.op.Is(OpUpdateOne) {
  13731. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13732. }
  13733. if m.id == nil || m.oldValue == nil {
  13734. return v, errors.New("OldStatus requires an ID field in the mutation")
  13735. }
  13736. oldValue, err := m.oldValue(ctx)
  13737. if err != nil {
  13738. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13739. }
  13740. return oldValue.Status, nil
  13741. }
  13742. // AddStatus adds u to the "status" field.
  13743. func (m *LabelTaggingMutation) AddStatus(u int8) {
  13744. if m.addstatus != nil {
  13745. *m.addstatus += u
  13746. } else {
  13747. m.addstatus = &u
  13748. }
  13749. }
  13750. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13751. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  13752. v := m.addstatus
  13753. if v == nil {
  13754. return
  13755. }
  13756. return *v, true
  13757. }
  13758. // ClearStatus clears the value of the "status" field.
  13759. func (m *LabelTaggingMutation) ClearStatus() {
  13760. m.status = nil
  13761. m.addstatus = nil
  13762. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  13763. }
  13764. // StatusCleared returns if the "status" field was cleared in this mutation.
  13765. func (m *LabelTaggingMutation) StatusCleared() bool {
  13766. _, ok := m.clearedFields[labeltagging.FieldStatus]
  13767. return ok
  13768. }
  13769. // ResetStatus resets all changes to the "status" field.
  13770. func (m *LabelTaggingMutation) ResetStatus() {
  13771. m.status = nil
  13772. m.addstatus = nil
  13773. delete(m.clearedFields, labeltagging.FieldStatus)
  13774. }
  13775. // SetDeletedAt sets the "deleted_at" field.
  13776. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  13777. m.deleted_at = &t
  13778. }
  13779. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13780. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  13781. v := m.deleted_at
  13782. if v == nil {
  13783. return
  13784. }
  13785. return *v, true
  13786. }
  13787. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  13788. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13790. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13791. if !m.op.Is(OpUpdateOne) {
  13792. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13793. }
  13794. if m.id == nil || m.oldValue == nil {
  13795. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13796. }
  13797. oldValue, err := m.oldValue(ctx)
  13798. if err != nil {
  13799. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13800. }
  13801. return oldValue.DeletedAt, nil
  13802. }
  13803. // ClearDeletedAt clears the value of the "deleted_at" field.
  13804. func (m *LabelTaggingMutation) ClearDeletedAt() {
  13805. m.deleted_at = nil
  13806. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  13807. }
  13808. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13809. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  13810. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  13811. return ok
  13812. }
  13813. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13814. func (m *LabelTaggingMutation) ResetDeletedAt() {
  13815. m.deleted_at = nil
  13816. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  13817. }
  13818. // SetOrganizationID sets the "organization_id" field.
  13819. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  13820. m.organization_id = &u
  13821. m.addorganization_id = nil
  13822. }
  13823. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13824. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  13825. v := m.organization_id
  13826. if v == nil {
  13827. return
  13828. }
  13829. return *v, true
  13830. }
  13831. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  13832. // If the LabelTagging 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 *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13835. if !m.op.Is(OpUpdateOne) {
  13836. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13837. }
  13838. if m.id == nil || m.oldValue == nil {
  13839. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  13844. }
  13845. return oldValue.OrganizationID, nil
  13846. }
  13847. // AddOrganizationID adds u to the "organization_id" field.
  13848. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  13849. if m.addorganization_id != nil {
  13850. *m.addorganization_id += u
  13851. } else {
  13852. m.addorganization_id = &u
  13853. }
  13854. }
  13855. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13856. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  13857. v := m.addorganization_id
  13858. if v == nil {
  13859. return
  13860. }
  13861. return *v, true
  13862. }
  13863. // ClearOrganizationID clears the value of the "organization_id" field.
  13864. func (m *LabelTaggingMutation) ClearOrganizationID() {
  13865. m.organization_id = nil
  13866. m.addorganization_id = nil
  13867. m.clearedFields[labeltagging.FieldOrganizationID] = struct{}{}
  13868. }
  13869. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13870. func (m *LabelTaggingMutation) OrganizationIDCleared() bool {
  13871. _, ok := m.clearedFields[labeltagging.FieldOrganizationID]
  13872. return ok
  13873. }
  13874. // ResetOrganizationID resets all changes to the "organization_id" field.
  13875. func (m *LabelTaggingMutation) ResetOrganizationID() {
  13876. m.organization_id = nil
  13877. m.addorganization_id = nil
  13878. delete(m.clearedFields, labeltagging.FieldOrganizationID)
  13879. }
  13880. // SetType sets the "type" field.
  13881. func (m *LabelTaggingMutation) SetType(i int) {
  13882. m._type = &i
  13883. m.add_type = nil
  13884. }
  13885. // GetType returns the value of the "type" field in the mutation.
  13886. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  13887. v := m._type
  13888. if v == nil {
  13889. return
  13890. }
  13891. return *v, true
  13892. }
  13893. // OldType returns the old "type" field's value of the LabelTagging entity.
  13894. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13896. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  13897. if !m.op.Is(OpUpdateOne) {
  13898. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13899. }
  13900. if m.id == nil || m.oldValue == nil {
  13901. return v, errors.New("OldType requires an ID field in the mutation")
  13902. }
  13903. oldValue, err := m.oldValue(ctx)
  13904. if err != nil {
  13905. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13906. }
  13907. return oldValue.Type, nil
  13908. }
  13909. // AddType adds i to the "type" field.
  13910. func (m *LabelTaggingMutation) AddType(i int) {
  13911. if m.add_type != nil {
  13912. *m.add_type += i
  13913. } else {
  13914. m.add_type = &i
  13915. }
  13916. }
  13917. // AddedType returns the value that was added to the "type" field in this mutation.
  13918. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  13919. v := m.add_type
  13920. if v == nil {
  13921. return
  13922. }
  13923. return *v, true
  13924. }
  13925. // ResetType resets all changes to the "type" field.
  13926. func (m *LabelTaggingMutation) ResetType() {
  13927. m._type = nil
  13928. m.add_type = nil
  13929. }
  13930. // SetConditions sets the "conditions" field.
  13931. func (m *LabelTaggingMutation) SetConditions(s []string) {
  13932. m.conditions = &s
  13933. m.appendconditions = nil
  13934. }
  13935. // Conditions returns the value of the "conditions" field in the mutation.
  13936. func (m *LabelTaggingMutation) Conditions() (r []string, exists bool) {
  13937. v := m.conditions
  13938. if v == nil {
  13939. return
  13940. }
  13941. return *v, true
  13942. }
  13943. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  13944. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13946. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v []string, err error) {
  13947. if !m.op.Is(OpUpdateOne) {
  13948. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13949. }
  13950. if m.id == nil || m.oldValue == nil {
  13951. return v, errors.New("OldConditions requires an ID field in the mutation")
  13952. }
  13953. oldValue, err := m.oldValue(ctx)
  13954. if err != nil {
  13955. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13956. }
  13957. return oldValue.Conditions, nil
  13958. }
  13959. // AppendConditions adds s to the "conditions" field.
  13960. func (m *LabelTaggingMutation) AppendConditions(s []string) {
  13961. m.appendconditions = append(m.appendconditions, s...)
  13962. }
  13963. // AppendedConditions returns the list of values that were appended to the "conditions" field in this mutation.
  13964. func (m *LabelTaggingMutation) AppendedConditions() ([]string, bool) {
  13965. if len(m.appendconditions) == 0 {
  13966. return nil, false
  13967. }
  13968. return m.appendconditions, true
  13969. }
  13970. // ClearConditions clears the value of the "conditions" field.
  13971. func (m *LabelTaggingMutation) ClearConditions() {
  13972. m.conditions = nil
  13973. m.appendconditions = nil
  13974. m.clearedFields[labeltagging.FieldConditions] = struct{}{}
  13975. }
  13976. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13977. func (m *LabelTaggingMutation) ConditionsCleared() bool {
  13978. _, ok := m.clearedFields[labeltagging.FieldConditions]
  13979. return ok
  13980. }
  13981. // ResetConditions resets all changes to the "conditions" field.
  13982. func (m *LabelTaggingMutation) ResetConditions() {
  13983. m.conditions = nil
  13984. m.appendconditions = nil
  13985. delete(m.clearedFields, labeltagging.FieldConditions)
  13986. }
  13987. // SetActionLabelAdd sets the "action_label_add" field.
  13988. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  13989. m.action_label_add = &u
  13990. m.appendaction_label_add = nil
  13991. }
  13992. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  13993. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  13994. v := m.action_label_add
  13995. if v == nil {
  13996. return
  13997. }
  13998. return *v, true
  13999. }
  14000. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  14001. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  14002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14003. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  14004. if !m.op.Is(OpUpdateOne) {
  14005. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  14006. }
  14007. if m.id == nil || m.oldValue == nil {
  14008. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  14009. }
  14010. oldValue, err := m.oldValue(ctx)
  14011. if err != nil {
  14012. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  14013. }
  14014. return oldValue.ActionLabelAdd, nil
  14015. }
  14016. // AppendActionLabelAdd adds u to the "action_label_add" field.
  14017. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  14018. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  14019. }
  14020. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  14021. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  14022. if len(m.appendaction_label_add) == 0 {
  14023. return nil, false
  14024. }
  14025. return m.appendaction_label_add, true
  14026. }
  14027. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  14028. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  14029. m.action_label_add = nil
  14030. m.appendaction_label_add = nil
  14031. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  14032. }
  14033. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  14034. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  14035. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  14036. return ok
  14037. }
  14038. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  14039. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  14040. m.action_label_add = nil
  14041. m.appendaction_label_add = nil
  14042. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  14043. }
  14044. // SetActionLabelDel sets the "action_label_del" field.
  14045. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  14046. m.action_label_del = &u
  14047. m.appendaction_label_del = nil
  14048. }
  14049. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  14050. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  14051. v := m.action_label_del
  14052. if v == nil {
  14053. return
  14054. }
  14055. return *v, true
  14056. }
  14057. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  14058. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  14059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14060. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  14061. if !m.op.Is(OpUpdateOne) {
  14062. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  14063. }
  14064. if m.id == nil || m.oldValue == nil {
  14065. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  14066. }
  14067. oldValue, err := m.oldValue(ctx)
  14068. if err != nil {
  14069. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  14070. }
  14071. return oldValue.ActionLabelDel, nil
  14072. }
  14073. // AppendActionLabelDel adds u to the "action_label_del" field.
  14074. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  14075. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  14076. }
  14077. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  14078. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  14079. if len(m.appendaction_label_del) == 0 {
  14080. return nil, false
  14081. }
  14082. return m.appendaction_label_del, true
  14083. }
  14084. // ClearActionLabelDel clears the value of the "action_label_del" field.
  14085. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  14086. m.action_label_del = nil
  14087. m.appendaction_label_del = nil
  14088. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  14089. }
  14090. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  14091. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  14092. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  14093. return ok
  14094. }
  14095. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  14096. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  14097. m.action_label_del = nil
  14098. m.appendaction_label_del = nil
  14099. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  14100. }
  14101. // Where appends a list predicates to the LabelTaggingMutation builder.
  14102. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  14103. m.predicates = append(m.predicates, ps...)
  14104. }
  14105. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  14106. // users can use type-assertion to append predicates that do not depend on any generated package.
  14107. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  14108. p := make([]predicate.LabelTagging, len(ps))
  14109. for i := range ps {
  14110. p[i] = ps[i]
  14111. }
  14112. m.Where(p...)
  14113. }
  14114. // Op returns the operation name.
  14115. func (m *LabelTaggingMutation) Op() Op {
  14116. return m.op
  14117. }
  14118. // SetOp allows setting the mutation operation.
  14119. func (m *LabelTaggingMutation) SetOp(op Op) {
  14120. m.op = op
  14121. }
  14122. // Type returns the node type of this mutation (LabelTagging).
  14123. func (m *LabelTaggingMutation) Type() string {
  14124. return m.typ
  14125. }
  14126. // Fields returns all fields that were changed during this mutation. Note that in
  14127. // order to get all numeric fields that were incremented/decremented, call
  14128. // AddedFields().
  14129. func (m *LabelTaggingMutation) Fields() []string {
  14130. fields := make([]string, 0, 9)
  14131. if m.created_at != nil {
  14132. fields = append(fields, labeltagging.FieldCreatedAt)
  14133. }
  14134. if m.updated_at != nil {
  14135. fields = append(fields, labeltagging.FieldUpdatedAt)
  14136. }
  14137. if m.status != nil {
  14138. fields = append(fields, labeltagging.FieldStatus)
  14139. }
  14140. if m.deleted_at != nil {
  14141. fields = append(fields, labeltagging.FieldDeletedAt)
  14142. }
  14143. if m.organization_id != nil {
  14144. fields = append(fields, labeltagging.FieldOrganizationID)
  14145. }
  14146. if m._type != nil {
  14147. fields = append(fields, labeltagging.FieldType)
  14148. }
  14149. if m.conditions != nil {
  14150. fields = append(fields, labeltagging.FieldConditions)
  14151. }
  14152. if m.action_label_add != nil {
  14153. fields = append(fields, labeltagging.FieldActionLabelAdd)
  14154. }
  14155. if m.action_label_del != nil {
  14156. fields = append(fields, labeltagging.FieldActionLabelDel)
  14157. }
  14158. return fields
  14159. }
  14160. // Field returns the value of a field with the given name. The second boolean
  14161. // return value indicates that this field was not set, or was not defined in the
  14162. // schema.
  14163. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  14164. switch name {
  14165. case labeltagging.FieldCreatedAt:
  14166. return m.CreatedAt()
  14167. case labeltagging.FieldUpdatedAt:
  14168. return m.UpdatedAt()
  14169. case labeltagging.FieldStatus:
  14170. return m.Status()
  14171. case labeltagging.FieldDeletedAt:
  14172. return m.DeletedAt()
  14173. case labeltagging.FieldOrganizationID:
  14174. return m.OrganizationID()
  14175. case labeltagging.FieldType:
  14176. return m.GetType()
  14177. case labeltagging.FieldConditions:
  14178. return m.Conditions()
  14179. case labeltagging.FieldActionLabelAdd:
  14180. return m.ActionLabelAdd()
  14181. case labeltagging.FieldActionLabelDel:
  14182. return m.ActionLabelDel()
  14183. }
  14184. return nil, false
  14185. }
  14186. // OldField returns the old value of the field from the database. An error is
  14187. // returned if the mutation operation is not UpdateOne, or the query to the
  14188. // database failed.
  14189. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14190. switch name {
  14191. case labeltagging.FieldCreatedAt:
  14192. return m.OldCreatedAt(ctx)
  14193. case labeltagging.FieldUpdatedAt:
  14194. return m.OldUpdatedAt(ctx)
  14195. case labeltagging.FieldStatus:
  14196. return m.OldStatus(ctx)
  14197. case labeltagging.FieldDeletedAt:
  14198. return m.OldDeletedAt(ctx)
  14199. case labeltagging.FieldOrganizationID:
  14200. return m.OldOrganizationID(ctx)
  14201. case labeltagging.FieldType:
  14202. return m.OldType(ctx)
  14203. case labeltagging.FieldConditions:
  14204. return m.OldConditions(ctx)
  14205. case labeltagging.FieldActionLabelAdd:
  14206. return m.OldActionLabelAdd(ctx)
  14207. case labeltagging.FieldActionLabelDel:
  14208. return m.OldActionLabelDel(ctx)
  14209. }
  14210. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  14211. }
  14212. // SetField sets the value of a field with the given name. It returns an error if
  14213. // the field is not defined in the schema, or if the type mismatched the field
  14214. // type.
  14215. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  14216. switch name {
  14217. case labeltagging.FieldCreatedAt:
  14218. v, ok := value.(time.Time)
  14219. if !ok {
  14220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14221. }
  14222. m.SetCreatedAt(v)
  14223. return nil
  14224. case labeltagging.FieldUpdatedAt:
  14225. v, ok := value.(time.Time)
  14226. if !ok {
  14227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14228. }
  14229. m.SetUpdatedAt(v)
  14230. return nil
  14231. case labeltagging.FieldStatus:
  14232. v, ok := value.(uint8)
  14233. if !ok {
  14234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14235. }
  14236. m.SetStatus(v)
  14237. return nil
  14238. case labeltagging.FieldDeletedAt:
  14239. v, ok := value.(time.Time)
  14240. if !ok {
  14241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14242. }
  14243. m.SetDeletedAt(v)
  14244. return nil
  14245. case labeltagging.FieldOrganizationID:
  14246. v, ok := value.(uint64)
  14247. if !ok {
  14248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14249. }
  14250. m.SetOrganizationID(v)
  14251. return nil
  14252. case labeltagging.FieldType:
  14253. v, ok := value.(int)
  14254. if !ok {
  14255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14256. }
  14257. m.SetType(v)
  14258. return nil
  14259. case labeltagging.FieldConditions:
  14260. v, ok := value.([]string)
  14261. if !ok {
  14262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14263. }
  14264. m.SetConditions(v)
  14265. return nil
  14266. case labeltagging.FieldActionLabelAdd:
  14267. v, ok := value.([]uint64)
  14268. if !ok {
  14269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14270. }
  14271. m.SetActionLabelAdd(v)
  14272. return nil
  14273. case labeltagging.FieldActionLabelDel:
  14274. v, ok := value.([]uint64)
  14275. if !ok {
  14276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14277. }
  14278. m.SetActionLabelDel(v)
  14279. return nil
  14280. }
  14281. return fmt.Errorf("unknown LabelTagging field %s", name)
  14282. }
  14283. // AddedFields returns all numeric fields that were incremented/decremented during
  14284. // this mutation.
  14285. func (m *LabelTaggingMutation) AddedFields() []string {
  14286. var fields []string
  14287. if m.addstatus != nil {
  14288. fields = append(fields, labeltagging.FieldStatus)
  14289. }
  14290. if m.addorganization_id != nil {
  14291. fields = append(fields, labeltagging.FieldOrganizationID)
  14292. }
  14293. if m.add_type != nil {
  14294. fields = append(fields, labeltagging.FieldType)
  14295. }
  14296. return fields
  14297. }
  14298. // AddedField returns the numeric value that was incremented/decremented on a field
  14299. // with the given name. The second boolean return value indicates that this field
  14300. // was not set, or was not defined in the schema.
  14301. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  14302. switch name {
  14303. case labeltagging.FieldStatus:
  14304. return m.AddedStatus()
  14305. case labeltagging.FieldOrganizationID:
  14306. return m.AddedOrganizationID()
  14307. case labeltagging.FieldType:
  14308. return m.AddedType()
  14309. }
  14310. return nil, false
  14311. }
  14312. // AddField adds the value to the field with the given name. It returns an error if
  14313. // the field is not defined in the schema, or if the type mismatched the field
  14314. // type.
  14315. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  14316. switch name {
  14317. case labeltagging.FieldStatus:
  14318. v, ok := value.(int8)
  14319. if !ok {
  14320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14321. }
  14322. m.AddStatus(v)
  14323. return nil
  14324. case labeltagging.FieldOrganizationID:
  14325. v, ok := value.(int64)
  14326. if !ok {
  14327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14328. }
  14329. m.AddOrganizationID(v)
  14330. return nil
  14331. case labeltagging.FieldType:
  14332. v, ok := value.(int)
  14333. if !ok {
  14334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14335. }
  14336. m.AddType(v)
  14337. return nil
  14338. }
  14339. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  14340. }
  14341. // ClearedFields returns all nullable fields that were cleared during this
  14342. // mutation.
  14343. func (m *LabelTaggingMutation) ClearedFields() []string {
  14344. var fields []string
  14345. if m.FieldCleared(labeltagging.FieldStatus) {
  14346. fields = append(fields, labeltagging.FieldStatus)
  14347. }
  14348. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  14349. fields = append(fields, labeltagging.FieldDeletedAt)
  14350. }
  14351. if m.FieldCleared(labeltagging.FieldOrganizationID) {
  14352. fields = append(fields, labeltagging.FieldOrganizationID)
  14353. }
  14354. if m.FieldCleared(labeltagging.FieldConditions) {
  14355. fields = append(fields, labeltagging.FieldConditions)
  14356. }
  14357. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  14358. fields = append(fields, labeltagging.FieldActionLabelAdd)
  14359. }
  14360. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  14361. fields = append(fields, labeltagging.FieldActionLabelDel)
  14362. }
  14363. return fields
  14364. }
  14365. // FieldCleared returns a boolean indicating if a field with the given name was
  14366. // cleared in this mutation.
  14367. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  14368. _, ok := m.clearedFields[name]
  14369. return ok
  14370. }
  14371. // ClearField clears the value of the field with the given name. It returns an
  14372. // error if the field is not defined in the schema.
  14373. func (m *LabelTaggingMutation) ClearField(name string) error {
  14374. switch name {
  14375. case labeltagging.FieldStatus:
  14376. m.ClearStatus()
  14377. return nil
  14378. case labeltagging.FieldDeletedAt:
  14379. m.ClearDeletedAt()
  14380. return nil
  14381. case labeltagging.FieldOrganizationID:
  14382. m.ClearOrganizationID()
  14383. return nil
  14384. case labeltagging.FieldConditions:
  14385. m.ClearConditions()
  14386. return nil
  14387. case labeltagging.FieldActionLabelAdd:
  14388. m.ClearActionLabelAdd()
  14389. return nil
  14390. case labeltagging.FieldActionLabelDel:
  14391. m.ClearActionLabelDel()
  14392. return nil
  14393. }
  14394. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  14395. }
  14396. // ResetField resets all changes in the mutation for the field with the given name.
  14397. // It returns an error if the field is not defined in the schema.
  14398. func (m *LabelTaggingMutation) ResetField(name string) error {
  14399. switch name {
  14400. case labeltagging.FieldCreatedAt:
  14401. m.ResetCreatedAt()
  14402. return nil
  14403. case labeltagging.FieldUpdatedAt:
  14404. m.ResetUpdatedAt()
  14405. return nil
  14406. case labeltagging.FieldStatus:
  14407. m.ResetStatus()
  14408. return nil
  14409. case labeltagging.FieldDeletedAt:
  14410. m.ResetDeletedAt()
  14411. return nil
  14412. case labeltagging.FieldOrganizationID:
  14413. m.ResetOrganizationID()
  14414. return nil
  14415. case labeltagging.FieldType:
  14416. m.ResetType()
  14417. return nil
  14418. case labeltagging.FieldConditions:
  14419. m.ResetConditions()
  14420. return nil
  14421. case labeltagging.FieldActionLabelAdd:
  14422. m.ResetActionLabelAdd()
  14423. return nil
  14424. case labeltagging.FieldActionLabelDel:
  14425. m.ResetActionLabelDel()
  14426. return nil
  14427. }
  14428. return fmt.Errorf("unknown LabelTagging field %s", name)
  14429. }
  14430. // AddedEdges returns all edge names that were set/added in this mutation.
  14431. func (m *LabelTaggingMutation) AddedEdges() []string {
  14432. edges := make([]string, 0, 0)
  14433. return edges
  14434. }
  14435. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14436. // name in this mutation.
  14437. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  14438. return nil
  14439. }
  14440. // RemovedEdges returns all edge names that were removed in this mutation.
  14441. func (m *LabelTaggingMutation) RemovedEdges() []string {
  14442. edges := make([]string, 0, 0)
  14443. return edges
  14444. }
  14445. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14446. // the given name in this mutation.
  14447. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  14448. return nil
  14449. }
  14450. // ClearedEdges returns all edge names that were cleared in this mutation.
  14451. func (m *LabelTaggingMutation) ClearedEdges() []string {
  14452. edges := make([]string, 0, 0)
  14453. return edges
  14454. }
  14455. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14456. // was cleared in this mutation.
  14457. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  14458. return false
  14459. }
  14460. // ClearEdge clears the value of the edge with the given name. It returns an error
  14461. // if that edge is not defined in the schema.
  14462. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  14463. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  14464. }
  14465. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14466. // It returns an error if the edge is not defined in the schema.
  14467. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  14468. return fmt.Errorf("unknown LabelTagging edge %s", name)
  14469. }
  14470. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  14471. type MessageMutation struct {
  14472. config
  14473. op Op
  14474. typ string
  14475. id *int
  14476. wx_wxid *string
  14477. wxid *string
  14478. content *string
  14479. clearedFields map[string]struct{}
  14480. done bool
  14481. oldValue func(context.Context) (*Message, error)
  14482. predicates []predicate.Message
  14483. }
  14484. var _ ent.Mutation = (*MessageMutation)(nil)
  14485. // messageOption allows management of the mutation configuration using functional options.
  14486. type messageOption func(*MessageMutation)
  14487. // newMessageMutation creates new mutation for the Message entity.
  14488. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  14489. m := &MessageMutation{
  14490. config: c,
  14491. op: op,
  14492. typ: TypeMessage,
  14493. clearedFields: make(map[string]struct{}),
  14494. }
  14495. for _, opt := range opts {
  14496. opt(m)
  14497. }
  14498. return m
  14499. }
  14500. // withMessageID sets the ID field of the mutation.
  14501. func withMessageID(id int) messageOption {
  14502. return func(m *MessageMutation) {
  14503. var (
  14504. err error
  14505. once sync.Once
  14506. value *Message
  14507. )
  14508. m.oldValue = func(ctx context.Context) (*Message, error) {
  14509. once.Do(func() {
  14510. if m.done {
  14511. err = errors.New("querying old values post mutation is not allowed")
  14512. } else {
  14513. value, err = m.Client().Message.Get(ctx, id)
  14514. }
  14515. })
  14516. return value, err
  14517. }
  14518. m.id = &id
  14519. }
  14520. }
  14521. // withMessage sets the old Message of the mutation.
  14522. func withMessage(node *Message) messageOption {
  14523. return func(m *MessageMutation) {
  14524. m.oldValue = func(context.Context) (*Message, error) {
  14525. return node, nil
  14526. }
  14527. m.id = &node.ID
  14528. }
  14529. }
  14530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14531. // executed in a transaction (ent.Tx), a transactional client is returned.
  14532. func (m MessageMutation) Client() *Client {
  14533. client := &Client{config: m.config}
  14534. client.init()
  14535. return client
  14536. }
  14537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14538. // it returns an error otherwise.
  14539. func (m MessageMutation) Tx() (*Tx, error) {
  14540. if _, ok := m.driver.(*txDriver); !ok {
  14541. return nil, errors.New("ent: mutation is not running in a transaction")
  14542. }
  14543. tx := &Tx{config: m.config}
  14544. tx.init()
  14545. return tx, nil
  14546. }
  14547. // ID returns the ID value in the mutation. Note that the ID is only available
  14548. // if it was provided to the builder or after it was returned from the database.
  14549. func (m *MessageMutation) ID() (id int, exists bool) {
  14550. if m.id == nil {
  14551. return
  14552. }
  14553. return *m.id, true
  14554. }
  14555. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14556. // That means, if the mutation is applied within a transaction with an isolation level such
  14557. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14558. // or updated by the mutation.
  14559. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  14560. switch {
  14561. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14562. id, exists := m.ID()
  14563. if exists {
  14564. return []int{id}, nil
  14565. }
  14566. fallthrough
  14567. case m.op.Is(OpUpdate | OpDelete):
  14568. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  14569. default:
  14570. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14571. }
  14572. }
  14573. // SetWxWxid sets the "wx_wxid" field.
  14574. func (m *MessageMutation) SetWxWxid(s string) {
  14575. m.wx_wxid = &s
  14576. }
  14577. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  14578. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  14579. v := m.wx_wxid
  14580. if v == nil {
  14581. return
  14582. }
  14583. return *v, true
  14584. }
  14585. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  14586. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  14587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14588. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  14589. if !m.op.Is(OpUpdateOne) {
  14590. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  14591. }
  14592. if m.id == nil || m.oldValue == nil {
  14593. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  14594. }
  14595. oldValue, err := m.oldValue(ctx)
  14596. if err != nil {
  14597. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  14598. }
  14599. return oldValue.WxWxid, nil
  14600. }
  14601. // ClearWxWxid clears the value of the "wx_wxid" field.
  14602. func (m *MessageMutation) ClearWxWxid() {
  14603. m.wx_wxid = nil
  14604. m.clearedFields[message.FieldWxWxid] = struct{}{}
  14605. }
  14606. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  14607. func (m *MessageMutation) WxWxidCleared() bool {
  14608. _, ok := m.clearedFields[message.FieldWxWxid]
  14609. return ok
  14610. }
  14611. // ResetWxWxid resets all changes to the "wx_wxid" field.
  14612. func (m *MessageMutation) ResetWxWxid() {
  14613. m.wx_wxid = nil
  14614. delete(m.clearedFields, message.FieldWxWxid)
  14615. }
  14616. // SetWxid sets the "wxid" field.
  14617. func (m *MessageMutation) SetWxid(s string) {
  14618. m.wxid = &s
  14619. }
  14620. // Wxid returns the value of the "wxid" field in the mutation.
  14621. func (m *MessageMutation) Wxid() (r string, exists bool) {
  14622. v := m.wxid
  14623. if v == nil {
  14624. return
  14625. }
  14626. return *v, true
  14627. }
  14628. // OldWxid returns the old "wxid" field's value of the Message entity.
  14629. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  14630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14631. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  14632. if !m.op.Is(OpUpdateOne) {
  14633. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  14634. }
  14635. if m.id == nil || m.oldValue == nil {
  14636. return v, errors.New("OldWxid requires an ID field in the mutation")
  14637. }
  14638. oldValue, err := m.oldValue(ctx)
  14639. if err != nil {
  14640. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  14641. }
  14642. return oldValue.Wxid, nil
  14643. }
  14644. // ResetWxid resets all changes to the "wxid" field.
  14645. func (m *MessageMutation) ResetWxid() {
  14646. m.wxid = nil
  14647. }
  14648. // SetContent sets the "content" field.
  14649. func (m *MessageMutation) SetContent(s string) {
  14650. m.content = &s
  14651. }
  14652. // Content returns the value of the "content" field in the mutation.
  14653. func (m *MessageMutation) Content() (r string, exists bool) {
  14654. v := m.content
  14655. if v == nil {
  14656. return
  14657. }
  14658. return *v, true
  14659. }
  14660. // OldContent returns the old "content" field's value of the Message entity.
  14661. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  14662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14663. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  14664. if !m.op.Is(OpUpdateOne) {
  14665. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14666. }
  14667. if m.id == nil || m.oldValue == nil {
  14668. return v, errors.New("OldContent requires an ID field in the mutation")
  14669. }
  14670. oldValue, err := m.oldValue(ctx)
  14671. if err != nil {
  14672. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14673. }
  14674. return oldValue.Content, nil
  14675. }
  14676. // ResetContent resets all changes to the "content" field.
  14677. func (m *MessageMutation) ResetContent() {
  14678. m.content = nil
  14679. }
  14680. // Where appends a list predicates to the MessageMutation builder.
  14681. func (m *MessageMutation) Where(ps ...predicate.Message) {
  14682. m.predicates = append(m.predicates, ps...)
  14683. }
  14684. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  14685. // users can use type-assertion to append predicates that do not depend on any generated package.
  14686. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  14687. p := make([]predicate.Message, len(ps))
  14688. for i := range ps {
  14689. p[i] = ps[i]
  14690. }
  14691. m.Where(p...)
  14692. }
  14693. // Op returns the operation name.
  14694. func (m *MessageMutation) Op() Op {
  14695. return m.op
  14696. }
  14697. // SetOp allows setting the mutation operation.
  14698. func (m *MessageMutation) SetOp(op Op) {
  14699. m.op = op
  14700. }
  14701. // Type returns the node type of this mutation (Message).
  14702. func (m *MessageMutation) Type() string {
  14703. return m.typ
  14704. }
  14705. // Fields returns all fields that were changed during this mutation. Note that in
  14706. // order to get all numeric fields that were incremented/decremented, call
  14707. // AddedFields().
  14708. func (m *MessageMutation) Fields() []string {
  14709. fields := make([]string, 0, 3)
  14710. if m.wx_wxid != nil {
  14711. fields = append(fields, message.FieldWxWxid)
  14712. }
  14713. if m.wxid != nil {
  14714. fields = append(fields, message.FieldWxid)
  14715. }
  14716. if m.content != nil {
  14717. fields = append(fields, message.FieldContent)
  14718. }
  14719. return fields
  14720. }
  14721. // Field returns the value of a field with the given name. The second boolean
  14722. // return value indicates that this field was not set, or was not defined in the
  14723. // schema.
  14724. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  14725. switch name {
  14726. case message.FieldWxWxid:
  14727. return m.WxWxid()
  14728. case message.FieldWxid:
  14729. return m.Wxid()
  14730. case message.FieldContent:
  14731. return m.Content()
  14732. }
  14733. return nil, false
  14734. }
  14735. // OldField returns the old value of the field from the database. An error is
  14736. // returned if the mutation operation is not UpdateOne, or the query to the
  14737. // database failed.
  14738. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14739. switch name {
  14740. case message.FieldWxWxid:
  14741. return m.OldWxWxid(ctx)
  14742. case message.FieldWxid:
  14743. return m.OldWxid(ctx)
  14744. case message.FieldContent:
  14745. return m.OldContent(ctx)
  14746. }
  14747. return nil, fmt.Errorf("unknown Message field %s", name)
  14748. }
  14749. // SetField sets the value of a field with the given name. It returns an error if
  14750. // the field is not defined in the schema, or if the type mismatched the field
  14751. // type.
  14752. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  14753. switch name {
  14754. case message.FieldWxWxid:
  14755. v, ok := value.(string)
  14756. if !ok {
  14757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14758. }
  14759. m.SetWxWxid(v)
  14760. return nil
  14761. case message.FieldWxid:
  14762. v, ok := value.(string)
  14763. if !ok {
  14764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14765. }
  14766. m.SetWxid(v)
  14767. return nil
  14768. case message.FieldContent:
  14769. v, ok := value.(string)
  14770. if !ok {
  14771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14772. }
  14773. m.SetContent(v)
  14774. return nil
  14775. }
  14776. return fmt.Errorf("unknown Message field %s", name)
  14777. }
  14778. // AddedFields returns all numeric fields that were incremented/decremented during
  14779. // this mutation.
  14780. func (m *MessageMutation) AddedFields() []string {
  14781. return nil
  14782. }
  14783. // AddedField returns the numeric value that was incremented/decremented on a field
  14784. // with the given name. The second boolean return value indicates that this field
  14785. // was not set, or was not defined in the schema.
  14786. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  14787. return nil, false
  14788. }
  14789. // AddField adds the value to the field with the given name. It returns an error if
  14790. // the field is not defined in the schema, or if the type mismatched the field
  14791. // type.
  14792. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  14793. switch name {
  14794. }
  14795. return fmt.Errorf("unknown Message numeric field %s", name)
  14796. }
  14797. // ClearedFields returns all nullable fields that were cleared during this
  14798. // mutation.
  14799. func (m *MessageMutation) ClearedFields() []string {
  14800. var fields []string
  14801. if m.FieldCleared(message.FieldWxWxid) {
  14802. fields = append(fields, message.FieldWxWxid)
  14803. }
  14804. return fields
  14805. }
  14806. // FieldCleared returns a boolean indicating if a field with the given name was
  14807. // cleared in this mutation.
  14808. func (m *MessageMutation) FieldCleared(name string) bool {
  14809. _, ok := m.clearedFields[name]
  14810. return ok
  14811. }
  14812. // ClearField clears the value of the field with the given name. It returns an
  14813. // error if the field is not defined in the schema.
  14814. func (m *MessageMutation) ClearField(name string) error {
  14815. switch name {
  14816. case message.FieldWxWxid:
  14817. m.ClearWxWxid()
  14818. return nil
  14819. }
  14820. return fmt.Errorf("unknown Message nullable field %s", name)
  14821. }
  14822. // ResetField resets all changes in the mutation for the field with the given name.
  14823. // It returns an error if the field is not defined in the schema.
  14824. func (m *MessageMutation) ResetField(name string) error {
  14825. switch name {
  14826. case message.FieldWxWxid:
  14827. m.ResetWxWxid()
  14828. return nil
  14829. case message.FieldWxid:
  14830. m.ResetWxid()
  14831. return nil
  14832. case message.FieldContent:
  14833. m.ResetContent()
  14834. return nil
  14835. }
  14836. return fmt.Errorf("unknown Message field %s", name)
  14837. }
  14838. // AddedEdges returns all edge names that were set/added in this mutation.
  14839. func (m *MessageMutation) AddedEdges() []string {
  14840. edges := make([]string, 0, 0)
  14841. return edges
  14842. }
  14843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14844. // name in this mutation.
  14845. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  14846. return nil
  14847. }
  14848. // RemovedEdges returns all edge names that were removed in this mutation.
  14849. func (m *MessageMutation) RemovedEdges() []string {
  14850. edges := make([]string, 0, 0)
  14851. return edges
  14852. }
  14853. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14854. // the given name in this mutation.
  14855. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  14856. return nil
  14857. }
  14858. // ClearedEdges returns all edge names that were cleared in this mutation.
  14859. func (m *MessageMutation) ClearedEdges() []string {
  14860. edges := make([]string, 0, 0)
  14861. return edges
  14862. }
  14863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14864. // was cleared in this mutation.
  14865. func (m *MessageMutation) EdgeCleared(name string) bool {
  14866. return false
  14867. }
  14868. // ClearEdge clears the value of the edge with the given name. It returns an error
  14869. // if that edge is not defined in the schema.
  14870. func (m *MessageMutation) ClearEdge(name string) error {
  14871. return fmt.Errorf("unknown Message unique edge %s", name)
  14872. }
  14873. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14874. // It returns an error if the edge is not defined in the schema.
  14875. func (m *MessageMutation) ResetEdge(name string) error {
  14876. return fmt.Errorf("unknown Message edge %s", name)
  14877. }
  14878. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  14879. type MessageRecordsMutation struct {
  14880. config
  14881. op Op
  14882. typ string
  14883. id *uint64
  14884. created_at *time.Time
  14885. updated_at *time.Time
  14886. status *uint8
  14887. addstatus *int8
  14888. bot_wxid *string
  14889. contact_type *int
  14890. addcontact_type *int
  14891. contact_wxid *string
  14892. content_type *int
  14893. addcontent_type *int
  14894. content *string
  14895. meta *custom_types.Meta
  14896. error_detail *string
  14897. send_time *time.Time
  14898. source_type *int
  14899. addsource_type *int
  14900. organization_id *uint64
  14901. addorganization_id *int64
  14902. clearedFields map[string]struct{}
  14903. sop_stage *uint64
  14904. clearedsop_stage bool
  14905. sop_node *uint64
  14906. clearedsop_node bool
  14907. message_contact *uint64
  14908. clearedmessage_contact bool
  14909. done bool
  14910. oldValue func(context.Context) (*MessageRecords, error)
  14911. predicates []predicate.MessageRecords
  14912. }
  14913. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  14914. // messagerecordsOption allows management of the mutation configuration using functional options.
  14915. type messagerecordsOption func(*MessageRecordsMutation)
  14916. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  14917. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  14918. m := &MessageRecordsMutation{
  14919. config: c,
  14920. op: op,
  14921. typ: TypeMessageRecords,
  14922. clearedFields: make(map[string]struct{}),
  14923. }
  14924. for _, opt := range opts {
  14925. opt(m)
  14926. }
  14927. return m
  14928. }
  14929. // withMessageRecordsID sets the ID field of the mutation.
  14930. func withMessageRecordsID(id uint64) messagerecordsOption {
  14931. return func(m *MessageRecordsMutation) {
  14932. var (
  14933. err error
  14934. once sync.Once
  14935. value *MessageRecords
  14936. )
  14937. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  14938. once.Do(func() {
  14939. if m.done {
  14940. err = errors.New("querying old values post mutation is not allowed")
  14941. } else {
  14942. value, err = m.Client().MessageRecords.Get(ctx, id)
  14943. }
  14944. })
  14945. return value, err
  14946. }
  14947. m.id = &id
  14948. }
  14949. }
  14950. // withMessageRecords sets the old MessageRecords of the mutation.
  14951. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14952. return func(m *MessageRecordsMutation) {
  14953. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14954. return node, nil
  14955. }
  14956. m.id = &node.ID
  14957. }
  14958. }
  14959. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14960. // executed in a transaction (ent.Tx), a transactional client is returned.
  14961. func (m MessageRecordsMutation) Client() *Client {
  14962. client := &Client{config: m.config}
  14963. client.init()
  14964. return client
  14965. }
  14966. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14967. // it returns an error otherwise.
  14968. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14969. if _, ok := m.driver.(*txDriver); !ok {
  14970. return nil, errors.New("ent: mutation is not running in a transaction")
  14971. }
  14972. tx := &Tx{config: m.config}
  14973. tx.init()
  14974. return tx, nil
  14975. }
  14976. // SetID sets the value of the id field. Note that this
  14977. // operation is only accepted on creation of MessageRecords entities.
  14978. func (m *MessageRecordsMutation) SetID(id uint64) {
  14979. m.id = &id
  14980. }
  14981. // ID returns the ID value in the mutation. Note that the ID is only available
  14982. // if it was provided to the builder or after it was returned from the database.
  14983. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14984. if m.id == nil {
  14985. return
  14986. }
  14987. return *m.id, true
  14988. }
  14989. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14990. // That means, if the mutation is applied within a transaction with an isolation level such
  14991. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14992. // or updated by the mutation.
  14993. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14994. switch {
  14995. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14996. id, exists := m.ID()
  14997. if exists {
  14998. return []uint64{id}, nil
  14999. }
  15000. fallthrough
  15001. case m.op.Is(OpUpdate | OpDelete):
  15002. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  15003. default:
  15004. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15005. }
  15006. }
  15007. // SetCreatedAt sets the "created_at" field.
  15008. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  15009. m.created_at = &t
  15010. }
  15011. // CreatedAt returns the value of the "created_at" field in the mutation.
  15012. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  15013. v := m.created_at
  15014. if v == nil {
  15015. return
  15016. }
  15017. return *v, true
  15018. }
  15019. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  15020. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15022. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15023. if !m.op.Is(OpUpdateOne) {
  15024. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15025. }
  15026. if m.id == nil || m.oldValue == nil {
  15027. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15028. }
  15029. oldValue, err := m.oldValue(ctx)
  15030. if err != nil {
  15031. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15032. }
  15033. return oldValue.CreatedAt, nil
  15034. }
  15035. // ResetCreatedAt resets all changes to the "created_at" field.
  15036. func (m *MessageRecordsMutation) ResetCreatedAt() {
  15037. m.created_at = nil
  15038. }
  15039. // SetUpdatedAt sets the "updated_at" field.
  15040. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  15041. m.updated_at = &t
  15042. }
  15043. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15044. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  15045. v := m.updated_at
  15046. if v == nil {
  15047. return
  15048. }
  15049. return *v, true
  15050. }
  15051. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  15052. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15054. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15055. if !m.op.Is(OpUpdateOne) {
  15056. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15057. }
  15058. if m.id == nil || m.oldValue == nil {
  15059. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15060. }
  15061. oldValue, err := m.oldValue(ctx)
  15062. if err != nil {
  15063. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15064. }
  15065. return oldValue.UpdatedAt, nil
  15066. }
  15067. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15068. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  15069. m.updated_at = nil
  15070. }
  15071. // SetStatus sets the "status" field.
  15072. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  15073. m.status = &u
  15074. m.addstatus = nil
  15075. }
  15076. // Status returns the value of the "status" field in the mutation.
  15077. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  15078. v := m.status
  15079. if v == nil {
  15080. return
  15081. }
  15082. return *v, true
  15083. }
  15084. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  15085. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15087. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15088. if !m.op.Is(OpUpdateOne) {
  15089. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15090. }
  15091. if m.id == nil || m.oldValue == nil {
  15092. return v, errors.New("OldStatus requires an ID field in the mutation")
  15093. }
  15094. oldValue, err := m.oldValue(ctx)
  15095. if err != nil {
  15096. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15097. }
  15098. return oldValue.Status, nil
  15099. }
  15100. // AddStatus adds u to the "status" field.
  15101. func (m *MessageRecordsMutation) AddStatus(u int8) {
  15102. if m.addstatus != nil {
  15103. *m.addstatus += u
  15104. } else {
  15105. m.addstatus = &u
  15106. }
  15107. }
  15108. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15109. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  15110. v := m.addstatus
  15111. if v == nil {
  15112. return
  15113. }
  15114. return *v, true
  15115. }
  15116. // ClearStatus clears the value of the "status" field.
  15117. func (m *MessageRecordsMutation) ClearStatus() {
  15118. m.status = nil
  15119. m.addstatus = nil
  15120. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  15121. }
  15122. // StatusCleared returns if the "status" field was cleared in this mutation.
  15123. func (m *MessageRecordsMutation) StatusCleared() bool {
  15124. _, ok := m.clearedFields[messagerecords.FieldStatus]
  15125. return ok
  15126. }
  15127. // ResetStatus resets all changes to the "status" field.
  15128. func (m *MessageRecordsMutation) ResetStatus() {
  15129. m.status = nil
  15130. m.addstatus = nil
  15131. delete(m.clearedFields, messagerecords.FieldStatus)
  15132. }
  15133. // SetBotWxid sets the "bot_wxid" field.
  15134. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  15135. m.bot_wxid = &s
  15136. }
  15137. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  15138. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  15139. v := m.bot_wxid
  15140. if v == nil {
  15141. return
  15142. }
  15143. return *v, true
  15144. }
  15145. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  15146. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15148. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  15149. if !m.op.Is(OpUpdateOne) {
  15150. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  15151. }
  15152. if m.id == nil || m.oldValue == nil {
  15153. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  15154. }
  15155. oldValue, err := m.oldValue(ctx)
  15156. if err != nil {
  15157. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  15158. }
  15159. return oldValue.BotWxid, nil
  15160. }
  15161. // ResetBotWxid resets all changes to the "bot_wxid" field.
  15162. func (m *MessageRecordsMutation) ResetBotWxid() {
  15163. m.bot_wxid = nil
  15164. }
  15165. // SetContactID sets the "contact_id" field.
  15166. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  15167. m.message_contact = &u
  15168. }
  15169. // ContactID returns the value of the "contact_id" field in the mutation.
  15170. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  15171. v := m.message_contact
  15172. if v == nil {
  15173. return
  15174. }
  15175. return *v, true
  15176. }
  15177. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  15178. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15180. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15181. if !m.op.Is(OpUpdateOne) {
  15182. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15183. }
  15184. if m.id == nil || m.oldValue == nil {
  15185. return v, errors.New("OldContactID requires an ID field in the mutation")
  15186. }
  15187. oldValue, err := m.oldValue(ctx)
  15188. if err != nil {
  15189. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15190. }
  15191. return oldValue.ContactID, nil
  15192. }
  15193. // ClearContactID clears the value of the "contact_id" field.
  15194. func (m *MessageRecordsMutation) ClearContactID() {
  15195. m.message_contact = nil
  15196. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  15197. }
  15198. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  15199. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  15200. _, ok := m.clearedFields[messagerecords.FieldContactID]
  15201. return ok
  15202. }
  15203. // ResetContactID resets all changes to the "contact_id" field.
  15204. func (m *MessageRecordsMutation) ResetContactID() {
  15205. m.message_contact = nil
  15206. delete(m.clearedFields, messagerecords.FieldContactID)
  15207. }
  15208. // SetContactType sets the "contact_type" field.
  15209. func (m *MessageRecordsMutation) SetContactType(i int) {
  15210. m.contact_type = &i
  15211. m.addcontact_type = nil
  15212. }
  15213. // ContactType returns the value of the "contact_type" field in the mutation.
  15214. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  15215. v := m.contact_type
  15216. if v == nil {
  15217. return
  15218. }
  15219. return *v, true
  15220. }
  15221. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  15222. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15224. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  15225. if !m.op.Is(OpUpdateOne) {
  15226. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  15227. }
  15228. if m.id == nil || m.oldValue == nil {
  15229. return v, errors.New("OldContactType requires an ID field in the mutation")
  15230. }
  15231. oldValue, err := m.oldValue(ctx)
  15232. if err != nil {
  15233. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  15234. }
  15235. return oldValue.ContactType, nil
  15236. }
  15237. // AddContactType adds i to the "contact_type" field.
  15238. func (m *MessageRecordsMutation) AddContactType(i int) {
  15239. if m.addcontact_type != nil {
  15240. *m.addcontact_type += i
  15241. } else {
  15242. m.addcontact_type = &i
  15243. }
  15244. }
  15245. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  15246. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  15247. v := m.addcontact_type
  15248. if v == nil {
  15249. return
  15250. }
  15251. return *v, true
  15252. }
  15253. // ResetContactType resets all changes to the "contact_type" field.
  15254. func (m *MessageRecordsMutation) ResetContactType() {
  15255. m.contact_type = nil
  15256. m.addcontact_type = nil
  15257. }
  15258. // SetContactWxid sets the "contact_wxid" field.
  15259. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  15260. m.contact_wxid = &s
  15261. }
  15262. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  15263. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  15264. v := m.contact_wxid
  15265. if v == nil {
  15266. return
  15267. }
  15268. return *v, true
  15269. }
  15270. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  15271. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15273. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  15274. if !m.op.Is(OpUpdateOne) {
  15275. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  15276. }
  15277. if m.id == nil || m.oldValue == nil {
  15278. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  15279. }
  15280. oldValue, err := m.oldValue(ctx)
  15281. if err != nil {
  15282. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  15283. }
  15284. return oldValue.ContactWxid, nil
  15285. }
  15286. // ResetContactWxid resets all changes to the "contact_wxid" field.
  15287. func (m *MessageRecordsMutation) ResetContactWxid() {
  15288. m.contact_wxid = nil
  15289. }
  15290. // SetContentType sets the "content_type" field.
  15291. func (m *MessageRecordsMutation) SetContentType(i int) {
  15292. m.content_type = &i
  15293. m.addcontent_type = nil
  15294. }
  15295. // ContentType returns the value of the "content_type" field in the mutation.
  15296. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  15297. v := m.content_type
  15298. if v == nil {
  15299. return
  15300. }
  15301. return *v, true
  15302. }
  15303. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  15304. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15306. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  15307. if !m.op.Is(OpUpdateOne) {
  15308. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  15309. }
  15310. if m.id == nil || m.oldValue == nil {
  15311. return v, errors.New("OldContentType requires an ID field in the mutation")
  15312. }
  15313. oldValue, err := m.oldValue(ctx)
  15314. if err != nil {
  15315. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  15316. }
  15317. return oldValue.ContentType, nil
  15318. }
  15319. // AddContentType adds i to the "content_type" field.
  15320. func (m *MessageRecordsMutation) AddContentType(i int) {
  15321. if m.addcontent_type != nil {
  15322. *m.addcontent_type += i
  15323. } else {
  15324. m.addcontent_type = &i
  15325. }
  15326. }
  15327. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  15328. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  15329. v := m.addcontent_type
  15330. if v == nil {
  15331. return
  15332. }
  15333. return *v, true
  15334. }
  15335. // ResetContentType resets all changes to the "content_type" field.
  15336. func (m *MessageRecordsMutation) ResetContentType() {
  15337. m.content_type = nil
  15338. m.addcontent_type = nil
  15339. }
  15340. // SetContent sets the "content" field.
  15341. func (m *MessageRecordsMutation) SetContent(s string) {
  15342. m.content = &s
  15343. }
  15344. // Content returns the value of the "content" field in the mutation.
  15345. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  15346. v := m.content
  15347. if v == nil {
  15348. return
  15349. }
  15350. return *v, true
  15351. }
  15352. // OldContent returns the old "content" field's value of the MessageRecords entity.
  15353. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15355. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  15356. if !m.op.Is(OpUpdateOne) {
  15357. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  15358. }
  15359. if m.id == nil || m.oldValue == nil {
  15360. return v, errors.New("OldContent requires an ID field in the mutation")
  15361. }
  15362. oldValue, err := m.oldValue(ctx)
  15363. if err != nil {
  15364. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  15365. }
  15366. return oldValue.Content, nil
  15367. }
  15368. // ResetContent resets all changes to the "content" field.
  15369. func (m *MessageRecordsMutation) ResetContent() {
  15370. m.content = nil
  15371. }
  15372. // SetMeta sets the "meta" field.
  15373. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  15374. m.meta = &ct
  15375. }
  15376. // Meta returns the value of the "meta" field in the mutation.
  15377. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  15378. v := m.meta
  15379. if v == nil {
  15380. return
  15381. }
  15382. return *v, true
  15383. }
  15384. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  15385. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15387. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  15388. if !m.op.Is(OpUpdateOne) {
  15389. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  15390. }
  15391. if m.id == nil || m.oldValue == nil {
  15392. return v, errors.New("OldMeta requires an ID field in the mutation")
  15393. }
  15394. oldValue, err := m.oldValue(ctx)
  15395. if err != nil {
  15396. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  15397. }
  15398. return oldValue.Meta, nil
  15399. }
  15400. // ClearMeta clears the value of the "meta" field.
  15401. func (m *MessageRecordsMutation) ClearMeta() {
  15402. m.meta = nil
  15403. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  15404. }
  15405. // MetaCleared returns if the "meta" field was cleared in this mutation.
  15406. func (m *MessageRecordsMutation) MetaCleared() bool {
  15407. _, ok := m.clearedFields[messagerecords.FieldMeta]
  15408. return ok
  15409. }
  15410. // ResetMeta resets all changes to the "meta" field.
  15411. func (m *MessageRecordsMutation) ResetMeta() {
  15412. m.meta = nil
  15413. delete(m.clearedFields, messagerecords.FieldMeta)
  15414. }
  15415. // SetErrorDetail sets the "error_detail" field.
  15416. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  15417. m.error_detail = &s
  15418. }
  15419. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  15420. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  15421. v := m.error_detail
  15422. if v == nil {
  15423. return
  15424. }
  15425. return *v, true
  15426. }
  15427. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  15428. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15430. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  15431. if !m.op.Is(OpUpdateOne) {
  15432. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  15433. }
  15434. if m.id == nil || m.oldValue == nil {
  15435. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  15436. }
  15437. oldValue, err := m.oldValue(ctx)
  15438. if err != nil {
  15439. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  15440. }
  15441. return oldValue.ErrorDetail, nil
  15442. }
  15443. // ResetErrorDetail resets all changes to the "error_detail" field.
  15444. func (m *MessageRecordsMutation) ResetErrorDetail() {
  15445. m.error_detail = nil
  15446. }
  15447. // SetSendTime sets the "send_time" field.
  15448. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  15449. m.send_time = &t
  15450. }
  15451. // SendTime returns the value of the "send_time" field in the mutation.
  15452. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  15453. v := m.send_time
  15454. if v == nil {
  15455. return
  15456. }
  15457. return *v, true
  15458. }
  15459. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  15460. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15462. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  15463. if !m.op.Is(OpUpdateOne) {
  15464. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  15465. }
  15466. if m.id == nil || m.oldValue == nil {
  15467. return v, errors.New("OldSendTime requires an ID field in the mutation")
  15468. }
  15469. oldValue, err := m.oldValue(ctx)
  15470. if err != nil {
  15471. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  15472. }
  15473. return oldValue.SendTime, nil
  15474. }
  15475. // ClearSendTime clears the value of the "send_time" field.
  15476. func (m *MessageRecordsMutation) ClearSendTime() {
  15477. m.send_time = nil
  15478. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  15479. }
  15480. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  15481. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  15482. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  15483. return ok
  15484. }
  15485. // ResetSendTime resets all changes to the "send_time" field.
  15486. func (m *MessageRecordsMutation) ResetSendTime() {
  15487. m.send_time = nil
  15488. delete(m.clearedFields, messagerecords.FieldSendTime)
  15489. }
  15490. // SetSourceType sets the "source_type" field.
  15491. func (m *MessageRecordsMutation) SetSourceType(i int) {
  15492. m.source_type = &i
  15493. m.addsource_type = nil
  15494. }
  15495. // SourceType returns the value of the "source_type" field in the mutation.
  15496. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  15497. v := m.source_type
  15498. if v == nil {
  15499. return
  15500. }
  15501. return *v, true
  15502. }
  15503. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  15504. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15506. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  15507. if !m.op.Is(OpUpdateOne) {
  15508. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  15509. }
  15510. if m.id == nil || m.oldValue == nil {
  15511. return v, errors.New("OldSourceType requires an ID field in the mutation")
  15512. }
  15513. oldValue, err := m.oldValue(ctx)
  15514. if err != nil {
  15515. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  15516. }
  15517. return oldValue.SourceType, nil
  15518. }
  15519. // AddSourceType adds i to the "source_type" field.
  15520. func (m *MessageRecordsMutation) AddSourceType(i int) {
  15521. if m.addsource_type != nil {
  15522. *m.addsource_type += i
  15523. } else {
  15524. m.addsource_type = &i
  15525. }
  15526. }
  15527. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  15528. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  15529. v := m.addsource_type
  15530. if v == nil {
  15531. return
  15532. }
  15533. return *v, true
  15534. }
  15535. // ResetSourceType resets all changes to the "source_type" field.
  15536. func (m *MessageRecordsMutation) ResetSourceType() {
  15537. m.source_type = nil
  15538. m.addsource_type = nil
  15539. }
  15540. // SetSourceID sets the "source_id" field.
  15541. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  15542. m.sop_stage = &u
  15543. }
  15544. // SourceID returns the value of the "source_id" field in the mutation.
  15545. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  15546. v := m.sop_stage
  15547. if v == nil {
  15548. return
  15549. }
  15550. return *v, true
  15551. }
  15552. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  15553. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15555. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  15556. if !m.op.Is(OpUpdateOne) {
  15557. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  15558. }
  15559. if m.id == nil || m.oldValue == nil {
  15560. return v, errors.New("OldSourceID requires an ID field in the mutation")
  15561. }
  15562. oldValue, err := m.oldValue(ctx)
  15563. if err != nil {
  15564. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  15565. }
  15566. return oldValue.SourceID, nil
  15567. }
  15568. // ClearSourceID clears the value of the "source_id" field.
  15569. func (m *MessageRecordsMutation) ClearSourceID() {
  15570. m.sop_stage = nil
  15571. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  15572. }
  15573. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  15574. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  15575. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  15576. return ok
  15577. }
  15578. // ResetSourceID resets all changes to the "source_id" field.
  15579. func (m *MessageRecordsMutation) ResetSourceID() {
  15580. m.sop_stage = nil
  15581. delete(m.clearedFields, messagerecords.FieldSourceID)
  15582. }
  15583. // SetSubSourceID sets the "sub_source_id" field.
  15584. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  15585. m.sop_node = &u
  15586. }
  15587. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  15588. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  15589. v := m.sop_node
  15590. if v == nil {
  15591. return
  15592. }
  15593. return *v, true
  15594. }
  15595. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  15596. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15598. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  15599. if !m.op.Is(OpUpdateOne) {
  15600. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  15601. }
  15602. if m.id == nil || m.oldValue == nil {
  15603. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  15604. }
  15605. oldValue, err := m.oldValue(ctx)
  15606. if err != nil {
  15607. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  15608. }
  15609. return oldValue.SubSourceID, nil
  15610. }
  15611. // ClearSubSourceID clears the value of the "sub_source_id" field.
  15612. func (m *MessageRecordsMutation) ClearSubSourceID() {
  15613. m.sop_node = nil
  15614. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  15615. }
  15616. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  15617. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  15618. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  15619. return ok
  15620. }
  15621. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  15622. func (m *MessageRecordsMutation) ResetSubSourceID() {
  15623. m.sop_node = nil
  15624. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  15625. }
  15626. // SetOrganizationID sets the "organization_id" field.
  15627. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  15628. m.organization_id = &u
  15629. m.addorganization_id = nil
  15630. }
  15631. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15632. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  15633. v := m.organization_id
  15634. if v == nil {
  15635. return
  15636. }
  15637. return *v, true
  15638. }
  15639. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  15640. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15642. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15643. if !m.op.Is(OpUpdateOne) {
  15644. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15645. }
  15646. if m.id == nil || m.oldValue == nil {
  15647. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15648. }
  15649. oldValue, err := m.oldValue(ctx)
  15650. if err != nil {
  15651. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15652. }
  15653. return oldValue.OrganizationID, nil
  15654. }
  15655. // AddOrganizationID adds u to the "organization_id" field.
  15656. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  15657. if m.addorganization_id != nil {
  15658. *m.addorganization_id += u
  15659. } else {
  15660. m.addorganization_id = &u
  15661. }
  15662. }
  15663. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15664. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  15665. v := m.addorganization_id
  15666. if v == nil {
  15667. return
  15668. }
  15669. return *v, true
  15670. }
  15671. // ClearOrganizationID clears the value of the "organization_id" field.
  15672. func (m *MessageRecordsMutation) ClearOrganizationID() {
  15673. m.organization_id = nil
  15674. m.addorganization_id = nil
  15675. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  15676. }
  15677. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15678. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  15679. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  15680. return ok
  15681. }
  15682. // ResetOrganizationID resets all changes to the "organization_id" field.
  15683. func (m *MessageRecordsMutation) ResetOrganizationID() {
  15684. m.organization_id = nil
  15685. m.addorganization_id = nil
  15686. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  15687. }
  15688. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  15689. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  15690. m.sop_stage = &id
  15691. }
  15692. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  15693. func (m *MessageRecordsMutation) ClearSopStage() {
  15694. m.clearedsop_stage = true
  15695. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  15696. }
  15697. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  15698. func (m *MessageRecordsMutation) SopStageCleared() bool {
  15699. return m.SourceIDCleared() || m.clearedsop_stage
  15700. }
  15701. // SopStageID returns the "sop_stage" edge ID in the mutation.
  15702. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  15703. if m.sop_stage != nil {
  15704. return *m.sop_stage, true
  15705. }
  15706. return
  15707. }
  15708. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  15709. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15710. // SopStageID instead. It exists only for internal usage by the builders.
  15711. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  15712. if id := m.sop_stage; id != nil {
  15713. ids = append(ids, *id)
  15714. }
  15715. return
  15716. }
  15717. // ResetSopStage resets all changes to the "sop_stage" edge.
  15718. func (m *MessageRecordsMutation) ResetSopStage() {
  15719. m.sop_stage = nil
  15720. m.clearedsop_stage = false
  15721. }
  15722. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  15723. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  15724. m.sop_node = &id
  15725. }
  15726. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  15727. func (m *MessageRecordsMutation) ClearSopNode() {
  15728. m.clearedsop_node = true
  15729. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  15730. }
  15731. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  15732. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  15733. return m.SubSourceIDCleared() || m.clearedsop_node
  15734. }
  15735. // SopNodeID returns the "sop_node" edge ID in the mutation.
  15736. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  15737. if m.sop_node != nil {
  15738. return *m.sop_node, true
  15739. }
  15740. return
  15741. }
  15742. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  15743. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15744. // SopNodeID instead. It exists only for internal usage by the builders.
  15745. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  15746. if id := m.sop_node; id != nil {
  15747. ids = append(ids, *id)
  15748. }
  15749. return
  15750. }
  15751. // ResetSopNode resets all changes to the "sop_node" edge.
  15752. func (m *MessageRecordsMutation) ResetSopNode() {
  15753. m.sop_node = nil
  15754. m.clearedsop_node = false
  15755. }
  15756. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  15757. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  15758. m.message_contact = &id
  15759. }
  15760. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  15761. func (m *MessageRecordsMutation) ClearMessageContact() {
  15762. m.clearedmessage_contact = true
  15763. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  15764. }
  15765. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  15766. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  15767. return m.ContactIDCleared() || m.clearedmessage_contact
  15768. }
  15769. // MessageContactID returns the "message_contact" edge ID in the mutation.
  15770. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  15771. if m.message_contact != nil {
  15772. return *m.message_contact, true
  15773. }
  15774. return
  15775. }
  15776. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  15777. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15778. // MessageContactID instead. It exists only for internal usage by the builders.
  15779. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  15780. if id := m.message_contact; id != nil {
  15781. ids = append(ids, *id)
  15782. }
  15783. return
  15784. }
  15785. // ResetMessageContact resets all changes to the "message_contact" edge.
  15786. func (m *MessageRecordsMutation) ResetMessageContact() {
  15787. m.message_contact = nil
  15788. m.clearedmessage_contact = false
  15789. }
  15790. // Where appends a list predicates to the MessageRecordsMutation builder.
  15791. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  15792. m.predicates = append(m.predicates, ps...)
  15793. }
  15794. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  15795. // users can use type-assertion to append predicates that do not depend on any generated package.
  15796. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  15797. p := make([]predicate.MessageRecords, len(ps))
  15798. for i := range ps {
  15799. p[i] = ps[i]
  15800. }
  15801. m.Where(p...)
  15802. }
  15803. // Op returns the operation name.
  15804. func (m *MessageRecordsMutation) Op() Op {
  15805. return m.op
  15806. }
  15807. // SetOp allows setting the mutation operation.
  15808. func (m *MessageRecordsMutation) SetOp(op Op) {
  15809. m.op = op
  15810. }
  15811. // Type returns the node type of this mutation (MessageRecords).
  15812. func (m *MessageRecordsMutation) Type() string {
  15813. return m.typ
  15814. }
  15815. // Fields returns all fields that were changed during this mutation. Note that in
  15816. // order to get all numeric fields that were incremented/decremented, call
  15817. // AddedFields().
  15818. func (m *MessageRecordsMutation) Fields() []string {
  15819. fields := make([]string, 0, 16)
  15820. if m.created_at != nil {
  15821. fields = append(fields, messagerecords.FieldCreatedAt)
  15822. }
  15823. if m.updated_at != nil {
  15824. fields = append(fields, messagerecords.FieldUpdatedAt)
  15825. }
  15826. if m.status != nil {
  15827. fields = append(fields, messagerecords.FieldStatus)
  15828. }
  15829. if m.bot_wxid != nil {
  15830. fields = append(fields, messagerecords.FieldBotWxid)
  15831. }
  15832. if m.message_contact != nil {
  15833. fields = append(fields, messagerecords.FieldContactID)
  15834. }
  15835. if m.contact_type != nil {
  15836. fields = append(fields, messagerecords.FieldContactType)
  15837. }
  15838. if m.contact_wxid != nil {
  15839. fields = append(fields, messagerecords.FieldContactWxid)
  15840. }
  15841. if m.content_type != nil {
  15842. fields = append(fields, messagerecords.FieldContentType)
  15843. }
  15844. if m.content != nil {
  15845. fields = append(fields, messagerecords.FieldContent)
  15846. }
  15847. if m.meta != nil {
  15848. fields = append(fields, messagerecords.FieldMeta)
  15849. }
  15850. if m.error_detail != nil {
  15851. fields = append(fields, messagerecords.FieldErrorDetail)
  15852. }
  15853. if m.send_time != nil {
  15854. fields = append(fields, messagerecords.FieldSendTime)
  15855. }
  15856. if m.source_type != nil {
  15857. fields = append(fields, messagerecords.FieldSourceType)
  15858. }
  15859. if m.sop_stage != nil {
  15860. fields = append(fields, messagerecords.FieldSourceID)
  15861. }
  15862. if m.sop_node != nil {
  15863. fields = append(fields, messagerecords.FieldSubSourceID)
  15864. }
  15865. if m.organization_id != nil {
  15866. fields = append(fields, messagerecords.FieldOrganizationID)
  15867. }
  15868. return fields
  15869. }
  15870. // Field returns the value of a field with the given name. The second boolean
  15871. // return value indicates that this field was not set, or was not defined in the
  15872. // schema.
  15873. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  15874. switch name {
  15875. case messagerecords.FieldCreatedAt:
  15876. return m.CreatedAt()
  15877. case messagerecords.FieldUpdatedAt:
  15878. return m.UpdatedAt()
  15879. case messagerecords.FieldStatus:
  15880. return m.Status()
  15881. case messagerecords.FieldBotWxid:
  15882. return m.BotWxid()
  15883. case messagerecords.FieldContactID:
  15884. return m.ContactID()
  15885. case messagerecords.FieldContactType:
  15886. return m.ContactType()
  15887. case messagerecords.FieldContactWxid:
  15888. return m.ContactWxid()
  15889. case messagerecords.FieldContentType:
  15890. return m.ContentType()
  15891. case messagerecords.FieldContent:
  15892. return m.Content()
  15893. case messagerecords.FieldMeta:
  15894. return m.Meta()
  15895. case messagerecords.FieldErrorDetail:
  15896. return m.ErrorDetail()
  15897. case messagerecords.FieldSendTime:
  15898. return m.SendTime()
  15899. case messagerecords.FieldSourceType:
  15900. return m.SourceType()
  15901. case messagerecords.FieldSourceID:
  15902. return m.SourceID()
  15903. case messagerecords.FieldSubSourceID:
  15904. return m.SubSourceID()
  15905. case messagerecords.FieldOrganizationID:
  15906. return m.OrganizationID()
  15907. }
  15908. return nil, false
  15909. }
  15910. // OldField returns the old value of the field from the database. An error is
  15911. // returned if the mutation operation is not UpdateOne, or the query to the
  15912. // database failed.
  15913. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15914. switch name {
  15915. case messagerecords.FieldCreatedAt:
  15916. return m.OldCreatedAt(ctx)
  15917. case messagerecords.FieldUpdatedAt:
  15918. return m.OldUpdatedAt(ctx)
  15919. case messagerecords.FieldStatus:
  15920. return m.OldStatus(ctx)
  15921. case messagerecords.FieldBotWxid:
  15922. return m.OldBotWxid(ctx)
  15923. case messagerecords.FieldContactID:
  15924. return m.OldContactID(ctx)
  15925. case messagerecords.FieldContactType:
  15926. return m.OldContactType(ctx)
  15927. case messagerecords.FieldContactWxid:
  15928. return m.OldContactWxid(ctx)
  15929. case messagerecords.FieldContentType:
  15930. return m.OldContentType(ctx)
  15931. case messagerecords.FieldContent:
  15932. return m.OldContent(ctx)
  15933. case messagerecords.FieldMeta:
  15934. return m.OldMeta(ctx)
  15935. case messagerecords.FieldErrorDetail:
  15936. return m.OldErrorDetail(ctx)
  15937. case messagerecords.FieldSendTime:
  15938. return m.OldSendTime(ctx)
  15939. case messagerecords.FieldSourceType:
  15940. return m.OldSourceType(ctx)
  15941. case messagerecords.FieldSourceID:
  15942. return m.OldSourceID(ctx)
  15943. case messagerecords.FieldSubSourceID:
  15944. return m.OldSubSourceID(ctx)
  15945. case messagerecords.FieldOrganizationID:
  15946. return m.OldOrganizationID(ctx)
  15947. }
  15948. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15949. }
  15950. // SetField sets the value of a field with the given name. It returns an error if
  15951. // the field is not defined in the schema, or if the type mismatched the field
  15952. // type.
  15953. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15954. switch name {
  15955. case messagerecords.FieldCreatedAt:
  15956. v, ok := value.(time.Time)
  15957. if !ok {
  15958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15959. }
  15960. m.SetCreatedAt(v)
  15961. return nil
  15962. case messagerecords.FieldUpdatedAt:
  15963. v, ok := value.(time.Time)
  15964. if !ok {
  15965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15966. }
  15967. m.SetUpdatedAt(v)
  15968. return nil
  15969. case messagerecords.FieldStatus:
  15970. v, ok := value.(uint8)
  15971. if !ok {
  15972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15973. }
  15974. m.SetStatus(v)
  15975. return nil
  15976. case messagerecords.FieldBotWxid:
  15977. v, ok := value.(string)
  15978. if !ok {
  15979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15980. }
  15981. m.SetBotWxid(v)
  15982. return nil
  15983. case messagerecords.FieldContactID:
  15984. v, ok := value.(uint64)
  15985. if !ok {
  15986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15987. }
  15988. m.SetContactID(v)
  15989. return nil
  15990. case messagerecords.FieldContactType:
  15991. v, ok := value.(int)
  15992. if !ok {
  15993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15994. }
  15995. m.SetContactType(v)
  15996. return nil
  15997. case messagerecords.FieldContactWxid:
  15998. v, ok := value.(string)
  15999. if !ok {
  16000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16001. }
  16002. m.SetContactWxid(v)
  16003. return nil
  16004. case messagerecords.FieldContentType:
  16005. v, ok := value.(int)
  16006. if !ok {
  16007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16008. }
  16009. m.SetContentType(v)
  16010. return nil
  16011. case messagerecords.FieldContent:
  16012. v, ok := value.(string)
  16013. if !ok {
  16014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16015. }
  16016. m.SetContent(v)
  16017. return nil
  16018. case messagerecords.FieldMeta:
  16019. v, ok := value.(custom_types.Meta)
  16020. if !ok {
  16021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16022. }
  16023. m.SetMeta(v)
  16024. return nil
  16025. case messagerecords.FieldErrorDetail:
  16026. v, ok := value.(string)
  16027. if !ok {
  16028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16029. }
  16030. m.SetErrorDetail(v)
  16031. return nil
  16032. case messagerecords.FieldSendTime:
  16033. v, ok := value.(time.Time)
  16034. if !ok {
  16035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16036. }
  16037. m.SetSendTime(v)
  16038. return nil
  16039. case messagerecords.FieldSourceType:
  16040. v, ok := value.(int)
  16041. if !ok {
  16042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16043. }
  16044. m.SetSourceType(v)
  16045. return nil
  16046. case messagerecords.FieldSourceID:
  16047. v, ok := value.(uint64)
  16048. if !ok {
  16049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16050. }
  16051. m.SetSourceID(v)
  16052. return nil
  16053. case messagerecords.FieldSubSourceID:
  16054. v, ok := value.(uint64)
  16055. if !ok {
  16056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16057. }
  16058. m.SetSubSourceID(v)
  16059. return nil
  16060. case messagerecords.FieldOrganizationID:
  16061. v, ok := value.(uint64)
  16062. if !ok {
  16063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16064. }
  16065. m.SetOrganizationID(v)
  16066. return nil
  16067. }
  16068. return fmt.Errorf("unknown MessageRecords field %s", name)
  16069. }
  16070. // AddedFields returns all numeric fields that were incremented/decremented during
  16071. // this mutation.
  16072. func (m *MessageRecordsMutation) AddedFields() []string {
  16073. var fields []string
  16074. if m.addstatus != nil {
  16075. fields = append(fields, messagerecords.FieldStatus)
  16076. }
  16077. if m.addcontact_type != nil {
  16078. fields = append(fields, messagerecords.FieldContactType)
  16079. }
  16080. if m.addcontent_type != nil {
  16081. fields = append(fields, messagerecords.FieldContentType)
  16082. }
  16083. if m.addsource_type != nil {
  16084. fields = append(fields, messagerecords.FieldSourceType)
  16085. }
  16086. if m.addorganization_id != nil {
  16087. fields = append(fields, messagerecords.FieldOrganizationID)
  16088. }
  16089. return fields
  16090. }
  16091. // AddedField returns the numeric value that was incremented/decremented on a field
  16092. // with the given name. The second boolean return value indicates that this field
  16093. // was not set, or was not defined in the schema.
  16094. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  16095. switch name {
  16096. case messagerecords.FieldStatus:
  16097. return m.AddedStatus()
  16098. case messagerecords.FieldContactType:
  16099. return m.AddedContactType()
  16100. case messagerecords.FieldContentType:
  16101. return m.AddedContentType()
  16102. case messagerecords.FieldSourceType:
  16103. return m.AddedSourceType()
  16104. case messagerecords.FieldOrganizationID:
  16105. return m.AddedOrganizationID()
  16106. }
  16107. return nil, false
  16108. }
  16109. // AddField adds the value to the field with the given name. It returns an error if
  16110. // the field is not defined in the schema, or if the type mismatched the field
  16111. // type.
  16112. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  16113. switch name {
  16114. case messagerecords.FieldStatus:
  16115. v, ok := value.(int8)
  16116. if !ok {
  16117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16118. }
  16119. m.AddStatus(v)
  16120. return nil
  16121. case messagerecords.FieldContactType:
  16122. v, ok := value.(int)
  16123. if !ok {
  16124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16125. }
  16126. m.AddContactType(v)
  16127. return nil
  16128. case messagerecords.FieldContentType:
  16129. v, ok := value.(int)
  16130. if !ok {
  16131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16132. }
  16133. m.AddContentType(v)
  16134. return nil
  16135. case messagerecords.FieldSourceType:
  16136. v, ok := value.(int)
  16137. if !ok {
  16138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16139. }
  16140. m.AddSourceType(v)
  16141. return nil
  16142. case messagerecords.FieldOrganizationID:
  16143. v, ok := value.(int64)
  16144. if !ok {
  16145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16146. }
  16147. m.AddOrganizationID(v)
  16148. return nil
  16149. }
  16150. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  16151. }
  16152. // ClearedFields returns all nullable fields that were cleared during this
  16153. // mutation.
  16154. func (m *MessageRecordsMutation) ClearedFields() []string {
  16155. var fields []string
  16156. if m.FieldCleared(messagerecords.FieldStatus) {
  16157. fields = append(fields, messagerecords.FieldStatus)
  16158. }
  16159. if m.FieldCleared(messagerecords.FieldContactID) {
  16160. fields = append(fields, messagerecords.FieldContactID)
  16161. }
  16162. if m.FieldCleared(messagerecords.FieldMeta) {
  16163. fields = append(fields, messagerecords.FieldMeta)
  16164. }
  16165. if m.FieldCleared(messagerecords.FieldSendTime) {
  16166. fields = append(fields, messagerecords.FieldSendTime)
  16167. }
  16168. if m.FieldCleared(messagerecords.FieldSourceID) {
  16169. fields = append(fields, messagerecords.FieldSourceID)
  16170. }
  16171. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  16172. fields = append(fields, messagerecords.FieldSubSourceID)
  16173. }
  16174. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  16175. fields = append(fields, messagerecords.FieldOrganizationID)
  16176. }
  16177. return fields
  16178. }
  16179. // FieldCleared returns a boolean indicating if a field with the given name was
  16180. // cleared in this mutation.
  16181. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  16182. _, ok := m.clearedFields[name]
  16183. return ok
  16184. }
  16185. // ClearField clears the value of the field with the given name. It returns an
  16186. // error if the field is not defined in the schema.
  16187. func (m *MessageRecordsMutation) ClearField(name string) error {
  16188. switch name {
  16189. case messagerecords.FieldStatus:
  16190. m.ClearStatus()
  16191. return nil
  16192. case messagerecords.FieldContactID:
  16193. m.ClearContactID()
  16194. return nil
  16195. case messagerecords.FieldMeta:
  16196. m.ClearMeta()
  16197. return nil
  16198. case messagerecords.FieldSendTime:
  16199. m.ClearSendTime()
  16200. return nil
  16201. case messagerecords.FieldSourceID:
  16202. m.ClearSourceID()
  16203. return nil
  16204. case messagerecords.FieldSubSourceID:
  16205. m.ClearSubSourceID()
  16206. return nil
  16207. case messagerecords.FieldOrganizationID:
  16208. m.ClearOrganizationID()
  16209. return nil
  16210. }
  16211. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  16212. }
  16213. // ResetField resets all changes in the mutation for the field with the given name.
  16214. // It returns an error if the field is not defined in the schema.
  16215. func (m *MessageRecordsMutation) ResetField(name string) error {
  16216. switch name {
  16217. case messagerecords.FieldCreatedAt:
  16218. m.ResetCreatedAt()
  16219. return nil
  16220. case messagerecords.FieldUpdatedAt:
  16221. m.ResetUpdatedAt()
  16222. return nil
  16223. case messagerecords.FieldStatus:
  16224. m.ResetStatus()
  16225. return nil
  16226. case messagerecords.FieldBotWxid:
  16227. m.ResetBotWxid()
  16228. return nil
  16229. case messagerecords.FieldContactID:
  16230. m.ResetContactID()
  16231. return nil
  16232. case messagerecords.FieldContactType:
  16233. m.ResetContactType()
  16234. return nil
  16235. case messagerecords.FieldContactWxid:
  16236. m.ResetContactWxid()
  16237. return nil
  16238. case messagerecords.FieldContentType:
  16239. m.ResetContentType()
  16240. return nil
  16241. case messagerecords.FieldContent:
  16242. m.ResetContent()
  16243. return nil
  16244. case messagerecords.FieldMeta:
  16245. m.ResetMeta()
  16246. return nil
  16247. case messagerecords.FieldErrorDetail:
  16248. m.ResetErrorDetail()
  16249. return nil
  16250. case messagerecords.FieldSendTime:
  16251. m.ResetSendTime()
  16252. return nil
  16253. case messagerecords.FieldSourceType:
  16254. m.ResetSourceType()
  16255. return nil
  16256. case messagerecords.FieldSourceID:
  16257. m.ResetSourceID()
  16258. return nil
  16259. case messagerecords.FieldSubSourceID:
  16260. m.ResetSubSourceID()
  16261. return nil
  16262. case messagerecords.FieldOrganizationID:
  16263. m.ResetOrganizationID()
  16264. return nil
  16265. }
  16266. return fmt.Errorf("unknown MessageRecords field %s", name)
  16267. }
  16268. // AddedEdges returns all edge names that were set/added in this mutation.
  16269. func (m *MessageRecordsMutation) AddedEdges() []string {
  16270. edges := make([]string, 0, 3)
  16271. if m.sop_stage != nil {
  16272. edges = append(edges, messagerecords.EdgeSopStage)
  16273. }
  16274. if m.sop_node != nil {
  16275. edges = append(edges, messagerecords.EdgeSopNode)
  16276. }
  16277. if m.message_contact != nil {
  16278. edges = append(edges, messagerecords.EdgeMessageContact)
  16279. }
  16280. return edges
  16281. }
  16282. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16283. // name in this mutation.
  16284. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  16285. switch name {
  16286. case messagerecords.EdgeSopStage:
  16287. if id := m.sop_stage; id != nil {
  16288. return []ent.Value{*id}
  16289. }
  16290. case messagerecords.EdgeSopNode:
  16291. if id := m.sop_node; id != nil {
  16292. return []ent.Value{*id}
  16293. }
  16294. case messagerecords.EdgeMessageContact:
  16295. if id := m.message_contact; id != nil {
  16296. return []ent.Value{*id}
  16297. }
  16298. }
  16299. return nil
  16300. }
  16301. // RemovedEdges returns all edge names that were removed in this mutation.
  16302. func (m *MessageRecordsMutation) RemovedEdges() []string {
  16303. edges := make([]string, 0, 3)
  16304. return edges
  16305. }
  16306. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16307. // the given name in this mutation.
  16308. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  16309. return nil
  16310. }
  16311. // ClearedEdges returns all edge names that were cleared in this mutation.
  16312. func (m *MessageRecordsMutation) ClearedEdges() []string {
  16313. edges := make([]string, 0, 3)
  16314. if m.clearedsop_stage {
  16315. edges = append(edges, messagerecords.EdgeSopStage)
  16316. }
  16317. if m.clearedsop_node {
  16318. edges = append(edges, messagerecords.EdgeSopNode)
  16319. }
  16320. if m.clearedmessage_contact {
  16321. edges = append(edges, messagerecords.EdgeMessageContact)
  16322. }
  16323. return edges
  16324. }
  16325. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16326. // was cleared in this mutation.
  16327. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  16328. switch name {
  16329. case messagerecords.EdgeSopStage:
  16330. return m.clearedsop_stage
  16331. case messagerecords.EdgeSopNode:
  16332. return m.clearedsop_node
  16333. case messagerecords.EdgeMessageContact:
  16334. return m.clearedmessage_contact
  16335. }
  16336. return false
  16337. }
  16338. // ClearEdge clears the value of the edge with the given name. It returns an error
  16339. // if that edge is not defined in the schema.
  16340. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  16341. switch name {
  16342. case messagerecords.EdgeSopStage:
  16343. m.ClearSopStage()
  16344. return nil
  16345. case messagerecords.EdgeSopNode:
  16346. m.ClearSopNode()
  16347. return nil
  16348. case messagerecords.EdgeMessageContact:
  16349. m.ClearMessageContact()
  16350. return nil
  16351. }
  16352. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  16353. }
  16354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16355. // It returns an error if the edge is not defined in the schema.
  16356. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  16357. switch name {
  16358. case messagerecords.EdgeSopStage:
  16359. m.ResetSopStage()
  16360. return nil
  16361. case messagerecords.EdgeSopNode:
  16362. m.ResetSopNode()
  16363. return nil
  16364. case messagerecords.EdgeMessageContact:
  16365. m.ResetMessageContact()
  16366. return nil
  16367. }
  16368. return fmt.Errorf("unknown MessageRecords edge %s", name)
  16369. }
  16370. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  16371. type MsgMutation struct {
  16372. config
  16373. op Op
  16374. typ string
  16375. id *uint64
  16376. created_at *time.Time
  16377. updated_at *time.Time
  16378. deleted_at *time.Time
  16379. status *uint8
  16380. addstatus *int8
  16381. fromwxid *string
  16382. toid *string
  16383. msgtype *int32
  16384. addmsgtype *int32
  16385. msg *string
  16386. batch_no *string
  16387. clearedFields map[string]struct{}
  16388. done bool
  16389. oldValue func(context.Context) (*Msg, error)
  16390. predicates []predicate.Msg
  16391. }
  16392. var _ ent.Mutation = (*MsgMutation)(nil)
  16393. // msgOption allows management of the mutation configuration using functional options.
  16394. type msgOption func(*MsgMutation)
  16395. // newMsgMutation creates new mutation for the Msg entity.
  16396. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  16397. m := &MsgMutation{
  16398. config: c,
  16399. op: op,
  16400. typ: TypeMsg,
  16401. clearedFields: make(map[string]struct{}),
  16402. }
  16403. for _, opt := range opts {
  16404. opt(m)
  16405. }
  16406. return m
  16407. }
  16408. // withMsgID sets the ID field of the mutation.
  16409. func withMsgID(id uint64) msgOption {
  16410. return func(m *MsgMutation) {
  16411. var (
  16412. err error
  16413. once sync.Once
  16414. value *Msg
  16415. )
  16416. m.oldValue = func(ctx context.Context) (*Msg, error) {
  16417. once.Do(func() {
  16418. if m.done {
  16419. err = errors.New("querying old values post mutation is not allowed")
  16420. } else {
  16421. value, err = m.Client().Msg.Get(ctx, id)
  16422. }
  16423. })
  16424. return value, err
  16425. }
  16426. m.id = &id
  16427. }
  16428. }
  16429. // withMsg sets the old Msg of the mutation.
  16430. func withMsg(node *Msg) msgOption {
  16431. return func(m *MsgMutation) {
  16432. m.oldValue = func(context.Context) (*Msg, error) {
  16433. return node, nil
  16434. }
  16435. m.id = &node.ID
  16436. }
  16437. }
  16438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16439. // executed in a transaction (ent.Tx), a transactional client is returned.
  16440. func (m MsgMutation) Client() *Client {
  16441. client := &Client{config: m.config}
  16442. client.init()
  16443. return client
  16444. }
  16445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16446. // it returns an error otherwise.
  16447. func (m MsgMutation) Tx() (*Tx, error) {
  16448. if _, ok := m.driver.(*txDriver); !ok {
  16449. return nil, errors.New("ent: mutation is not running in a transaction")
  16450. }
  16451. tx := &Tx{config: m.config}
  16452. tx.init()
  16453. return tx, nil
  16454. }
  16455. // SetID sets the value of the id field. Note that this
  16456. // operation is only accepted on creation of Msg entities.
  16457. func (m *MsgMutation) SetID(id uint64) {
  16458. m.id = &id
  16459. }
  16460. // ID returns the ID value in the mutation. Note that the ID is only available
  16461. // if it was provided to the builder or after it was returned from the database.
  16462. func (m *MsgMutation) ID() (id uint64, exists bool) {
  16463. if m.id == nil {
  16464. return
  16465. }
  16466. return *m.id, true
  16467. }
  16468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16469. // That means, if the mutation is applied within a transaction with an isolation level such
  16470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16471. // or updated by the mutation.
  16472. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  16473. switch {
  16474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16475. id, exists := m.ID()
  16476. if exists {
  16477. return []uint64{id}, nil
  16478. }
  16479. fallthrough
  16480. case m.op.Is(OpUpdate | OpDelete):
  16481. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  16482. default:
  16483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16484. }
  16485. }
  16486. // SetCreatedAt sets the "created_at" field.
  16487. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  16488. m.created_at = &t
  16489. }
  16490. // CreatedAt returns the value of the "created_at" field in the mutation.
  16491. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  16492. v := m.created_at
  16493. if v == nil {
  16494. return
  16495. }
  16496. return *v, true
  16497. }
  16498. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  16499. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16501. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16502. if !m.op.Is(OpUpdateOne) {
  16503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16504. }
  16505. if m.id == nil || m.oldValue == nil {
  16506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16507. }
  16508. oldValue, err := m.oldValue(ctx)
  16509. if err != nil {
  16510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16511. }
  16512. return oldValue.CreatedAt, nil
  16513. }
  16514. // ResetCreatedAt resets all changes to the "created_at" field.
  16515. func (m *MsgMutation) ResetCreatedAt() {
  16516. m.created_at = nil
  16517. }
  16518. // SetUpdatedAt sets the "updated_at" field.
  16519. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  16520. m.updated_at = &t
  16521. }
  16522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16523. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  16524. v := m.updated_at
  16525. if v == nil {
  16526. return
  16527. }
  16528. return *v, true
  16529. }
  16530. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  16531. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16533. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16534. if !m.op.Is(OpUpdateOne) {
  16535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16536. }
  16537. if m.id == nil || m.oldValue == nil {
  16538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16539. }
  16540. oldValue, err := m.oldValue(ctx)
  16541. if err != nil {
  16542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16543. }
  16544. return oldValue.UpdatedAt, nil
  16545. }
  16546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16547. func (m *MsgMutation) ResetUpdatedAt() {
  16548. m.updated_at = nil
  16549. }
  16550. // SetDeletedAt sets the "deleted_at" field.
  16551. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  16552. m.deleted_at = &t
  16553. }
  16554. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16555. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  16556. v := m.deleted_at
  16557. if v == nil {
  16558. return
  16559. }
  16560. return *v, true
  16561. }
  16562. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  16563. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16565. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16566. if !m.op.Is(OpUpdateOne) {
  16567. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16568. }
  16569. if m.id == nil || m.oldValue == nil {
  16570. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16571. }
  16572. oldValue, err := m.oldValue(ctx)
  16573. if err != nil {
  16574. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16575. }
  16576. return oldValue.DeletedAt, nil
  16577. }
  16578. // ClearDeletedAt clears the value of the "deleted_at" field.
  16579. func (m *MsgMutation) ClearDeletedAt() {
  16580. m.deleted_at = nil
  16581. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  16582. }
  16583. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16584. func (m *MsgMutation) DeletedAtCleared() bool {
  16585. _, ok := m.clearedFields[msg.FieldDeletedAt]
  16586. return ok
  16587. }
  16588. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16589. func (m *MsgMutation) ResetDeletedAt() {
  16590. m.deleted_at = nil
  16591. delete(m.clearedFields, msg.FieldDeletedAt)
  16592. }
  16593. // SetStatus sets the "status" field.
  16594. func (m *MsgMutation) SetStatus(u uint8) {
  16595. m.status = &u
  16596. m.addstatus = nil
  16597. }
  16598. // Status returns the value of the "status" field in the mutation.
  16599. func (m *MsgMutation) Status() (r uint8, exists bool) {
  16600. v := m.status
  16601. if v == nil {
  16602. return
  16603. }
  16604. return *v, true
  16605. }
  16606. // OldStatus returns the old "status" field's value of the Msg entity.
  16607. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16609. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16610. if !m.op.Is(OpUpdateOne) {
  16611. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16612. }
  16613. if m.id == nil || m.oldValue == nil {
  16614. return v, errors.New("OldStatus requires an ID field in the mutation")
  16615. }
  16616. oldValue, err := m.oldValue(ctx)
  16617. if err != nil {
  16618. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16619. }
  16620. return oldValue.Status, nil
  16621. }
  16622. // AddStatus adds u to the "status" field.
  16623. func (m *MsgMutation) AddStatus(u int8) {
  16624. if m.addstatus != nil {
  16625. *m.addstatus += u
  16626. } else {
  16627. m.addstatus = &u
  16628. }
  16629. }
  16630. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16631. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  16632. v := m.addstatus
  16633. if v == nil {
  16634. return
  16635. }
  16636. return *v, true
  16637. }
  16638. // ClearStatus clears the value of the "status" field.
  16639. func (m *MsgMutation) ClearStatus() {
  16640. m.status = nil
  16641. m.addstatus = nil
  16642. m.clearedFields[msg.FieldStatus] = struct{}{}
  16643. }
  16644. // StatusCleared returns if the "status" field was cleared in this mutation.
  16645. func (m *MsgMutation) StatusCleared() bool {
  16646. _, ok := m.clearedFields[msg.FieldStatus]
  16647. return ok
  16648. }
  16649. // ResetStatus resets all changes to the "status" field.
  16650. func (m *MsgMutation) ResetStatus() {
  16651. m.status = nil
  16652. m.addstatus = nil
  16653. delete(m.clearedFields, msg.FieldStatus)
  16654. }
  16655. // SetFromwxid sets the "fromwxid" field.
  16656. func (m *MsgMutation) SetFromwxid(s string) {
  16657. m.fromwxid = &s
  16658. }
  16659. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  16660. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  16661. v := m.fromwxid
  16662. if v == nil {
  16663. return
  16664. }
  16665. return *v, true
  16666. }
  16667. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  16668. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16670. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  16671. if !m.op.Is(OpUpdateOne) {
  16672. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  16673. }
  16674. if m.id == nil || m.oldValue == nil {
  16675. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  16676. }
  16677. oldValue, err := m.oldValue(ctx)
  16678. if err != nil {
  16679. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  16680. }
  16681. return oldValue.Fromwxid, nil
  16682. }
  16683. // ClearFromwxid clears the value of the "fromwxid" field.
  16684. func (m *MsgMutation) ClearFromwxid() {
  16685. m.fromwxid = nil
  16686. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  16687. }
  16688. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  16689. func (m *MsgMutation) FromwxidCleared() bool {
  16690. _, ok := m.clearedFields[msg.FieldFromwxid]
  16691. return ok
  16692. }
  16693. // ResetFromwxid resets all changes to the "fromwxid" field.
  16694. func (m *MsgMutation) ResetFromwxid() {
  16695. m.fromwxid = nil
  16696. delete(m.clearedFields, msg.FieldFromwxid)
  16697. }
  16698. // SetToid sets the "toid" field.
  16699. func (m *MsgMutation) SetToid(s string) {
  16700. m.toid = &s
  16701. }
  16702. // Toid returns the value of the "toid" field in the mutation.
  16703. func (m *MsgMutation) Toid() (r string, exists bool) {
  16704. v := m.toid
  16705. if v == nil {
  16706. return
  16707. }
  16708. return *v, true
  16709. }
  16710. // OldToid returns the old "toid" field's value of the Msg entity.
  16711. // If the Msg 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 *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  16714. if !m.op.Is(OpUpdateOne) {
  16715. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  16716. }
  16717. if m.id == nil || m.oldValue == nil {
  16718. return v, errors.New("OldToid 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 OldToid: %w", err)
  16723. }
  16724. return oldValue.Toid, nil
  16725. }
  16726. // ClearToid clears the value of the "toid" field.
  16727. func (m *MsgMutation) ClearToid() {
  16728. m.toid = nil
  16729. m.clearedFields[msg.FieldToid] = struct{}{}
  16730. }
  16731. // ToidCleared returns if the "toid" field was cleared in this mutation.
  16732. func (m *MsgMutation) ToidCleared() bool {
  16733. _, ok := m.clearedFields[msg.FieldToid]
  16734. return ok
  16735. }
  16736. // ResetToid resets all changes to the "toid" field.
  16737. func (m *MsgMutation) ResetToid() {
  16738. m.toid = nil
  16739. delete(m.clearedFields, msg.FieldToid)
  16740. }
  16741. // SetMsgtype sets the "msgtype" field.
  16742. func (m *MsgMutation) SetMsgtype(i int32) {
  16743. m.msgtype = &i
  16744. m.addmsgtype = nil
  16745. }
  16746. // Msgtype returns the value of the "msgtype" field in the mutation.
  16747. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  16748. v := m.msgtype
  16749. if v == nil {
  16750. return
  16751. }
  16752. return *v, true
  16753. }
  16754. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  16755. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16757. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  16758. if !m.op.Is(OpUpdateOne) {
  16759. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  16760. }
  16761. if m.id == nil || m.oldValue == nil {
  16762. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  16763. }
  16764. oldValue, err := m.oldValue(ctx)
  16765. if err != nil {
  16766. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  16767. }
  16768. return oldValue.Msgtype, nil
  16769. }
  16770. // AddMsgtype adds i to the "msgtype" field.
  16771. func (m *MsgMutation) AddMsgtype(i int32) {
  16772. if m.addmsgtype != nil {
  16773. *m.addmsgtype += i
  16774. } else {
  16775. m.addmsgtype = &i
  16776. }
  16777. }
  16778. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  16779. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  16780. v := m.addmsgtype
  16781. if v == nil {
  16782. return
  16783. }
  16784. return *v, true
  16785. }
  16786. // ClearMsgtype clears the value of the "msgtype" field.
  16787. func (m *MsgMutation) ClearMsgtype() {
  16788. m.msgtype = nil
  16789. m.addmsgtype = nil
  16790. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  16791. }
  16792. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  16793. func (m *MsgMutation) MsgtypeCleared() bool {
  16794. _, ok := m.clearedFields[msg.FieldMsgtype]
  16795. return ok
  16796. }
  16797. // ResetMsgtype resets all changes to the "msgtype" field.
  16798. func (m *MsgMutation) ResetMsgtype() {
  16799. m.msgtype = nil
  16800. m.addmsgtype = nil
  16801. delete(m.clearedFields, msg.FieldMsgtype)
  16802. }
  16803. // SetMsg sets the "msg" field.
  16804. func (m *MsgMutation) SetMsg(s string) {
  16805. m.msg = &s
  16806. }
  16807. // Msg returns the value of the "msg" field in the mutation.
  16808. func (m *MsgMutation) Msg() (r string, exists bool) {
  16809. v := m.msg
  16810. if v == nil {
  16811. return
  16812. }
  16813. return *v, true
  16814. }
  16815. // OldMsg returns the old "msg" field's value of the Msg entity.
  16816. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16818. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  16819. if !m.op.Is(OpUpdateOne) {
  16820. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  16821. }
  16822. if m.id == nil || m.oldValue == nil {
  16823. return v, errors.New("OldMsg requires an ID field in the mutation")
  16824. }
  16825. oldValue, err := m.oldValue(ctx)
  16826. if err != nil {
  16827. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  16828. }
  16829. return oldValue.Msg, nil
  16830. }
  16831. // ClearMsg clears the value of the "msg" field.
  16832. func (m *MsgMutation) ClearMsg() {
  16833. m.msg = nil
  16834. m.clearedFields[msg.FieldMsg] = struct{}{}
  16835. }
  16836. // MsgCleared returns if the "msg" field was cleared in this mutation.
  16837. func (m *MsgMutation) MsgCleared() bool {
  16838. _, ok := m.clearedFields[msg.FieldMsg]
  16839. return ok
  16840. }
  16841. // ResetMsg resets all changes to the "msg" field.
  16842. func (m *MsgMutation) ResetMsg() {
  16843. m.msg = nil
  16844. delete(m.clearedFields, msg.FieldMsg)
  16845. }
  16846. // SetBatchNo sets the "batch_no" field.
  16847. func (m *MsgMutation) SetBatchNo(s string) {
  16848. m.batch_no = &s
  16849. }
  16850. // BatchNo returns the value of the "batch_no" field in the mutation.
  16851. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  16852. v := m.batch_no
  16853. if v == nil {
  16854. return
  16855. }
  16856. return *v, true
  16857. }
  16858. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  16859. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16861. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  16862. if !m.op.Is(OpUpdateOne) {
  16863. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  16864. }
  16865. if m.id == nil || m.oldValue == nil {
  16866. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  16867. }
  16868. oldValue, err := m.oldValue(ctx)
  16869. if err != nil {
  16870. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  16871. }
  16872. return oldValue.BatchNo, nil
  16873. }
  16874. // ClearBatchNo clears the value of the "batch_no" field.
  16875. func (m *MsgMutation) ClearBatchNo() {
  16876. m.batch_no = nil
  16877. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  16878. }
  16879. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  16880. func (m *MsgMutation) BatchNoCleared() bool {
  16881. _, ok := m.clearedFields[msg.FieldBatchNo]
  16882. return ok
  16883. }
  16884. // ResetBatchNo resets all changes to the "batch_no" field.
  16885. func (m *MsgMutation) ResetBatchNo() {
  16886. m.batch_no = nil
  16887. delete(m.clearedFields, msg.FieldBatchNo)
  16888. }
  16889. // Where appends a list predicates to the MsgMutation builder.
  16890. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  16891. m.predicates = append(m.predicates, ps...)
  16892. }
  16893. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  16894. // users can use type-assertion to append predicates that do not depend on any generated package.
  16895. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  16896. p := make([]predicate.Msg, len(ps))
  16897. for i := range ps {
  16898. p[i] = ps[i]
  16899. }
  16900. m.Where(p...)
  16901. }
  16902. // Op returns the operation name.
  16903. func (m *MsgMutation) Op() Op {
  16904. return m.op
  16905. }
  16906. // SetOp allows setting the mutation operation.
  16907. func (m *MsgMutation) SetOp(op Op) {
  16908. m.op = op
  16909. }
  16910. // Type returns the node type of this mutation (Msg).
  16911. func (m *MsgMutation) Type() string {
  16912. return m.typ
  16913. }
  16914. // Fields returns all fields that were changed during this mutation. Note that in
  16915. // order to get all numeric fields that were incremented/decremented, call
  16916. // AddedFields().
  16917. func (m *MsgMutation) Fields() []string {
  16918. fields := make([]string, 0, 9)
  16919. if m.created_at != nil {
  16920. fields = append(fields, msg.FieldCreatedAt)
  16921. }
  16922. if m.updated_at != nil {
  16923. fields = append(fields, msg.FieldUpdatedAt)
  16924. }
  16925. if m.deleted_at != nil {
  16926. fields = append(fields, msg.FieldDeletedAt)
  16927. }
  16928. if m.status != nil {
  16929. fields = append(fields, msg.FieldStatus)
  16930. }
  16931. if m.fromwxid != nil {
  16932. fields = append(fields, msg.FieldFromwxid)
  16933. }
  16934. if m.toid != nil {
  16935. fields = append(fields, msg.FieldToid)
  16936. }
  16937. if m.msgtype != nil {
  16938. fields = append(fields, msg.FieldMsgtype)
  16939. }
  16940. if m.msg != nil {
  16941. fields = append(fields, msg.FieldMsg)
  16942. }
  16943. if m.batch_no != nil {
  16944. fields = append(fields, msg.FieldBatchNo)
  16945. }
  16946. return fields
  16947. }
  16948. // Field returns the value of a field with the given name. The second boolean
  16949. // return value indicates that this field was not set, or was not defined in the
  16950. // schema.
  16951. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16952. switch name {
  16953. case msg.FieldCreatedAt:
  16954. return m.CreatedAt()
  16955. case msg.FieldUpdatedAt:
  16956. return m.UpdatedAt()
  16957. case msg.FieldDeletedAt:
  16958. return m.DeletedAt()
  16959. case msg.FieldStatus:
  16960. return m.Status()
  16961. case msg.FieldFromwxid:
  16962. return m.Fromwxid()
  16963. case msg.FieldToid:
  16964. return m.Toid()
  16965. case msg.FieldMsgtype:
  16966. return m.Msgtype()
  16967. case msg.FieldMsg:
  16968. return m.Msg()
  16969. case msg.FieldBatchNo:
  16970. return m.BatchNo()
  16971. }
  16972. return nil, false
  16973. }
  16974. // OldField returns the old value of the field from the database. An error is
  16975. // returned if the mutation operation is not UpdateOne, or the query to the
  16976. // database failed.
  16977. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16978. switch name {
  16979. case msg.FieldCreatedAt:
  16980. return m.OldCreatedAt(ctx)
  16981. case msg.FieldUpdatedAt:
  16982. return m.OldUpdatedAt(ctx)
  16983. case msg.FieldDeletedAt:
  16984. return m.OldDeletedAt(ctx)
  16985. case msg.FieldStatus:
  16986. return m.OldStatus(ctx)
  16987. case msg.FieldFromwxid:
  16988. return m.OldFromwxid(ctx)
  16989. case msg.FieldToid:
  16990. return m.OldToid(ctx)
  16991. case msg.FieldMsgtype:
  16992. return m.OldMsgtype(ctx)
  16993. case msg.FieldMsg:
  16994. return m.OldMsg(ctx)
  16995. case msg.FieldBatchNo:
  16996. return m.OldBatchNo(ctx)
  16997. }
  16998. return nil, fmt.Errorf("unknown Msg field %s", name)
  16999. }
  17000. // SetField sets the value of a field with the given name. It returns an error if
  17001. // the field is not defined in the schema, or if the type mismatched the field
  17002. // type.
  17003. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  17004. switch name {
  17005. case msg.FieldCreatedAt:
  17006. v, ok := value.(time.Time)
  17007. if !ok {
  17008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17009. }
  17010. m.SetCreatedAt(v)
  17011. return nil
  17012. case msg.FieldUpdatedAt:
  17013. v, ok := value.(time.Time)
  17014. if !ok {
  17015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17016. }
  17017. m.SetUpdatedAt(v)
  17018. return nil
  17019. case msg.FieldDeletedAt:
  17020. v, ok := value.(time.Time)
  17021. if !ok {
  17022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17023. }
  17024. m.SetDeletedAt(v)
  17025. return nil
  17026. case msg.FieldStatus:
  17027. v, ok := value.(uint8)
  17028. if !ok {
  17029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17030. }
  17031. m.SetStatus(v)
  17032. return nil
  17033. case msg.FieldFromwxid:
  17034. v, ok := value.(string)
  17035. if !ok {
  17036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17037. }
  17038. m.SetFromwxid(v)
  17039. return nil
  17040. case msg.FieldToid:
  17041. v, ok := value.(string)
  17042. if !ok {
  17043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17044. }
  17045. m.SetToid(v)
  17046. return nil
  17047. case msg.FieldMsgtype:
  17048. v, ok := value.(int32)
  17049. if !ok {
  17050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17051. }
  17052. m.SetMsgtype(v)
  17053. return nil
  17054. case msg.FieldMsg:
  17055. v, ok := value.(string)
  17056. if !ok {
  17057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17058. }
  17059. m.SetMsg(v)
  17060. return nil
  17061. case msg.FieldBatchNo:
  17062. v, ok := value.(string)
  17063. if !ok {
  17064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17065. }
  17066. m.SetBatchNo(v)
  17067. return nil
  17068. }
  17069. return fmt.Errorf("unknown Msg field %s", name)
  17070. }
  17071. // AddedFields returns all numeric fields that were incremented/decremented during
  17072. // this mutation.
  17073. func (m *MsgMutation) AddedFields() []string {
  17074. var fields []string
  17075. if m.addstatus != nil {
  17076. fields = append(fields, msg.FieldStatus)
  17077. }
  17078. if m.addmsgtype != nil {
  17079. fields = append(fields, msg.FieldMsgtype)
  17080. }
  17081. return fields
  17082. }
  17083. // AddedField returns the numeric value that was incremented/decremented on a field
  17084. // with the given name. The second boolean return value indicates that this field
  17085. // was not set, or was not defined in the schema.
  17086. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  17087. switch name {
  17088. case msg.FieldStatus:
  17089. return m.AddedStatus()
  17090. case msg.FieldMsgtype:
  17091. return m.AddedMsgtype()
  17092. }
  17093. return nil, false
  17094. }
  17095. // AddField adds the value to the field with the given name. It returns an error if
  17096. // the field is not defined in the schema, or if the type mismatched the field
  17097. // type.
  17098. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  17099. switch name {
  17100. case msg.FieldStatus:
  17101. v, ok := value.(int8)
  17102. if !ok {
  17103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17104. }
  17105. m.AddStatus(v)
  17106. return nil
  17107. case msg.FieldMsgtype:
  17108. v, ok := value.(int32)
  17109. if !ok {
  17110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17111. }
  17112. m.AddMsgtype(v)
  17113. return nil
  17114. }
  17115. return fmt.Errorf("unknown Msg numeric field %s", name)
  17116. }
  17117. // ClearedFields returns all nullable fields that were cleared during this
  17118. // mutation.
  17119. func (m *MsgMutation) ClearedFields() []string {
  17120. var fields []string
  17121. if m.FieldCleared(msg.FieldDeletedAt) {
  17122. fields = append(fields, msg.FieldDeletedAt)
  17123. }
  17124. if m.FieldCleared(msg.FieldStatus) {
  17125. fields = append(fields, msg.FieldStatus)
  17126. }
  17127. if m.FieldCleared(msg.FieldFromwxid) {
  17128. fields = append(fields, msg.FieldFromwxid)
  17129. }
  17130. if m.FieldCleared(msg.FieldToid) {
  17131. fields = append(fields, msg.FieldToid)
  17132. }
  17133. if m.FieldCleared(msg.FieldMsgtype) {
  17134. fields = append(fields, msg.FieldMsgtype)
  17135. }
  17136. if m.FieldCleared(msg.FieldMsg) {
  17137. fields = append(fields, msg.FieldMsg)
  17138. }
  17139. if m.FieldCleared(msg.FieldBatchNo) {
  17140. fields = append(fields, msg.FieldBatchNo)
  17141. }
  17142. return fields
  17143. }
  17144. // FieldCleared returns a boolean indicating if a field with the given name was
  17145. // cleared in this mutation.
  17146. func (m *MsgMutation) FieldCleared(name string) bool {
  17147. _, ok := m.clearedFields[name]
  17148. return ok
  17149. }
  17150. // ClearField clears the value of the field with the given name. It returns an
  17151. // error if the field is not defined in the schema.
  17152. func (m *MsgMutation) ClearField(name string) error {
  17153. switch name {
  17154. case msg.FieldDeletedAt:
  17155. m.ClearDeletedAt()
  17156. return nil
  17157. case msg.FieldStatus:
  17158. m.ClearStatus()
  17159. return nil
  17160. case msg.FieldFromwxid:
  17161. m.ClearFromwxid()
  17162. return nil
  17163. case msg.FieldToid:
  17164. m.ClearToid()
  17165. return nil
  17166. case msg.FieldMsgtype:
  17167. m.ClearMsgtype()
  17168. return nil
  17169. case msg.FieldMsg:
  17170. m.ClearMsg()
  17171. return nil
  17172. case msg.FieldBatchNo:
  17173. m.ClearBatchNo()
  17174. return nil
  17175. }
  17176. return fmt.Errorf("unknown Msg nullable field %s", name)
  17177. }
  17178. // ResetField resets all changes in the mutation for the field with the given name.
  17179. // It returns an error if the field is not defined in the schema.
  17180. func (m *MsgMutation) ResetField(name string) error {
  17181. switch name {
  17182. case msg.FieldCreatedAt:
  17183. m.ResetCreatedAt()
  17184. return nil
  17185. case msg.FieldUpdatedAt:
  17186. m.ResetUpdatedAt()
  17187. return nil
  17188. case msg.FieldDeletedAt:
  17189. m.ResetDeletedAt()
  17190. return nil
  17191. case msg.FieldStatus:
  17192. m.ResetStatus()
  17193. return nil
  17194. case msg.FieldFromwxid:
  17195. m.ResetFromwxid()
  17196. return nil
  17197. case msg.FieldToid:
  17198. m.ResetToid()
  17199. return nil
  17200. case msg.FieldMsgtype:
  17201. m.ResetMsgtype()
  17202. return nil
  17203. case msg.FieldMsg:
  17204. m.ResetMsg()
  17205. return nil
  17206. case msg.FieldBatchNo:
  17207. m.ResetBatchNo()
  17208. return nil
  17209. }
  17210. return fmt.Errorf("unknown Msg field %s", name)
  17211. }
  17212. // AddedEdges returns all edge names that were set/added in this mutation.
  17213. func (m *MsgMutation) AddedEdges() []string {
  17214. edges := make([]string, 0, 0)
  17215. return edges
  17216. }
  17217. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17218. // name in this mutation.
  17219. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  17220. return nil
  17221. }
  17222. // RemovedEdges returns all edge names that were removed in this mutation.
  17223. func (m *MsgMutation) RemovedEdges() []string {
  17224. edges := make([]string, 0, 0)
  17225. return edges
  17226. }
  17227. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17228. // the given name in this mutation.
  17229. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  17230. return nil
  17231. }
  17232. // ClearedEdges returns all edge names that were cleared in this mutation.
  17233. func (m *MsgMutation) ClearedEdges() []string {
  17234. edges := make([]string, 0, 0)
  17235. return edges
  17236. }
  17237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17238. // was cleared in this mutation.
  17239. func (m *MsgMutation) EdgeCleared(name string) bool {
  17240. return false
  17241. }
  17242. // ClearEdge clears the value of the edge with the given name. It returns an error
  17243. // if that edge is not defined in the schema.
  17244. func (m *MsgMutation) ClearEdge(name string) error {
  17245. return fmt.Errorf("unknown Msg unique edge %s", name)
  17246. }
  17247. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17248. // It returns an error if the edge is not defined in the schema.
  17249. func (m *MsgMutation) ResetEdge(name string) error {
  17250. return fmt.Errorf("unknown Msg edge %s", name)
  17251. }
  17252. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  17253. type ServerMutation struct {
  17254. config
  17255. op Op
  17256. typ string
  17257. id *uint64
  17258. created_at *time.Time
  17259. updated_at *time.Time
  17260. status *uint8
  17261. addstatus *int8
  17262. deleted_at *time.Time
  17263. name *string
  17264. public_ip *string
  17265. private_ip *string
  17266. admin_port *string
  17267. clearedFields map[string]struct{}
  17268. wxs map[uint64]struct{}
  17269. removedwxs map[uint64]struct{}
  17270. clearedwxs bool
  17271. done bool
  17272. oldValue func(context.Context) (*Server, error)
  17273. predicates []predicate.Server
  17274. }
  17275. var _ ent.Mutation = (*ServerMutation)(nil)
  17276. // serverOption allows management of the mutation configuration using functional options.
  17277. type serverOption func(*ServerMutation)
  17278. // newServerMutation creates new mutation for the Server entity.
  17279. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  17280. m := &ServerMutation{
  17281. config: c,
  17282. op: op,
  17283. typ: TypeServer,
  17284. clearedFields: make(map[string]struct{}),
  17285. }
  17286. for _, opt := range opts {
  17287. opt(m)
  17288. }
  17289. return m
  17290. }
  17291. // withServerID sets the ID field of the mutation.
  17292. func withServerID(id uint64) serverOption {
  17293. return func(m *ServerMutation) {
  17294. var (
  17295. err error
  17296. once sync.Once
  17297. value *Server
  17298. )
  17299. m.oldValue = func(ctx context.Context) (*Server, error) {
  17300. once.Do(func() {
  17301. if m.done {
  17302. err = errors.New("querying old values post mutation is not allowed")
  17303. } else {
  17304. value, err = m.Client().Server.Get(ctx, id)
  17305. }
  17306. })
  17307. return value, err
  17308. }
  17309. m.id = &id
  17310. }
  17311. }
  17312. // withServer sets the old Server of the mutation.
  17313. func withServer(node *Server) serverOption {
  17314. return func(m *ServerMutation) {
  17315. m.oldValue = func(context.Context) (*Server, error) {
  17316. return node, nil
  17317. }
  17318. m.id = &node.ID
  17319. }
  17320. }
  17321. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17322. // executed in a transaction (ent.Tx), a transactional client is returned.
  17323. func (m ServerMutation) Client() *Client {
  17324. client := &Client{config: m.config}
  17325. client.init()
  17326. return client
  17327. }
  17328. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17329. // it returns an error otherwise.
  17330. func (m ServerMutation) Tx() (*Tx, error) {
  17331. if _, ok := m.driver.(*txDriver); !ok {
  17332. return nil, errors.New("ent: mutation is not running in a transaction")
  17333. }
  17334. tx := &Tx{config: m.config}
  17335. tx.init()
  17336. return tx, nil
  17337. }
  17338. // SetID sets the value of the id field. Note that this
  17339. // operation is only accepted on creation of Server entities.
  17340. func (m *ServerMutation) SetID(id uint64) {
  17341. m.id = &id
  17342. }
  17343. // ID returns the ID value in the mutation. Note that the ID is only available
  17344. // if it was provided to the builder or after it was returned from the database.
  17345. func (m *ServerMutation) ID() (id uint64, exists bool) {
  17346. if m.id == nil {
  17347. return
  17348. }
  17349. return *m.id, true
  17350. }
  17351. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17352. // That means, if the mutation is applied within a transaction with an isolation level such
  17353. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17354. // or updated by the mutation.
  17355. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  17356. switch {
  17357. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17358. id, exists := m.ID()
  17359. if exists {
  17360. return []uint64{id}, nil
  17361. }
  17362. fallthrough
  17363. case m.op.Is(OpUpdate | OpDelete):
  17364. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  17365. default:
  17366. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17367. }
  17368. }
  17369. // SetCreatedAt sets the "created_at" field.
  17370. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  17371. m.created_at = &t
  17372. }
  17373. // CreatedAt returns the value of the "created_at" field in the mutation.
  17374. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  17375. v := m.created_at
  17376. if v == nil {
  17377. return
  17378. }
  17379. return *v, true
  17380. }
  17381. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  17382. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17384. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17385. if !m.op.Is(OpUpdateOne) {
  17386. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17387. }
  17388. if m.id == nil || m.oldValue == nil {
  17389. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17390. }
  17391. oldValue, err := m.oldValue(ctx)
  17392. if err != nil {
  17393. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17394. }
  17395. return oldValue.CreatedAt, nil
  17396. }
  17397. // ResetCreatedAt resets all changes to the "created_at" field.
  17398. func (m *ServerMutation) ResetCreatedAt() {
  17399. m.created_at = nil
  17400. }
  17401. // SetUpdatedAt sets the "updated_at" field.
  17402. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  17403. m.updated_at = &t
  17404. }
  17405. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17406. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  17407. v := m.updated_at
  17408. if v == nil {
  17409. return
  17410. }
  17411. return *v, true
  17412. }
  17413. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  17414. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17416. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17417. if !m.op.Is(OpUpdateOne) {
  17418. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17419. }
  17420. if m.id == nil || m.oldValue == nil {
  17421. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17422. }
  17423. oldValue, err := m.oldValue(ctx)
  17424. if err != nil {
  17425. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17426. }
  17427. return oldValue.UpdatedAt, nil
  17428. }
  17429. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17430. func (m *ServerMutation) ResetUpdatedAt() {
  17431. m.updated_at = nil
  17432. }
  17433. // SetStatus sets the "status" field.
  17434. func (m *ServerMutation) SetStatus(u uint8) {
  17435. m.status = &u
  17436. m.addstatus = nil
  17437. }
  17438. // Status returns the value of the "status" field in the mutation.
  17439. func (m *ServerMutation) Status() (r uint8, exists bool) {
  17440. v := m.status
  17441. if v == nil {
  17442. return
  17443. }
  17444. return *v, true
  17445. }
  17446. // OldStatus returns the old "status" field's value of the Server entity.
  17447. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17449. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17450. if !m.op.Is(OpUpdateOne) {
  17451. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17452. }
  17453. if m.id == nil || m.oldValue == nil {
  17454. return v, errors.New("OldStatus requires an ID field in the mutation")
  17455. }
  17456. oldValue, err := m.oldValue(ctx)
  17457. if err != nil {
  17458. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17459. }
  17460. return oldValue.Status, nil
  17461. }
  17462. // AddStatus adds u to the "status" field.
  17463. func (m *ServerMutation) AddStatus(u int8) {
  17464. if m.addstatus != nil {
  17465. *m.addstatus += u
  17466. } else {
  17467. m.addstatus = &u
  17468. }
  17469. }
  17470. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17471. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  17472. v := m.addstatus
  17473. if v == nil {
  17474. return
  17475. }
  17476. return *v, true
  17477. }
  17478. // ClearStatus clears the value of the "status" field.
  17479. func (m *ServerMutation) ClearStatus() {
  17480. m.status = nil
  17481. m.addstatus = nil
  17482. m.clearedFields[server.FieldStatus] = struct{}{}
  17483. }
  17484. // StatusCleared returns if the "status" field was cleared in this mutation.
  17485. func (m *ServerMutation) StatusCleared() bool {
  17486. _, ok := m.clearedFields[server.FieldStatus]
  17487. return ok
  17488. }
  17489. // ResetStatus resets all changes to the "status" field.
  17490. func (m *ServerMutation) ResetStatus() {
  17491. m.status = nil
  17492. m.addstatus = nil
  17493. delete(m.clearedFields, server.FieldStatus)
  17494. }
  17495. // SetDeletedAt sets the "deleted_at" field.
  17496. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  17497. m.deleted_at = &t
  17498. }
  17499. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17500. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  17501. v := m.deleted_at
  17502. if v == nil {
  17503. return
  17504. }
  17505. return *v, true
  17506. }
  17507. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  17508. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17510. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17511. if !m.op.Is(OpUpdateOne) {
  17512. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17513. }
  17514. if m.id == nil || m.oldValue == nil {
  17515. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17516. }
  17517. oldValue, err := m.oldValue(ctx)
  17518. if err != nil {
  17519. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17520. }
  17521. return oldValue.DeletedAt, nil
  17522. }
  17523. // ClearDeletedAt clears the value of the "deleted_at" field.
  17524. func (m *ServerMutation) ClearDeletedAt() {
  17525. m.deleted_at = nil
  17526. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  17527. }
  17528. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17529. func (m *ServerMutation) DeletedAtCleared() bool {
  17530. _, ok := m.clearedFields[server.FieldDeletedAt]
  17531. return ok
  17532. }
  17533. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17534. func (m *ServerMutation) ResetDeletedAt() {
  17535. m.deleted_at = nil
  17536. delete(m.clearedFields, server.FieldDeletedAt)
  17537. }
  17538. // SetName sets the "name" field.
  17539. func (m *ServerMutation) SetName(s string) {
  17540. m.name = &s
  17541. }
  17542. // Name returns the value of the "name" field in the mutation.
  17543. func (m *ServerMutation) Name() (r string, exists bool) {
  17544. v := m.name
  17545. if v == nil {
  17546. return
  17547. }
  17548. return *v, true
  17549. }
  17550. // OldName returns the old "name" field's value of the Server entity.
  17551. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17553. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  17554. if !m.op.Is(OpUpdateOne) {
  17555. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17556. }
  17557. if m.id == nil || m.oldValue == nil {
  17558. return v, errors.New("OldName requires an ID field in the mutation")
  17559. }
  17560. oldValue, err := m.oldValue(ctx)
  17561. if err != nil {
  17562. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17563. }
  17564. return oldValue.Name, nil
  17565. }
  17566. // ResetName resets all changes to the "name" field.
  17567. func (m *ServerMutation) ResetName() {
  17568. m.name = nil
  17569. }
  17570. // SetPublicIP sets the "public_ip" field.
  17571. func (m *ServerMutation) SetPublicIP(s string) {
  17572. m.public_ip = &s
  17573. }
  17574. // PublicIP returns the value of the "public_ip" field in the mutation.
  17575. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  17576. v := m.public_ip
  17577. if v == nil {
  17578. return
  17579. }
  17580. return *v, true
  17581. }
  17582. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  17583. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17585. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  17586. if !m.op.Is(OpUpdateOne) {
  17587. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  17588. }
  17589. if m.id == nil || m.oldValue == nil {
  17590. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  17591. }
  17592. oldValue, err := m.oldValue(ctx)
  17593. if err != nil {
  17594. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  17595. }
  17596. return oldValue.PublicIP, nil
  17597. }
  17598. // ResetPublicIP resets all changes to the "public_ip" field.
  17599. func (m *ServerMutation) ResetPublicIP() {
  17600. m.public_ip = nil
  17601. }
  17602. // SetPrivateIP sets the "private_ip" field.
  17603. func (m *ServerMutation) SetPrivateIP(s string) {
  17604. m.private_ip = &s
  17605. }
  17606. // PrivateIP returns the value of the "private_ip" field in the mutation.
  17607. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  17608. v := m.private_ip
  17609. if v == nil {
  17610. return
  17611. }
  17612. return *v, true
  17613. }
  17614. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  17615. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17617. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  17618. if !m.op.Is(OpUpdateOne) {
  17619. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  17620. }
  17621. if m.id == nil || m.oldValue == nil {
  17622. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  17623. }
  17624. oldValue, err := m.oldValue(ctx)
  17625. if err != nil {
  17626. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  17627. }
  17628. return oldValue.PrivateIP, nil
  17629. }
  17630. // ResetPrivateIP resets all changes to the "private_ip" field.
  17631. func (m *ServerMutation) ResetPrivateIP() {
  17632. m.private_ip = nil
  17633. }
  17634. // SetAdminPort sets the "admin_port" field.
  17635. func (m *ServerMutation) SetAdminPort(s string) {
  17636. m.admin_port = &s
  17637. }
  17638. // AdminPort returns the value of the "admin_port" field in the mutation.
  17639. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  17640. v := m.admin_port
  17641. if v == nil {
  17642. return
  17643. }
  17644. return *v, true
  17645. }
  17646. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  17647. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17649. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  17650. if !m.op.Is(OpUpdateOne) {
  17651. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  17652. }
  17653. if m.id == nil || m.oldValue == nil {
  17654. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  17655. }
  17656. oldValue, err := m.oldValue(ctx)
  17657. if err != nil {
  17658. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  17659. }
  17660. return oldValue.AdminPort, nil
  17661. }
  17662. // ResetAdminPort resets all changes to the "admin_port" field.
  17663. func (m *ServerMutation) ResetAdminPort() {
  17664. m.admin_port = nil
  17665. }
  17666. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  17667. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  17668. if m.wxs == nil {
  17669. m.wxs = make(map[uint64]struct{})
  17670. }
  17671. for i := range ids {
  17672. m.wxs[ids[i]] = struct{}{}
  17673. }
  17674. }
  17675. // ClearWxs clears the "wxs" edge to the Wx entity.
  17676. func (m *ServerMutation) ClearWxs() {
  17677. m.clearedwxs = true
  17678. }
  17679. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  17680. func (m *ServerMutation) WxsCleared() bool {
  17681. return m.clearedwxs
  17682. }
  17683. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  17684. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  17685. if m.removedwxs == nil {
  17686. m.removedwxs = make(map[uint64]struct{})
  17687. }
  17688. for i := range ids {
  17689. delete(m.wxs, ids[i])
  17690. m.removedwxs[ids[i]] = struct{}{}
  17691. }
  17692. }
  17693. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  17694. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  17695. for id := range m.removedwxs {
  17696. ids = append(ids, id)
  17697. }
  17698. return
  17699. }
  17700. // WxsIDs returns the "wxs" edge IDs in the mutation.
  17701. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  17702. for id := range m.wxs {
  17703. ids = append(ids, id)
  17704. }
  17705. return
  17706. }
  17707. // ResetWxs resets all changes to the "wxs" edge.
  17708. func (m *ServerMutation) ResetWxs() {
  17709. m.wxs = nil
  17710. m.clearedwxs = false
  17711. m.removedwxs = nil
  17712. }
  17713. // Where appends a list predicates to the ServerMutation builder.
  17714. func (m *ServerMutation) Where(ps ...predicate.Server) {
  17715. m.predicates = append(m.predicates, ps...)
  17716. }
  17717. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  17718. // users can use type-assertion to append predicates that do not depend on any generated package.
  17719. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  17720. p := make([]predicate.Server, len(ps))
  17721. for i := range ps {
  17722. p[i] = ps[i]
  17723. }
  17724. m.Where(p...)
  17725. }
  17726. // Op returns the operation name.
  17727. func (m *ServerMutation) Op() Op {
  17728. return m.op
  17729. }
  17730. // SetOp allows setting the mutation operation.
  17731. func (m *ServerMutation) SetOp(op Op) {
  17732. m.op = op
  17733. }
  17734. // Type returns the node type of this mutation (Server).
  17735. func (m *ServerMutation) Type() string {
  17736. return m.typ
  17737. }
  17738. // Fields returns all fields that were changed during this mutation. Note that in
  17739. // order to get all numeric fields that were incremented/decremented, call
  17740. // AddedFields().
  17741. func (m *ServerMutation) Fields() []string {
  17742. fields := make([]string, 0, 8)
  17743. if m.created_at != nil {
  17744. fields = append(fields, server.FieldCreatedAt)
  17745. }
  17746. if m.updated_at != nil {
  17747. fields = append(fields, server.FieldUpdatedAt)
  17748. }
  17749. if m.status != nil {
  17750. fields = append(fields, server.FieldStatus)
  17751. }
  17752. if m.deleted_at != nil {
  17753. fields = append(fields, server.FieldDeletedAt)
  17754. }
  17755. if m.name != nil {
  17756. fields = append(fields, server.FieldName)
  17757. }
  17758. if m.public_ip != nil {
  17759. fields = append(fields, server.FieldPublicIP)
  17760. }
  17761. if m.private_ip != nil {
  17762. fields = append(fields, server.FieldPrivateIP)
  17763. }
  17764. if m.admin_port != nil {
  17765. fields = append(fields, server.FieldAdminPort)
  17766. }
  17767. return fields
  17768. }
  17769. // Field returns the value of a field with the given name. The second boolean
  17770. // return value indicates that this field was not set, or was not defined in the
  17771. // schema.
  17772. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  17773. switch name {
  17774. case server.FieldCreatedAt:
  17775. return m.CreatedAt()
  17776. case server.FieldUpdatedAt:
  17777. return m.UpdatedAt()
  17778. case server.FieldStatus:
  17779. return m.Status()
  17780. case server.FieldDeletedAt:
  17781. return m.DeletedAt()
  17782. case server.FieldName:
  17783. return m.Name()
  17784. case server.FieldPublicIP:
  17785. return m.PublicIP()
  17786. case server.FieldPrivateIP:
  17787. return m.PrivateIP()
  17788. case server.FieldAdminPort:
  17789. return m.AdminPort()
  17790. }
  17791. return nil, false
  17792. }
  17793. // OldField returns the old value of the field from the database. An error is
  17794. // returned if the mutation operation is not UpdateOne, or the query to the
  17795. // database failed.
  17796. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17797. switch name {
  17798. case server.FieldCreatedAt:
  17799. return m.OldCreatedAt(ctx)
  17800. case server.FieldUpdatedAt:
  17801. return m.OldUpdatedAt(ctx)
  17802. case server.FieldStatus:
  17803. return m.OldStatus(ctx)
  17804. case server.FieldDeletedAt:
  17805. return m.OldDeletedAt(ctx)
  17806. case server.FieldName:
  17807. return m.OldName(ctx)
  17808. case server.FieldPublicIP:
  17809. return m.OldPublicIP(ctx)
  17810. case server.FieldPrivateIP:
  17811. return m.OldPrivateIP(ctx)
  17812. case server.FieldAdminPort:
  17813. return m.OldAdminPort(ctx)
  17814. }
  17815. return nil, fmt.Errorf("unknown Server field %s", name)
  17816. }
  17817. // SetField sets the value of a field with the given name. It returns an error if
  17818. // the field is not defined in the schema, or if the type mismatched the field
  17819. // type.
  17820. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  17821. switch name {
  17822. case server.FieldCreatedAt:
  17823. v, ok := value.(time.Time)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.SetCreatedAt(v)
  17828. return nil
  17829. case server.FieldUpdatedAt:
  17830. v, ok := value.(time.Time)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.SetUpdatedAt(v)
  17835. return nil
  17836. case server.FieldStatus:
  17837. v, ok := value.(uint8)
  17838. if !ok {
  17839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17840. }
  17841. m.SetStatus(v)
  17842. return nil
  17843. case server.FieldDeletedAt:
  17844. v, ok := value.(time.Time)
  17845. if !ok {
  17846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17847. }
  17848. m.SetDeletedAt(v)
  17849. return nil
  17850. case server.FieldName:
  17851. v, ok := value.(string)
  17852. if !ok {
  17853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17854. }
  17855. m.SetName(v)
  17856. return nil
  17857. case server.FieldPublicIP:
  17858. v, ok := value.(string)
  17859. if !ok {
  17860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17861. }
  17862. m.SetPublicIP(v)
  17863. return nil
  17864. case server.FieldPrivateIP:
  17865. v, ok := value.(string)
  17866. if !ok {
  17867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17868. }
  17869. m.SetPrivateIP(v)
  17870. return nil
  17871. case server.FieldAdminPort:
  17872. v, ok := value.(string)
  17873. if !ok {
  17874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17875. }
  17876. m.SetAdminPort(v)
  17877. return nil
  17878. }
  17879. return fmt.Errorf("unknown Server field %s", name)
  17880. }
  17881. // AddedFields returns all numeric fields that were incremented/decremented during
  17882. // this mutation.
  17883. func (m *ServerMutation) AddedFields() []string {
  17884. var fields []string
  17885. if m.addstatus != nil {
  17886. fields = append(fields, server.FieldStatus)
  17887. }
  17888. return fields
  17889. }
  17890. // AddedField returns the numeric value that was incremented/decremented on a field
  17891. // with the given name. The second boolean return value indicates that this field
  17892. // was not set, or was not defined in the schema.
  17893. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  17894. switch name {
  17895. case server.FieldStatus:
  17896. return m.AddedStatus()
  17897. }
  17898. return nil, false
  17899. }
  17900. // AddField adds the value to the field with the given name. It returns an error if
  17901. // the field is not defined in the schema, or if the type mismatched the field
  17902. // type.
  17903. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  17904. switch name {
  17905. case server.FieldStatus:
  17906. v, ok := value.(int8)
  17907. if !ok {
  17908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17909. }
  17910. m.AddStatus(v)
  17911. return nil
  17912. }
  17913. return fmt.Errorf("unknown Server numeric field %s", name)
  17914. }
  17915. // ClearedFields returns all nullable fields that were cleared during this
  17916. // mutation.
  17917. func (m *ServerMutation) ClearedFields() []string {
  17918. var fields []string
  17919. if m.FieldCleared(server.FieldStatus) {
  17920. fields = append(fields, server.FieldStatus)
  17921. }
  17922. if m.FieldCleared(server.FieldDeletedAt) {
  17923. fields = append(fields, server.FieldDeletedAt)
  17924. }
  17925. return fields
  17926. }
  17927. // FieldCleared returns a boolean indicating if a field with the given name was
  17928. // cleared in this mutation.
  17929. func (m *ServerMutation) FieldCleared(name string) bool {
  17930. _, ok := m.clearedFields[name]
  17931. return ok
  17932. }
  17933. // ClearField clears the value of the field with the given name. It returns an
  17934. // error if the field is not defined in the schema.
  17935. func (m *ServerMutation) ClearField(name string) error {
  17936. switch name {
  17937. case server.FieldStatus:
  17938. m.ClearStatus()
  17939. return nil
  17940. case server.FieldDeletedAt:
  17941. m.ClearDeletedAt()
  17942. return nil
  17943. }
  17944. return fmt.Errorf("unknown Server nullable field %s", name)
  17945. }
  17946. // ResetField resets all changes in the mutation for the field with the given name.
  17947. // It returns an error if the field is not defined in the schema.
  17948. func (m *ServerMutation) ResetField(name string) error {
  17949. switch name {
  17950. case server.FieldCreatedAt:
  17951. m.ResetCreatedAt()
  17952. return nil
  17953. case server.FieldUpdatedAt:
  17954. m.ResetUpdatedAt()
  17955. return nil
  17956. case server.FieldStatus:
  17957. m.ResetStatus()
  17958. return nil
  17959. case server.FieldDeletedAt:
  17960. m.ResetDeletedAt()
  17961. return nil
  17962. case server.FieldName:
  17963. m.ResetName()
  17964. return nil
  17965. case server.FieldPublicIP:
  17966. m.ResetPublicIP()
  17967. return nil
  17968. case server.FieldPrivateIP:
  17969. m.ResetPrivateIP()
  17970. return nil
  17971. case server.FieldAdminPort:
  17972. m.ResetAdminPort()
  17973. return nil
  17974. }
  17975. return fmt.Errorf("unknown Server field %s", name)
  17976. }
  17977. // AddedEdges returns all edge names that were set/added in this mutation.
  17978. func (m *ServerMutation) AddedEdges() []string {
  17979. edges := make([]string, 0, 1)
  17980. if m.wxs != nil {
  17981. edges = append(edges, server.EdgeWxs)
  17982. }
  17983. return edges
  17984. }
  17985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17986. // name in this mutation.
  17987. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17988. switch name {
  17989. case server.EdgeWxs:
  17990. ids := make([]ent.Value, 0, len(m.wxs))
  17991. for id := range m.wxs {
  17992. ids = append(ids, id)
  17993. }
  17994. return ids
  17995. }
  17996. return nil
  17997. }
  17998. // RemovedEdges returns all edge names that were removed in this mutation.
  17999. func (m *ServerMutation) RemovedEdges() []string {
  18000. edges := make([]string, 0, 1)
  18001. if m.removedwxs != nil {
  18002. edges = append(edges, server.EdgeWxs)
  18003. }
  18004. return edges
  18005. }
  18006. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18007. // the given name in this mutation.
  18008. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  18009. switch name {
  18010. case server.EdgeWxs:
  18011. ids := make([]ent.Value, 0, len(m.removedwxs))
  18012. for id := range m.removedwxs {
  18013. ids = append(ids, id)
  18014. }
  18015. return ids
  18016. }
  18017. return nil
  18018. }
  18019. // ClearedEdges returns all edge names that were cleared in this mutation.
  18020. func (m *ServerMutation) ClearedEdges() []string {
  18021. edges := make([]string, 0, 1)
  18022. if m.clearedwxs {
  18023. edges = append(edges, server.EdgeWxs)
  18024. }
  18025. return edges
  18026. }
  18027. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18028. // was cleared in this mutation.
  18029. func (m *ServerMutation) EdgeCleared(name string) bool {
  18030. switch name {
  18031. case server.EdgeWxs:
  18032. return m.clearedwxs
  18033. }
  18034. return false
  18035. }
  18036. // ClearEdge clears the value of the edge with the given name. It returns an error
  18037. // if that edge is not defined in the schema.
  18038. func (m *ServerMutation) ClearEdge(name string) error {
  18039. switch name {
  18040. }
  18041. return fmt.Errorf("unknown Server unique edge %s", name)
  18042. }
  18043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18044. // It returns an error if the edge is not defined in the schema.
  18045. func (m *ServerMutation) ResetEdge(name string) error {
  18046. switch name {
  18047. case server.EdgeWxs:
  18048. m.ResetWxs()
  18049. return nil
  18050. }
  18051. return fmt.Errorf("unknown Server edge %s", name)
  18052. }
  18053. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  18054. type SopNodeMutation struct {
  18055. config
  18056. op Op
  18057. typ string
  18058. id *uint64
  18059. created_at *time.Time
  18060. updated_at *time.Time
  18061. status *uint8
  18062. addstatus *int8
  18063. deleted_at *time.Time
  18064. parent_id *uint64
  18065. addparent_id *int64
  18066. name *string
  18067. condition_type *int
  18068. addcondition_type *int
  18069. condition_list *[]string
  18070. appendcondition_list []string
  18071. no_reply_condition *uint64
  18072. addno_reply_condition *int64
  18073. no_reply_unit *string
  18074. action_message *[]custom_types.Action
  18075. appendaction_message []custom_types.Action
  18076. action_label_add *[]uint64
  18077. appendaction_label_add []uint64
  18078. action_label_del *[]uint64
  18079. appendaction_label_del []uint64
  18080. action_forward **custom_types.ActionForward
  18081. clearedFields map[string]struct{}
  18082. sop_stage *uint64
  18083. clearedsop_stage bool
  18084. node_messages map[uint64]struct{}
  18085. removednode_messages map[uint64]struct{}
  18086. clearednode_messages bool
  18087. done bool
  18088. oldValue func(context.Context) (*SopNode, error)
  18089. predicates []predicate.SopNode
  18090. }
  18091. var _ ent.Mutation = (*SopNodeMutation)(nil)
  18092. // sopnodeOption allows management of the mutation configuration using functional options.
  18093. type sopnodeOption func(*SopNodeMutation)
  18094. // newSopNodeMutation creates new mutation for the SopNode entity.
  18095. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  18096. m := &SopNodeMutation{
  18097. config: c,
  18098. op: op,
  18099. typ: TypeSopNode,
  18100. clearedFields: make(map[string]struct{}),
  18101. }
  18102. for _, opt := range opts {
  18103. opt(m)
  18104. }
  18105. return m
  18106. }
  18107. // withSopNodeID sets the ID field of the mutation.
  18108. func withSopNodeID(id uint64) sopnodeOption {
  18109. return func(m *SopNodeMutation) {
  18110. var (
  18111. err error
  18112. once sync.Once
  18113. value *SopNode
  18114. )
  18115. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  18116. once.Do(func() {
  18117. if m.done {
  18118. err = errors.New("querying old values post mutation is not allowed")
  18119. } else {
  18120. value, err = m.Client().SopNode.Get(ctx, id)
  18121. }
  18122. })
  18123. return value, err
  18124. }
  18125. m.id = &id
  18126. }
  18127. }
  18128. // withSopNode sets the old SopNode of the mutation.
  18129. func withSopNode(node *SopNode) sopnodeOption {
  18130. return func(m *SopNodeMutation) {
  18131. m.oldValue = func(context.Context) (*SopNode, error) {
  18132. return node, nil
  18133. }
  18134. m.id = &node.ID
  18135. }
  18136. }
  18137. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18138. // executed in a transaction (ent.Tx), a transactional client is returned.
  18139. func (m SopNodeMutation) Client() *Client {
  18140. client := &Client{config: m.config}
  18141. client.init()
  18142. return client
  18143. }
  18144. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18145. // it returns an error otherwise.
  18146. func (m SopNodeMutation) Tx() (*Tx, error) {
  18147. if _, ok := m.driver.(*txDriver); !ok {
  18148. return nil, errors.New("ent: mutation is not running in a transaction")
  18149. }
  18150. tx := &Tx{config: m.config}
  18151. tx.init()
  18152. return tx, nil
  18153. }
  18154. // SetID sets the value of the id field. Note that this
  18155. // operation is only accepted on creation of SopNode entities.
  18156. func (m *SopNodeMutation) SetID(id uint64) {
  18157. m.id = &id
  18158. }
  18159. // ID returns the ID value in the mutation. Note that the ID is only available
  18160. // if it was provided to the builder or after it was returned from the database.
  18161. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  18162. if m.id == nil {
  18163. return
  18164. }
  18165. return *m.id, true
  18166. }
  18167. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18168. // That means, if the mutation is applied within a transaction with an isolation level such
  18169. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18170. // or updated by the mutation.
  18171. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18172. switch {
  18173. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18174. id, exists := m.ID()
  18175. if exists {
  18176. return []uint64{id}, nil
  18177. }
  18178. fallthrough
  18179. case m.op.Is(OpUpdate | OpDelete):
  18180. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  18181. default:
  18182. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18183. }
  18184. }
  18185. // SetCreatedAt sets the "created_at" field.
  18186. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  18187. m.created_at = &t
  18188. }
  18189. // CreatedAt returns the value of the "created_at" field in the mutation.
  18190. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  18191. v := m.created_at
  18192. if v == nil {
  18193. return
  18194. }
  18195. return *v, true
  18196. }
  18197. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  18198. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18200. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18201. if !m.op.Is(OpUpdateOne) {
  18202. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18203. }
  18204. if m.id == nil || m.oldValue == nil {
  18205. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18206. }
  18207. oldValue, err := m.oldValue(ctx)
  18208. if err != nil {
  18209. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18210. }
  18211. return oldValue.CreatedAt, nil
  18212. }
  18213. // ResetCreatedAt resets all changes to the "created_at" field.
  18214. func (m *SopNodeMutation) ResetCreatedAt() {
  18215. m.created_at = nil
  18216. }
  18217. // SetUpdatedAt sets the "updated_at" field.
  18218. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  18219. m.updated_at = &t
  18220. }
  18221. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18222. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  18223. v := m.updated_at
  18224. if v == nil {
  18225. return
  18226. }
  18227. return *v, true
  18228. }
  18229. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  18230. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18232. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18233. if !m.op.Is(OpUpdateOne) {
  18234. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18235. }
  18236. if m.id == nil || m.oldValue == nil {
  18237. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18238. }
  18239. oldValue, err := m.oldValue(ctx)
  18240. if err != nil {
  18241. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18242. }
  18243. return oldValue.UpdatedAt, nil
  18244. }
  18245. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18246. func (m *SopNodeMutation) ResetUpdatedAt() {
  18247. m.updated_at = nil
  18248. }
  18249. // SetStatus sets the "status" field.
  18250. func (m *SopNodeMutation) SetStatus(u uint8) {
  18251. m.status = &u
  18252. m.addstatus = nil
  18253. }
  18254. // Status returns the value of the "status" field in the mutation.
  18255. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  18256. v := m.status
  18257. if v == nil {
  18258. return
  18259. }
  18260. return *v, true
  18261. }
  18262. // OldStatus returns the old "status" field's value of the SopNode entity.
  18263. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18265. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18266. if !m.op.Is(OpUpdateOne) {
  18267. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18268. }
  18269. if m.id == nil || m.oldValue == nil {
  18270. return v, errors.New("OldStatus requires an ID field in the mutation")
  18271. }
  18272. oldValue, err := m.oldValue(ctx)
  18273. if err != nil {
  18274. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18275. }
  18276. return oldValue.Status, nil
  18277. }
  18278. // AddStatus adds u to the "status" field.
  18279. func (m *SopNodeMutation) AddStatus(u int8) {
  18280. if m.addstatus != nil {
  18281. *m.addstatus += u
  18282. } else {
  18283. m.addstatus = &u
  18284. }
  18285. }
  18286. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18287. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  18288. v := m.addstatus
  18289. if v == nil {
  18290. return
  18291. }
  18292. return *v, true
  18293. }
  18294. // ClearStatus clears the value of the "status" field.
  18295. func (m *SopNodeMutation) ClearStatus() {
  18296. m.status = nil
  18297. m.addstatus = nil
  18298. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  18299. }
  18300. // StatusCleared returns if the "status" field was cleared in this mutation.
  18301. func (m *SopNodeMutation) StatusCleared() bool {
  18302. _, ok := m.clearedFields[sopnode.FieldStatus]
  18303. return ok
  18304. }
  18305. // ResetStatus resets all changes to the "status" field.
  18306. func (m *SopNodeMutation) ResetStatus() {
  18307. m.status = nil
  18308. m.addstatus = nil
  18309. delete(m.clearedFields, sopnode.FieldStatus)
  18310. }
  18311. // SetDeletedAt sets the "deleted_at" field.
  18312. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  18313. m.deleted_at = &t
  18314. }
  18315. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18316. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  18317. v := m.deleted_at
  18318. if v == nil {
  18319. return
  18320. }
  18321. return *v, true
  18322. }
  18323. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  18324. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18326. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18327. if !m.op.Is(OpUpdateOne) {
  18328. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18329. }
  18330. if m.id == nil || m.oldValue == nil {
  18331. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18332. }
  18333. oldValue, err := m.oldValue(ctx)
  18334. if err != nil {
  18335. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18336. }
  18337. return oldValue.DeletedAt, nil
  18338. }
  18339. // ClearDeletedAt clears the value of the "deleted_at" field.
  18340. func (m *SopNodeMutation) ClearDeletedAt() {
  18341. m.deleted_at = nil
  18342. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  18343. }
  18344. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18345. func (m *SopNodeMutation) DeletedAtCleared() bool {
  18346. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  18347. return ok
  18348. }
  18349. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18350. func (m *SopNodeMutation) ResetDeletedAt() {
  18351. m.deleted_at = nil
  18352. delete(m.clearedFields, sopnode.FieldDeletedAt)
  18353. }
  18354. // SetStageID sets the "stage_id" field.
  18355. func (m *SopNodeMutation) SetStageID(u uint64) {
  18356. m.sop_stage = &u
  18357. }
  18358. // StageID returns the value of the "stage_id" field in the mutation.
  18359. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  18360. v := m.sop_stage
  18361. if v == nil {
  18362. return
  18363. }
  18364. return *v, true
  18365. }
  18366. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  18367. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18369. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  18370. if !m.op.Is(OpUpdateOne) {
  18371. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  18372. }
  18373. if m.id == nil || m.oldValue == nil {
  18374. return v, errors.New("OldStageID requires an ID field in the mutation")
  18375. }
  18376. oldValue, err := m.oldValue(ctx)
  18377. if err != nil {
  18378. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  18379. }
  18380. return oldValue.StageID, nil
  18381. }
  18382. // ResetStageID resets all changes to the "stage_id" field.
  18383. func (m *SopNodeMutation) ResetStageID() {
  18384. m.sop_stage = nil
  18385. }
  18386. // SetParentID sets the "parent_id" field.
  18387. func (m *SopNodeMutation) SetParentID(u uint64) {
  18388. m.parent_id = &u
  18389. m.addparent_id = nil
  18390. }
  18391. // ParentID returns the value of the "parent_id" field in the mutation.
  18392. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  18393. v := m.parent_id
  18394. if v == nil {
  18395. return
  18396. }
  18397. return *v, true
  18398. }
  18399. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  18400. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18402. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  18403. if !m.op.Is(OpUpdateOne) {
  18404. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  18405. }
  18406. if m.id == nil || m.oldValue == nil {
  18407. return v, errors.New("OldParentID requires an ID field in the mutation")
  18408. }
  18409. oldValue, err := m.oldValue(ctx)
  18410. if err != nil {
  18411. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  18412. }
  18413. return oldValue.ParentID, nil
  18414. }
  18415. // AddParentID adds u to the "parent_id" field.
  18416. func (m *SopNodeMutation) AddParentID(u int64) {
  18417. if m.addparent_id != nil {
  18418. *m.addparent_id += u
  18419. } else {
  18420. m.addparent_id = &u
  18421. }
  18422. }
  18423. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  18424. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  18425. v := m.addparent_id
  18426. if v == nil {
  18427. return
  18428. }
  18429. return *v, true
  18430. }
  18431. // ResetParentID resets all changes to the "parent_id" field.
  18432. func (m *SopNodeMutation) ResetParentID() {
  18433. m.parent_id = nil
  18434. m.addparent_id = nil
  18435. }
  18436. // SetName sets the "name" field.
  18437. func (m *SopNodeMutation) SetName(s string) {
  18438. m.name = &s
  18439. }
  18440. // Name returns the value of the "name" field in the mutation.
  18441. func (m *SopNodeMutation) Name() (r string, exists bool) {
  18442. v := m.name
  18443. if v == nil {
  18444. return
  18445. }
  18446. return *v, true
  18447. }
  18448. // OldName returns the old "name" field's value of the SopNode entity.
  18449. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18451. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  18452. if !m.op.Is(OpUpdateOne) {
  18453. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18454. }
  18455. if m.id == nil || m.oldValue == nil {
  18456. return v, errors.New("OldName requires an ID field in the mutation")
  18457. }
  18458. oldValue, err := m.oldValue(ctx)
  18459. if err != nil {
  18460. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18461. }
  18462. return oldValue.Name, nil
  18463. }
  18464. // ResetName resets all changes to the "name" field.
  18465. func (m *SopNodeMutation) ResetName() {
  18466. m.name = nil
  18467. }
  18468. // SetConditionType sets the "condition_type" field.
  18469. func (m *SopNodeMutation) SetConditionType(i int) {
  18470. m.condition_type = &i
  18471. m.addcondition_type = nil
  18472. }
  18473. // ConditionType returns the value of the "condition_type" field in the mutation.
  18474. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  18475. v := m.condition_type
  18476. if v == nil {
  18477. return
  18478. }
  18479. return *v, true
  18480. }
  18481. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  18482. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18484. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18485. if !m.op.Is(OpUpdateOne) {
  18486. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18487. }
  18488. if m.id == nil || m.oldValue == nil {
  18489. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18490. }
  18491. oldValue, err := m.oldValue(ctx)
  18492. if err != nil {
  18493. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18494. }
  18495. return oldValue.ConditionType, nil
  18496. }
  18497. // AddConditionType adds i to the "condition_type" field.
  18498. func (m *SopNodeMutation) AddConditionType(i int) {
  18499. if m.addcondition_type != nil {
  18500. *m.addcondition_type += i
  18501. } else {
  18502. m.addcondition_type = &i
  18503. }
  18504. }
  18505. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18506. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  18507. v := m.addcondition_type
  18508. if v == nil {
  18509. return
  18510. }
  18511. return *v, true
  18512. }
  18513. // ResetConditionType resets all changes to the "condition_type" field.
  18514. func (m *SopNodeMutation) ResetConditionType() {
  18515. m.condition_type = nil
  18516. m.addcondition_type = nil
  18517. }
  18518. // SetConditionList sets the "condition_list" field.
  18519. func (m *SopNodeMutation) SetConditionList(s []string) {
  18520. m.condition_list = &s
  18521. m.appendcondition_list = nil
  18522. }
  18523. // ConditionList returns the value of the "condition_list" field in the mutation.
  18524. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  18525. v := m.condition_list
  18526. if v == nil {
  18527. return
  18528. }
  18529. return *v, true
  18530. }
  18531. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  18532. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18534. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  18535. if !m.op.Is(OpUpdateOne) {
  18536. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18537. }
  18538. if m.id == nil || m.oldValue == nil {
  18539. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18540. }
  18541. oldValue, err := m.oldValue(ctx)
  18542. if err != nil {
  18543. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18544. }
  18545. return oldValue.ConditionList, nil
  18546. }
  18547. // AppendConditionList adds s to the "condition_list" field.
  18548. func (m *SopNodeMutation) AppendConditionList(s []string) {
  18549. m.appendcondition_list = append(m.appendcondition_list, s...)
  18550. }
  18551. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18552. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  18553. if len(m.appendcondition_list) == 0 {
  18554. return nil, false
  18555. }
  18556. return m.appendcondition_list, true
  18557. }
  18558. // ClearConditionList clears the value of the "condition_list" field.
  18559. func (m *SopNodeMutation) ClearConditionList() {
  18560. m.condition_list = nil
  18561. m.appendcondition_list = nil
  18562. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  18563. }
  18564. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  18565. func (m *SopNodeMutation) ConditionListCleared() bool {
  18566. _, ok := m.clearedFields[sopnode.FieldConditionList]
  18567. return ok
  18568. }
  18569. // ResetConditionList resets all changes to the "condition_list" field.
  18570. func (m *SopNodeMutation) ResetConditionList() {
  18571. m.condition_list = nil
  18572. m.appendcondition_list = nil
  18573. delete(m.clearedFields, sopnode.FieldConditionList)
  18574. }
  18575. // SetNoReplyCondition sets the "no_reply_condition" field.
  18576. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  18577. m.no_reply_condition = &u
  18578. m.addno_reply_condition = nil
  18579. }
  18580. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  18581. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  18582. v := m.no_reply_condition
  18583. if v == nil {
  18584. return
  18585. }
  18586. return *v, true
  18587. }
  18588. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  18589. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18591. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  18592. if !m.op.Is(OpUpdateOne) {
  18593. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  18594. }
  18595. if m.id == nil || m.oldValue == nil {
  18596. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  18597. }
  18598. oldValue, err := m.oldValue(ctx)
  18599. if err != nil {
  18600. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  18601. }
  18602. return oldValue.NoReplyCondition, nil
  18603. }
  18604. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  18605. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  18606. if m.addno_reply_condition != nil {
  18607. *m.addno_reply_condition += u
  18608. } else {
  18609. m.addno_reply_condition = &u
  18610. }
  18611. }
  18612. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  18613. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  18614. v := m.addno_reply_condition
  18615. if v == nil {
  18616. return
  18617. }
  18618. return *v, true
  18619. }
  18620. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  18621. func (m *SopNodeMutation) ResetNoReplyCondition() {
  18622. m.no_reply_condition = nil
  18623. m.addno_reply_condition = nil
  18624. }
  18625. // SetNoReplyUnit sets the "no_reply_unit" field.
  18626. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  18627. m.no_reply_unit = &s
  18628. }
  18629. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  18630. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  18631. v := m.no_reply_unit
  18632. if v == nil {
  18633. return
  18634. }
  18635. return *v, true
  18636. }
  18637. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  18638. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18640. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  18641. if !m.op.Is(OpUpdateOne) {
  18642. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  18643. }
  18644. if m.id == nil || m.oldValue == nil {
  18645. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  18646. }
  18647. oldValue, err := m.oldValue(ctx)
  18648. if err != nil {
  18649. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  18650. }
  18651. return oldValue.NoReplyUnit, nil
  18652. }
  18653. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  18654. func (m *SopNodeMutation) ResetNoReplyUnit() {
  18655. m.no_reply_unit = nil
  18656. }
  18657. // SetActionMessage sets the "action_message" field.
  18658. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  18659. m.action_message = &ct
  18660. m.appendaction_message = nil
  18661. }
  18662. // ActionMessage returns the value of the "action_message" field in the mutation.
  18663. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18664. v := m.action_message
  18665. if v == nil {
  18666. return
  18667. }
  18668. return *v, true
  18669. }
  18670. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  18671. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18673. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18674. if !m.op.Is(OpUpdateOne) {
  18675. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18676. }
  18677. if m.id == nil || m.oldValue == nil {
  18678. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18679. }
  18680. oldValue, err := m.oldValue(ctx)
  18681. if err != nil {
  18682. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18683. }
  18684. return oldValue.ActionMessage, nil
  18685. }
  18686. // AppendActionMessage adds ct to the "action_message" field.
  18687. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  18688. m.appendaction_message = append(m.appendaction_message, ct...)
  18689. }
  18690. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18691. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18692. if len(m.appendaction_message) == 0 {
  18693. return nil, false
  18694. }
  18695. return m.appendaction_message, true
  18696. }
  18697. // ClearActionMessage clears the value of the "action_message" field.
  18698. func (m *SopNodeMutation) ClearActionMessage() {
  18699. m.action_message = nil
  18700. m.appendaction_message = nil
  18701. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  18702. }
  18703. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18704. func (m *SopNodeMutation) ActionMessageCleared() bool {
  18705. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  18706. return ok
  18707. }
  18708. // ResetActionMessage resets all changes to the "action_message" field.
  18709. func (m *SopNodeMutation) ResetActionMessage() {
  18710. m.action_message = nil
  18711. m.appendaction_message = nil
  18712. delete(m.clearedFields, sopnode.FieldActionMessage)
  18713. }
  18714. // SetActionLabelAdd sets the "action_label_add" field.
  18715. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  18716. m.action_label_add = &u
  18717. m.appendaction_label_add = nil
  18718. }
  18719. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18720. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18721. v := m.action_label_add
  18722. if v == nil {
  18723. return
  18724. }
  18725. return *v, true
  18726. }
  18727. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  18728. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18730. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18731. if !m.op.Is(OpUpdateOne) {
  18732. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18733. }
  18734. if m.id == nil || m.oldValue == nil {
  18735. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18736. }
  18737. oldValue, err := m.oldValue(ctx)
  18738. if err != nil {
  18739. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18740. }
  18741. return oldValue.ActionLabelAdd, nil
  18742. }
  18743. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18744. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  18745. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18746. }
  18747. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18748. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18749. if len(m.appendaction_label_add) == 0 {
  18750. return nil, false
  18751. }
  18752. return m.appendaction_label_add, true
  18753. }
  18754. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18755. func (m *SopNodeMutation) ClearActionLabelAdd() {
  18756. m.action_label_add = nil
  18757. m.appendaction_label_add = nil
  18758. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  18759. }
  18760. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18761. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  18762. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  18763. return ok
  18764. }
  18765. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18766. func (m *SopNodeMutation) ResetActionLabelAdd() {
  18767. m.action_label_add = nil
  18768. m.appendaction_label_add = nil
  18769. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  18770. }
  18771. // SetActionLabelDel sets the "action_label_del" field.
  18772. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  18773. m.action_label_del = &u
  18774. m.appendaction_label_del = nil
  18775. }
  18776. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18777. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  18778. v := m.action_label_del
  18779. if v == nil {
  18780. return
  18781. }
  18782. return *v, true
  18783. }
  18784. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  18785. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18787. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18788. if !m.op.Is(OpUpdateOne) {
  18789. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18790. }
  18791. if m.id == nil || m.oldValue == nil {
  18792. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18793. }
  18794. oldValue, err := m.oldValue(ctx)
  18795. if err != nil {
  18796. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18797. }
  18798. return oldValue.ActionLabelDel, nil
  18799. }
  18800. // AppendActionLabelDel adds u to the "action_label_del" field.
  18801. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  18802. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18803. }
  18804. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18805. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18806. if len(m.appendaction_label_del) == 0 {
  18807. return nil, false
  18808. }
  18809. return m.appendaction_label_del, true
  18810. }
  18811. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18812. func (m *SopNodeMutation) ClearActionLabelDel() {
  18813. m.action_label_del = nil
  18814. m.appendaction_label_del = nil
  18815. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  18816. }
  18817. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18818. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  18819. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  18820. return ok
  18821. }
  18822. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18823. func (m *SopNodeMutation) ResetActionLabelDel() {
  18824. m.action_label_del = nil
  18825. m.appendaction_label_del = nil
  18826. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  18827. }
  18828. // SetActionForward sets the "action_forward" field.
  18829. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18830. m.action_forward = &ctf
  18831. }
  18832. // ActionForward returns the value of the "action_forward" field in the mutation.
  18833. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18834. v := m.action_forward
  18835. if v == nil {
  18836. return
  18837. }
  18838. return *v, true
  18839. }
  18840. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  18841. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18843. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18844. if !m.op.Is(OpUpdateOne) {
  18845. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18846. }
  18847. if m.id == nil || m.oldValue == nil {
  18848. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18849. }
  18850. oldValue, err := m.oldValue(ctx)
  18851. if err != nil {
  18852. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18853. }
  18854. return oldValue.ActionForward, nil
  18855. }
  18856. // ClearActionForward clears the value of the "action_forward" field.
  18857. func (m *SopNodeMutation) ClearActionForward() {
  18858. m.action_forward = nil
  18859. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  18860. }
  18861. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18862. func (m *SopNodeMutation) ActionForwardCleared() bool {
  18863. _, ok := m.clearedFields[sopnode.FieldActionForward]
  18864. return ok
  18865. }
  18866. // ResetActionForward resets all changes to the "action_forward" field.
  18867. func (m *SopNodeMutation) ResetActionForward() {
  18868. m.action_forward = nil
  18869. delete(m.clearedFields, sopnode.FieldActionForward)
  18870. }
  18871. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18872. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  18873. m.sop_stage = &id
  18874. }
  18875. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18876. func (m *SopNodeMutation) ClearSopStage() {
  18877. m.clearedsop_stage = true
  18878. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  18879. }
  18880. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18881. func (m *SopNodeMutation) SopStageCleared() bool {
  18882. return m.clearedsop_stage
  18883. }
  18884. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18885. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  18886. if m.sop_stage != nil {
  18887. return *m.sop_stage, true
  18888. }
  18889. return
  18890. }
  18891. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18892. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18893. // SopStageID instead. It exists only for internal usage by the builders.
  18894. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  18895. if id := m.sop_stage; id != nil {
  18896. ids = append(ids, *id)
  18897. }
  18898. return
  18899. }
  18900. // ResetSopStage resets all changes to the "sop_stage" edge.
  18901. func (m *SopNodeMutation) ResetSopStage() {
  18902. m.sop_stage = nil
  18903. m.clearedsop_stage = false
  18904. }
  18905. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  18906. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  18907. if m.node_messages == nil {
  18908. m.node_messages = make(map[uint64]struct{})
  18909. }
  18910. for i := range ids {
  18911. m.node_messages[ids[i]] = struct{}{}
  18912. }
  18913. }
  18914. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  18915. func (m *SopNodeMutation) ClearNodeMessages() {
  18916. m.clearednode_messages = true
  18917. }
  18918. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  18919. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  18920. return m.clearednode_messages
  18921. }
  18922. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  18923. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  18924. if m.removednode_messages == nil {
  18925. m.removednode_messages = make(map[uint64]struct{})
  18926. }
  18927. for i := range ids {
  18928. delete(m.node_messages, ids[i])
  18929. m.removednode_messages[ids[i]] = struct{}{}
  18930. }
  18931. }
  18932. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  18933. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  18934. for id := range m.removednode_messages {
  18935. ids = append(ids, id)
  18936. }
  18937. return
  18938. }
  18939. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  18940. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  18941. for id := range m.node_messages {
  18942. ids = append(ids, id)
  18943. }
  18944. return
  18945. }
  18946. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18947. func (m *SopNodeMutation) ResetNodeMessages() {
  18948. m.node_messages = nil
  18949. m.clearednode_messages = false
  18950. m.removednode_messages = nil
  18951. }
  18952. // Where appends a list predicates to the SopNodeMutation builder.
  18953. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18954. m.predicates = append(m.predicates, ps...)
  18955. }
  18956. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18957. // users can use type-assertion to append predicates that do not depend on any generated package.
  18958. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18959. p := make([]predicate.SopNode, len(ps))
  18960. for i := range ps {
  18961. p[i] = ps[i]
  18962. }
  18963. m.Where(p...)
  18964. }
  18965. // Op returns the operation name.
  18966. func (m *SopNodeMutation) Op() Op {
  18967. return m.op
  18968. }
  18969. // SetOp allows setting the mutation operation.
  18970. func (m *SopNodeMutation) SetOp(op Op) {
  18971. m.op = op
  18972. }
  18973. // Type returns the node type of this mutation (SopNode).
  18974. func (m *SopNodeMutation) Type() string {
  18975. return m.typ
  18976. }
  18977. // Fields returns all fields that were changed during this mutation. Note that in
  18978. // order to get all numeric fields that were incremented/decremented, call
  18979. // AddedFields().
  18980. func (m *SopNodeMutation) Fields() []string {
  18981. fields := make([]string, 0, 15)
  18982. if m.created_at != nil {
  18983. fields = append(fields, sopnode.FieldCreatedAt)
  18984. }
  18985. if m.updated_at != nil {
  18986. fields = append(fields, sopnode.FieldUpdatedAt)
  18987. }
  18988. if m.status != nil {
  18989. fields = append(fields, sopnode.FieldStatus)
  18990. }
  18991. if m.deleted_at != nil {
  18992. fields = append(fields, sopnode.FieldDeletedAt)
  18993. }
  18994. if m.sop_stage != nil {
  18995. fields = append(fields, sopnode.FieldStageID)
  18996. }
  18997. if m.parent_id != nil {
  18998. fields = append(fields, sopnode.FieldParentID)
  18999. }
  19000. if m.name != nil {
  19001. fields = append(fields, sopnode.FieldName)
  19002. }
  19003. if m.condition_type != nil {
  19004. fields = append(fields, sopnode.FieldConditionType)
  19005. }
  19006. if m.condition_list != nil {
  19007. fields = append(fields, sopnode.FieldConditionList)
  19008. }
  19009. if m.no_reply_condition != nil {
  19010. fields = append(fields, sopnode.FieldNoReplyCondition)
  19011. }
  19012. if m.no_reply_unit != nil {
  19013. fields = append(fields, sopnode.FieldNoReplyUnit)
  19014. }
  19015. if m.action_message != nil {
  19016. fields = append(fields, sopnode.FieldActionMessage)
  19017. }
  19018. if m.action_label_add != nil {
  19019. fields = append(fields, sopnode.FieldActionLabelAdd)
  19020. }
  19021. if m.action_label_del != nil {
  19022. fields = append(fields, sopnode.FieldActionLabelDel)
  19023. }
  19024. if m.action_forward != nil {
  19025. fields = append(fields, sopnode.FieldActionForward)
  19026. }
  19027. return fields
  19028. }
  19029. // Field returns the value of a field with the given name. The second boolean
  19030. // return value indicates that this field was not set, or was not defined in the
  19031. // schema.
  19032. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  19033. switch name {
  19034. case sopnode.FieldCreatedAt:
  19035. return m.CreatedAt()
  19036. case sopnode.FieldUpdatedAt:
  19037. return m.UpdatedAt()
  19038. case sopnode.FieldStatus:
  19039. return m.Status()
  19040. case sopnode.FieldDeletedAt:
  19041. return m.DeletedAt()
  19042. case sopnode.FieldStageID:
  19043. return m.StageID()
  19044. case sopnode.FieldParentID:
  19045. return m.ParentID()
  19046. case sopnode.FieldName:
  19047. return m.Name()
  19048. case sopnode.FieldConditionType:
  19049. return m.ConditionType()
  19050. case sopnode.FieldConditionList:
  19051. return m.ConditionList()
  19052. case sopnode.FieldNoReplyCondition:
  19053. return m.NoReplyCondition()
  19054. case sopnode.FieldNoReplyUnit:
  19055. return m.NoReplyUnit()
  19056. case sopnode.FieldActionMessage:
  19057. return m.ActionMessage()
  19058. case sopnode.FieldActionLabelAdd:
  19059. return m.ActionLabelAdd()
  19060. case sopnode.FieldActionLabelDel:
  19061. return m.ActionLabelDel()
  19062. case sopnode.FieldActionForward:
  19063. return m.ActionForward()
  19064. }
  19065. return nil, false
  19066. }
  19067. // OldField returns the old value of the field from the database. An error is
  19068. // returned if the mutation operation is not UpdateOne, or the query to the
  19069. // database failed.
  19070. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19071. switch name {
  19072. case sopnode.FieldCreatedAt:
  19073. return m.OldCreatedAt(ctx)
  19074. case sopnode.FieldUpdatedAt:
  19075. return m.OldUpdatedAt(ctx)
  19076. case sopnode.FieldStatus:
  19077. return m.OldStatus(ctx)
  19078. case sopnode.FieldDeletedAt:
  19079. return m.OldDeletedAt(ctx)
  19080. case sopnode.FieldStageID:
  19081. return m.OldStageID(ctx)
  19082. case sopnode.FieldParentID:
  19083. return m.OldParentID(ctx)
  19084. case sopnode.FieldName:
  19085. return m.OldName(ctx)
  19086. case sopnode.FieldConditionType:
  19087. return m.OldConditionType(ctx)
  19088. case sopnode.FieldConditionList:
  19089. return m.OldConditionList(ctx)
  19090. case sopnode.FieldNoReplyCondition:
  19091. return m.OldNoReplyCondition(ctx)
  19092. case sopnode.FieldNoReplyUnit:
  19093. return m.OldNoReplyUnit(ctx)
  19094. case sopnode.FieldActionMessage:
  19095. return m.OldActionMessage(ctx)
  19096. case sopnode.FieldActionLabelAdd:
  19097. return m.OldActionLabelAdd(ctx)
  19098. case sopnode.FieldActionLabelDel:
  19099. return m.OldActionLabelDel(ctx)
  19100. case sopnode.FieldActionForward:
  19101. return m.OldActionForward(ctx)
  19102. }
  19103. return nil, fmt.Errorf("unknown SopNode field %s", name)
  19104. }
  19105. // SetField sets the value of a field with the given name. It returns an error if
  19106. // the field is not defined in the schema, or if the type mismatched the field
  19107. // type.
  19108. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  19109. switch name {
  19110. case sopnode.FieldCreatedAt:
  19111. v, ok := value.(time.Time)
  19112. if !ok {
  19113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19114. }
  19115. m.SetCreatedAt(v)
  19116. return nil
  19117. case sopnode.FieldUpdatedAt:
  19118. v, ok := value.(time.Time)
  19119. if !ok {
  19120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19121. }
  19122. m.SetUpdatedAt(v)
  19123. return nil
  19124. case sopnode.FieldStatus:
  19125. v, ok := value.(uint8)
  19126. if !ok {
  19127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19128. }
  19129. m.SetStatus(v)
  19130. return nil
  19131. case sopnode.FieldDeletedAt:
  19132. v, ok := value.(time.Time)
  19133. if !ok {
  19134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19135. }
  19136. m.SetDeletedAt(v)
  19137. return nil
  19138. case sopnode.FieldStageID:
  19139. v, ok := value.(uint64)
  19140. if !ok {
  19141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19142. }
  19143. m.SetStageID(v)
  19144. return nil
  19145. case sopnode.FieldParentID:
  19146. v, ok := value.(uint64)
  19147. if !ok {
  19148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19149. }
  19150. m.SetParentID(v)
  19151. return nil
  19152. case sopnode.FieldName:
  19153. v, ok := value.(string)
  19154. if !ok {
  19155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19156. }
  19157. m.SetName(v)
  19158. return nil
  19159. case sopnode.FieldConditionType:
  19160. v, ok := value.(int)
  19161. if !ok {
  19162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19163. }
  19164. m.SetConditionType(v)
  19165. return nil
  19166. case sopnode.FieldConditionList:
  19167. v, ok := value.([]string)
  19168. if !ok {
  19169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19170. }
  19171. m.SetConditionList(v)
  19172. return nil
  19173. case sopnode.FieldNoReplyCondition:
  19174. v, ok := value.(uint64)
  19175. if !ok {
  19176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19177. }
  19178. m.SetNoReplyCondition(v)
  19179. return nil
  19180. case sopnode.FieldNoReplyUnit:
  19181. v, ok := value.(string)
  19182. if !ok {
  19183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19184. }
  19185. m.SetNoReplyUnit(v)
  19186. return nil
  19187. case sopnode.FieldActionMessage:
  19188. v, ok := value.([]custom_types.Action)
  19189. if !ok {
  19190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19191. }
  19192. m.SetActionMessage(v)
  19193. return nil
  19194. case sopnode.FieldActionLabelAdd:
  19195. v, ok := value.([]uint64)
  19196. if !ok {
  19197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19198. }
  19199. m.SetActionLabelAdd(v)
  19200. return nil
  19201. case sopnode.FieldActionLabelDel:
  19202. v, ok := value.([]uint64)
  19203. if !ok {
  19204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19205. }
  19206. m.SetActionLabelDel(v)
  19207. return nil
  19208. case sopnode.FieldActionForward:
  19209. v, ok := value.(*custom_types.ActionForward)
  19210. if !ok {
  19211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19212. }
  19213. m.SetActionForward(v)
  19214. return nil
  19215. }
  19216. return fmt.Errorf("unknown SopNode field %s", name)
  19217. }
  19218. // AddedFields returns all numeric fields that were incremented/decremented during
  19219. // this mutation.
  19220. func (m *SopNodeMutation) AddedFields() []string {
  19221. var fields []string
  19222. if m.addstatus != nil {
  19223. fields = append(fields, sopnode.FieldStatus)
  19224. }
  19225. if m.addparent_id != nil {
  19226. fields = append(fields, sopnode.FieldParentID)
  19227. }
  19228. if m.addcondition_type != nil {
  19229. fields = append(fields, sopnode.FieldConditionType)
  19230. }
  19231. if m.addno_reply_condition != nil {
  19232. fields = append(fields, sopnode.FieldNoReplyCondition)
  19233. }
  19234. return fields
  19235. }
  19236. // AddedField returns the numeric value that was incremented/decremented on a field
  19237. // with the given name. The second boolean return value indicates that this field
  19238. // was not set, or was not defined in the schema.
  19239. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  19240. switch name {
  19241. case sopnode.FieldStatus:
  19242. return m.AddedStatus()
  19243. case sopnode.FieldParentID:
  19244. return m.AddedParentID()
  19245. case sopnode.FieldConditionType:
  19246. return m.AddedConditionType()
  19247. case sopnode.FieldNoReplyCondition:
  19248. return m.AddedNoReplyCondition()
  19249. }
  19250. return nil, false
  19251. }
  19252. // AddField adds the value to the field with the given name. It returns an error if
  19253. // the field is not defined in the schema, or if the type mismatched the field
  19254. // type.
  19255. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  19256. switch name {
  19257. case sopnode.FieldStatus:
  19258. v, ok := value.(int8)
  19259. if !ok {
  19260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19261. }
  19262. m.AddStatus(v)
  19263. return nil
  19264. case sopnode.FieldParentID:
  19265. v, ok := value.(int64)
  19266. if !ok {
  19267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19268. }
  19269. m.AddParentID(v)
  19270. return nil
  19271. case sopnode.FieldConditionType:
  19272. v, ok := value.(int)
  19273. if !ok {
  19274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19275. }
  19276. m.AddConditionType(v)
  19277. return nil
  19278. case sopnode.FieldNoReplyCondition:
  19279. v, ok := value.(int64)
  19280. if !ok {
  19281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19282. }
  19283. m.AddNoReplyCondition(v)
  19284. return nil
  19285. }
  19286. return fmt.Errorf("unknown SopNode numeric field %s", name)
  19287. }
  19288. // ClearedFields returns all nullable fields that were cleared during this
  19289. // mutation.
  19290. func (m *SopNodeMutation) ClearedFields() []string {
  19291. var fields []string
  19292. if m.FieldCleared(sopnode.FieldStatus) {
  19293. fields = append(fields, sopnode.FieldStatus)
  19294. }
  19295. if m.FieldCleared(sopnode.FieldDeletedAt) {
  19296. fields = append(fields, sopnode.FieldDeletedAt)
  19297. }
  19298. if m.FieldCleared(sopnode.FieldConditionList) {
  19299. fields = append(fields, sopnode.FieldConditionList)
  19300. }
  19301. if m.FieldCleared(sopnode.FieldActionMessage) {
  19302. fields = append(fields, sopnode.FieldActionMessage)
  19303. }
  19304. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  19305. fields = append(fields, sopnode.FieldActionLabelAdd)
  19306. }
  19307. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  19308. fields = append(fields, sopnode.FieldActionLabelDel)
  19309. }
  19310. if m.FieldCleared(sopnode.FieldActionForward) {
  19311. fields = append(fields, sopnode.FieldActionForward)
  19312. }
  19313. return fields
  19314. }
  19315. // FieldCleared returns a boolean indicating if a field with the given name was
  19316. // cleared in this mutation.
  19317. func (m *SopNodeMutation) FieldCleared(name string) bool {
  19318. _, ok := m.clearedFields[name]
  19319. return ok
  19320. }
  19321. // ClearField clears the value of the field with the given name. It returns an
  19322. // error if the field is not defined in the schema.
  19323. func (m *SopNodeMutation) ClearField(name string) error {
  19324. switch name {
  19325. case sopnode.FieldStatus:
  19326. m.ClearStatus()
  19327. return nil
  19328. case sopnode.FieldDeletedAt:
  19329. m.ClearDeletedAt()
  19330. return nil
  19331. case sopnode.FieldConditionList:
  19332. m.ClearConditionList()
  19333. return nil
  19334. case sopnode.FieldActionMessage:
  19335. m.ClearActionMessage()
  19336. return nil
  19337. case sopnode.FieldActionLabelAdd:
  19338. m.ClearActionLabelAdd()
  19339. return nil
  19340. case sopnode.FieldActionLabelDel:
  19341. m.ClearActionLabelDel()
  19342. return nil
  19343. case sopnode.FieldActionForward:
  19344. m.ClearActionForward()
  19345. return nil
  19346. }
  19347. return fmt.Errorf("unknown SopNode nullable field %s", name)
  19348. }
  19349. // ResetField resets all changes in the mutation for the field with the given name.
  19350. // It returns an error if the field is not defined in the schema.
  19351. func (m *SopNodeMutation) ResetField(name string) error {
  19352. switch name {
  19353. case sopnode.FieldCreatedAt:
  19354. m.ResetCreatedAt()
  19355. return nil
  19356. case sopnode.FieldUpdatedAt:
  19357. m.ResetUpdatedAt()
  19358. return nil
  19359. case sopnode.FieldStatus:
  19360. m.ResetStatus()
  19361. return nil
  19362. case sopnode.FieldDeletedAt:
  19363. m.ResetDeletedAt()
  19364. return nil
  19365. case sopnode.FieldStageID:
  19366. m.ResetStageID()
  19367. return nil
  19368. case sopnode.FieldParentID:
  19369. m.ResetParentID()
  19370. return nil
  19371. case sopnode.FieldName:
  19372. m.ResetName()
  19373. return nil
  19374. case sopnode.FieldConditionType:
  19375. m.ResetConditionType()
  19376. return nil
  19377. case sopnode.FieldConditionList:
  19378. m.ResetConditionList()
  19379. return nil
  19380. case sopnode.FieldNoReplyCondition:
  19381. m.ResetNoReplyCondition()
  19382. return nil
  19383. case sopnode.FieldNoReplyUnit:
  19384. m.ResetNoReplyUnit()
  19385. return nil
  19386. case sopnode.FieldActionMessage:
  19387. m.ResetActionMessage()
  19388. return nil
  19389. case sopnode.FieldActionLabelAdd:
  19390. m.ResetActionLabelAdd()
  19391. return nil
  19392. case sopnode.FieldActionLabelDel:
  19393. m.ResetActionLabelDel()
  19394. return nil
  19395. case sopnode.FieldActionForward:
  19396. m.ResetActionForward()
  19397. return nil
  19398. }
  19399. return fmt.Errorf("unknown SopNode field %s", name)
  19400. }
  19401. // AddedEdges returns all edge names that were set/added in this mutation.
  19402. func (m *SopNodeMutation) AddedEdges() []string {
  19403. edges := make([]string, 0, 2)
  19404. if m.sop_stage != nil {
  19405. edges = append(edges, sopnode.EdgeSopStage)
  19406. }
  19407. if m.node_messages != nil {
  19408. edges = append(edges, sopnode.EdgeNodeMessages)
  19409. }
  19410. return edges
  19411. }
  19412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19413. // name in this mutation.
  19414. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  19415. switch name {
  19416. case sopnode.EdgeSopStage:
  19417. if id := m.sop_stage; id != nil {
  19418. return []ent.Value{*id}
  19419. }
  19420. case sopnode.EdgeNodeMessages:
  19421. ids := make([]ent.Value, 0, len(m.node_messages))
  19422. for id := range m.node_messages {
  19423. ids = append(ids, id)
  19424. }
  19425. return ids
  19426. }
  19427. return nil
  19428. }
  19429. // RemovedEdges returns all edge names that were removed in this mutation.
  19430. func (m *SopNodeMutation) RemovedEdges() []string {
  19431. edges := make([]string, 0, 2)
  19432. if m.removednode_messages != nil {
  19433. edges = append(edges, sopnode.EdgeNodeMessages)
  19434. }
  19435. return edges
  19436. }
  19437. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19438. // the given name in this mutation.
  19439. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  19440. switch name {
  19441. case sopnode.EdgeNodeMessages:
  19442. ids := make([]ent.Value, 0, len(m.removednode_messages))
  19443. for id := range m.removednode_messages {
  19444. ids = append(ids, id)
  19445. }
  19446. return ids
  19447. }
  19448. return nil
  19449. }
  19450. // ClearedEdges returns all edge names that were cleared in this mutation.
  19451. func (m *SopNodeMutation) ClearedEdges() []string {
  19452. edges := make([]string, 0, 2)
  19453. if m.clearedsop_stage {
  19454. edges = append(edges, sopnode.EdgeSopStage)
  19455. }
  19456. if m.clearednode_messages {
  19457. edges = append(edges, sopnode.EdgeNodeMessages)
  19458. }
  19459. return edges
  19460. }
  19461. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19462. // was cleared in this mutation.
  19463. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  19464. switch name {
  19465. case sopnode.EdgeSopStage:
  19466. return m.clearedsop_stage
  19467. case sopnode.EdgeNodeMessages:
  19468. return m.clearednode_messages
  19469. }
  19470. return false
  19471. }
  19472. // ClearEdge clears the value of the edge with the given name. It returns an error
  19473. // if that edge is not defined in the schema.
  19474. func (m *SopNodeMutation) ClearEdge(name string) error {
  19475. switch name {
  19476. case sopnode.EdgeSopStage:
  19477. m.ClearSopStage()
  19478. return nil
  19479. }
  19480. return fmt.Errorf("unknown SopNode unique edge %s", name)
  19481. }
  19482. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19483. // It returns an error if the edge is not defined in the schema.
  19484. func (m *SopNodeMutation) ResetEdge(name string) error {
  19485. switch name {
  19486. case sopnode.EdgeSopStage:
  19487. m.ResetSopStage()
  19488. return nil
  19489. case sopnode.EdgeNodeMessages:
  19490. m.ResetNodeMessages()
  19491. return nil
  19492. }
  19493. return fmt.Errorf("unknown SopNode edge %s", name)
  19494. }
  19495. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  19496. type SopStageMutation struct {
  19497. config
  19498. op Op
  19499. typ string
  19500. id *uint64
  19501. created_at *time.Time
  19502. updated_at *time.Time
  19503. status *uint8
  19504. addstatus *int8
  19505. deleted_at *time.Time
  19506. name *string
  19507. condition_type *int
  19508. addcondition_type *int
  19509. condition_operator *int
  19510. addcondition_operator *int
  19511. condition_list *[]custom_types.Condition
  19512. appendcondition_list []custom_types.Condition
  19513. action_message *[]custom_types.Action
  19514. appendaction_message []custom_types.Action
  19515. action_label_add *[]uint64
  19516. appendaction_label_add []uint64
  19517. action_label_del *[]uint64
  19518. appendaction_label_del []uint64
  19519. action_forward **custom_types.ActionForward
  19520. index_sort *int
  19521. addindex_sort *int
  19522. clearedFields map[string]struct{}
  19523. sop_task *uint64
  19524. clearedsop_task bool
  19525. stage_nodes map[uint64]struct{}
  19526. removedstage_nodes map[uint64]struct{}
  19527. clearedstage_nodes bool
  19528. stage_messages map[uint64]struct{}
  19529. removedstage_messages map[uint64]struct{}
  19530. clearedstage_messages bool
  19531. done bool
  19532. oldValue func(context.Context) (*SopStage, error)
  19533. predicates []predicate.SopStage
  19534. }
  19535. var _ ent.Mutation = (*SopStageMutation)(nil)
  19536. // sopstageOption allows management of the mutation configuration using functional options.
  19537. type sopstageOption func(*SopStageMutation)
  19538. // newSopStageMutation creates new mutation for the SopStage entity.
  19539. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  19540. m := &SopStageMutation{
  19541. config: c,
  19542. op: op,
  19543. typ: TypeSopStage,
  19544. clearedFields: make(map[string]struct{}),
  19545. }
  19546. for _, opt := range opts {
  19547. opt(m)
  19548. }
  19549. return m
  19550. }
  19551. // withSopStageID sets the ID field of the mutation.
  19552. func withSopStageID(id uint64) sopstageOption {
  19553. return func(m *SopStageMutation) {
  19554. var (
  19555. err error
  19556. once sync.Once
  19557. value *SopStage
  19558. )
  19559. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  19560. once.Do(func() {
  19561. if m.done {
  19562. err = errors.New("querying old values post mutation is not allowed")
  19563. } else {
  19564. value, err = m.Client().SopStage.Get(ctx, id)
  19565. }
  19566. })
  19567. return value, err
  19568. }
  19569. m.id = &id
  19570. }
  19571. }
  19572. // withSopStage sets the old SopStage of the mutation.
  19573. func withSopStage(node *SopStage) sopstageOption {
  19574. return func(m *SopStageMutation) {
  19575. m.oldValue = func(context.Context) (*SopStage, error) {
  19576. return node, nil
  19577. }
  19578. m.id = &node.ID
  19579. }
  19580. }
  19581. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19582. // executed in a transaction (ent.Tx), a transactional client is returned.
  19583. func (m SopStageMutation) Client() *Client {
  19584. client := &Client{config: m.config}
  19585. client.init()
  19586. return client
  19587. }
  19588. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19589. // it returns an error otherwise.
  19590. func (m SopStageMutation) Tx() (*Tx, error) {
  19591. if _, ok := m.driver.(*txDriver); !ok {
  19592. return nil, errors.New("ent: mutation is not running in a transaction")
  19593. }
  19594. tx := &Tx{config: m.config}
  19595. tx.init()
  19596. return tx, nil
  19597. }
  19598. // SetID sets the value of the id field. Note that this
  19599. // operation is only accepted on creation of SopStage entities.
  19600. func (m *SopStageMutation) SetID(id uint64) {
  19601. m.id = &id
  19602. }
  19603. // ID returns the ID value in the mutation. Note that the ID is only available
  19604. // if it was provided to the builder or after it was returned from the database.
  19605. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  19606. if m.id == nil {
  19607. return
  19608. }
  19609. return *m.id, true
  19610. }
  19611. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19612. // That means, if the mutation is applied within a transaction with an isolation level such
  19613. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19614. // or updated by the mutation.
  19615. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  19616. switch {
  19617. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19618. id, exists := m.ID()
  19619. if exists {
  19620. return []uint64{id}, nil
  19621. }
  19622. fallthrough
  19623. case m.op.Is(OpUpdate | OpDelete):
  19624. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  19625. default:
  19626. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19627. }
  19628. }
  19629. // SetCreatedAt sets the "created_at" field.
  19630. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  19631. m.created_at = &t
  19632. }
  19633. // CreatedAt returns the value of the "created_at" field in the mutation.
  19634. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  19635. v := m.created_at
  19636. if v == nil {
  19637. return
  19638. }
  19639. return *v, true
  19640. }
  19641. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  19642. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19644. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19645. if !m.op.Is(OpUpdateOne) {
  19646. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19647. }
  19648. if m.id == nil || m.oldValue == nil {
  19649. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19650. }
  19651. oldValue, err := m.oldValue(ctx)
  19652. if err != nil {
  19653. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19654. }
  19655. return oldValue.CreatedAt, nil
  19656. }
  19657. // ResetCreatedAt resets all changes to the "created_at" field.
  19658. func (m *SopStageMutation) ResetCreatedAt() {
  19659. m.created_at = nil
  19660. }
  19661. // SetUpdatedAt sets the "updated_at" field.
  19662. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  19663. m.updated_at = &t
  19664. }
  19665. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19666. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  19667. v := m.updated_at
  19668. if v == nil {
  19669. return
  19670. }
  19671. return *v, true
  19672. }
  19673. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  19674. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19676. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19677. if !m.op.Is(OpUpdateOne) {
  19678. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19679. }
  19680. if m.id == nil || m.oldValue == nil {
  19681. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19682. }
  19683. oldValue, err := m.oldValue(ctx)
  19684. if err != nil {
  19685. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19686. }
  19687. return oldValue.UpdatedAt, nil
  19688. }
  19689. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19690. func (m *SopStageMutation) ResetUpdatedAt() {
  19691. m.updated_at = nil
  19692. }
  19693. // SetStatus sets the "status" field.
  19694. func (m *SopStageMutation) SetStatus(u uint8) {
  19695. m.status = &u
  19696. m.addstatus = nil
  19697. }
  19698. // Status returns the value of the "status" field in the mutation.
  19699. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  19700. v := m.status
  19701. if v == nil {
  19702. return
  19703. }
  19704. return *v, true
  19705. }
  19706. // OldStatus returns the old "status" field's value of the SopStage entity.
  19707. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19709. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19710. if !m.op.Is(OpUpdateOne) {
  19711. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19712. }
  19713. if m.id == nil || m.oldValue == nil {
  19714. return v, errors.New("OldStatus requires an ID field in the mutation")
  19715. }
  19716. oldValue, err := m.oldValue(ctx)
  19717. if err != nil {
  19718. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19719. }
  19720. return oldValue.Status, nil
  19721. }
  19722. // AddStatus adds u to the "status" field.
  19723. func (m *SopStageMutation) AddStatus(u int8) {
  19724. if m.addstatus != nil {
  19725. *m.addstatus += u
  19726. } else {
  19727. m.addstatus = &u
  19728. }
  19729. }
  19730. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19731. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  19732. v := m.addstatus
  19733. if v == nil {
  19734. return
  19735. }
  19736. return *v, true
  19737. }
  19738. // ClearStatus clears the value of the "status" field.
  19739. func (m *SopStageMutation) ClearStatus() {
  19740. m.status = nil
  19741. m.addstatus = nil
  19742. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  19743. }
  19744. // StatusCleared returns if the "status" field was cleared in this mutation.
  19745. func (m *SopStageMutation) StatusCleared() bool {
  19746. _, ok := m.clearedFields[sopstage.FieldStatus]
  19747. return ok
  19748. }
  19749. // ResetStatus resets all changes to the "status" field.
  19750. func (m *SopStageMutation) ResetStatus() {
  19751. m.status = nil
  19752. m.addstatus = nil
  19753. delete(m.clearedFields, sopstage.FieldStatus)
  19754. }
  19755. // SetDeletedAt sets the "deleted_at" field.
  19756. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  19757. m.deleted_at = &t
  19758. }
  19759. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19760. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  19761. v := m.deleted_at
  19762. if v == nil {
  19763. return
  19764. }
  19765. return *v, true
  19766. }
  19767. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  19768. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19770. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19771. if !m.op.Is(OpUpdateOne) {
  19772. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19773. }
  19774. if m.id == nil || m.oldValue == nil {
  19775. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19776. }
  19777. oldValue, err := m.oldValue(ctx)
  19778. if err != nil {
  19779. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19780. }
  19781. return oldValue.DeletedAt, nil
  19782. }
  19783. // ClearDeletedAt clears the value of the "deleted_at" field.
  19784. func (m *SopStageMutation) ClearDeletedAt() {
  19785. m.deleted_at = nil
  19786. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  19787. }
  19788. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19789. func (m *SopStageMutation) DeletedAtCleared() bool {
  19790. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  19791. return ok
  19792. }
  19793. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19794. func (m *SopStageMutation) ResetDeletedAt() {
  19795. m.deleted_at = nil
  19796. delete(m.clearedFields, sopstage.FieldDeletedAt)
  19797. }
  19798. // SetTaskID sets the "task_id" field.
  19799. func (m *SopStageMutation) SetTaskID(u uint64) {
  19800. m.sop_task = &u
  19801. }
  19802. // TaskID returns the value of the "task_id" field in the mutation.
  19803. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  19804. v := m.sop_task
  19805. if v == nil {
  19806. return
  19807. }
  19808. return *v, true
  19809. }
  19810. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  19811. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19813. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  19814. if !m.op.Is(OpUpdateOne) {
  19815. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  19816. }
  19817. if m.id == nil || m.oldValue == nil {
  19818. return v, errors.New("OldTaskID requires an ID field in the mutation")
  19819. }
  19820. oldValue, err := m.oldValue(ctx)
  19821. if err != nil {
  19822. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  19823. }
  19824. return oldValue.TaskID, nil
  19825. }
  19826. // ResetTaskID resets all changes to the "task_id" field.
  19827. func (m *SopStageMutation) ResetTaskID() {
  19828. m.sop_task = nil
  19829. }
  19830. // SetName sets the "name" field.
  19831. func (m *SopStageMutation) SetName(s string) {
  19832. m.name = &s
  19833. }
  19834. // Name returns the value of the "name" field in the mutation.
  19835. func (m *SopStageMutation) Name() (r string, exists bool) {
  19836. v := m.name
  19837. if v == nil {
  19838. return
  19839. }
  19840. return *v, true
  19841. }
  19842. // OldName returns the old "name" field's value of the SopStage entity.
  19843. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19845. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  19846. if !m.op.Is(OpUpdateOne) {
  19847. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19848. }
  19849. if m.id == nil || m.oldValue == nil {
  19850. return v, errors.New("OldName requires an ID field in the mutation")
  19851. }
  19852. oldValue, err := m.oldValue(ctx)
  19853. if err != nil {
  19854. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19855. }
  19856. return oldValue.Name, nil
  19857. }
  19858. // ResetName resets all changes to the "name" field.
  19859. func (m *SopStageMutation) ResetName() {
  19860. m.name = nil
  19861. }
  19862. // SetConditionType sets the "condition_type" field.
  19863. func (m *SopStageMutation) SetConditionType(i int) {
  19864. m.condition_type = &i
  19865. m.addcondition_type = nil
  19866. }
  19867. // ConditionType returns the value of the "condition_type" field in the mutation.
  19868. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  19869. v := m.condition_type
  19870. if v == nil {
  19871. return
  19872. }
  19873. return *v, true
  19874. }
  19875. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  19876. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19878. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  19879. if !m.op.Is(OpUpdateOne) {
  19880. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  19881. }
  19882. if m.id == nil || m.oldValue == nil {
  19883. return v, errors.New("OldConditionType requires an ID field in the mutation")
  19884. }
  19885. oldValue, err := m.oldValue(ctx)
  19886. if err != nil {
  19887. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  19888. }
  19889. return oldValue.ConditionType, nil
  19890. }
  19891. // AddConditionType adds i to the "condition_type" field.
  19892. func (m *SopStageMutation) AddConditionType(i int) {
  19893. if m.addcondition_type != nil {
  19894. *m.addcondition_type += i
  19895. } else {
  19896. m.addcondition_type = &i
  19897. }
  19898. }
  19899. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  19900. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  19901. v := m.addcondition_type
  19902. if v == nil {
  19903. return
  19904. }
  19905. return *v, true
  19906. }
  19907. // ResetConditionType resets all changes to the "condition_type" field.
  19908. func (m *SopStageMutation) ResetConditionType() {
  19909. m.condition_type = nil
  19910. m.addcondition_type = nil
  19911. }
  19912. // SetConditionOperator sets the "condition_operator" field.
  19913. func (m *SopStageMutation) SetConditionOperator(i int) {
  19914. m.condition_operator = &i
  19915. m.addcondition_operator = nil
  19916. }
  19917. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  19918. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  19919. v := m.condition_operator
  19920. if v == nil {
  19921. return
  19922. }
  19923. return *v, true
  19924. }
  19925. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  19926. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19928. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  19929. if !m.op.Is(OpUpdateOne) {
  19930. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  19931. }
  19932. if m.id == nil || m.oldValue == nil {
  19933. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  19934. }
  19935. oldValue, err := m.oldValue(ctx)
  19936. if err != nil {
  19937. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  19938. }
  19939. return oldValue.ConditionOperator, nil
  19940. }
  19941. // AddConditionOperator adds i to the "condition_operator" field.
  19942. func (m *SopStageMutation) AddConditionOperator(i int) {
  19943. if m.addcondition_operator != nil {
  19944. *m.addcondition_operator += i
  19945. } else {
  19946. m.addcondition_operator = &i
  19947. }
  19948. }
  19949. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19950. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19951. v := m.addcondition_operator
  19952. if v == nil {
  19953. return
  19954. }
  19955. return *v, true
  19956. }
  19957. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19958. func (m *SopStageMutation) ResetConditionOperator() {
  19959. m.condition_operator = nil
  19960. m.addcondition_operator = nil
  19961. }
  19962. // SetConditionList sets the "condition_list" field.
  19963. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19964. m.condition_list = &ct
  19965. m.appendcondition_list = nil
  19966. }
  19967. // ConditionList returns the value of the "condition_list" field in the mutation.
  19968. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19969. v := m.condition_list
  19970. if v == nil {
  19971. return
  19972. }
  19973. return *v, true
  19974. }
  19975. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19976. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19978. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19979. if !m.op.Is(OpUpdateOne) {
  19980. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19981. }
  19982. if m.id == nil || m.oldValue == nil {
  19983. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19984. }
  19985. oldValue, err := m.oldValue(ctx)
  19986. if err != nil {
  19987. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19988. }
  19989. return oldValue.ConditionList, nil
  19990. }
  19991. // AppendConditionList adds ct to the "condition_list" field.
  19992. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19993. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19994. }
  19995. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19996. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19997. if len(m.appendcondition_list) == 0 {
  19998. return nil, false
  19999. }
  20000. return m.appendcondition_list, true
  20001. }
  20002. // ResetConditionList resets all changes to the "condition_list" field.
  20003. func (m *SopStageMutation) ResetConditionList() {
  20004. m.condition_list = nil
  20005. m.appendcondition_list = nil
  20006. }
  20007. // SetActionMessage sets the "action_message" field.
  20008. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  20009. m.action_message = &ct
  20010. m.appendaction_message = nil
  20011. }
  20012. // ActionMessage returns the value of the "action_message" field in the mutation.
  20013. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  20014. v := m.action_message
  20015. if v == nil {
  20016. return
  20017. }
  20018. return *v, true
  20019. }
  20020. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  20021. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20023. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  20024. if !m.op.Is(OpUpdateOne) {
  20025. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  20026. }
  20027. if m.id == nil || m.oldValue == nil {
  20028. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  20029. }
  20030. oldValue, err := m.oldValue(ctx)
  20031. if err != nil {
  20032. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  20033. }
  20034. return oldValue.ActionMessage, nil
  20035. }
  20036. // AppendActionMessage adds ct to the "action_message" field.
  20037. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  20038. m.appendaction_message = append(m.appendaction_message, ct...)
  20039. }
  20040. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  20041. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  20042. if len(m.appendaction_message) == 0 {
  20043. return nil, false
  20044. }
  20045. return m.appendaction_message, true
  20046. }
  20047. // ClearActionMessage clears the value of the "action_message" field.
  20048. func (m *SopStageMutation) ClearActionMessage() {
  20049. m.action_message = nil
  20050. m.appendaction_message = nil
  20051. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  20052. }
  20053. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  20054. func (m *SopStageMutation) ActionMessageCleared() bool {
  20055. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  20056. return ok
  20057. }
  20058. // ResetActionMessage resets all changes to the "action_message" field.
  20059. func (m *SopStageMutation) ResetActionMessage() {
  20060. m.action_message = nil
  20061. m.appendaction_message = nil
  20062. delete(m.clearedFields, sopstage.FieldActionMessage)
  20063. }
  20064. // SetActionLabelAdd sets the "action_label_add" field.
  20065. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  20066. m.action_label_add = &u
  20067. m.appendaction_label_add = nil
  20068. }
  20069. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  20070. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  20071. v := m.action_label_add
  20072. if v == nil {
  20073. return
  20074. }
  20075. return *v, true
  20076. }
  20077. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  20078. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20080. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  20081. if !m.op.Is(OpUpdateOne) {
  20082. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  20083. }
  20084. if m.id == nil || m.oldValue == nil {
  20085. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  20086. }
  20087. oldValue, err := m.oldValue(ctx)
  20088. if err != nil {
  20089. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  20090. }
  20091. return oldValue.ActionLabelAdd, nil
  20092. }
  20093. // AppendActionLabelAdd adds u to the "action_label_add" field.
  20094. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  20095. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  20096. }
  20097. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  20098. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  20099. if len(m.appendaction_label_add) == 0 {
  20100. return nil, false
  20101. }
  20102. return m.appendaction_label_add, true
  20103. }
  20104. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  20105. func (m *SopStageMutation) ClearActionLabelAdd() {
  20106. m.action_label_add = nil
  20107. m.appendaction_label_add = nil
  20108. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  20109. }
  20110. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  20111. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  20112. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  20113. return ok
  20114. }
  20115. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  20116. func (m *SopStageMutation) ResetActionLabelAdd() {
  20117. m.action_label_add = nil
  20118. m.appendaction_label_add = nil
  20119. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  20120. }
  20121. // SetActionLabelDel sets the "action_label_del" field.
  20122. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  20123. m.action_label_del = &u
  20124. m.appendaction_label_del = nil
  20125. }
  20126. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  20127. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  20128. v := m.action_label_del
  20129. if v == nil {
  20130. return
  20131. }
  20132. return *v, true
  20133. }
  20134. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  20135. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20137. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  20138. if !m.op.Is(OpUpdateOne) {
  20139. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  20140. }
  20141. if m.id == nil || m.oldValue == nil {
  20142. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  20143. }
  20144. oldValue, err := m.oldValue(ctx)
  20145. if err != nil {
  20146. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  20147. }
  20148. return oldValue.ActionLabelDel, nil
  20149. }
  20150. // AppendActionLabelDel adds u to the "action_label_del" field.
  20151. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  20152. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  20153. }
  20154. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  20155. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  20156. if len(m.appendaction_label_del) == 0 {
  20157. return nil, false
  20158. }
  20159. return m.appendaction_label_del, true
  20160. }
  20161. // ClearActionLabelDel clears the value of the "action_label_del" field.
  20162. func (m *SopStageMutation) ClearActionLabelDel() {
  20163. m.action_label_del = nil
  20164. m.appendaction_label_del = nil
  20165. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  20166. }
  20167. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  20168. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  20169. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  20170. return ok
  20171. }
  20172. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  20173. func (m *SopStageMutation) ResetActionLabelDel() {
  20174. m.action_label_del = nil
  20175. m.appendaction_label_del = nil
  20176. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  20177. }
  20178. // SetActionForward sets the "action_forward" field.
  20179. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  20180. m.action_forward = &ctf
  20181. }
  20182. // ActionForward returns the value of the "action_forward" field in the mutation.
  20183. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  20184. v := m.action_forward
  20185. if v == nil {
  20186. return
  20187. }
  20188. return *v, true
  20189. }
  20190. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  20191. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20193. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  20194. if !m.op.Is(OpUpdateOne) {
  20195. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  20196. }
  20197. if m.id == nil || m.oldValue == nil {
  20198. return v, errors.New("OldActionForward requires an ID field in the mutation")
  20199. }
  20200. oldValue, err := m.oldValue(ctx)
  20201. if err != nil {
  20202. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  20203. }
  20204. return oldValue.ActionForward, nil
  20205. }
  20206. // ClearActionForward clears the value of the "action_forward" field.
  20207. func (m *SopStageMutation) ClearActionForward() {
  20208. m.action_forward = nil
  20209. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  20210. }
  20211. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  20212. func (m *SopStageMutation) ActionForwardCleared() bool {
  20213. _, ok := m.clearedFields[sopstage.FieldActionForward]
  20214. return ok
  20215. }
  20216. // ResetActionForward resets all changes to the "action_forward" field.
  20217. func (m *SopStageMutation) ResetActionForward() {
  20218. m.action_forward = nil
  20219. delete(m.clearedFields, sopstage.FieldActionForward)
  20220. }
  20221. // SetIndexSort sets the "index_sort" field.
  20222. func (m *SopStageMutation) SetIndexSort(i int) {
  20223. m.index_sort = &i
  20224. m.addindex_sort = nil
  20225. }
  20226. // IndexSort returns the value of the "index_sort" field in the mutation.
  20227. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  20228. v := m.index_sort
  20229. if v == nil {
  20230. return
  20231. }
  20232. return *v, true
  20233. }
  20234. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  20235. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20237. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  20238. if !m.op.Is(OpUpdateOne) {
  20239. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  20240. }
  20241. if m.id == nil || m.oldValue == nil {
  20242. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  20243. }
  20244. oldValue, err := m.oldValue(ctx)
  20245. if err != nil {
  20246. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  20247. }
  20248. return oldValue.IndexSort, nil
  20249. }
  20250. // AddIndexSort adds i to the "index_sort" field.
  20251. func (m *SopStageMutation) AddIndexSort(i int) {
  20252. if m.addindex_sort != nil {
  20253. *m.addindex_sort += i
  20254. } else {
  20255. m.addindex_sort = &i
  20256. }
  20257. }
  20258. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  20259. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  20260. v := m.addindex_sort
  20261. if v == nil {
  20262. return
  20263. }
  20264. return *v, true
  20265. }
  20266. // ClearIndexSort clears the value of the "index_sort" field.
  20267. func (m *SopStageMutation) ClearIndexSort() {
  20268. m.index_sort = nil
  20269. m.addindex_sort = nil
  20270. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  20271. }
  20272. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  20273. func (m *SopStageMutation) IndexSortCleared() bool {
  20274. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  20275. return ok
  20276. }
  20277. // ResetIndexSort resets all changes to the "index_sort" field.
  20278. func (m *SopStageMutation) ResetIndexSort() {
  20279. m.index_sort = nil
  20280. m.addindex_sort = nil
  20281. delete(m.clearedFields, sopstage.FieldIndexSort)
  20282. }
  20283. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  20284. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  20285. m.sop_task = &id
  20286. }
  20287. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  20288. func (m *SopStageMutation) ClearSopTask() {
  20289. m.clearedsop_task = true
  20290. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  20291. }
  20292. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  20293. func (m *SopStageMutation) SopTaskCleared() bool {
  20294. return m.clearedsop_task
  20295. }
  20296. // SopTaskID returns the "sop_task" edge ID in the mutation.
  20297. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  20298. if m.sop_task != nil {
  20299. return *m.sop_task, true
  20300. }
  20301. return
  20302. }
  20303. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  20304. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20305. // SopTaskID instead. It exists only for internal usage by the builders.
  20306. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  20307. if id := m.sop_task; id != nil {
  20308. ids = append(ids, *id)
  20309. }
  20310. return
  20311. }
  20312. // ResetSopTask resets all changes to the "sop_task" edge.
  20313. func (m *SopStageMutation) ResetSopTask() {
  20314. m.sop_task = nil
  20315. m.clearedsop_task = false
  20316. }
  20317. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  20318. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  20319. if m.stage_nodes == nil {
  20320. m.stage_nodes = make(map[uint64]struct{})
  20321. }
  20322. for i := range ids {
  20323. m.stage_nodes[ids[i]] = struct{}{}
  20324. }
  20325. }
  20326. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  20327. func (m *SopStageMutation) ClearStageNodes() {
  20328. m.clearedstage_nodes = true
  20329. }
  20330. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  20331. func (m *SopStageMutation) StageNodesCleared() bool {
  20332. return m.clearedstage_nodes
  20333. }
  20334. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  20335. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  20336. if m.removedstage_nodes == nil {
  20337. m.removedstage_nodes = make(map[uint64]struct{})
  20338. }
  20339. for i := range ids {
  20340. delete(m.stage_nodes, ids[i])
  20341. m.removedstage_nodes[ids[i]] = struct{}{}
  20342. }
  20343. }
  20344. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  20345. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  20346. for id := range m.removedstage_nodes {
  20347. ids = append(ids, id)
  20348. }
  20349. return
  20350. }
  20351. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  20352. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  20353. for id := range m.stage_nodes {
  20354. ids = append(ids, id)
  20355. }
  20356. return
  20357. }
  20358. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  20359. func (m *SopStageMutation) ResetStageNodes() {
  20360. m.stage_nodes = nil
  20361. m.clearedstage_nodes = false
  20362. m.removedstage_nodes = nil
  20363. }
  20364. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  20365. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  20366. if m.stage_messages == nil {
  20367. m.stage_messages = make(map[uint64]struct{})
  20368. }
  20369. for i := range ids {
  20370. m.stage_messages[ids[i]] = struct{}{}
  20371. }
  20372. }
  20373. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  20374. func (m *SopStageMutation) ClearStageMessages() {
  20375. m.clearedstage_messages = true
  20376. }
  20377. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  20378. func (m *SopStageMutation) StageMessagesCleared() bool {
  20379. return m.clearedstage_messages
  20380. }
  20381. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  20382. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  20383. if m.removedstage_messages == nil {
  20384. m.removedstage_messages = make(map[uint64]struct{})
  20385. }
  20386. for i := range ids {
  20387. delete(m.stage_messages, ids[i])
  20388. m.removedstage_messages[ids[i]] = struct{}{}
  20389. }
  20390. }
  20391. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  20392. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  20393. for id := range m.removedstage_messages {
  20394. ids = append(ids, id)
  20395. }
  20396. return
  20397. }
  20398. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  20399. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  20400. for id := range m.stage_messages {
  20401. ids = append(ids, id)
  20402. }
  20403. return
  20404. }
  20405. // ResetStageMessages resets all changes to the "stage_messages" edge.
  20406. func (m *SopStageMutation) ResetStageMessages() {
  20407. m.stage_messages = nil
  20408. m.clearedstage_messages = false
  20409. m.removedstage_messages = nil
  20410. }
  20411. // Where appends a list predicates to the SopStageMutation builder.
  20412. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  20413. m.predicates = append(m.predicates, ps...)
  20414. }
  20415. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  20416. // users can use type-assertion to append predicates that do not depend on any generated package.
  20417. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  20418. p := make([]predicate.SopStage, len(ps))
  20419. for i := range ps {
  20420. p[i] = ps[i]
  20421. }
  20422. m.Where(p...)
  20423. }
  20424. // Op returns the operation name.
  20425. func (m *SopStageMutation) Op() Op {
  20426. return m.op
  20427. }
  20428. // SetOp allows setting the mutation operation.
  20429. func (m *SopStageMutation) SetOp(op Op) {
  20430. m.op = op
  20431. }
  20432. // Type returns the node type of this mutation (SopStage).
  20433. func (m *SopStageMutation) Type() string {
  20434. return m.typ
  20435. }
  20436. // Fields returns all fields that were changed during this mutation. Note that in
  20437. // order to get all numeric fields that were incremented/decremented, call
  20438. // AddedFields().
  20439. func (m *SopStageMutation) Fields() []string {
  20440. fields := make([]string, 0, 14)
  20441. if m.created_at != nil {
  20442. fields = append(fields, sopstage.FieldCreatedAt)
  20443. }
  20444. if m.updated_at != nil {
  20445. fields = append(fields, sopstage.FieldUpdatedAt)
  20446. }
  20447. if m.status != nil {
  20448. fields = append(fields, sopstage.FieldStatus)
  20449. }
  20450. if m.deleted_at != nil {
  20451. fields = append(fields, sopstage.FieldDeletedAt)
  20452. }
  20453. if m.sop_task != nil {
  20454. fields = append(fields, sopstage.FieldTaskID)
  20455. }
  20456. if m.name != nil {
  20457. fields = append(fields, sopstage.FieldName)
  20458. }
  20459. if m.condition_type != nil {
  20460. fields = append(fields, sopstage.FieldConditionType)
  20461. }
  20462. if m.condition_operator != nil {
  20463. fields = append(fields, sopstage.FieldConditionOperator)
  20464. }
  20465. if m.condition_list != nil {
  20466. fields = append(fields, sopstage.FieldConditionList)
  20467. }
  20468. if m.action_message != nil {
  20469. fields = append(fields, sopstage.FieldActionMessage)
  20470. }
  20471. if m.action_label_add != nil {
  20472. fields = append(fields, sopstage.FieldActionLabelAdd)
  20473. }
  20474. if m.action_label_del != nil {
  20475. fields = append(fields, sopstage.FieldActionLabelDel)
  20476. }
  20477. if m.action_forward != nil {
  20478. fields = append(fields, sopstage.FieldActionForward)
  20479. }
  20480. if m.index_sort != nil {
  20481. fields = append(fields, sopstage.FieldIndexSort)
  20482. }
  20483. return fields
  20484. }
  20485. // Field returns the value of a field with the given name. The second boolean
  20486. // return value indicates that this field was not set, or was not defined in the
  20487. // schema.
  20488. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  20489. switch name {
  20490. case sopstage.FieldCreatedAt:
  20491. return m.CreatedAt()
  20492. case sopstage.FieldUpdatedAt:
  20493. return m.UpdatedAt()
  20494. case sopstage.FieldStatus:
  20495. return m.Status()
  20496. case sopstage.FieldDeletedAt:
  20497. return m.DeletedAt()
  20498. case sopstage.FieldTaskID:
  20499. return m.TaskID()
  20500. case sopstage.FieldName:
  20501. return m.Name()
  20502. case sopstage.FieldConditionType:
  20503. return m.ConditionType()
  20504. case sopstage.FieldConditionOperator:
  20505. return m.ConditionOperator()
  20506. case sopstage.FieldConditionList:
  20507. return m.ConditionList()
  20508. case sopstage.FieldActionMessage:
  20509. return m.ActionMessage()
  20510. case sopstage.FieldActionLabelAdd:
  20511. return m.ActionLabelAdd()
  20512. case sopstage.FieldActionLabelDel:
  20513. return m.ActionLabelDel()
  20514. case sopstage.FieldActionForward:
  20515. return m.ActionForward()
  20516. case sopstage.FieldIndexSort:
  20517. return m.IndexSort()
  20518. }
  20519. return nil, false
  20520. }
  20521. // OldField returns the old value of the field from the database. An error is
  20522. // returned if the mutation operation is not UpdateOne, or the query to the
  20523. // database failed.
  20524. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20525. switch name {
  20526. case sopstage.FieldCreatedAt:
  20527. return m.OldCreatedAt(ctx)
  20528. case sopstage.FieldUpdatedAt:
  20529. return m.OldUpdatedAt(ctx)
  20530. case sopstage.FieldStatus:
  20531. return m.OldStatus(ctx)
  20532. case sopstage.FieldDeletedAt:
  20533. return m.OldDeletedAt(ctx)
  20534. case sopstage.FieldTaskID:
  20535. return m.OldTaskID(ctx)
  20536. case sopstage.FieldName:
  20537. return m.OldName(ctx)
  20538. case sopstage.FieldConditionType:
  20539. return m.OldConditionType(ctx)
  20540. case sopstage.FieldConditionOperator:
  20541. return m.OldConditionOperator(ctx)
  20542. case sopstage.FieldConditionList:
  20543. return m.OldConditionList(ctx)
  20544. case sopstage.FieldActionMessage:
  20545. return m.OldActionMessage(ctx)
  20546. case sopstage.FieldActionLabelAdd:
  20547. return m.OldActionLabelAdd(ctx)
  20548. case sopstage.FieldActionLabelDel:
  20549. return m.OldActionLabelDel(ctx)
  20550. case sopstage.FieldActionForward:
  20551. return m.OldActionForward(ctx)
  20552. case sopstage.FieldIndexSort:
  20553. return m.OldIndexSort(ctx)
  20554. }
  20555. return nil, fmt.Errorf("unknown SopStage field %s", name)
  20556. }
  20557. // SetField sets the value of a field with the given name. It returns an error if
  20558. // the field is not defined in the schema, or if the type mismatched the field
  20559. // type.
  20560. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  20561. switch name {
  20562. case sopstage.FieldCreatedAt:
  20563. v, ok := value.(time.Time)
  20564. if !ok {
  20565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20566. }
  20567. m.SetCreatedAt(v)
  20568. return nil
  20569. case sopstage.FieldUpdatedAt:
  20570. v, ok := value.(time.Time)
  20571. if !ok {
  20572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20573. }
  20574. m.SetUpdatedAt(v)
  20575. return nil
  20576. case sopstage.FieldStatus:
  20577. v, ok := value.(uint8)
  20578. if !ok {
  20579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20580. }
  20581. m.SetStatus(v)
  20582. return nil
  20583. case sopstage.FieldDeletedAt:
  20584. v, ok := value.(time.Time)
  20585. if !ok {
  20586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20587. }
  20588. m.SetDeletedAt(v)
  20589. return nil
  20590. case sopstage.FieldTaskID:
  20591. v, ok := value.(uint64)
  20592. if !ok {
  20593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20594. }
  20595. m.SetTaskID(v)
  20596. return nil
  20597. case sopstage.FieldName:
  20598. v, ok := value.(string)
  20599. if !ok {
  20600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20601. }
  20602. m.SetName(v)
  20603. return nil
  20604. case sopstage.FieldConditionType:
  20605. v, ok := value.(int)
  20606. if !ok {
  20607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20608. }
  20609. m.SetConditionType(v)
  20610. return nil
  20611. case sopstage.FieldConditionOperator:
  20612. v, ok := value.(int)
  20613. if !ok {
  20614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20615. }
  20616. m.SetConditionOperator(v)
  20617. return nil
  20618. case sopstage.FieldConditionList:
  20619. v, ok := value.([]custom_types.Condition)
  20620. if !ok {
  20621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20622. }
  20623. m.SetConditionList(v)
  20624. return nil
  20625. case sopstage.FieldActionMessage:
  20626. v, ok := value.([]custom_types.Action)
  20627. if !ok {
  20628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20629. }
  20630. m.SetActionMessage(v)
  20631. return nil
  20632. case sopstage.FieldActionLabelAdd:
  20633. v, ok := value.([]uint64)
  20634. if !ok {
  20635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20636. }
  20637. m.SetActionLabelAdd(v)
  20638. return nil
  20639. case sopstage.FieldActionLabelDel:
  20640. v, ok := value.([]uint64)
  20641. if !ok {
  20642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20643. }
  20644. m.SetActionLabelDel(v)
  20645. return nil
  20646. case sopstage.FieldActionForward:
  20647. v, ok := value.(*custom_types.ActionForward)
  20648. if !ok {
  20649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20650. }
  20651. m.SetActionForward(v)
  20652. return nil
  20653. case sopstage.FieldIndexSort:
  20654. v, ok := value.(int)
  20655. if !ok {
  20656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20657. }
  20658. m.SetIndexSort(v)
  20659. return nil
  20660. }
  20661. return fmt.Errorf("unknown SopStage field %s", name)
  20662. }
  20663. // AddedFields returns all numeric fields that were incremented/decremented during
  20664. // this mutation.
  20665. func (m *SopStageMutation) AddedFields() []string {
  20666. var fields []string
  20667. if m.addstatus != nil {
  20668. fields = append(fields, sopstage.FieldStatus)
  20669. }
  20670. if m.addcondition_type != nil {
  20671. fields = append(fields, sopstage.FieldConditionType)
  20672. }
  20673. if m.addcondition_operator != nil {
  20674. fields = append(fields, sopstage.FieldConditionOperator)
  20675. }
  20676. if m.addindex_sort != nil {
  20677. fields = append(fields, sopstage.FieldIndexSort)
  20678. }
  20679. return fields
  20680. }
  20681. // AddedField returns the numeric value that was incremented/decremented on a field
  20682. // with the given name. The second boolean return value indicates that this field
  20683. // was not set, or was not defined in the schema.
  20684. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  20685. switch name {
  20686. case sopstage.FieldStatus:
  20687. return m.AddedStatus()
  20688. case sopstage.FieldConditionType:
  20689. return m.AddedConditionType()
  20690. case sopstage.FieldConditionOperator:
  20691. return m.AddedConditionOperator()
  20692. case sopstage.FieldIndexSort:
  20693. return m.AddedIndexSort()
  20694. }
  20695. return nil, false
  20696. }
  20697. // AddField adds the value to the field with the given name. It returns an error if
  20698. // the field is not defined in the schema, or if the type mismatched the field
  20699. // type.
  20700. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  20701. switch name {
  20702. case sopstage.FieldStatus:
  20703. v, ok := value.(int8)
  20704. if !ok {
  20705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20706. }
  20707. m.AddStatus(v)
  20708. return nil
  20709. case sopstage.FieldConditionType:
  20710. v, ok := value.(int)
  20711. if !ok {
  20712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20713. }
  20714. m.AddConditionType(v)
  20715. return nil
  20716. case sopstage.FieldConditionOperator:
  20717. v, ok := value.(int)
  20718. if !ok {
  20719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20720. }
  20721. m.AddConditionOperator(v)
  20722. return nil
  20723. case sopstage.FieldIndexSort:
  20724. v, ok := value.(int)
  20725. if !ok {
  20726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20727. }
  20728. m.AddIndexSort(v)
  20729. return nil
  20730. }
  20731. return fmt.Errorf("unknown SopStage numeric field %s", name)
  20732. }
  20733. // ClearedFields returns all nullable fields that were cleared during this
  20734. // mutation.
  20735. func (m *SopStageMutation) ClearedFields() []string {
  20736. var fields []string
  20737. if m.FieldCleared(sopstage.FieldStatus) {
  20738. fields = append(fields, sopstage.FieldStatus)
  20739. }
  20740. if m.FieldCleared(sopstage.FieldDeletedAt) {
  20741. fields = append(fields, sopstage.FieldDeletedAt)
  20742. }
  20743. if m.FieldCleared(sopstage.FieldActionMessage) {
  20744. fields = append(fields, sopstage.FieldActionMessage)
  20745. }
  20746. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  20747. fields = append(fields, sopstage.FieldActionLabelAdd)
  20748. }
  20749. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  20750. fields = append(fields, sopstage.FieldActionLabelDel)
  20751. }
  20752. if m.FieldCleared(sopstage.FieldActionForward) {
  20753. fields = append(fields, sopstage.FieldActionForward)
  20754. }
  20755. if m.FieldCleared(sopstage.FieldIndexSort) {
  20756. fields = append(fields, sopstage.FieldIndexSort)
  20757. }
  20758. return fields
  20759. }
  20760. // FieldCleared returns a boolean indicating if a field with the given name was
  20761. // cleared in this mutation.
  20762. func (m *SopStageMutation) FieldCleared(name string) bool {
  20763. _, ok := m.clearedFields[name]
  20764. return ok
  20765. }
  20766. // ClearField clears the value of the field with the given name. It returns an
  20767. // error if the field is not defined in the schema.
  20768. func (m *SopStageMutation) ClearField(name string) error {
  20769. switch name {
  20770. case sopstage.FieldStatus:
  20771. m.ClearStatus()
  20772. return nil
  20773. case sopstage.FieldDeletedAt:
  20774. m.ClearDeletedAt()
  20775. return nil
  20776. case sopstage.FieldActionMessage:
  20777. m.ClearActionMessage()
  20778. return nil
  20779. case sopstage.FieldActionLabelAdd:
  20780. m.ClearActionLabelAdd()
  20781. return nil
  20782. case sopstage.FieldActionLabelDel:
  20783. m.ClearActionLabelDel()
  20784. return nil
  20785. case sopstage.FieldActionForward:
  20786. m.ClearActionForward()
  20787. return nil
  20788. case sopstage.FieldIndexSort:
  20789. m.ClearIndexSort()
  20790. return nil
  20791. }
  20792. return fmt.Errorf("unknown SopStage nullable field %s", name)
  20793. }
  20794. // ResetField resets all changes in the mutation for the field with the given name.
  20795. // It returns an error if the field is not defined in the schema.
  20796. func (m *SopStageMutation) ResetField(name string) error {
  20797. switch name {
  20798. case sopstage.FieldCreatedAt:
  20799. m.ResetCreatedAt()
  20800. return nil
  20801. case sopstage.FieldUpdatedAt:
  20802. m.ResetUpdatedAt()
  20803. return nil
  20804. case sopstage.FieldStatus:
  20805. m.ResetStatus()
  20806. return nil
  20807. case sopstage.FieldDeletedAt:
  20808. m.ResetDeletedAt()
  20809. return nil
  20810. case sopstage.FieldTaskID:
  20811. m.ResetTaskID()
  20812. return nil
  20813. case sopstage.FieldName:
  20814. m.ResetName()
  20815. return nil
  20816. case sopstage.FieldConditionType:
  20817. m.ResetConditionType()
  20818. return nil
  20819. case sopstage.FieldConditionOperator:
  20820. m.ResetConditionOperator()
  20821. return nil
  20822. case sopstage.FieldConditionList:
  20823. m.ResetConditionList()
  20824. return nil
  20825. case sopstage.FieldActionMessage:
  20826. m.ResetActionMessage()
  20827. return nil
  20828. case sopstage.FieldActionLabelAdd:
  20829. m.ResetActionLabelAdd()
  20830. return nil
  20831. case sopstage.FieldActionLabelDel:
  20832. m.ResetActionLabelDel()
  20833. return nil
  20834. case sopstage.FieldActionForward:
  20835. m.ResetActionForward()
  20836. return nil
  20837. case sopstage.FieldIndexSort:
  20838. m.ResetIndexSort()
  20839. return nil
  20840. }
  20841. return fmt.Errorf("unknown SopStage field %s", name)
  20842. }
  20843. // AddedEdges returns all edge names that were set/added in this mutation.
  20844. func (m *SopStageMutation) AddedEdges() []string {
  20845. edges := make([]string, 0, 3)
  20846. if m.sop_task != nil {
  20847. edges = append(edges, sopstage.EdgeSopTask)
  20848. }
  20849. if m.stage_nodes != nil {
  20850. edges = append(edges, sopstage.EdgeStageNodes)
  20851. }
  20852. if m.stage_messages != nil {
  20853. edges = append(edges, sopstage.EdgeStageMessages)
  20854. }
  20855. return edges
  20856. }
  20857. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20858. // name in this mutation.
  20859. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  20860. switch name {
  20861. case sopstage.EdgeSopTask:
  20862. if id := m.sop_task; id != nil {
  20863. return []ent.Value{*id}
  20864. }
  20865. case sopstage.EdgeStageNodes:
  20866. ids := make([]ent.Value, 0, len(m.stage_nodes))
  20867. for id := range m.stage_nodes {
  20868. ids = append(ids, id)
  20869. }
  20870. return ids
  20871. case sopstage.EdgeStageMessages:
  20872. ids := make([]ent.Value, 0, len(m.stage_messages))
  20873. for id := range m.stage_messages {
  20874. ids = append(ids, id)
  20875. }
  20876. return ids
  20877. }
  20878. return nil
  20879. }
  20880. // RemovedEdges returns all edge names that were removed in this mutation.
  20881. func (m *SopStageMutation) RemovedEdges() []string {
  20882. edges := make([]string, 0, 3)
  20883. if m.removedstage_nodes != nil {
  20884. edges = append(edges, sopstage.EdgeStageNodes)
  20885. }
  20886. if m.removedstage_messages != nil {
  20887. edges = append(edges, sopstage.EdgeStageMessages)
  20888. }
  20889. return edges
  20890. }
  20891. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20892. // the given name in this mutation.
  20893. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  20894. switch name {
  20895. case sopstage.EdgeStageNodes:
  20896. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  20897. for id := range m.removedstage_nodes {
  20898. ids = append(ids, id)
  20899. }
  20900. return ids
  20901. case sopstage.EdgeStageMessages:
  20902. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  20903. for id := range m.removedstage_messages {
  20904. ids = append(ids, id)
  20905. }
  20906. return ids
  20907. }
  20908. return nil
  20909. }
  20910. // ClearedEdges returns all edge names that were cleared in this mutation.
  20911. func (m *SopStageMutation) ClearedEdges() []string {
  20912. edges := make([]string, 0, 3)
  20913. if m.clearedsop_task {
  20914. edges = append(edges, sopstage.EdgeSopTask)
  20915. }
  20916. if m.clearedstage_nodes {
  20917. edges = append(edges, sopstage.EdgeStageNodes)
  20918. }
  20919. if m.clearedstage_messages {
  20920. edges = append(edges, sopstage.EdgeStageMessages)
  20921. }
  20922. return edges
  20923. }
  20924. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20925. // was cleared in this mutation.
  20926. func (m *SopStageMutation) EdgeCleared(name string) bool {
  20927. switch name {
  20928. case sopstage.EdgeSopTask:
  20929. return m.clearedsop_task
  20930. case sopstage.EdgeStageNodes:
  20931. return m.clearedstage_nodes
  20932. case sopstage.EdgeStageMessages:
  20933. return m.clearedstage_messages
  20934. }
  20935. return false
  20936. }
  20937. // ClearEdge clears the value of the edge with the given name. It returns an error
  20938. // if that edge is not defined in the schema.
  20939. func (m *SopStageMutation) ClearEdge(name string) error {
  20940. switch name {
  20941. case sopstage.EdgeSopTask:
  20942. m.ClearSopTask()
  20943. return nil
  20944. }
  20945. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20946. }
  20947. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20948. // It returns an error if the edge is not defined in the schema.
  20949. func (m *SopStageMutation) ResetEdge(name string) error {
  20950. switch name {
  20951. case sopstage.EdgeSopTask:
  20952. m.ResetSopTask()
  20953. return nil
  20954. case sopstage.EdgeStageNodes:
  20955. m.ResetStageNodes()
  20956. return nil
  20957. case sopstage.EdgeStageMessages:
  20958. m.ResetStageMessages()
  20959. return nil
  20960. }
  20961. return fmt.Errorf("unknown SopStage edge %s", name)
  20962. }
  20963. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20964. type SopTaskMutation struct {
  20965. config
  20966. op Op
  20967. typ string
  20968. id *uint64
  20969. created_at *time.Time
  20970. updated_at *time.Time
  20971. status *uint8
  20972. addstatus *int8
  20973. deleted_at *time.Time
  20974. name *string
  20975. bot_wxid_list *[]string
  20976. appendbot_wxid_list []string
  20977. _type *int
  20978. add_type *int
  20979. plan_start_time *time.Time
  20980. plan_end_time *time.Time
  20981. creator_id *string
  20982. organization_id *uint64
  20983. addorganization_id *int64
  20984. token *[]string
  20985. appendtoken []string
  20986. clearedFields map[string]struct{}
  20987. task_stages map[uint64]struct{}
  20988. removedtask_stages map[uint64]struct{}
  20989. clearedtask_stages bool
  20990. done bool
  20991. oldValue func(context.Context) (*SopTask, error)
  20992. predicates []predicate.SopTask
  20993. }
  20994. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20995. // soptaskOption allows management of the mutation configuration using functional options.
  20996. type soptaskOption func(*SopTaskMutation)
  20997. // newSopTaskMutation creates new mutation for the SopTask entity.
  20998. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20999. m := &SopTaskMutation{
  21000. config: c,
  21001. op: op,
  21002. typ: TypeSopTask,
  21003. clearedFields: make(map[string]struct{}),
  21004. }
  21005. for _, opt := range opts {
  21006. opt(m)
  21007. }
  21008. return m
  21009. }
  21010. // withSopTaskID sets the ID field of the mutation.
  21011. func withSopTaskID(id uint64) soptaskOption {
  21012. return func(m *SopTaskMutation) {
  21013. var (
  21014. err error
  21015. once sync.Once
  21016. value *SopTask
  21017. )
  21018. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  21019. once.Do(func() {
  21020. if m.done {
  21021. err = errors.New("querying old values post mutation is not allowed")
  21022. } else {
  21023. value, err = m.Client().SopTask.Get(ctx, id)
  21024. }
  21025. })
  21026. return value, err
  21027. }
  21028. m.id = &id
  21029. }
  21030. }
  21031. // withSopTask sets the old SopTask of the mutation.
  21032. func withSopTask(node *SopTask) soptaskOption {
  21033. return func(m *SopTaskMutation) {
  21034. m.oldValue = func(context.Context) (*SopTask, error) {
  21035. return node, nil
  21036. }
  21037. m.id = &node.ID
  21038. }
  21039. }
  21040. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21041. // executed in a transaction (ent.Tx), a transactional client is returned.
  21042. func (m SopTaskMutation) Client() *Client {
  21043. client := &Client{config: m.config}
  21044. client.init()
  21045. return client
  21046. }
  21047. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21048. // it returns an error otherwise.
  21049. func (m SopTaskMutation) Tx() (*Tx, error) {
  21050. if _, ok := m.driver.(*txDriver); !ok {
  21051. return nil, errors.New("ent: mutation is not running in a transaction")
  21052. }
  21053. tx := &Tx{config: m.config}
  21054. tx.init()
  21055. return tx, nil
  21056. }
  21057. // SetID sets the value of the id field. Note that this
  21058. // operation is only accepted on creation of SopTask entities.
  21059. func (m *SopTaskMutation) SetID(id uint64) {
  21060. m.id = &id
  21061. }
  21062. // ID returns the ID value in the mutation. Note that the ID is only available
  21063. // if it was provided to the builder or after it was returned from the database.
  21064. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  21065. if m.id == nil {
  21066. return
  21067. }
  21068. return *m.id, true
  21069. }
  21070. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21071. // That means, if the mutation is applied within a transaction with an isolation level such
  21072. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21073. // or updated by the mutation.
  21074. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  21075. switch {
  21076. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21077. id, exists := m.ID()
  21078. if exists {
  21079. return []uint64{id}, nil
  21080. }
  21081. fallthrough
  21082. case m.op.Is(OpUpdate | OpDelete):
  21083. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  21084. default:
  21085. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21086. }
  21087. }
  21088. // SetCreatedAt sets the "created_at" field.
  21089. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  21090. m.created_at = &t
  21091. }
  21092. // CreatedAt returns the value of the "created_at" field in the mutation.
  21093. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  21094. v := m.created_at
  21095. if v == nil {
  21096. return
  21097. }
  21098. return *v, true
  21099. }
  21100. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  21101. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21103. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21104. if !m.op.Is(OpUpdateOne) {
  21105. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21106. }
  21107. if m.id == nil || m.oldValue == nil {
  21108. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21109. }
  21110. oldValue, err := m.oldValue(ctx)
  21111. if err != nil {
  21112. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21113. }
  21114. return oldValue.CreatedAt, nil
  21115. }
  21116. // ResetCreatedAt resets all changes to the "created_at" field.
  21117. func (m *SopTaskMutation) ResetCreatedAt() {
  21118. m.created_at = nil
  21119. }
  21120. // SetUpdatedAt sets the "updated_at" field.
  21121. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  21122. m.updated_at = &t
  21123. }
  21124. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21125. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  21126. v := m.updated_at
  21127. if v == nil {
  21128. return
  21129. }
  21130. return *v, true
  21131. }
  21132. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  21133. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21135. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21136. if !m.op.Is(OpUpdateOne) {
  21137. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21138. }
  21139. if m.id == nil || m.oldValue == nil {
  21140. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21141. }
  21142. oldValue, err := m.oldValue(ctx)
  21143. if err != nil {
  21144. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21145. }
  21146. return oldValue.UpdatedAt, nil
  21147. }
  21148. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21149. func (m *SopTaskMutation) ResetUpdatedAt() {
  21150. m.updated_at = nil
  21151. }
  21152. // SetStatus sets the "status" field.
  21153. func (m *SopTaskMutation) SetStatus(u uint8) {
  21154. m.status = &u
  21155. m.addstatus = nil
  21156. }
  21157. // Status returns the value of the "status" field in the mutation.
  21158. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  21159. v := m.status
  21160. if v == nil {
  21161. return
  21162. }
  21163. return *v, true
  21164. }
  21165. // OldStatus returns the old "status" field's value of the SopTask entity.
  21166. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21168. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21169. if !m.op.Is(OpUpdateOne) {
  21170. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21171. }
  21172. if m.id == nil || m.oldValue == nil {
  21173. return v, errors.New("OldStatus requires an ID field in the mutation")
  21174. }
  21175. oldValue, err := m.oldValue(ctx)
  21176. if err != nil {
  21177. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21178. }
  21179. return oldValue.Status, nil
  21180. }
  21181. // AddStatus adds u to the "status" field.
  21182. func (m *SopTaskMutation) AddStatus(u int8) {
  21183. if m.addstatus != nil {
  21184. *m.addstatus += u
  21185. } else {
  21186. m.addstatus = &u
  21187. }
  21188. }
  21189. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21190. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  21191. v := m.addstatus
  21192. if v == nil {
  21193. return
  21194. }
  21195. return *v, true
  21196. }
  21197. // ClearStatus clears the value of the "status" field.
  21198. func (m *SopTaskMutation) ClearStatus() {
  21199. m.status = nil
  21200. m.addstatus = nil
  21201. m.clearedFields[soptask.FieldStatus] = struct{}{}
  21202. }
  21203. // StatusCleared returns if the "status" field was cleared in this mutation.
  21204. func (m *SopTaskMutation) StatusCleared() bool {
  21205. _, ok := m.clearedFields[soptask.FieldStatus]
  21206. return ok
  21207. }
  21208. // ResetStatus resets all changes to the "status" field.
  21209. func (m *SopTaskMutation) ResetStatus() {
  21210. m.status = nil
  21211. m.addstatus = nil
  21212. delete(m.clearedFields, soptask.FieldStatus)
  21213. }
  21214. // SetDeletedAt sets the "deleted_at" field.
  21215. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  21216. m.deleted_at = &t
  21217. }
  21218. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21219. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  21220. v := m.deleted_at
  21221. if v == nil {
  21222. return
  21223. }
  21224. return *v, true
  21225. }
  21226. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  21227. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21229. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21230. if !m.op.Is(OpUpdateOne) {
  21231. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21232. }
  21233. if m.id == nil || m.oldValue == nil {
  21234. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21235. }
  21236. oldValue, err := m.oldValue(ctx)
  21237. if err != nil {
  21238. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21239. }
  21240. return oldValue.DeletedAt, nil
  21241. }
  21242. // ClearDeletedAt clears the value of the "deleted_at" field.
  21243. func (m *SopTaskMutation) ClearDeletedAt() {
  21244. m.deleted_at = nil
  21245. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  21246. }
  21247. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21248. func (m *SopTaskMutation) DeletedAtCleared() bool {
  21249. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  21250. return ok
  21251. }
  21252. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21253. func (m *SopTaskMutation) ResetDeletedAt() {
  21254. m.deleted_at = nil
  21255. delete(m.clearedFields, soptask.FieldDeletedAt)
  21256. }
  21257. // SetName sets the "name" field.
  21258. func (m *SopTaskMutation) SetName(s string) {
  21259. m.name = &s
  21260. }
  21261. // Name returns the value of the "name" field in the mutation.
  21262. func (m *SopTaskMutation) Name() (r string, exists bool) {
  21263. v := m.name
  21264. if v == nil {
  21265. return
  21266. }
  21267. return *v, true
  21268. }
  21269. // OldName returns the old "name" field's value of the SopTask entity.
  21270. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21272. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  21273. if !m.op.Is(OpUpdateOne) {
  21274. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21275. }
  21276. if m.id == nil || m.oldValue == nil {
  21277. return v, errors.New("OldName requires an ID field in the mutation")
  21278. }
  21279. oldValue, err := m.oldValue(ctx)
  21280. if err != nil {
  21281. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21282. }
  21283. return oldValue.Name, nil
  21284. }
  21285. // ResetName resets all changes to the "name" field.
  21286. func (m *SopTaskMutation) ResetName() {
  21287. m.name = nil
  21288. }
  21289. // SetBotWxidList sets the "bot_wxid_list" field.
  21290. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  21291. m.bot_wxid_list = &s
  21292. m.appendbot_wxid_list = nil
  21293. }
  21294. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  21295. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  21296. v := m.bot_wxid_list
  21297. if v == nil {
  21298. return
  21299. }
  21300. return *v, true
  21301. }
  21302. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  21303. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21305. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  21306. if !m.op.Is(OpUpdateOne) {
  21307. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  21308. }
  21309. if m.id == nil || m.oldValue == nil {
  21310. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  21311. }
  21312. oldValue, err := m.oldValue(ctx)
  21313. if err != nil {
  21314. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  21315. }
  21316. return oldValue.BotWxidList, nil
  21317. }
  21318. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  21319. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  21320. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  21321. }
  21322. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  21323. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  21324. if len(m.appendbot_wxid_list) == 0 {
  21325. return nil, false
  21326. }
  21327. return m.appendbot_wxid_list, true
  21328. }
  21329. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  21330. func (m *SopTaskMutation) ClearBotWxidList() {
  21331. m.bot_wxid_list = nil
  21332. m.appendbot_wxid_list = nil
  21333. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  21334. }
  21335. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  21336. func (m *SopTaskMutation) BotWxidListCleared() bool {
  21337. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  21338. return ok
  21339. }
  21340. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  21341. func (m *SopTaskMutation) ResetBotWxidList() {
  21342. m.bot_wxid_list = nil
  21343. m.appendbot_wxid_list = nil
  21344. delete(m.clearedFields, soptask.FieldBotWxidList)
  21345. }
  21346. // SetType sets the "type" field.
  21347. func (m *SopTaskMutation) SetType(i int) {
  21348. m._type = &i
  21349. m.add_type = nil
  21350. }
  21351. // GetType returns the value of the "type" field in the mutation.
  21352. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  21353. v := m._type
  21354. if v == nil {
  21355. return
  21356. }
  21357. return *v, true
  21358. }
  21359. // OldType returns the old "type" field's value of the SopTask entity.
  21360. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21362. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  21363. if !m.op.Is(OpUpdateOne) {
  21364. return v, errors.New("OldType is only allowed on UpdateOne operations")
  21365. }
  21366. if m.id == nil || m.oldValue == nil {
  21367. return v, errors.New("OldType requires an ID field in the mutation")
  21368. }
  21369. oldValue, err := m.oldValue(ctx)
  21370. if err != nil {
  21371. return v, fmt.Errorf("querying old value for OldType: %w", err)
  21372. }
  21373. return oldValue.Type, nil
  21374. }
  21375. // AddType adds i to the "type" field.
  21376. func (m *SopTaskMutation) AddType(i int) {
  21377. if m.add_type != nil {
  21378. *m.add_type += i
  21379. } else {
  21380. m.add_type = &i
  21381. }
  21382. }
  21383. // AddedType returns the value that was added to the "type" field in this mutation.
  21384. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  21385. v := m.add_type
  21386. if v == nil {
  21387. return
  21388. }
  21389. return *v, true
  21390. }
  21391. // ResetType resets all changes to the "type" field.
  21392. func (m *SopTaskMutation) ResetType() {
  21393. m._type = nil
  21394. m.add_type = nil
  21395. }
  21396. // SetPlanStartTime sets the "plan_start_time" field.
  21397. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  21398. m.plan_start_time = &t
  21399. }
  21400. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  21401. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  21402. v := m.plan_start_time
  21403. if v == nil {
  21404. return
  21405. }
  21406. return *v, true
  21407. }
  21408. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  21409. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21411. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  21412. if !m.op.Is(OpUpdateOne) {
  21413. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  21414. }
  21415. if m.id == nil || m.oldValue == nil {
  21416. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  21417. }
  21418. oldValue, err := m.oldValue(ctx)
  21419. if err != nil {
  21420. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  21421. }
  21422. return oldValue.PlanStartTime, nil
  21423. }
  21424. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  21425. func (m *SopTaskMutation) ClearPlanStartTime() {
  21426. m.plan_start_time = nil
  21427. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  21428. }
  21429. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  21430. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  21431. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  21432. return ok
  21433. }
  21434. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  21435. func (m *SopTaskMutation) ResetPlanStartTime() {
  21436. m.plan_start_time = nil
  21437. delete(m.clearedFields, soptask.FieldPlanStartTime)
  21438. }
  21439. // SetPlanEndTime sets the "plan_end_time" field.
  21440. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  21441. m.plan_end_time = &t
  21442. }
  21443. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  21444. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  21445. v := m.plan_end_time
  21446. if v == nil {
  21447. return
  21448. }
  21449. return *v, true
  21450. }
  21451. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  21452. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21454. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  21455. if !m.op.Is(OpUpdateOne) {
  21456. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  21457. }
  21458. if m.id == nil || m.oldValue == nil {
  21459. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  21460. }
  21461. oldValue, err := m.oldValue(ctx)
  21462. if err != nil {
  21463. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  21464. }
  21465. return oldValue.PlanEndTime, nil
  21466. }
  21467. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  21468. func (m *SopTaskMutation) ClearPlanEndTime() {
  21469. m.plan_end_time = nil
  21470. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  21471. }
  21472. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  21473. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  21474. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  21475. return ok
  21476. }
  21477. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  21478. func (m *SopTaskMutation) ResetPlanEndTime() {
  21479. m.plan_end_time = nil
  21480. delete(m.clearedFields, soptask.FieldPlanEndTime)
  21481. }
  21482. // SetCreatorID sets the "creator_id" field.
  21483. func (m *SopTaskMutation) SetCreatorID(s string) {
  21484. m.creator_id = &s
  21485. }
  21486. // CreatorID returns the value of the "creator_id" field in the mutation.
  21487. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  21488. v := m.creator_id
  21489. if v == nil {
  21490. return
  21491. }
  21492. return *v, true
  21493. }
  21494. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  21495. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21497. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  21498. if !m.op.Is(OpUpdateOne) {
  21499. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  21500. }
  21501. if m.id == nil || m.oldValue == nil {
  21502. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  21503. }
  21504. oldValue, err := m.oldValue(ctx)
  21505. if err != nil {
  21506. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  21507. }
  21508. return oldValue.CreatorID, nil
  21509. }
  21510. // ClearCreatorID clears the value of the "creator_id" field.
  21511. func (m *SopTaskMutation) ClearCreatorID() {
  21512. m.creator_id = nil
  21513. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  21514. }
  21515. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  21516. func (m *SopTaskMutation) CreatorIDCleared() bool {
  21517. _, ok := m.clearedFields[soptask.FieldCreatorID]
  21518. return ok
  21519. }
  21520. // ResetCreatorID resets all changes to the "creator_id" field.
  21521. func (m *SopTaskMutation) ResetCreatorID() {
  21522. m.creator_id = nil
  21523. delete(m.clearedFields, soptask.FieldCreatorID)
  21524. }
  21525. // SetOrganizationID sets the "organization_id" field.
  21526. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  21527. m.organization_id = &u
  21528. m.addorganization_id = nil
  21529. }
  21530. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21531. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  21532. v := m.organization_id
  21533. if v == nil {
  21534. return
  21535. }
  21536. return *v, true
  21537. }
  21538. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  21539. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21541. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21542. if !m.op.Is(OpUpdateOne) {
  21543. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21544. }
  21545. if m.id == nil || m.oldValue == nil {
  21546. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21547. }
  21548. oldValue, err := m.oldValue(ctx)
  21549. if err != nil {
  21550. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21551. }
  21552. return oldValue.OrganizationID, nil
  21553. }
  21554. // AddOrganizationID adds u to the "organization_id" field.
  21555. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  21556. if m.addorganization_id != nil {
  21557. *m.addorganization_id += u
  21558. } else {
  21559. m.addorganization_id = &u
  21560. }
  21561. }
  21562. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21563. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  21564. v := m.addorganization_id
  21565. if v == nil {
  21566. return
  21567. }
  21568. return *v, true
  21569. }
  21570. // ClearOrganizationID clears the value of the "organization_id" field.
  21571. func (m *SopTaskMutation) ClearOrganizationID() {
  21572. m.organization_id = nil
  21573. m.addorganization_id = nil
  21574. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  21575. }
  21576. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21577. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  21578. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  21579. return ok
  21580. }
  21581. // ResetOrganizationID resets all changes to the "organization_id" field.
  21582. func (m *SopTaskMutation) ResetOrganizationID() {
  21583. m.organization_id = nil
  21584. m.addorganization_id = nil
  21585. delete(m.clearedFields, soptask.FieldOrganizationID)
  21586. }
  21587. // SetToken sets the "token" field.
  21588. func (m *SopTaskMutation) SetToken(s []string) {
  21589. m.token = &s
  21590. m.appendtoken = nil
  21591. }
  21592. // Token returns the value of the "token" field in the mutation.
  21593. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  21594. v := m.token
  21595. if v == nil {
  21596. return
  21597. }
  21598. return *v, true
  21599. }
  21600. // OldToken returns the old "token" field's value of the SopTask entity.
  21601. // If the SopTask 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 *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  21604. if !m.op.Is(OpUpdateOne) {
  21605. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21606. }
  21607. if m.id == nil || m.oldValue == nil {
  21608. return v, errors.New("OldToken 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 OldToken: %w", err)
  21613. }
  21614. return oldValue.Token, nil
  21615. }
  21616. // AppendToken adds s to the "token" field.
  21617. func (m *SopTaskMutation) AppendToken(s []string) {
  21618. m.appendtoken = append(m.appendtoken, s...)
  21619. }
  21620. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  21621. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  21622. if len(m.appendtoken) == 0 {
  21623. return nil, false
  21624. }
  21625. return m.appendtoken, true
  21626. }
  21627. // ClearToken clears the value of the "token" field.
  21628. func (m *SopTaskMutation) ClearToken() {
  21629. m.token = nil
  21630. m.appendtoken = nil
  21631. m.clearedFields[soptask.FieldToken] = struct{}{}
  21632. }
  21633. // TokenCleared returns if the "token" field was cleared in this mutation.
  21634. func (m *SopTaskMutation) TokenCleared() bool {
  21635. _, ok := m.clearedFields[soptask.FieldToken]
  21636. return ok
  21637. }
  21638. // ResetToken resets all changes to the "token" field.
  21639. func (m *SopTaskMutation) ResetToken() {
  21640. m.token = nil
  21641. m.appendtoken = nil
  21642. delete(m.clearedFields, soptask.FieldToken)
  21643. }
  21644. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  21645. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  21646. if m.task_stages == nil {
  21647. m.task_stages = make(map[uint64]struct{})
  21648. }
  21649. for i := range ids {
  21650. m.task_stages[ids[i]] = struct{}{}
  21651. }
  21652. }
  21653. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  21654. func (m *SopTaskMutation) ClearTaskStages() {
  21655. m.clearedtask_stages = true
  21656. }
  21657. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  21658. func (m *SopTaskMutation) TaskStagesCleared() bool {
  21659. return m.clearedtask_stages
  21660. }
  21661. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  21662. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  21663. if m.removedtask_stages == nil {
  21664. m.removedtask_stages = make(map[uint64]struct{})
  21665. }
  21666. for i := range ids {
  21667. delete(m.task_stages, ids[i])
  21668. m.removedtask_stages[ids[i]] = struct{}{}
  21669. }
  21670. }
  21671. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  21672. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  21673. for id := range m.removedtask_stages {
  21674. ids = append(ids, id)
  21675. }
  21676. return
  21677. }
  21678. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  21679. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  21680. for id := range m.task_stages {
  21681. ids = append(ids, id)
  21682. }
  21683. return
  21684. }
  21685. // ResetTaskStages resets all changes to the "task_stages" edge.
  21686. func (m *SopTaskMutation) ResetTaskStages() {
  21687. m.task_stages = nil
  21688. m.clearedtask_stages = false
  21689. m.removedtask_stages = nil
  21690. }
  21691. // Where appends a list predicates to the SopTaskMutation builder.
  21692. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  21693. m.predicates = append(m.predicates, ps...)
  21694. }
  21695. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  21696. // users can use type-assertion to append predicates that do not depend on any generated package.
  21697. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  21698. p := make([]predicate.SopTask, len(ps))
  21699. for i := range ps {
  21700. p[i] = ps[i]
  21701. }
  21702. m.Where(p...)
  21703. }
  21704. // Op returns the operation name.
  21705. func (m *SopTaskMutation) Op() Op {
  21706. return m.op
  21707. }
  21708. // SetOp allows setting the mutation operation.
  21709. func (m *SopTaskMutation) SetOp(op Op) {
  21710. m.op = op
  21711. }
  21712. // Type returns the node type of this mutation (SopTask).
  21713. func (m *SopTaskMutation) Type() string {
  21714. return m.typ
  21715. }
  21716. // Fields returns all fields that were changed during this mutation. Note that in
  21717. // order to get all numeric fields that were incremented/decremented, call
  21718. // AddedFields().
  21719. func (m *SopTaskMutation) Fields() []string {
  21720. fields := make([]string, 0, 12)
  21721. if m.created_at != nil {
  21722. fields = append(fields, soptask.FieldCreatedAt)
  21723. }
  21724. if m.updated_at != nil {
  21725. fields = append(fields, soptask.FieldUpdatedAt)
  21726. }
  21727. if m.status != nil {
  21728. fields = append(fields, soptask.FieldStatus)
  21729. }
  21730. if m.deleted_at != nil {
  21731. fields = append(fields, soptask.FieldDeletedAt)
  21732. }
  21733. if m.name != nil {
  21734. fields = append(fields, soptask.FieldName)
  21735. }
  21736. if m.bot_wxid_list != nil {
  21737. fields = append(fields, soptask.FieldBotWxidList)
  21738. }
  21739. if m._type != nil {
  21740. fields = append(fields, soptask.FieldType)
  21741. }
  21742. if m.plan_start_time != nil {
  21743. fields = append(fields, soptask.FieldPlanStartTime)
  21744. }
  21745. if m.plan_end_time != nil {
  21746. fields = append(fields, soptask.FieldPlanEndTime)
  21747. }
  21748. if m.creator_id != nil {
  21749. fields = append(fields, soptask.FieldCreatorID)
  21750. }
  21751. if m.organization_id != nil {
  21752. fields = append(fields, soptask.FieldOrganizationID)
  21753. }
  21754. if m.token != nil {
  21755. fields = append(fields, soptask.FieldToken)
  21756. }
  21757. return fields
  21758. }
  21759. // Field returns the value of a field with the given name. The second boolean
  21760. // return value indicates that this field was not set, or was not defined in the
  21761. // schema.
  21762. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  21763. switch name {
  21764. case soptask.FieldCreatedAt:
  21765. return m.CreatedAt()
  21766. case soptask.FieldUpdatedAt:
  21767. return m.UpdatedAt()
  21768. case soptask.FieldStatus:
  21769. return m.Status()
  21770. case soptask.FieldDeletedAt:
  21771. return m.DeletedAt()
  21772. case soptask.FieldName:
  21773. return m.Name()
  21774. case soptask.FieldBotWxidList:
  21775. return m.BotWxidList()
  21776. case soptask.FieldType:
  21777. return m.GetType()
  21778. case soptask.FieldPlanStartTime:
  21779. return m.PlanStartTime()
  21780. case soptask.FieldPlanEndTime:
  21781. return m.PlanEndTime()
  21782. case soptask.FieldCreatorID:
  21783. return m.CreatorID()
  21784. case soptask.FieldOrganizationID:
  21785. return m.OrganizationID()
  21786. case soptask.FieldToken:
  21787. return m.Token()
  21788. }
  21789. return nil, false
  21790. }
  21791. // OldField returns the old value of the field from the database. An error is
  21792. // returned if the mutation operation is not UpdateOne, or the query to the
  21793. // database failed.
  21794. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21795. switch name {
  21796. case soptask.FieldCreatedAt:
  21797. return m.OldCreatedAt(ctx)
  21798. case soptask.FieldUpdatedAt:
  21799. return m.OldUpdatedAt(ctx)
  21800. case soptask.FieldStatus:
  21801. return m.OldStatus(ctx)
  21802. case soptask.FieldDeletedAt:
  21803. return m.OldDeletedAt(ctx)
  21804. case soptask.FieldName:
  21805. return m.OldName(ctx)
  21806. case soptask.FieldBotWxidList:
  21807. return m.OldBotWxidList(ctx)
  21808. case soptask.FieldType:
  21809. return m.OldType(ctx)
  21810. case soptask.FieldPlanStartTime:
  21811. return m.OldPlanStartTime(ctx)
  21812. case soptask.FieldPlanEndTime:
  21813. return m.OldPlanEndTime(ctx)
  21814. case soptask.FieldCreatorID:
  21815. return m.OldCreatorID(ctx)
  21816. case soptask.FieldOrganizationID:
  21817. return m.OldOrganizationID(ctx)
  21818. case soptask.FieldToken:
  21819. return m.OldToken(ctx)
  21820. }
  21821. return nil, fmt.Errorf("unknown SopTask field %s", name)
  21822. }
  21823. // SetField sets the value of a field with the given name. It returns an error if
  21824. // the field is not defined in the schema, or if the type mismatched the field
  21825. // type.
  21826. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  21827. switch name {
  21828. case soptask.FieldCreatedAt:
  21829. v, ok := value.(time.Time)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.SetCreatedAt(v)
  21834. return nil
  21835. case soptask.FieldUpdatedAt:
  21836. v, ok := value.(time.Time)
  21837. if !ok {
  21838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21839. }
  21840. m.SetUpdatedAt(v)
  21841. return nil
  21842. case soptask.FieldStatus:
  21843. v, ok := value.(uint8)
  21844. if !ok {
  21845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21846. }
  21847. m.SetStatus(v)
  21848. return nil
  21849. case soptask.FieldDeletedAt:
  21850. v, ok := value.(time.Time)
  21851. if !ok {
  21852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21853. }
  21854. m.SetDeletedAt(v)
  21855. return nil
  21856. case soptask.FieldName:
  21857. v, ok := value.(string)
  21858. if !ok {
  21859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21860. }
  21861. m.SetName(v)
  21862. return nil
  21863. case soptask.FieldBotWxidList:
  21864. v, ok := value.([]string)
  21865. if !ok {
  21866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21867. }
  21868. m.SetBotWxidList(v)
  21869. return nil
  21870. case soptask.FieldType:
  21871. v, ok := value.(int)
  21872. if !ok {
  21873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21874. }
  21875. m.SetType(v)
  21876. return nil
  21877. case soptask.FieldPlanStartTime:
  21878. v, ok := value.(time.Time)
  21879. if !ok {
  21880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21881. }
  21882. m.SetPlanStartTime(v)
  21883. return nil
  21884. case soptask.FieldPlanEndTime:
  21885. v, ok := value.(time.Time)
  21886. if !ok {
  21887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21888. }
  21889. m.SetPlanEndTime(v)
  21890. return nil
  21891. case soptask.FieldCreatorID:
  21892. v, ok := value.(string)
  21893. if !ok {
  21894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21895. }
  21896. m.SetCreatorID(v)
  21897. return nil
  21898. case soptask.FieldOrganizationID:
  21899. v, ok := value.(uint64)
  21900. if !ok {
  21901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21902. }
  21903. m.SetOrganizationID(v)
  21904. return nil
  21905. case soptask.FieldToken:
  21906. v, ok := value.([]string)
  21907. if !ok {
  21908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21909. }
  21910. m.SetToken(v)
  21911. return nil
  21912. }
  21913. return fmt.Errorf("unknown SopTask field %s", name)
  21914. }
  21915. // AddedFields returns all numeric fields that were incremented/decremented during
  21916. // this mutation.
  21917. func (m *SopTaskMutation) AddedFields() []string {
  21918. var fields []string
  21919. if m.addstatus != nil {
  21920. fields = append(fields, soptask.FieldStatus)
  21921. }
  21922. if m.add_type != nil {
  21923. fields = append(fields, soptask.FieldType)
  21924. }
  21925. if m.addorganization_id != nil {
  21926. fields = append(fields, soptask.FieldOrganizationID)
  21927. }
  21928. return fields
  21929. }
  21930. // AddedField returns the numeric value that was incremented/decremented on a field
  21931. // with the given name. The second boolean return value indicates that this field
  21932. // was not set, or was not defined in the schema.
  21933. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  21934. switch name {
  21935. case soptask.FieldStatus:
  21936. return m.AddedStatus()
  21937. case soptask.FieldType:
  21938. return m.AddedType()
  21939. case soptask.FieldOrganizationID:
  21940. return m.AddedOrganizationID()
  21941. }
  21942. return nil, false
  21943. }
  21944. // AddField adds the value to the field with the given name. It returns an error if
  21945. // the field is not defined in the schema, or if the type mismatched the field
  21946. // type.
  21947. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21948. switch name {
  21949. case soptask.FieldStatus:
  21950. v, ok := value.(int8)
  21951. if !ok {
  21952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21953. }
  21954. m.AddStatus(v)
  21955. return nil
  21956. case soptask.FieldType:
  21957. v, ok := value.(int)
  21958. if !ok {
  21959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21960. }
  21961. m.AddType(v)
  21962. return nil
  21963. case soptask.FieldOrganizationID:
  21964. v, ok := value.(int64)
  21965. if !ok {
  21966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21967. }
  21968. m.AddOrganizationID(v)
  21969. return nil
  21970. }
  21971. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21972. }
  21973. // ClearedFields returns all nullable fields that were cleared during this
  21974. // mutation.
  21975. func (m *SopTaskMutation) ClearedFields() []string {
  21976. var fields []string
  21977. if m.FieldCleared(soptask.FieldStatus) {
  21978. fields = append(fields, soptask.FieldStatus)
  21979. }
  21980. if m.FieldCleared(soptask.FieldDeletedAt) {
  21981. fields = append(fields, soptask.FieldDeletedAt)
  21982. }
  21983. if m.FieldCleared(soptask.FieldBotWxidList) {
  21984. fields = append(fields, soptask.FieldBotWxidList)
  21985. }
  21986. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21987. fields = append(fields, soptask.FieldPlanStartTime)
  21988. }
  21989. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21990. fields = append(fields, soptask.FieldPlanEndTime)
  21991. }
  21992. if m.FieldCleared(soptask.FieldCreatorID) {
  21993. fields = append(fields, soptask.FieldCreatorID)
  21994. }
  21995. if m.FieldCleared(soptask.FieldOrganizationID) {
  21996. fields = append(fields, soptask.FieldOrganizationID)
  21997. }
  21998. if m.FieldCleared(soptask.FieldToken) {
  21999. fields = append(fields, soptask.FieldToken)
  22000. }
  22001. return fields
  22002. }
  22003. // FieldCleared returns a boolean indicating if a field with the given name was
  22004. // cleared in this mutation.
  22005. func (m *SopTaskMutation) FieldCleared(name string) bool {
  22006. _, ok := m.clearedFields[name]
  22007. return ok
  22008. }
  22009. // ClearField clears the value of the field with the given name. It returns an
  22010. // error if the field is not defined in the schema.
  22011. func (m *SopTaskMutation) ClearField(name string) error {
  22012. switch name {
  22013. case soptask.FieldStatus:
  22014. m.ClearStatus()
  22015. return nil
  22016. case soptask.FieldDeletedAt:
  22017. m.ClearDeletedAt()
  22018. return nil
  22019. case soptask.FieldBotWxidList:
  22020. m.ClearBotWxidList()
  22021. return nil
  22022. case soptask.FieldPlanStartTime:
  22023. m.ClearPlanStartTime()
  22024. return nil
  22025. case soptask.FieldPlanEndTime:
  22026. m.ClearPlanEndTime()
  22027. return nil
  22028. case soptask.FieldCreatorID:
  22029. m.ClearCreatorID()
  22030. return nil
  22031. case soptask.FieldOrganizationID:
  22032. m.ClearOrganizationID()
  22033. return nil
  22034. case soptask.FieldToken:
  22035. m.ClearToken()
  22036. return nil
  22037. }
  22038. return fmt.Errorf("unknown SopTask nullable field %s", name)
  22039. }
  22040. // ResetField resets all changes in the mutation for the field with the given name.
  22041. // It returns an error if the field is not defined in the schema.
  22042. func (m *SopTaskMutation) ResetField(name string) error {
  22043. switch name {
  22044. case soptask.FieldCreatedAt:
  22045. m.ResetCreatedAt()
  22046. return nil
  22047. case soptask.FieldUpdatedAt:
  22048. m.ResetUpdatedAt()
  22049. return nil
  22050. case soptask.FieldStatus:
  22051. m.ResetStatus()
  22052. return nil
  22053. case soptask.FieldDeletedAt:
  22054. m.ResetDeletedAt()
  22055. return nil
  22056. case soptask.FieldName:
  22057. m.ResetName()
  22058. return nil
  22059. case soptask.FieldBotWxidList:
  22060. m.ResetBotWxidList()
  22061. return nil
  22062. case soptask.FieldType:
  22063. m.ResetType()
  22064. return nil
  22065. case soptask.FieldPlanStartTime:
  22066. m.ResetPlanStartTime()
  22067. return nil
  22068. case soptask.FieldPlanEndTime:
  22069. m.ResetPlanEndTime()
  22070. return nil
  22071. case soptask.FieldCreatorID:
  22072. m.ResetCreatorID()
  22073. return nil
  22074. case soptask.FieldOrganizationID:
  22075. m.ResetOrganizationID()
  22076. return nil
  22077. case soptask.FieldToken:
  22078. m.ResetToken()
  22079. return nil
  22080. }
  22081. return fmt.Errorf("unknown SopTask field %s", name)
  22082. }
  22083. // AddedEdges returns all edge names that were set/added in this mutation.
  22084. func (m *SopTaskMutation) AddedEdges() []string {
  22085. edges := make([]string, 0, 1)
  22086. if m.task_stages != nil {
  22087. edges = append(edges, soptask.EdgeTaskStages)
  22088. }
  22089. return edges
  22090. }
  22091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22092. // name in this mutation.
  22093. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  22094. switch name {
  22095. case soptask.EdgeTaskStages:
  22096. ids := make([]ent.Value, 0, len(m.task_stages))
  22097. for id := range m.task_stages {
  22098. ids = append(ids, id)
  22099. }
  22100. return ids
  22101. }
  22102. return nil
  22103. }
  22104. // RemovedEdges returns all edge names that were removed in this mutation.
  22105. func (m *SopTaskMutation) RemovedEdges() []string {
  22106. edges := make([]string, 0, 1)
  22107. if m.removedtask_stages != nil {
  22108. edges = append(edges, soptask.EdgeTaskStages)
  22109. }
  22110. return edges
  22111. }
  22112. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22113. // the given name in this mutation.
  22114. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  22115. switch name {
  22116. case soptask.EdgeTaskStages:
  22117. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  22118. for id := range m.removedtask_stages {
  22119. ids = append(ids, id)
  22120. }
  22121. return ids
  22122. }
  22123. return nil
  22124. }
  22125. // ClearedEdges returns all edge names that were cleared in this mutation.
  22126. func (m *SopTaskMutation) ClearedEdges() []string {
  22127. edges := make([]string, 0, 1)
  22128. if m.clearedtask_stages {
  22129. edges = append(edges, soptask.EdgeTaskStages)
  22130. }
  22131. return edges
  22132. }
  22133. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22134. // was cleared in this mutation.
  22135. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  22136. switch name {
  22137. case soptask.EdgeTaskStages:
  22138. return m.clearedtask_stages
  22139. }
  22140. return false
  22141. }
  22142. // ClearEdge clears the value of the edge with the given name. It returns an error
  22143. // if that edge is not defined in the schema.
  22144. func (m *SopTaskMutation) ClearEdge(name string) error {
  22145. switch name {
  22146. }
  22147. return fmt.Errorf("unknown SopTask unique edge %s", name)
  22148. }
  22149. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22150. // It returns an error if the edge is not defined in the schema.
  22151. func (m *SopTaskMutation) ResetEdge(name string) error {
  22152. switch name {
  22153. case soptask.EdgeTaskStages:
  22154. m.ResetTaskStages()
  22155. return nil
  22156. }
  22157. return fmt.Errorf("unknown SopTask edge %s", name)
  22158. }
  22159. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  22160. type TokenMutation struct {
  22161. config
  22162. op Op
  22163. typ string
  22164. id *uint64
  22165. created_at *time.Time
  22166. updated_at *time.Time
  22167. deleted_at *time.Time
  22168. expire_at *time.Time
  22169. token *string
  22170. mac *string
  22171. organization_id *uint64
  22172. addorganization_id *int64
  22173. custom_agent_base *string
  22174. custom_agent_key *string
  22175. openai_base *string
  22176. openai_key *string
  22177. clearedFields map[string]struct{}
  22178. agent *uint64
  22179. clearedagent bool
  22180. done bool
  22181. oldValue func(context.Context) (*Token, error)
  22182. predicates []predicate.Token
  22183. }
  22184. var _ ent.Mutation = (*TokenMutation)(nil)
  22185. // tokenOption allows management of the mutation configuration using functional options.
  22186. type tokenOption func(*TokenMutation)
  22187. // newTokenMutation creates new mutation for the Token entity.
  22188. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  22189. m := &TokenMutation{
  22190. config: c,
  22191. op: op,
  22192. typ: TypeToken,
  22193. clearedFields: make(map[string]struct{}),
  22194. }
  22195. for _, opt := range opts {
  22196. opt(m)
  22197. }
  22198. return m
  22199. }
  22200. // withTokenID sets the ID field of the mutation.
  22201. func withTokenID(id uint64) tokenOption {
  22202. return func(m *TokenMutation) {
  22203. var (
  22204. err error
  22205. once sync.Once
  22206. value *Token
  22207. )
  22208. m.oldValue = func(ctx context.Context) (*Token, error) {
  22209. once.Do(func() {
  22210. if m.done {
  22211. err = errors.New("querying old values post mutation is not allowed")
  22212. } else {
  22213. value, err = m.Client().Token.Get(ctx, id)
  22214. }
  22215. })
  22216. return value, err
  22217. }
  22218. m.id = &id
  22219. }
  22220. }
  22221. // withToken sets the old Token of the mutation.
  22222. func withToken(node *Token) tokenOption {
  22223. return func(m *TokenMutation) {
  22224. m.oldValue = func(context.Context) (*Token, error) {
  22225. return node, nil
  22226. }
  22227. m.id = &node.ID
  22228. }
  22229. }
  22230. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22231. // executed in a transaction (ent.Tx), a transactional client is returned.
  22232. func (m TokenMutation) Client() *Client {
  22233. client := &Client{config: m.config}
  22234. client.init()
  22235. return client
  22236. }
  22237. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22238. // it returns an error otherwise.
  22239. func (m TokenMutation) Tx() (*Tx, error) {
  22240. if _, ok := m.driver.(*txDriver); !ok {
  22241. return nil, errors.New("ent: mutation is not running in a transaction")
  22242. }
  22243. tx := &Tx{config: m.config}
  22244. tx.init()
  22245. return tx, nil
  22246. }
  22247. // SetID sets the value of the id field. Note that this
  22248. // operation is only accepted on creation of Token entities.
  22249. func (m *TokenMutation) SetID(id uint64) {
  22250. m.id = &id
  22251. }
  22252. // ID returns the ID value in the mutation. Note that the ID is only available
  22253. // if it was provided to the builder or after it was returned from the database.
  22254. func (m *TokenMutation) ID() (id uint64, exists bool) {
  22255. if m.id == nil {
  22256. return
  22257. }
  22258. return *m.id, true
  22259. }
  22260. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22261. // That means, if the mutation is applied within a transaction with an isolation level such
  22262. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22263. // or updated by the mutation.
  22264. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  22265. switch {
  22266. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22267. id, exists := m.ID()
  22268. if exists {
  22269. return []uint64{id}, nil
  22270. }
  22271. fallthrough
  22272. case m.op.Is(OpUpdate | OpDelete):
  22273. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  22274. default:
  22275. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22276. }
  22277. }
  22278. // SetCreatedAt sets the "created_at" field.
  22279. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  22280. m.created_at = &t
  22281. }
  22282. // CreatedAt returns the value of the "created_at" field in the mutation.
  22283. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  22284. v := m.created_at
  22285. if v == nil {
  22286. return
  22287. }
  22288. return *v, true
  22289. }
  22290. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  22291. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22293. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22294. if !m.op.Is(OpUpdateOne) {
  22295. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22296. }
  22297. if m.id == nil || m.oldValue == nil {
  22298. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22299. }
  22300. oldValue, err := m.oldValue(ctx)
  22301. if err != nil {
  22302. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22303. }
  22304. return oldValue.CreatedAt, nil
  22305. }
  22306. // ResetCreatedAt resets all changes to the "created_at" field.
  22307. func (m *TokenMutation) ResetCreatedAt() {
  22308. m.created_at = nil
  22309. }
  22310. // SetUpdatedAt sets the "updated_at" field.
  22311. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  22312. m.updated_at = &t
  22313. }
  22314. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22315. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  22316. v := m.updated_at
  22317. if v == nil {
  22318. return
  22319. }
  22320. return *v, true
  22321. }
  22322. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  22323. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22325. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22326. if !m.op.Is(OpUpdateOne) {
  22327. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22328. }
  22329. if m.id == nil || m.oldValue == nil {
  22330. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22331. }
  22332. oldValue, err := m.oldValue(ctx)
  22333. if err != nil {
  22334. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22335. }
  22336. return oldValue.UpdatedAt, nil
  22337. }
  22338. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22339. func (m *TokenMutation) ResetUpdatedAt() {
  22340. m.updated_at = nil
  22341. }
  22342. // SetDeletedAt sets the "deleted_at" field.
  22343. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  22344. m.deleted_at = &t
  22345. }
  22346. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22347. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  22348. v := m.deleted_at
  22349. if v == nil {
  22350. return
  22351. }
  22352. return *v, true
  22353. }
  22354. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  22355. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22357. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22358. if !m.op.Is(OpUpdateOne) {
  22359. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22360. }
  22361. if m.id == nil || m.oldValue == nil {
  22362. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22363. }
  22364. oldValue, err := m.oldValue(ctx)
  22365. if err != nil {
  22366. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22367. }
  22368. return oldValue.DeletedAt, nil
  22369. }
  22370. // ClearDeletedAt clears the value of the "deleted_at" field.
  22371. func (m *TokenMutation) ClearDeletedAt() {
  22372. m.deleted_at = nil
  22373. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  22374. }
  22375. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22376. func (m *TokenMutation) DeletedAtCleared() bool {
  22377. _, ok := m.clearedFields[token.FieldDeletedAt]
  22378. return ok
  22379. }
  22380. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22381. func (m *TokenMutation) ResetDeletedAt() {
  22382. m.deleted_at = nil
  22383. delete(m.clearedFields, token.FieldDeletedAt)
  22384. }
  22385. // SetExpireAt sets the "expire_at" field.
  22386. func (m *TokenMutation) SetExpireAt(t time.Time) {
  22387. m.expire_at = &t
  22388. }
  22389. // ExpireAt returns the value of the "expire_at" field in the mutation.
  22390. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  22391. v := m.expire_at
  22392. if v == nil {
  22393. return
  22394. }
  22395. return *v, true
  22396. }
  22397. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  22398. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22400. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  22401. if !m.op.Is(OpUpdateOne) {
  22402. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  22403. }
  22404. if m.id == nil || m.oldValue == nil {
  22405. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  22406. }
  22407. oldValue, err := m.oldValue(ctx)
  22408. if err != nil {
  22409. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  22410. }
  22411. return oldValue.ExpireAt, nil
  22412. }
  22413. // ClearExpireAt clears the value of the "expire_at" field.
  22414. func (m *TokenMutation) ClearExpireAt() {
  22415. m.expire_at = nil
  22416. m.clearedFields[token.FieldExpireAt] = struct{}{}
  22417. }
  22418. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  22419. func (m *TokenMutation) ExpireAtCleared() bool {
  22420. _, ok := m.clearedFields[token.FieldExpireAt]
  22421. return ok
  22422. }
  22423. // ResetExpireAt resets all changes to the "expire_at" field.
  22424. func (m *TokenMutation) ResetExpireAt() {
  22425. m.expire_at = nil
  22426. delete(m.clearedFields, token.FieldExpireAt)
  22427. }
  22428. // SetToken sets the "token" field.
  22429. func (m *TokenMutation) SetToken(s string) {
  22430. m.token = &s
  22431. }
  22432. // Token returns the value of the "token" field in the mutation.
  22433. func (m *TokenMutation) Token() (r string, exists bool) {
  22434. v := m.token
  22435. if v == nil {
  22436. return
  22437. }
  22438. return *v, true
  22439. }
  22440. // OldToken returns the old "token" field's value of the Token entity.
  22441. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22443. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  22444. if !m.op.Is(OpUpdateOne) {
  22445. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  22446. }
  22447. if m.id == nil || m.oldValue == nil {
  22448. return v, errors.New("OldToken requires an ID field in the mutation")
  22449. }
  22450. oldValue, err := m.oldValue(ctx)
  22451. if err != nil {
  22452. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  22453. }
  22454. return oldValue.Token, nil
  22455. }
  22456. // ClearToken clears the value of the "token" field.
  22457. func (m *TokenMutation) ClearToken() {
  22458. m.token = nil
  22459. m.clearedFields[token.FieldToken] = struct{}{}
  22460. }
  22461. // TokenCleared returns if the "token" field was cleared in this mutation.
  22462. func (m *TokenMutation) TokenCleared() bool {
  22463. _, ok := m.clearedFields[token.FieldToken]
  22464. return ok
  22465. }
  22466. // ResetToken resets all changes to the "token" field.
  22467. func (m *TokenMutation) ResetToken() {
  22468. m.token = nil
  22469. delete(m.clearedFields, token.FieldToken)
  22470. }
  22471. // SetMAC sets the "mac" field.
  22472. func (m *TokenMutation) SetMAC(s string) {
  22473. m.mac = &s
  22474. }
  22475. // MAC returns the value of the "mac" field in the mutation.
  22476. func (m *TokenMutation) MAC() (r string, exists bool) {
  22477. v := m.mac
  22478. if v == nil {
  22479. return
  22480. }
  22481. return *v, true
  22482. }
  22483. // OldMAC returns the old "mac" field's value of the Token entity.
  22484. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22486. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  22487. if !m.op.Is(OpUpdateOne) {
  22488. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  22489. }
  22490. if m.id == nil || m.oldValue == nil {
  22491. return v, errors.New("OldMAC requires an ID field in the mutation")
  22492. }
  22493. oldValue, err := m.oldValue(ctx)
  22494. if err != nil {
  22495. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  22496. }
  22497. return oldValue.MAC, nil
  22498. }
  22499. // ClearMAC clears the value of the "mac" field.
  22500. func (m *TokenMutation) ClearMAC() {
  22501. m.mac = nil
  22502. m.clearedFields[token.FieldMAC] = struct{}{}
  22503. }
  22504. // MACCleared returns if the "mac" field was cleared in this mutation.
  22505. func (m *TokenMutation) MACCleared() bool {
  22506. _, ok := m.clearedFields[token.FieldMAC]
  22507. return ok
  22508. }
  22509. // ResetMAC resets all changes to the "mac" field.
  22510. func (m *TokenMutation) ResetMAC() {
  22511. m.mac = nil
  22512. delete(m.clearedFields, token.FieldMAC)
  22513. }
  22514. // SetOrganizationID sets the "organization_id" field.
  22515. func (m *TokenMutation) SetOrganizationID(u uint64) {
  22516. m.organization_id = &u
  22517. m.addorganization_id = nil
  22518. }
  22519. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22520. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  22521. v := m.organization_id
  22522. if v == nil {
  22523. return
  22524. }
  22525. return *v, true
  22526. }
  22527. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  22528. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22530. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22531. if !m.op.Is(OpUpdateOne) {
  22532. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22533. }
  22534. if m.id == nil || m.oldValue == nil {
  22535. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22536. }
  22537. oldValue, err := m.oldValue(ctx)
  22538. if err != nil {
  22539. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22540. }
  22541. return oldValue.OrganizationID, nil
  22542. }
  22543. // AddOrganizationID adds u to the "organization_id" field.
  22544. func (m *TokenMutation) AddOrganizationID(u int64) {
  22545. if m.addorganization_id != nil {
  22546. *m.addorganization_id += u
  22547. } else {
  22548. m.addorganization_id = &u
  22549. }
  22550. }
  22551. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22552. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  22553. v := m.addorganization_id
  22554. if v == nil {
  22555. return
  22556. }
  22557. return *v, true
  22558. }
  22559. // ResetOrganizationID resets all changes to the "organization_id" field.
  22560. func (m *TokenMutation) ResetOrganizationID() {
  22561. m.organization_id = nil
  22562. m.addorganization_id = nil
  22563. }
  22564. // SetAgentID sets the "agent_id" field.
  22565. func (m *TokenMutation) SetAgentID(u uint64) {
  22566. m.agent = &u
  22567. }
  22568. // AgentID returns the value of the "agent_id" field in the mutation.
  22569. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  22570. v := m.agent
  22571. if v == nil {
  22572. return
  22573. }
  22574. return *v, true
  22575. }
  22576. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  22577. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22579. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  22580. if !m.op.Is(OpUpdateOne) {
  22581. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  22582. }
  22583. if m.id == nil || m.oldValue == nil {
  22584. return v, errors.New("OldAgentID requires an ID field in the mutation")
  22585. }
  22586. oldValue, err := m.oldValue(ctx)
  22587. if err != nil {
  22588. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  22589. }
  22590. return oldValue.AgentID, nil
  22591. }
  22592. // ResetAgentID resets all changes to the "agent_id" field.
  22593. func (m *TokenMutation) ResetAgentID() {
  22594. m.agent = nil
  22595. }
  22596. // SetCustomAgentBase sets the "custom_agent_base" field.
  22597. func (m *TokenMutation) SetCustomAgentBase(s string) {
  22598. m.custom_agent_base = &s
  22599. }
  22600. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  22601. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  22602. v := m.custom_agent_base
  22603. if v == nil {
  22604. return
  22605. }
  22606. return *v, true
  22607. }
  22608. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  22609. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22611. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  22612. if !m.op.Is(OpUpdateOne) {
  22613. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  22614. }
  22615. if m.id == nil || m.oldValue == nil {
  22616. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  22617. }
  22618. oldValue, err := m.oldValue(ctx)
  22619. if err != nil {
  22620. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  22621. }
  22622. return oldValue.CustomAgentBase, nil
  22623. }
  22624. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  22625. func (m *TokenMutation) ClearCustomAgentBase() {
  22626. m.custom_agent_base = nil
  22627. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  22628. }
  22629. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  22630. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  22631. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  22632. return ok
  22633. }
  22634. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  22635. func (m *TokenMutation) ResetCustomAgentBase() {
  22636. m.custom_agent_base = nil
  22637. delete(m.clearedFields, token.FieldCustomAgentBase)
  22638. }
  22639. // SetCustomAgentKey sets the "custom_agent_key" field.
  22640. func (m *TokenMutation) SetCustomAgentKey(s string) {
  22641. m.custom_agent_key = &s
  22642. }
  22643. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  22644. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  22645. v := m.custom_agent_key
  22646. if v == nil {
  22647. return
  22648. }
  22649. return *v, true
  22650. }
  22651. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  22652. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22654. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  22655. if !m.op.Is(OpUpdateOne) {
  22656. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  22657. }
  22658. if m.id == nil || m.oldValue == nil {
  22659. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  22660. }
  22661. oldValue, err := m.oldValue(ctx)
  22662. if err != nil {
  22663. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  22664. }
  22665. return oldValue.CustomAgentKey, nil
  22666. }
  22667. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  22668. func (m *TokenMutation) ClearCustomAgentKey() {
  22669. m.custom_agent_key = nil
  22670. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  22671. }
  22672. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  22673. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  22674. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  22675. return ok
  22676. }
  22677. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  22678. func (m *TokenMutation) ResetCustomAgentKey() {
  22679. m.custom_agent_key = nil
  22680. delete(m.clearedFields, token.FieldCustomAgentKey)
  22681. }
  22682. // SetOpenaiBase sets the "openai_base" field.
  22683. func (m *TokenMutation) SetOpenaiBase(s string) {
  22684. m.openai_base = &s
  22685. }
  22686. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  22687. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  22688. v := m.openai_base
  22689. if v == nil {
  22690. return
  22691. }
  22692. return *v, true
  22693. }
  22694. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  22695. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22697. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  22698. if !m.op.Is(OpUpdateOne) {
  22699. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  22700. }
  22701. if m.id == nil || m.oldValue == nil {
  22702. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  22703. }
  22704. oldValue, err := m.oldValue(ctx)
  22705. if err != nil {
  22706. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  22707. }
  22708. return oldValue.OpenaiBase, nil
  22709. }
  22710. // ClearOpenaiBase clears the value of the "openai_base" field.
  22711. func (m *TokenMutation) ClearOpenaiBase() {
  22712. m.openai_base = nil
  22713. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  22714. }
  22715. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  22716. func (m *TokenMutation) OpenaiBaseCleared() bool {
  22717. _, ok := m.clearedFields[token.FieldOpenaiBase]
  22718. return ok
  22719. }
  22720. // ResetOpenaiBase resets all changes to the "openai_base" field.
  22721. func (m *TokenMutation) ResetOpenaiBase() {
  22722. m.openai_base = nil
  22723. delete(m.clearedFields, token.FieldOpenaiBase)
  22724. }
  22725. // SetOpenaiKey sets the "openai_key" field.
  22726. func (m *TokenMutation) SetOpenaiKey(s string) {
  22727. m.openai_key = &s
  22728. }
  22729. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  22730. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  22731. v := m.openai_key
  22732. if v == nil {
  22733. return
  22734. }
  22735. return *v, true
  22736. }
  22737. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  22738. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22740. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  22741. if !m.op.Is(OpUpdateOne) {
  22742. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  22743. }
  22744. if m.id == nil || m.oldValue == nil {
  22745. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  22746. }
  22747. oldValue, err := m.oldValue(ctx)
  22748. if err != nil {
  22749. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  22750. }
  22751. return oldValue.OpenaiKey, nil
  22752. }
  22753. // ClearOpenaiKey clears the value of the "openai_key" field.
  22754. func (m *TokenMutation) ClearOpenaiKey() {
  22755. m.openai_key = nil
  22756. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  22757. }
  22758. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  22759. func (m *TokenMutation) OpenaiKeyCleared() bool {
  22760. _, ok := m.clearedFields[token.FieldOpenaiKey]
  22761. return ok
  22762. }
  22763. // ResetOpenaiKey resets all changes to the "openai_key" field.
  22764. func (m *TokenMutation) ResetOpenaiKey() {
  22765. m.openai_key = nil
  22766. delete(m.clearedFields, token.FieldOpenaiKey)
  22767. }
  22768. // ClearAgent clears the "agent" edge to the Agent entity.
  22769. func (m *TokenMutation) ClearAgent() {
  22770. m.clearedagent = true
  22771. m.clearedFields[token.FieldAgentID] = struct{}{}
  22772. }
  22773. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  22774. func (m *TokenMutation) AgentCleared() bool {
  22775. return m.clearedagent
  22776. }
  22777. // AgentIDs returns the "agent" edge IDs in the mutation.
  22778. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22779. // AgentID instead. It exists only for internal usage by the builders.
  22780. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  22781. if id := m.agent; id != nil {
  22782. ids = append(ids, *id)
  22783. }
  22784. return
  22785. }
  22786. // ResetAgent resets all changes to the "agent" edge.
  22787. func (m *TokenMutation) ResetAgent() {
  22788. m.agent = nil
  22789. m.clearedagent = false
  22790. }
  22791. // Where appends a list predicates to the TokenMutation builder.
  22792. func (m *TokenMutation) Where(ps ...predicate.Token) {
  22793. m.predicates = append(m.predicates, ps...)
  22794. }
  22795. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  22796. // users can use type-assertion to append predicates that do not depend on any generated package.
  22797. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  22798. p := make([]predicate.Token, len(ps))
  22799. for i := range ps {
  22800. p[i] = ps[i]
  22801. }
  22802. m.Where(p...)
  22803. }
  22804. // Op returns the operation name.
  22805. func (m *TokenMutation) Op() Op {
  22806. return m.op
  22807. }
  22808. // SetOp allows setting the mutation operation.
  22809. func (m *TokenMutation) SetOp(op Op) {
  22810. m.op = op
  22811. }
  22812. // Type returns the node type of this mutation (Token).
  22813. func (m *TokenMutation) Type() string {
  22814. return m.typ
  22815. }
  22816. // Fields returns all fields that were changed during this mutation. Note that in
  22817. // order to get all numeric fields that were incremented/decremented, call
  22818. // AddedFields().
  22819. func (m *TokenMutation) Fields() []string {
  22820. fields := make([]string, 0, 12)
  22821. if m.created_at != nil {
  22822. fields = append(fields, token.FieldCreatedAt)
  22823. }
  22824. if m.updated_at != nil {
  22825. fields = append(fields, token.FieldUpdatedAt)
  22826. }
  22827. if m.deleted_at != nil {
  22828. fields = append(fields, token.FieldDeletedAt)
  22829. }
  22830. if m.expire_at != nil {
  22831. fields = append(fields, token.FieldExpireAt)
  22832. }
  22833. if m.token != nil {
  22834. fields = append(fields, token.FieldToken)
  22835. }
  22836. if m.mac != nil {
  22837. fields = append(fields, token.FieldMAC)
  22838. }
  22839. if m.organization_id != nil {
  22840. fields = append(fields, token.FieldOrganizationID)
  22841. }
  22842. if m.agent != nil {
  22843. fields = append(fields, token.FieldAgentID)
  22844. }
  22845. if m.custom_agent_base != nil {
  22846. fields = append(fields, token.FieldCustomAgentBase)
  22847. }
  22848. if m.custom_agent_key != nil {
  22849. fields = append(fields, token.FieldCustomAgentKey)
  22850. }
  22851. if m.openai_base != nil {
  22852. fields = append(fields, token.FieldOpenaiBase)
  22853. }
  22854. if m.openai_key != nil {
  22855. fields = append(fields, token.FieldOpenaiKey)
  22856. }
  22857. return fields
  22858. }
  22859. // Field returns the value of a field with the given name. The second boolean
  22860. // return value indicates that this field was not set, or was not defined in the
  22861. // schema.
  22862. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  22863. switch name {
  22864. case token.FieldCreatedAt:
  22865. return m.CreatedAt()
  22866. case token.FieldUpdatedAt:
  22867. return m.UpdatedAt()
  22868. case token.FieldDeletedAt:
  22869. return m.DeletedAt()
  22870. case token.FieldExpireAt:
  22871. return m.ExpireAt()
  22872. case token.FieldToken:
  22873. return m.Token()
  22874. case token.FieldMAC:
  22875. return m.MAC()
  22876. case token.FieldOrganizationID:
  22877. return m.OrganizationID()
  22878. case token.FieldAgentID:
  22879. return m.AgentID()
  22880. case token.FieldCustomAgentBase:
  22881. return m.CustomAgentBase()
  22882. case token.FieldCustomAgentKey:
  22883. return m.CustomAgentKey()
  22884. case token.FieldOpenaiBase:
  22885. return m.OpenaiBase()
  22886. case token.FieldOpenaiKey:
  22887. return m.OpenaiKey()
  22888. }
  22889. return nil, false
  22890. }
  22891. // OldField returns the old value of the field from the database. An error is
  22892. // returned if the mutation operation is not UpdateOne, or the query to the
  22893. // database failed.
  22894. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22895. switch name {
  22896. case token.FieldCreatedAt:
  22897. return m.OldCreatedAt(ctx)
  22898. case token.FieldUpdatedAt:
  22899. return m.OldUpdatedAt(ctx)
  22900. case token.FieldDeletedAt:
  22901. return m.OldDeletedAt(ctx)
  22902. case token.FieldExpireAt:
  22903. return m.OldExpireAt(ctx)
  22904. case token.FieldToken:
  22905. return m.OldToken(ctx)
  22906. case token.FieldMAC:
  22907. return m.OldMAC(ctx)
  22908. case token.FieldOrganizationID:
  22909. return m.OldOrganizationID(ctx)
  22910. case token.FieldAgentID:
  22911. return m.OldAgentID(ctx)
  22912. case token.FieldCustomAgentBase:
  22913. return m.OldCustomAgentBase(ctx)
  22914. case token.FieldCustomAgentKey:
  22915. return m.OldCustomAgentKey(ctx)
  22916. case token.FieldOpenaiBase:
  22917. return m.OldOpenaiBase(ctx)
  22918. case token.FieldOpenaiKey:
  22919. return m.OldOpenaiKey(ctx)
  22920. }
  22921. return nil, fmt.Errorf("unknown Token field %s", name)
  22922. }
  22923. // SetField sets the value of a field with the given name. It returns an error if
  22924. // the field is not defined in the schema, or if the type mismatched the field
  22925. // type.
  22926. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  22927. switch name {
  22928. case token.FieldCreatedAt:
  22929. v, ok := value.(time.Time)
  22930. if !ok {
  22931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22932. }
  22933. m.SetCreatedAt(v)
  22934. return nil
  22935. case token.FieldUpdatedAt:
  22936. v, ok := value.(time.Time)
  22937. if !ok {
  22938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22939. }
  22940. m.SetUpdatedAt(v)
  22941. return nil
  22942. case token.FieldDeletedAt:
  22943. v, ok := value.(time.Time)
  22944. if !ok {
  22945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22946. }
  22947. m.SetDeletedAt(v)
  22948. return nil
  22949. case token.FieldExpireAt:
  22950. v, ok := value.(time.Time)
  22951. if !ok {
  22952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22953. }
  22954. m.SetExpireAt(v)
  22955. return nil
  22956. case token.FieldToken:
  22957. v, ok := value.(string)
  22958. if !ok {
  22959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22960. }
  22961. m.SetToken(v)
  22962. return nil
  22963. case token.FieldMAC:
  22964. v, ok := value.(string)
  22965. if !ok {
  22966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22967. }
  22968. m.SetMAC(v)
  22969. return nil
  22970. case token.FieldOrganizationID:
  22971. v, ok := value.(uint64)
  22972. if !ok {
  22973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22974. }
  22975. m.SetOrganizationID(v)
  22976. return nil
  22977. case token.FieldAgentID:
  22978. v, ok := value.(uint64)
  22979. if !ok {
  22980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22981. }
  22982. m.SetAgentID(v)
  22983. return nil
  22984. case token.FieldCustomAgentBase:
  22985. v, ok := value.(string)
  22986. if !ok {
  22987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22988. }
  22989. m.SetCustomAgentBase(v)
  22990. return nil
  22991. case token.FieldCustomAgentKey:
  22992. v, ok := value.(string)
  22993. if !ok {
  22994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22995. }
  22996. m.SetCustomAgentKey(v)
  22997. return nil
  22998. case token.FieldOpenaiBase:
  22999. v, ok := value.(string)
  23000. if !ok {
  23001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23002. }
  23003. m.SetOpenaiBase(v)
  23004. return nil
  23005. case token.FieldOpenaiKey:
  23006. v, ok := value.(string)
  23007. if !ok {
  23008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23009. }
  23010. m.SetOpenaiKey(v)
  23011. return nil
  23012. }
  23013. return fmt.Errorf("unknown Token field %s", name)
  23014. }
  23015. // AddedFields returns all numeric fields that were incremented/decremented during
  23016. // this mutation.
  23017. func (m *TokenMutation) AddedFields() []string {
  23018. var fields []string
  23019. if m.addorganization_id != nil {
  23020. fields = append(fields, token.FieldOrganizationID)
  23021. }
  23022. return fields
  23023. }
  23024. // AddedField returns the numeric value that was incremented/decremented on a field
  23025. // with the given name. The second boolean return value indicates that this field
  23026. // was not set, or was not defined in the schema.
  23027. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  23028. switch name {
  23029. case token.FieldOrganizationID:
  23030. return m.AddedOrganizationID()
  23031. }
  23032. return nil, false
  23033. }
  23034. // AddField adds the value to the field with the given name. It returns an error if
  23035. // the field is not defined in the schema, or if the type mismatched the field
  23036. // type.
  23037. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  23038. switch name {
  23039. case token.FieldOrganizationID:
  23040. v, ok := value.(int64)
  23041. if !ok {
  23042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23043. }
  23044. m.AddOrganizationID(v)
  23045. return nil
  23046. }
  23047. return fmt.Errorf("unknown Token numeric field %s", name)
  23048. }
  23049. // ClearedFields returns all nullable fields that were cleared during this
  23050. // mutation.
  23051. func (m *TokenMutation) ClearedFields() []string {
  23052. var fields []string
  23053. if m.FieldCleared(token.FieldDeletedAt) {
  23054. fields = append(fields, token.FieldDeletedAt)
  23055. }
  23056. if m.FieldCleared(token.FieldExpireAt) {
  23057. fields = append(fields, token.FieldExpireAt)
  23058. }
  23059. if m.FieldCleared(token.FieldToken) {
  23060. fields = append(fields, token.FieldToken)
  23061. }
  23062. if m.FieldCleared(token.FieldMAC) {
  23063. fields = append(fields, token.FieldMAC)
  23064. }
  23065. if m.FieldCleared(token.FieldCustomAgentBase) {
  23066. fields = append(fields, token.FieldCustomAgentBase)
  23067. }
  23068. if m.FieldCleared(token.FieldCustomAgentKey) {
  23069. fields = append(fields, token.FieldCustomAgentKey)
  23070. }
  23071. if m.FieldCleared(token.FieldOpenaiBase) {
  23072. fields = append(fields, token.FieldOpenaiBase)
  23073. }
  23074. if m.FieldCleared(token.FieldOpenaiKey) {
  23075. fields = append(fields, token.FieldOpenaiKey)
  23076. }
  23077. return fields
  23078. }
  23079. // FieldCleared returns a boolean indicating if a field with the given name was
  23080. // cleared in this mutation.
  23081. func (m *TokenMutation) FieldCleared(name string) bool {
  23082. _, ok := m.clearedFields[name]
  23083. return ok
  23084. }
  23085. // ClearField clears the value of the field with the given name. It returns an
  23086. // error if the field is not defined in the schema.
  23087. func (m *TokenMutation) ClearField(name string) error {
  23088. switch name {
  23089. case token.FieldDeletedAt:
  23090. m.ClearDeletedAt()
  23091. return nil
  23092. case token.FieldExpireAt:
  23093. m.ClearExpireAt()
  23094. return nil
  23095. case token.FieldToken:
  23096. m.ClearToken()
  23097. return nil
  23098. case token.FieldMAC:
  23099. m.ClearMAC()
  23100. return nil
  23101. case token.FieldCustomAgentBase:
  23102. m.ClearCustomAgentBase()
  23103. return nil
  23104. case token.FieldCustomAgentKey:
  23105. m.ClearCustomAgentKey()
  23106. return nil
  23107. case token.FieldOpenaiBase:
  23108. m.ClearOpenaiBase()
  23109. return nil
  23110. case token.FieldOpenaiKey:
  23111. m.ClearOpenaiKey()
  23112. return nil
  23113. }
  23114. return fmt.Errorf("unknown Token nullable field %s", name)
  23115. }
  23116. // ResetField resets all changes in the mutation for the field with the given name.
  23117. // It returns an error if the field is not defined in the schema.
  23118. func (m *TokenMutation) ResetField(name string) error {
  23119. switch name {
  23120. case token.FieldCreatedAt:
  23121. m.ResetCreatedAt()
  23122. return nil
  23123. case token.FieldUpdatedAt:
  23124. m.ResetUpdatedAt()
  23125. return nil
  23126. case token.FieldDeletedAt:
  23127. m.ResetDeletedAt()
  23128. return nil
  23129. case token.FieldExpireAt:
  23130. m.ResetExpireAt()
  23131. return nil
  23132. case token.FieldToken:
  23133. m.ResetToken()
  23134. return nil
  23135. case token.FieldMAC:
  23136. m.ResetMAC()
  23137. return nil
  23138. case token.FieldOrganizationID:
  23139. m.ResetOrganizationID()
  23140. return nil
  23141. case token.FieldAgentID:
  23142. m.ResetAgentID()
  23143. return nil
  23144. case token.FieldCustomAgentBase:
  23145. m.ResetCustomAgentBase()
  23146. return nil
  23147. case token.FieldCustomAgentKey:
  23148. m.ResetCustomAgentKey()
  23149. return nil
  23150. case token.FieldOpenaiBase:
  23151. m.ResetOpenaiBase()
  23152. return nil
  23153. case token.FieldOpenaiKey:
  23154. m.ResetOpenaiKey()
  23155. return nil
  23156. }
  23157. return fmt.Errorf("unknown Token field %s", name)
  23158. }
  23159. // AddedEdges returns all edge names that were set/added in this mutation.
  23160. func (m *TokenMutation) AddedEdges() []string {
  23161. edges := make([]string, 0, 1)
  23162. if m.agent != nil {
  23163. edges = append(edges, token.EdgeAgent)
  23164. }
  23165. return edges
  23166. }
  23167. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23168. // name in this mutation.
  23169. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  23170. switch name {
  23171. case token.EdgeAgent:
  23172. if id := m.agent; id != nil {
  23173. return []ent.Value{*id}
  23174. }
  23175. }
  23176. return nil
  23177. }
  23178. // RemovedEdges returns all edge names that were removed in this mutation.
  23179. func (m *TokenMutation) RemovedEdges() []string {
  23180. edges := make([]string, 0, 1)
  23181. return edges
  23182. }
  23183. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23184. // the given name in this mutation.
  23185. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  23186. return nil
  23187. }
  23188. // ClearedEdges returns all edge names that were cleared in this mutation.
  23189. func (m *TokenMutation) ClearedEdges() []string {
  23190. edges := make([]string, 0, 1)
  23191. if m.clearedagent {
  23192. edges = append(edges, token.EdgeAgent)
  23193. }
  23194. return edges
  23195. }
  23196. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23197. // was cleared in this mutation.
  23198. func (m *TokenMutation) EdgeCleared(name string) bool {
  23199. switch name {
  23200. case token.EdgeAgent:
  23201. return m.clearedagent
  23202. }
  23203. return false
  23204. }
  23205. // ClearEdge clears the value of the edge with the given name. It returns an error
  23206. // if that edge is not defined in the schema.
  23207. func (m *TokenMutation) ClearEdge(name string) error {
  23208. switch name {
  23209. case token.EdgeAgent:
  23210. m.ClearAgent()
  23211. return nil
  23212. }
  23213. return fmt.Errorf("unknown Token unique edge %s", name)
  23214. }
  23215. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23216. // It returns an error if the edge is not defined in the schema.
  23217. func (m *TokenMutation) ResetEdge(name string) error {
  23218. switch name {
  23219. case token.EdgeAgent:
  23220. m.ResetAgent()
  23221. return nil
  23222. }
  23223. return fmt.Errorf("unknown Token edge %s", name)
  23224. }
  23225. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  23226. type TutorialMutation struct {
  23227. config
  23228. op Op
  23229. typ string
  23230. id *uint64
  23231. created_at *time.Time
  23232. updated_at *time.Time
  23233. deleted_at *time.Time
  23234. index *int
  23235. addindex *int
  23236. title *string
  23237. content *string
  23238. organization_id *uint64
  23239. addorganization_id *int64
  23240. clearedFields map[string]struct{}
  23241. employee *uint64
  23242. clearedemployee bool
  23243. done bool
  23244. oldValue func(context.Context) (*Tutorial, error)
  23245. predicates []predicate.Tutorial
  23246. }
  23247. var _ ent.Mutation = (*TutorialMutation)(nil)
  23248. // tutorialOption allows management of the mutation configuration using functional options.
  23249. type tutorialOption func(*TutorialMutation)
  23250. // newTutorialMutation creates new mutation for the Tutorial entity.
  23251. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  23252. m := &TutorialMutation{
  23253. config: c,
  23254. op: op,
  23255. typ: TypeTutorial,
  23256. clearedFields: make(map[string]struct{}),
  23257. }
  23258. for _, opt := range opts {
  23259. opt(m)
  23260. }
  23261. return m
  23262. }
  23263. // withTutorialID sets the ID field of the mutation.
  23264. func withTutorialID(id uint64) tutorialOption {
  23265. return func(m *TutorialMutation) {
  23266. var (
  23267. err error
  23268. once sync.Once
  23269. value *Tutorial
  23270. )
  23271. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  23272. once.Do(func() {
  23273. if m.done {
  23274. err = errors.New("querying old values post mutation is not allowed")
  23275. } else {
  23276. value, err = m.Client().Tutorial.Get(ctx, id)
  23277. }
  23278. })
  23279. return value, err
  23280. }
  23281. m.id = &id
  23282. }
  23283. }
  23284. // withTutorial sets the old Tutorial of the mutation.
  23285. func withTutorial(node *Tutorial) tutorialOption {
  23286. return func(m *TutorialMutation) {
  23287. m.oldValue = func(context.Context) (*Tutorial, error) {
  23288. return node, nil
  23289. }
  23290. m.id = &node.ID
  23291. }
  23292. }
  23293. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23294. // executed in a transaction (ent.Tx), a transactional client is returned.
  23295. func (m TutorialMutation) Client() *Client {
  23296. client := &Client{config: m.config}
  23297. client.init()
  23298. return client
  23299. }
  23300. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23301. // it returns an error otherwise.
  23302. func (m TutorialMutation) Tx() (*Tx, error) {
  23303. if _, ok := m.driver.(*txDriver); !ok {
  23304. return nil, errors.New("ent: mutation is not running in a transaction")
  23305. }
  23306. tx := &Tx{config: m.config}
  23307. tx.init()
  23308. return tx, nil
  23309. }
  23310. // SetID sets the value of the id field. Note that this
  23311. // operation is only accepted on creation of Tutorial entities.
  23312. func (m *TutorialMutation) SetID(id uint64) {
  23313. m.id = &id
  23314. }
  23315. // ID returns the ID value in the mutation. Note that the ID is only available
  23316. // if it was provided to the builder or after it was returned from the database.
  23317. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  23318. if m.id == nil {
  23319. return
  23320. }
  23321. return *m.id, true
  23322. }
  23323. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23324. // That means, if the mutation is applied within a transaction with an isolation level such
  23325. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23326. // or updated by the mutation.
  23327. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  23328. switch {
  23329. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23330. id, exists := m.ID()
  23331. if exists {
  23332. return []uint64{id}, nil
  23333. }
  23334. fallthrough
  23335. case m.op.Is(OpUpdate | OpDelete):
  23336. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  23337. default:
  23338. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23339. }
  23340. }
  23341. // SetCreatedAt sets the "created_at" field.
  23342. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  23343. m.created_at = &t
  23344. }
  23345. // CreatedAt returns the value of the "created_at" field in the mutation.
  23346. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  23347. v := m.created_at
  23348. if v == nil {
  23349. return
  23350. }
  23351. return *v, true
  23352. }
  23353. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  23354. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23356. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23357. if !m.op.Is(OpUpdateOne) {
  23358. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23359. }
  23360. if m.id == nil || m.oldValue == nil {
  23361. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23362. }
  23363. oldValue, err := m.oldValue(ctx)
  23364. if err != nil {
  23365. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23366. }
  23367. return oldValue.CreatedAt, nil
  23368. }
  23369. // ResetCreatedAt resets all changes to the "created_at" field.
  23370. func (m *TutorialMutation) ResetCreatedAt() {
  23371. m.created_at = nil
  23372. }
  23373. // SetUpdatedAt sets the "updated_at" field.
  23374. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  23375. m.updated_at = &t
  23376. }
  23377. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23378. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  23379. v := m.updated_at
  23380. if v == nil {
  23381. return
  23382. }
  23383. return *v, true
  23384. }
  23385. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  23386. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23388. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23389. if !m.op.Is(OpUpdateOne) {
  23390. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23391. }
  23392. if m.id == nil || m.oldValue == nil {
  23393. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23394. }
  23395. oldValue, err := m.oldValue(ctx)
  23396. if err != nil {
  23397. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23398. }
  23399. return oldValue.UpdatedAt, nil
  23400. }
  23401. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23402. func (m *TutorialMutation) ResetUpdatedAt() {
  23403. m.updated_at = nil
  23404. }
  23405. // SetDeletedAt sets the "deleted_at" field.
  23406. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  23407. m.deleted_at = &t
  23408. }
  23409. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23410. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  23411. v := m.deleted_at
  23412. if v == nil {
  23413. return
  23414. }
  23415. return *v, true
  23416. }
  23417. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  23418. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23420. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23421. if !m.op.Is(OpUpdateOne) {
  23422. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23423. }
  23424. if m.id == nil || m.oldValue == nil {
  23425. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23426. }
  23427. oldValue, err := m.oldValue(ctx)
  23428. if err != nil {
  23429. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23430. }
  23431. return oldValue.DeletedAt, nil
  23432. }
  23433. // ClearDeletedAt clears the value of the "deleted_at" field.
  23434. func (m *TutorialMutation) ClearDeletedAt() {
  23435. m.deleted_at = nil
  23436. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  23437. }
  23438. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23439. func (m *TutorialMutation) DeletedAtCleared() bool {
  23440. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  23441. return ok
  23442. }
  23443. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23444. func (m *TutorialMutation) ResetDeletedAt() {
  23445. m.deleted_at = nil
  23446. delete(m.clearedFields, tutorial.FieldDeletedAt)
  23447. }
  23448. // SetEmployeeID sets the "employee_id" field.
  23449. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  23450. m.employee = &u
  23451. }
  23452. // EmployeeID returns the value of the "employee_id" field in the mutation.
  23453. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  23454. v := m.employee
  23455. if v == nil {
  23456. return
  23457. }
  23458. return *v, true
  23459. }
  23460. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  23461. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23463. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  23464. if !m.op.Is(OpUpdateOne) {
  23465. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  23466. }
  23467. if m.id == nil || m.oldValue == nil {
  23468. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  23469. }
  23470. oldValue, err := m.oldValue(ctx)
  23471. if err != nil {
  23472. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  23473. }
  23474. return oldValue.EmployeeID, nil
  23475. }
  23476. // ResetEmployeeID resets all changes to the "employee_id" field.
  23477. func (m *TutorialMutation) ResetEmployeeID() {
  23478. m.employee = nil
  23479. }
  23480. // SetIndex sets the "index" field.
  23481. func (m *TutorialMutation) SetIndex(i int) {
  23482. m.index = &i
  23483. m.addindex = nil
  23484. }
  23485. // Index returns the value of the "index" field in the mutation.
  23486. func (m *TutorialMutation) Index() (r int, exists bool) {
  23487. v := m.index
  23488. if v == nil {
  23489. return
  23490. }
  23491. return *v, true
  23492. }
  23493. // OldIndex returns the old "index" field's value of the Tutorial entity.
  23494. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23496. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  23497. if !m.op.Is(OpUpdateOne) {
  23498. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  23499. }
  23500. if m.id == nil || m.oldValue == nil {
  23501. return v, errors.New("OldIndex requires an ID field in the mutation")
  23502. }
  23503. oldValue, err := m.oldValue(ctx)
  23504. if err != nil {
  23505. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  23506. }
  23507. return oldValue.Index, nil
  23508. }
  23509. // AddIndex adds i to the "index" field.
  23510. func (m *TutorialMutation) AddIndex(i int) {
  23511. if m.addindex != nil {
  23512. *m.addindex += i
  23513. } else {
  23514. m.addindex = &i
  23515. }
  23516. }
  23517. // AddedIndex returns the value that was added to the "index" field in this mutation.
  23518. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  23519. v := m.addindex
  23520. if v == nil {
  23521. return
  23522. }
  23523. return *v, true
  23524. }
  23525. // ResetIndex resets all changes to the "index" field.
  23526. func (m *TutorialMutation) ResetIndex() {
  23527. m.index = nil
  23528. m.addindex = nil
  23529. }
  23530. // SetTitle sets the "title" field.
  23531. func (m *TutorialMutation) SetTitle(s string) {
  23532. m.title = &s
  23533. }
  23534. // Title returns the value of the "title" field in the mutation.
  23535. func (m *TutorialMutation) Title() (r string, exists bool) {
  23536. v := m.title
  23537. if v == nil {
  23538. return
  23539. }
  23540. return *v, true
  23541. }
  23542. // OldTitle returns the old "title" field's value of the Tutorial entity.
  23543. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23545. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  23546. if !m.op.Is(OpUpdateOne) {
  23547. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  23548. }
  23549. if m.id == nil || m.oldValue == nil {
  23550. return v, errors.New("OldTitle requires an ID field in the mutation")
  23551. }
  23552. oldValue, err := m.oldValue(ctx)
  23553. if err != nil {
  23554. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  23555. }
  23556. return oldValue.Title, nil
  23557. }
  23558. // ResetTitle resets all changes to the "title" field.
  23559. func (m *TutorialMutation) ResetTitle() {
  23560. m.title = nil
  23561. }
  23562. // SetContent sets the "content" field.
  23563. func (m *TutorialMutation) SetContent(s string) {
  23564. m.content = &s
  23565. }
  23566. // Content returns the value of the "content" field in the mutation.
  23567. func (m *TutorialMutation) Content() (r string, exists bool) {
  23568. v := m.content
  23569. if v == nil {
  23570. return
  23571. }
  23572. return *v, true
  23573. }
  23574. // OldContent returns the old "content" field's value of the Tutorial entity.
  23575. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23577. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  23578. if !m.op.Is(OpUpdateOne) {
  23579. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23580. }
  23581. if m.id == nil || m.oldValue == nil {
  23582. return v, errors.New("OldContent requires an ID field in the mutation")
  23583. }
  23584. oldValue, err := m.oldValue(ctx)
  23585. if err != nil {
  23586. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23587. }
  23588. return oldValue.Content, nil
  23589. }
  23590. // ResetContent resets all changes to the "content" field.
  23591. func (m *TutorialMutation) ResetContent() {
  23592. m.content = nil
  23593. }
  23594. // SetOrganizationID sets the "organization_id" field.
  23595. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  23596. m.organization_id = &u
  23597. m.addorganization_id = nil
  23598. }
  23599. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23600. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  23601. v := m.organization_id
  23602. if v == nil {
  23603. return
  23604. }
  23605. return *v, true
  23606. }
  23607. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  23608. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23610. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23611. if !m.op.Is(OpUpdateOne) {
  23612. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23613. }
  23614. if m.id == nil || m.oldValue == nil {
  23615. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23616. }
  23617. oldValue, err := m.oldValue(ctx)
  23618. if err != nil {
  23619. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23620. }
  23621. return oldValue.OrganizationID, nil
  23622. }
  23623. // AddOrganizationID adds u to the "organization_id" field.
  23624. func (m *TutorialMutation) AddOrganizationID(u int64) {
  23625. if m.addorganization_id != nil {
  23626. *m.addorganization_id += u
  23627. } else {
  23628. m.addorganization_id = &u
  23629. }
  23630. }
  23631. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23632. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  23633. v := m.addorganization_id
  23634. if v == nil {
  23635. return
  23636. }
  23637. return *v, true
  23638. }
  23639. // ResetOrganizationID resets all changes to the "organization_id" field.
  23640. func (m *TutorialMutation) ResetOrganizationID() {
  23641. m.organization_id = nil
  23642. m.addorganization_id = nil
  23643. }
  23644. // ClearEmployee clears the "employee" edge to the Employee entity.
  23645. func (m *TutorialMutation) ClearEmployee() {
  23646. m.clearedemployee = true
  23647. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  23648. }
  23649. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  23650. func (m *TutorialMutation) EmployeeCleared() bool {
  23651. return m.clearedemployee
  23652. }
  23653. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  23654. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23655. // EmployeeID instead. It exists only for internal usage by the builders.
  23656. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  23657. if id := m.employee; id != nil {
  23658. ids = append(ids, *id)
  23659. }
  23660. return
  23661. }
  23662. // ResetEmployee resets all changes to the "employee" edge.
  23663. func (m *TutorialMutation) ResetEmployee() {
  23664. m.employee = nil
  23665. m.clearedemployee = false
  23666. }
  23667. // Where appends a list predicates to the TutorialMutation builder.
  23668. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  23669. m.predicates = append(m.predicates, ps...)
  23670. }
  23671. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  23672. // users can use type-assertion to append predicates that do not depend on any generated package.
  23673. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  23674. p := make([]predicate.Tutorial, len(ps))
  23675. for i := range ps {
  23676. p[i] = ps[i]
  23677. }
  23678. m.Where(p...)
  23679. }
  23680. // Op returns the operation name.
  23681. func (m *TutorialMutation) Op() Op {
  23682. return m.op
  23683. }
  23684. // SetOp allows setting the mutation operation.
  23685. func (m *TutorialMutation) SetOp(op Op) {
  23686. m.op = op
  23687. }
  23688. // Type returns the node type of this mutation (Tutorial).
  23689. func (m *TutorialMutation) Type() string {
  23690. return m.typ
  23691. }
  23692. // Fields returns all fields that were changed during this mutation. Note that in
  23693. // order to get all numeric fields that were incremented/decremented, call
  23694. // AddedFields().
  23695. func (m *TutorialMutation) Fields() []string {
  23696. fields := make([]string, 0, 8)
  23697. if m.created_at != nil {
  23698. fields = append(fields, tutorial.FieldCreatedAt)
  23699. }
  23700. if m.updated_at != nil {
  23701. fields = append(fields, tutorial.FieldUpdatedAt)
  23702. }
  23703. if m.deleted_at != nil {
  23704. fields = append(fields, tutorial.FieldDeletedAt)
  23705. }
  23706. if m.employee != nil {
  23707. fields = append(fields, tutorial.FieldEmployeeID)
  23708. }
  23709. if m.index != nil {
  23710. fields = append(fields, tutorial.FieldIndex)
  23711. }
  23712. if m.title != nil {
  23713. fields = append(fields, tutorial.FieldTitle)
  23714. }
  23715. if m.content != nil {
  23716. fields = append(fields, tutorial.FieldContent)
  23717. }
  23718. if m.organization_id != nil {
  23719. fields = append(fields, tutorial.FieldOrganizationID)
  23720. }
  23721. return fields
  23722. }
  23723. // Field returns the value of a field with the given name. The second boolean
  23724. // return value indicates that this field was not set, or was not defined in the
  23725. // schema.
  23726. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  23727. switch name {
  23728. case tutorial.FieldCreatedAt:
  23729. return m.CreatedAt()
  23730. case tutorial.FieldUpdatedAt:
  23731. return m.UpdatedAt()
  23732. case tutorial.FieldDeletedAt:
  23733. return m.DeletedAt()
  23734. case tutorial.FieldEmployeeID:
  23735. return m.EmployeeID()
  23736. case tutorial.FieldIndex:
  23737. return m.Index()
  23738. case tutorial.FieldTitle:
  23739. return m.Title()
  23740. case tutorial.FieldContent:
  23741. return m.Content()
  23742. case tutorial.FieldOrganizationID:
  23743. return m.OrganizationID()
  23744. }
  23745. return nil, false
  23746. }
  23747. // OldField returns the old value of the field from the database. An error is
  23748. // returned if the mutation operation is not UpdateOne, or the query to the
  23749. // database failed.
  23750. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23751. switch name {
  23752. case tutorial.FieldCreatedAt:
  23753. return m.OldCreatedAt(ctx)
  23754. case tutorial.FieldUpdatedAt:
  23755. return m.OldUpdatedAt(ctx)
  23756. case tutorial.FieldDeletedAt:
  23757. return m.OldDeletedAt(ctx)
  23758. case tutorial.FieldEmployeeID:
  23759. return m.OldEmployeeID(ctx)
  23760. case tutorial.FieldIndex:
  23761. return m.OldIndex(ctx)
  23762. case tutorial.FieldTitle:
  23763. return m.OldTitle(ctx)
  23764. case tutorial.FieldContent:
  23765. return m.OldContent(ctx)
  23766. case tutorial.FieldOrganizationID:
  23767. return m.OldOrganizationID(ctx)
  23768. }
  23769. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  23770. }
  23771. // SetField sets the value of a field with the given name. It returns an error if
  23772. // the field is not defined in the schema, or if the type mismatched the field
  23773. // type.
  23774. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  23775. switch name {
  23776. case tutorial.FieldCreatedAt:
  23777. v, ok := value.(time.Time)
  23778. if !ok {
  23779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23780. }
  23781. m.SetCreatedAt(v)
  23782. return nil
  23783. case tutorial.FieldUpdatedAt:
  23784. v, ok := value.(time.Time)
  23785. if !ok {
  23786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23787. }
  23788. m.SetUpdatedAt(v)
  23789. return nil
  23790. case tutorial.FieldDeletedAt:
  23791. v, ok := value.(time.Time)
  23792. if !ok {
  23793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23794. }
  23795. m.SetDeletedAt(v)
  23796. return nil
  23797. case tutorial.FieldEmployeeID:
  23798. v, ok := value.(uint64)
  23799. if !ok {
  23800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23801. }
  23802. m.SetEmployeeID(v)
  23803. return nil
  23804. case tutorial.FieldIndex:
  23805. v, ok := value.(int)
  23806. if !ok {
  23807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23808. }
  23809. m.SetIndex(v)
  23810. return nil
  23811. case tutorial.FieldTitle:
  23812. v, ok := value.(string)
  23813. if !ok {
  23814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23815. }
  23816. m.SetTitle(v)
  23817. return nil
  23818. case tutorial.FieldContent:
  23819. v, ok := value.(string)
  23820. if !ok {
  23821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23822. }
  23823. m.SetContent(v)
  23824. return nil
  23825. case tutorial.FieldOrganizationID:
  23826. v, ok := value.(uint64)
  23827. if !ok {
  23828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23829. }
  23830. m.SetOrganizationID(v)
  23831. return nil
  23832. }
  23833. return fmt.Errorf("unknown Tutorial field %s", name)
  23834. }
  23835. // AddedFields returns all numeric fields that were incremented/decremented during
  23836. // this mutation.
  23837. func (m *TutorialMutation) AddedFields() []string {
  23838. var fields []string
  23839. if m.addindex != nil {
  23840. fields = append(fields, tutorial.FieldIndex)
  23841. }
  23842. if m.addorganization_id != nil {
  23843. fields = append(fields, tutorial.FieldOrganizationID)
  23844. }
  23845. return fields
  23846. }
  23847. // AddedField returns the numeric value that was incremented/decremented on a field
  23848. // with the given name. The second boolean return value indicates that this field
  23849. // was not set, or was not defined in the schema.
  23850. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  23851. switch name {
  23852. case tutorial.FieldIndex:
  23853. return m.AddedIndex()
  23854. case tutorial.FieldOrganizationID:
  23855. return m.AddedOrganizationID()
  23856. }
  23857. return nil, false
  23858. }
  23859. // AddField adds the value to the field with the given name. It returns an error if
  23860. // the field is not defined in the schema, or if the type mismatched the field
  23861. // type.
  23862. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  23863. switch name {
  23864. case tutorial.FieldIndex:
  23865. v, ok := value.(int)
  23866. if !ok {
  23867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23868. }
  23869. m.AddIndex(v)
  23870. return nil
  23871. case tutorial.FieldOrganizationID:
  23872. v, ok := value.(int64)
  23873. if !ok {
  23874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23875. }
  23876. m.AddOrganizationID(v)
  23877. return nil
  23878. }
  23879. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  23880. }
  23881. // ClearedFields returns all nullable fields that were cleared during this
  23882. // mutation.
  23883. func (m *TutorialMutation) ClearedFields() []string {
  23884. var fields []string
  23885. if m.FieldCleared(tutorial.FieldDeletedAt) {
  23886. fields = append(fields, tutorial.FieldDeletedAt)
  23887. }
  23888. return fields
  23889. }
  23890. // FieldCleared returns a boolean indicating if a field with the given name was
  23891. // cleared in this mutation.
  23892. func (m *TutorialMutation) FieldCleared(name string) bool {
  23893. _, ok := m.clearedFields[name]
  23894. return ok
  23895. }
  23896. // ClearField clears the value of the field with the given name. It returns an
  23897. // error if the field is not defined in the schema.
  23898. func (m *TutorialMutation) ClearField(name string) error {
  23899. switch name {
  23900. case tutorial.FieldDeletedAt:
  23901. m.ClearDeletedAt()
  23902. return nil
  23903. }
  23904. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  23905. }
  23906. // ResetField resets all changes in the mutation for the field with the given name.
  23907. // It returns an error if the field is not defined in the schema.
  23908. func (m *TutorialMutation) ResetField(name string) error {
  23909. switch name {
  23910. case tutorial.FieldCreatedAt:
  23911. m.ResetCreatedAt()
  23912. return nil
  23913. case tutorial.FieldUpdatedAt:
  23914. m.ResetUpdatedAt()
  23915. return nil
  23916. case tutorial.FieldDeletedAt:
  23917. m.ResetDeletedAt()
  23918. return nil
  23919. case tutorial.FieldEmployeeID:
  23920. m.ResetEmployeeID()
  23921. return nil
  23922. case tutorial.FieldIndex:
  23923. m.ResetIndex()
  23924. return nil
  23925. case tutorial.FieldTitle:
  23926. m.ResetTitle()
  23927. return nil
  23928. case tutorial.FieldContent:
  23929. m.ResetContent()
  23930. return nil
  23931. case tutorial.FieldOrganizationID:
  23932. m.ResetOrganizationID()
  23933. return nil
  23934. }
  23935. return fmt.Errorf("unknown Tutorial field %s", name)
  23936. }
  23937. // AddedEdges returns all edge names that were set/added in this mutation.
  23938. func (m *TutorialMutation) AddedEdges() []string {
  23939. edges := make([]string, 0, 1)
  23940. if m.employee != nil {
  23941. edges = append(edges, tutorial.EdgeEmployee)
  23942. }
  23943. return edges
  23944. }
  23945. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23946. // name in this mutation.
  23947. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23948. switch name {
  23949. case tutorial.EdgeEmployee:
  23950. if id := m.employee; id != nil {
  23951. return []ent.Value{*id}
  23952. }
  23953. }
  23954. return nil
  23955. }
  23956. // RemovedEdges returns all edge names that were removed in this mutation.
  23957. func (m *TutorialMutation) RemovedEdges() []string {
  23958. edges := make([]string, 0, 1)
  23959. return edges
  23960. }
  23961. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23962. // the given name in this mutation.
  23963. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23964. return nil
  23965. }
  23966. // ClearedEdges returns all edge names that were cleared in this mutation.
  23967. func (m *TutorialMutation) ClearedEdges() []string {
  23968. edges := make([]string, 0, 1)
  23969. if m.clearedemployee {
  23970. edges = append(edges, tutorial.EdgeEmployee)
  23971. }
  23972. return edges
  23973. }
  23974. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23975. // was cleared in this mutation.
  23976. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23977. switch name {
  23978. case tutorial.EdgeEmployee:
  23979. return m.clearedemployee
  23980. }
  23981. return false
  23982. }
  23983. // ClearEdge clears the value of the edge with the given name. It returns an error
  23984. // if that edge is not defined in the schema.
  23985. func (m *TutorialMutation) ClearEdge(name string) error {
  23986. switch name {
  23987. case tutorial.EdgeEmployee:
  23988. m.ClearEmployee()
  23989. return nil
  23990. }
  23991. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23992. }
  23993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23994. // It returns an error if the edge is not defined in the schema.
  23995. func (m *TutorialMutation) ResetEdge(name string) error {
  23996. switch name {
  23997. case tutorial.EdgeEmployee:
  23998. m.ResetEmployee()
  23999. return nil
  24000. }
  24001. return fmt.Errorf("unknown Tutorial edge %s", name)
  24002. }
  24003. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  24004. type UsageDetailMutation struct {
  24005. config
  24006. op Op
  24007. typ string
  24008. id *uint64
  24009. created_at *time.Time
  24010. updated_at *time.Time
  24011. status *uint8
  24012. addstatus *int8
  24013. _type *int
  24014. add_type *int
  24015. bot_id *string
  24016. receiver_id *string
  24017. app *int
  24018. addapp *int
  24019. session_id *uint64
  24020. addsession_id *int64
  24021. request *string
  24022. response *string
  24023. total_tokens *uint64
  24024. addtotal_tokens *int64
  24025. prompt_tokens *uint64
  24026. addprompt_tokens *int64
  24027. completion_tokens *uint64
  24028. addcompletion_tokens *int64
  24029. organization_id *uint64
  24030. addorganization_id *int64
  24031. clearedFields map[string]struct{}
  24032. done bool
  24033. oldValue func(context.Context) (*UsageDetail, error)
  24034. predicates []predicate.UsageDetail
  24035. }
  24036. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  24037. // usagedetailOption allows management of the mutation configuration using functional options.
  24038. type usagedetailOption func(*UsageDetailMutation)
  24039. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  24040. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  24041. m := &UsageDetailMutation{
  24042. config: c,
  24043. op: op,
  24044. typ: TypeUsageDetail,
  24045. clearedFields: make(map[string]struct{}),
  24046. }
  24047. for _, opt := range opts {
  24048. opt(m)
  24049. }
  24050. return m
  24051. }
  24052. // withUsageDetailID sets the ID field of the mutation.
  24053. func withUsageDetailID(id uint64) usagedetailOption {
  24054. return func(m *UsageDetailMutation) {
  24055. var (
  24056. err error
  24057. once sync.Once
  24058. value *UsageDetail
  24059. )
  24060. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  24061. once.Do(func() {
  24062. if m.done {
  24063. err = errors.New("querying old values post mutation is not allowed")
  24064. } else {
  24065. value, err = m.Client().UsageDetail.Get(ctx, id)
  24066. }
  24067. })
  24068. return value, err
  24069. }
  24070. m.id = &id
  24071. }
  24072. }
  24073. // withUsageDetail sets the old UsageDetail of the mutation.
  24074. func withUsageDetail(node *UsageDetail) usagedetailOption {
  24075. return func(m *UsageDetailMutation) {
  24076. m.oldValue = func(context.Context) (*UsageDetail, error) {
  24077. return node, nil
  24078. }
  24079. m.id = &node.ID
  24080. }
  24081. }
  24082. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24083. // executed in a transaction (ent.Tx), a transactional client is returned.
  24084. func (m UsageDetailMutation) Client() *Client {
  24085. client := &Client{config: m.config}
  24086. client.init()
  24087. return client
  24088. }
  24089. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24090. // it returns an error otherwise.
  24091. func (m UsageDetailMutation) Tx() (*Tx, error) {
  24092. if _, ok := m.driver.(*txDriver); !ok {
  24093. return nil, errors.New("ent: mutation is not running in a transaction")
  24094. }
  24095. tx := &Tx{config: m.config}
  24096. tx.init()
  24097. return tx, nil
  24098. }
  24099. // SetID sets the value of the id field. Note that this
  24100. // operation is only accepted on creation of UsageDetail entities.
  24101. func (m *UsageDetailMutation) SetID(id uint64) {
  24102. m.id = &id
  24103. }
  24104. // ID returns the ID value in the mutation. Note that the ID is only available
  24105. // if it was provided to the builder or after it was returned from the database.
  24106. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  24107. if m.id == nil {
  24108. return
  24109. }
  24110. return *m.id, true
  24111. }
  24112. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24113. // That means, if the mutation is applied within a transaction with an isolation level such
  24114. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24115. // or updated by the mutation.
  24116. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  24117. switch {
  24118. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24119. id, exists := m.ID()
  24120. if exists {
  24121. return []uint64{id}, nil
  24122. }
  24123. fallthrough
  24124. case m.op.Is(OpUpdate | OpDelete):
  24125. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  24126. default:
  24127. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24128. }
  24129. }
  24130. // SetCreatedAt sets the "created_at" field.
  24131. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  24132. m.created_at = &t
  24133. }
  24134. // CreatedAt returns the value of the "created_at" field in the mutation.
  24135. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  24136. v := m.created_at
  24137. if v == nil {
  24138. return
  24139. }
  24140. return *v, true
  24141. }
  24142. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  24143. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24145. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24146. if !m.op.Is(OpUpdateOne) {
  24147. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24148. }
  24149. if m.id == nil || m.oldValue == nil {
  24150. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24151. }
  24152. oldValue, err := m.oldValue(ctx)
  24153. if err != nil {
  24154. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24155. }
  24156. return oldValue.CreatedAt, nil
  24157. }
  24158. // ResetCreatedAt resets all changes to the "created_at" field.
  24159. func (m *UsageDetailMutation) ResetCreatedAt() {
  24160. m.created_at = nil
  24161. }
  24162. // SetUpdatedAt sets the "updated_at" field.
  24163. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  24164. m.updated_at = &t
  24165. }
  24166. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24167. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  24168. v := m.updated_at
  24169. if v == nil {
  24170. return
  24171. }
  24172. return *v, true
  24173. }
  24174. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  24175. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24177. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24178. if !m.op.Is(OpUpdateOne) {
  24179. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24180. }
  24181. if m.id == nil || m.oldValue == nil {
  24182. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24183. }
  24184. oldValue, err := m.oldValue(ctx)
  24185. if err != nil {
  24186. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24187. }
  24188. return oldValue.UpdatedAt, nil
  24189. }
  24190. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24191. func (m *UsageDetailMutation) ResetUpdatedAt() {
  24192. m.updated_at = nil
  24193. }
  24194. // SetStatus sets the "status" field.
  24195. func (m *UsageDetailMutation) SetStatus(u uint8) {
  24196. m.status = &u
  24197. m.addstatus = nil
  24198. }
  24199. // Status returns the value of the "status" field in the mutation.
  24200. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  24201. v := m.status
  24202. if v == nil {
  24203. return
  24204. }
  24205. return *v, true
  24206. }
  24207. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  24208. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24210. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24211. if !m.op.Is(OpUpdateOne) {
  24212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24213. }
  24214. if m.id == nil || m.oldValue == nil {
  24215. return v, errors.New("OldStatus requires an ID field in the mutation")
  24216. }
  24217. oldValue, err := m.oldValue(ctx)
  24218. if err != nil {
  24219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24220. }
  24221. return oldValue.Status, nil
  24222. }
  24223. // AddStatus adds u to the "status" field.
  24224. func (m *UsageDetailMutation) AddStatus(u int8) {
  24225. if m.addstatus != nil {
  24226. *m.addstatus += u
  24227. } else {
  24228. m.addstatus = &u
  24229. }
  24230. }
  24231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24232. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  24233. v := m.addstatus
  24234. if v == nil {
  24235. return
  24236. }
  24237. return *v, true
  24238. }
  24239. // ClearStatus clears the value of the "status" field.
  24240. func (m *UsageDetailMutation) ClearStatus() {
  24241. m.status = nil
  24242. m.addstatus = nil
  24243. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  24244. }
  24245. // StatusCleared returns if the "status" field was cleared in this mutation.
  24246. func (m *UsageDetailMutation) StatusCleared() bool {
  24247. _, ok := m.clearedFields[usagedetail.FieldStatus]
  24248. return ok
  24249. }
  24250. // ResetStatus resets all changes to the "status" field.
  24251. func (m *UsageDetailMutation) ResetStatus() {
  24252. m.status = nil
  24253. m.addstatus = nil
  24254. delete(m.clearedFields, usagedetail.FieldStatus)
  24255. }
  24256. // SetType sets the "type" field.
  24257. func (m *UsageDetailMutation) SetType(i int) {
  24258. m._type = &i
  24259. m.add_type = nil
  24260. }
  24261. // GetType returns the value of the "type" field in the mutation.
  24262. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  24263. v := m._type
  24264. if v == nil {
  24265. return
  24266. }
  24267. return *v, true
  24268. }
  24269. // OldType returns the old "type" field's value of the UsageDetail entity.
  24270. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24272. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  24273. if !m.op.Is(OpUpdateOne) {
  24274. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24275. }
  24276. if m.id == nil || m.oldValue == nil {
  24277. return v, errors.New("OldType requires an ID field in the mutation")
  24278. }
  24279. oldValue, err := m.oldValue(ctx)
  24280. if err != nil {
  24281. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24282. }
  24283. return oldValue.Type, nil
  24284. }
  24285. // AddType adds i to the "type" field.
  24286. func (m *UsageDetailMutation) AddType(i int) {
  24287. if m.add_type != nil {
  24288. *m.add_type += i
  24289. } else {
  24290. m.add_type = &i
  24291. }
  24292. }
  24293. // AddedType returns the value that was added to the "type" field in this mutation.
  24294. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  24295. v := m.add_type
  24296. if v == nil {
  24297. return
  24298. }
  24299. return *v, true
  24300. }
  24301. // ClearType clears the value of the "type" field.
  24302. func (m *UsageDetailMutation) ClearType() {
  24303. m._type = nil
  24304. m.add_type = nil
  24305. m.clearedFields[usagedetail.FieldType] = struct{}{}
  24306. }
  24307. // TypeCleared returns if the "type" field was cleared in this mutation.
  24308. func (m *UsageDetailMutation) TypeCleared() bool {
  24309. _, ok := m.clearedFields[usagedetail.FieldType]
  24310. return ok
  24311. }
  24312. // ResetType resets all changes to the "type" field.
  24313. func (m *UsageDetailMutation) ResetType() {
  24314. m._type = nil
  24315. m.add_type = nil
  24316. delete(m.clearedFields, usagedetail.FieldType)
  24317. }
  24318. // SetBotID sets the "bot_id" field.
  24319. func (m *UsageDetailMutation) SetBotID(s string) {
  24320. m.bot_id = &s
  24321. }
  24322. // BotID returns the value of the "bot_id" field in the mutation.
  24323. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  24324. v := m.bot_id
  24325. if v == nil {
  24326. return
  24327. }
  24328. return *v, true
  24329. }
  24330. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  24331. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24333. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  24334. if !m.op.Is(OpUpdateOne) {
  24335. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24336. }
  24337. if m.id == nil || m.oldValue == nil {
  24338. return v, errors.New("OldBotID requires an ID field in the mutation")
  24339. }
  24340. oldValue, err := m.oldValue(ctx)
  24341. if err != nil {
  24342. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24343. }
  24344. return oldValue.BotID, nil
  24345. }
  24346. // ResetBotID resets all changes to the "bot_id" field.
  24347. func (m *UsageDetailMutation) ResetBotID() {
  24348. m.bot_id = nil
  24349. }
  24350. // SetReceiverID sets the "receiver_id" field.
  24351. func (m *UsageDetailMutation) SetReceiverID(s string) {
  24352. m.receiver_id = &s
  24353. }
  24354. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  24355. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  24356. v := m.receiver_id
  24357. if v == nil {
  24358. return
  24359. }
  24360. return *v, true
  24361. }
  24362. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  24363. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24365. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  24366. if !m.op.Is(OpUpdateOne) {
  24367. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  24368. }
  24369. if m.id == nil || m.oldValue == nil {
  24370. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  24371. }
  24372. oldValue, err := m.oldValue(ctx)
  24373. if err != nil {
  24374. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  24375. }
  24376. return oldValue.ReceiverID, nil
  24377. }
  24378. // ResetReceiverID resets all changes to the "receiver_id" field.
  24379. func (m *UsageDetailMutation) ResetReceiverID() {
  24380. m.receiver_id = nil
  24381. }
  24382. // SetApp sets the "app" field.
  24383. func (m *UsageDetailMutation) SetApp(i int) {
  24384. m.app = &i
  24385. m.addapp = nil
  24386. }
  24387. // App returns the value of the "app" field in the mutation.
  24388. func (m *UsageDetailMutation) App() (r int, exists bool) {
  24389. v := m.app
  24390. if v == nil {
  24391. return
  24392. }
  24393. return *v, true
  24394. }
  24395. // OldApp returns the old "app" field's value of the UsageDetail entity.
  24396. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24398. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  24399. if !m.op.Is(OpUpdateOne) {
  24400. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  24401. }
  24402. if m.id == nil || m.oldValue == nil {
  24403. return v, errors.New("OldApp requires an ID field in the mutation")
  24404. }
  24405. oldValue, err := m.oldValue(ctx)
  24406. if err != nil {
  24407. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  24408. }
  24409. return oldValue.App, nil
  24410. }
  24411. // AddApp adds i to the "app" field.
  24412. func (m *UsageDetailMutation) AddApp(i int) {
  24413. if m.addapp != nil {
  24414. *m.addapp += i
  24415. } else {
  24416. m.addapp = &i
  24417. }
  24418. }
  24419. // AddedApp returns the value that was added to the "app" field in this mutation.
  24420. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  24421. v := m.addapp
  24422. if v == nil {
  24423. return
  24424. }
  24425. return *v, true
  24426. }
  24427. // ClearApp clears the value of the "app" field.
  24428. func (m *UsageDetailMutation) ClearApp() {
  24429. m.app = nil
  24430. m.addapp = nil
  24431. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  24432. }
  24433. // AppCleared returns if the "app" field was cleared in this mutation.
  24434. func (m *UsageDetailMutation) AppCleared() bool {
  24435. _, ok := m.clearedFields[usagedetail.FieldApp]
  24436. return ok
  24437. }
  24438. // ResetApp resets all changes to the "app" field.
  24439. func (m *UsageDetailMutation) ResetApp() {
  24440. m.app = nil
  24441. m.addapp = nil
  24442. delete(m.clearedFields, usagedetail.FieldApp)
  24443. }
  24444. // SetSessionID sets the "session_id" field.
  24445. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  24446. m.session_id = &u
  24447. m.addsession_id = nil
  24448. }
  24449. // SessionID returns the value of the "session_id" field in the mutation.
  24450. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  24451. v := m.session_id
  24452. if v == nil {
  24453. return
  24454. }
  24455. return *v, true
  24456. }
  24457. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  24458. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24460. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  24461. if !m.op.Is(OpUpdateOne) {
  24462. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  24463. }
  24464. if m.id == nil || m.oldValue == nil {
  24465. return v, errors.New("OldSessionID requires an ID field in the mutation")
  24466. }
  24467. oldValue, err := m.oldValue(ctx)
  24468. if err != nil {
  24469. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  24470. }
  24471. return oldValue.SessionID, nil
  24472. }
  24473. // AddSessionID adds u to the "session_id" field.
  24474. func (m *UsageDetailMutation) AddSessionID(u int64) {
  24475. if m.addsession_id != nil {
  24476. *m.addsession_id += u
  24477. } else {
  24478. m.addsession_id = &u
  24479. }
  24480. }
  24481. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  24482. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  24483. v := m.addsession_id
  24484. if v == nil {
  24485. return
  24486. }
  24487. return *v, true
  24488. }
  24489. // ClearSessionID clears the value of the "session_id" field.
  24490. func (m *UsageDetailMutation) ClearSessionID() {
  24491. m.session_id = nil
  24492. m.addsession_id = nil
  24493. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  24494. }
  24495. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  24496. func (m *UsageDetailMutation) SessionIDCleared() bool {
  24497. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  24498. return ok
  24499. }
  24500. // ResetSessionID resets all changes to the "session_id" field.
  24501. func (m *UsageDetailMutation) ResetSessionID() {
  24502. m.session_id = nil
  24503. m.addsession_id = nil
  24504. delete(m.clearedFields, usagedetail.FieldSessionID)
  24505. }
  24506. // SetRequest sets the "request" field.
  24507. func (m *UsageDetailMutation) SetRequest(s string) {
  24508. m.request = &s
  24509. }
  24510. // Request returns the value of the "request" field in the mutation.
  24511. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  24512. v := m.request
  24513. if v == nil {
  24514. return
  24515. }
  24516. return *v, true
  24517. }
  24518. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  24519. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24521. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  24522. if !m.op.Is(OpUpdateOne) {
  24523. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  24524. }
  24525. if m.id == nil || m.oldValue == nil {
  24526. return v, errors.New("OldRequest requires an ID field in the mutation")
  24527. }
  24528. oldValue, err := m.oldValue(ctx)
  24529. if err != nil {
  24530. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  24531. }
  24532. return oldValue.Request, nil
  24533. }
  24534. // ResetRequest resets all changes to the "request" field.
  24535. func (m *UsageDetailMutation) ResetRequest() {
  24536. m.request = nil
  24537. }
  24538. // SetResponse sets the "response" field.
  24539. func (m *UsageDetailMutation) SetResponse(s string) {
  24540. m.response = &s
  24541. }
  24542. // Response returns the value of the "response" field in the mutation.
  24543. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  24544. v := m.response
  24545. if v == nil {
  24546. return
  24547. }
  24548. return *v, true
  24549. }
  24550. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  24551. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24553. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  24554. if !m.op.Is(OpUpdateOne) {
  24555. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  24556. }
  24557. if m.id == nil || m.oldValue == nil {
  24558. return v, errors.New("OldResponse requires an ID field in the mutation")
  24559. }
  24560. oldValue, err := m.oldValue(ctx)
  24561. if err != nil {
  24562. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  24563. }
  24564. return oldValue.Response, nil
  24565. }
  24566. // ResetResponse resets all changes to the "response" field.
  24567. func (m *UsageDetailMutation) ResetResponse() {
  24568. m.response = nil
  24569. }
  24570. // SetTotalTokens sets the "total_tokens" field.
  24571. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  24572. m.total_tokens = &u
  24573. m.addtotal_tokens = nil
  24574. }
  24575. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  24576. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  24577. v := m.total_tokens
  24578. if v == nil {
  24579. return
  24580. }
  24581. return *v, true
  24582. }
  24583. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  24584. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24586. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24587. if !m.op.Is(OpUpdateOne) {
  24588. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24589. }
  24590. if m.id == nil || m.oldValue == nil {
  24591. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24592. }
  24593. oldValue, err := m.oldValue(ctx)
  24594. if err != nil {
  24595. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24596. }
  24597. return oldValue.TotalTokens, nil
  24598. }
  24599. // AddTotalTokens adds u to the "total_tokens" field.
  24600. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  24601. if m.addtotal_tokens != nil {
  24602. *m.addtotal_tokens += u
  24603. } else {
  24604. m.addtotal_tokens = &u
  24605. }
  24606. }
  24607. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24608. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  24609. v := m.addtotal_tokens
  24610. if v == nil {
  24611. return
  24612. }
  24613. return *v, true
  24614. }
  24615. // ClearTotalTokens clears the value of the "total_tokens" field.
  24616. func (m *UsageDetailMutation) ClearTotalTokens() {
  24617. m.total_tokens = nil
  24618. m.addtotal_tokens = nil
  24619. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  24620. }
  24621. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24622. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  24623. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  24624. return ok
  24625. }
  24626. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24627. func (m *UsageDetailMutation) ResetTotalTokens() {
  24628. m.total_tokens = nil
  24629. m.addtotal_tokens = nil
  24630. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  24631. }
  24632. // SetPromptTokens sets the "prompt_tokens" field.
  24633. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  24634. m.prompt_tokens = &u
  24635. m.addprompt_tokens = nil
  24636. }
  24637. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  24638. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  24639. v := m.prompt_tokens
  24640. if v == nil {
  24641. return
  24642. }
  24643. return *v, true
  24644. }
  24645. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  24646. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24648. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  24649. if !m.op.Is(OpUpdateOne) {
  24650. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  24651. }
  24652. if m.id == nil || m.oldValue == nil {
  24653. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  24654. }
  24655. oldValue, err := m.oldValue(ctx)
  24656. if err != nil {
  24657. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  24658. }
  24659. return oldValue.PromptTokens, nil
  24660. }
  24661. // AddPromptTokens adds u to the "prompt_tokens" field.
  24662. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  24663. if m.addprompt_tokens != nil {
  24664. *m.addprompt_tokens += u
  24665. } else {
  24666. m.addprompt_tokens = &u
  24667. }
  24668. }
  24669. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  24670. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  24671. v := m.addprompt_tokens
  24672. if v == nil {
  24673. return
  24674. }
  24675. return *v, true
  24676. }
  24677. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  24678. func (m *UsageDetailMutation) ClearPromptTokens() {
  24679. m.prompt_tokens = nil
  24680. m.addprompt_tokens = nil
  24681. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  24682. }
  24683. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  24684. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  24685. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  24686. return ok
  24687. }
  24688. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  24689. func (m *UsageDetailMutation) ResetPromptTokens() {
  24690. m.prompt_tokens = nil
  24691. m.addprompt_tokens = nil
  24692. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  24693. }
  24694. // SetCompletionTokens sets the "completion_tokens" field.
  24695. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  24696. m.completion_tokens = &u
  24697. m.addcompletion_tokens = nil
  24698. }
  24699. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  24700. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  24701. v := m.completion_tokens
  24702. if v == nil {
  24703. return
  24704. }
  24705. return *v, true
  24706. }
  24707. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  24708. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24710. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  24711. if !m.op.Is(OpUpdateOne) {
  24712. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  24713. }
  24714. if m.id == nil || m.oldValue == nil {
  24715. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  24716. }
  24717. oldValue, err := m.oldValue(ctx)
  24718. if err != nil {
  24719. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  24720. }
  24721. return oldValue.CompletionTokens, nil
  24722. }
  24723. // AddCompletionTokens adds u to the "completion_tokens" field.
  24724. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  24725. if m.addcompletion_tokens != nil {
  24726. *m.addcompletion_tokens += u
  24727. } else {
  24728. m.addcompletion_tokens = &u
  24729. }
  24730. }
  24731. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  24732. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  24733. v := m.addcompletion_tokens
  24734. if v == nil {
  24735. return
  24736. }
  24737. return *v, true
  24738. }
  24739. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  24740. func (m *UsageDetailMutation) ClearCompletionTokens() {
  24741. m.completion_tokens = nil
  24742. m.addcompletion_tokens = nil
  24743. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  24744. }
  24745. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  24746. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  24747. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  24748. return ok
  24749. }
  24750. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  24751. func (m *UsageDetailMutation) ResetCompletionTokens() {
  24752. m.completion_tokens = nil
  24753. m.addcompletion_tokens = nil
  24754. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  24755. }
  24756. // SetOrganizationID sets the "organization_id" field.
  24757. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  24758. m.organization_id = &u
  24759. m.addorganization_id = nil
  24760. }
  24761. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24762. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  24763. v := m.organization_id
  24764. if v == nil {
  24765. return
  24766. }
  24767. return *v, true
  24768. }
  24769. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  24770. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24772. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24773. if !m.op.Is(OpUpdateOne) {
  24774. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24775. }
  24776. if m.id == nil || m.oldValue == nil {
  24777. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24778. }
  24779. oldValue, err := m.oldValue(ctx)
  24780. if err != nil {
  24781. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24782. }
  24783. return oldValue.OrganizationID, nil
  24784. }
  24785. // AddOrganizationID adds u to the "organization_id" field.
  24786. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  24787. if m.addorganization_id != nil {
  24788. *m.addorganization_id += u
  24789. } else {
  24790. m.addorganization_id = &u
  24791. }
  24792. }
  24793. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24794. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  24795. v := m.addorganization_id
  24796. if v == nil {
  24797. return
  24798. }
  24799. return *v, true
  24800. }
  24801. // ClearOrganizationID clears the value of the "organization_id" field.
  24802. func (m *UsageDetailMutation) ClearOrganizationID() {
  24803. m.organization_id = nil
  24804. m.addorganization_id = nil
  24805. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  24806. }
  24807. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24808. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  24809. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  24810. return ok
  24811. }
  24812. // ResetOrganizationID resets all changes to the "organization_id" field.
  24813. func (m *UsageDetailMutation) ResetOrganizationID() {
  24814. m.organization_id = nil
  24815. m.addorganization_id = nil
  24816. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  24817. }
  24818. // Where appends a list predicates to the UsageDetailMutation builder.
  24819. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  24820. m.predicates = append(m.predicates, ps...)
  24821. }
  24822. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  24823. // users can use type-assertion to append predicates that do not depend on any generated package.
  24824. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  24825. p := make([]predicate.UsageDetail, len(ps))
  24826. for i := range ps {
  24827. p[i] = ps[i]
  24828. }
  24829. m.Where(p...)
  24830. }
  24831. // Op returns the operation name.
  24832. func (m *UsageDetailMutation) Op() Op {
  24833. return m.op
  24834. }
  24835. // SetOp allows setting the mutation operation.
  24836. func (m *UsageDetailMutation) SetOp(op Op) {
  24837. m.op = op
  24838. }
  24839. // Type returns the node type of this mutation (UsageDetail).
  24840. func (m *UsageDetailMutation) Type() string {
  24841. return m.typ
  24842. }
  24843. // Fields returns all fields that were changed during this mutation. Note that in
  24844. // order to get all numeric fields that were incremented/decremented, call
  24845. // AddedFields().
  24846. func (m *UsageDetailMutation) Fields() []string {
  24847. fields := make([]string, 0, 14)
  24848. if m.created_at != nil {
  24849. fields = append(fields, usagedetail.FieldCreatedAt)
  24850. }
  24851. if m.updated_at != nil {
  24852. fields = append(fields, usagedetail.FieldUpdatedAt)
  24853. }
  24854. if m.status != nil {
  24855. fields = append(fields, usagedetail.FieldStatus)
  24856. }
  24857. if m._type != nil {
  24858. fields = append(fields, usagedetail.FieldType)
  24859. }
  24860. if m.bot_id != nil {
  24861. fields = append(fields, usagedetail.FieldBotID)
  24862. }
  24863. if m.receiver_id != nil {
  24864. fields = append(fields, usagedetail.FieldReceiverID)
  24865. }
  24866. if m.app != nil {
  24867. fields = append(fields, usagedetail.FieldApp)
  24868. }
  24869. if m.session_id != nil {
  24870. fields = append(fields, usagedetail.FieldSessionID)
  24871. }
  24872. if m.request != nil {
  24873. fields = append(fields, usagedetail.FieldRequest)
  24874. }
  24875. if m.response != nil {
  24876. fields = append(fields, usagedetail.FieldResponse)
  24877. }
  24878. if m.total_tokens != nil {
  24879. fields = append(fields, usagedetail.FieldTotalTokens)
  24880. }
  24881. if m.prompt_tokens != nil {
  24882. fields = append(fields, usagedetail.FieldPromptTokens)
  24883. }
  24884. if m.completion_tokens != nil {
  24885. fields = append(fields, usagedetail.FieldCompletionTokens)
  24886. }
  24887. if m.organization_id != nil {
  24888. fields = append(fields, usagedetail.FieldOrganizationID)
  24889. }
  24890. return fields
  24891. }
  24892. // Field returns the value of a field with the given name. The second boolean
  24893. // return value indicates that this field was not set, or was not defined in the
  24894. // schema.
  24895. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  24896. switch name {
  24897. case usagedetail.FieldCreatedAt:
  24898. return m.CreatedAt()
  24899. case usagedetail.FieldUpdatedAt:
  24900. return m.UpdatedAt()
  24901. case usagedetail.FieldStatus:
  24902. return m.Status()
  24903. case usagedetail.FieldType:
  24904. return m.GetType()
  24905. case usagedetail.FieldBotID:
  24906. return m.BotID()
  24907. case usagedetail.FieldReceiverID:
  24908. return m.ReceiverID()
  24909. case usagedetail.FieldApp:
  24910. return m.App()
  24911. case usagedetail.FieldSessionID:
  24912. return m.SessionID()
  24913. case usagedetail.FieldRequest:
  24914. return m.Request()
  24915. case usagedetail.FieldResponse:
  24916. return m.Response()
  24917. case usagedetail.FieldTotalTokens:
  24918. return m.TotalTokens()
  24919. case usagedetail.FieldPromptTokens:
  24920. return m.PromptTokens()
  24921. case usagedetail.FieldCompletionTokens:
  24922. return m.CompletionTokens()
  24923. case usagedetail.FieldOrganizationID:
  24924. return m.OrganizationID()
  24925. }
  24926. return nil, false
  24927. }
  24928. // OldField returns the old value of the field from the database. An error is
  24929. // returned if the mutation operation is not UpdateOne, or the query to the
  24930. // database failed.
  24931. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24932. switch name {
  24933. case usagedetail.FieldCreatedAt:
  24934. return m.OldCreatedAt(ctx)
  24935. case usagedetail.FieldUpdatedAt:
  24936. return m.OldUpdatedAt(ctx)
  24937. case usagedetail.FieldStatus:
  24938. return m.OldStatus(ctx)
  24939. case usagedetail.FieldType:
  24940. return m.OldType(ctx)
  24941. case usagedetail.FieldBotID:
  24942. return m.OldBotID(ctx)
  24943. case usagedetail.FieldReceiverID:
  24944. return m.OldReceiverID(ctx)
  24945. case usagedetail.FieldApp:
  24946. return m.OldApp(ctx)
  24947. case usagedetail.FieldSessionID:
  24948. return m.OldSessionID(ctx)
  24949. case usagedetail.FieldRequest:
  24950. return m.OldRequest(ctx)
  24951. case usagedetail.FieldResponse:
  24952. return m.OldResponse(ctx)
  24953. case usagedetail.FieldTotalTokens:
  24954. return m.OldTotalTokens(ctx)
  24955. case usagedetail.FieldPromptTokens:
  24956. return m.OldPromptTokens(ctx)
  24957. case usagedetail.FieldCompletionTokens:
  24958. return m.OldCompletionTokens(ctx)
  24959. case usagedetail.FieldOrganizationID:
  24960. return m.OldOrganizationID(ctx)
  24961. }
  24962. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24963. }
  24964. // SetField sets the value of a field with the given name. It returns an error if
  24965. // the field is not defined in the schema, or if the type mismatched the field
  24966. // type.
  24967. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24968. switch name {
  24969. case usagedetail.FieldCreatedAt:
  24970. v, ok := value.(time.Time)
  24971. if !ok {
  24972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24973. }
  24974. m.SetCreatedAt(v)
  24975. return nil
  24976. case usagedetail.FieldUpdatedAt:
  24977. v, ok := value.(time.Time)
  24978. if !ok {
  24979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24980. }
  24981. m.SetUpdatedAt(v)
  24982. return nil
  24983. case usagedetail.FieldStatus:
  24984. v, ok := value.(uint8)
  24985. if !ok {
  24986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24987. }
  24988. m.SetStatus(v)
  24989. return nil
  24990. case usagedetail.FieldType:
  24991. v, ok := value.(int)
  24992. if !ok {
  24993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24994. }
  24995. m.SetType(v)
  24996. return nil
  24997. case usagedetail.FieldBotID:
  24998. v, ok := value.(string)
  24999. if !ok {
  25000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25001. }
  25002. m.SetBotID(v)
  25003. return nil
  25004. case usagedetail.FieldReceiverID:
  25005. v, ok := value.(string)
  25006. if !ok {
  25007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25008. }
  25009. m.SetReceiverID(v)
  25010. return nil
  25011. case usagedetail.FieldApp:
  25012. v, ok := value.(int)
  25013. if !ok {
  25014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25015. }
  25016. m.SetApp(v)
  25017. return nil
  25018. case usagedetail.FieldSessionID:
  25019. v, ok := value.(uint64)
  25020. if !ok {
  25021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25022. }
  25023. m.SetSessionID(v)
  25024. return nil
  25025. case usagedetail.FieldRequest:
  25026. v, ok := value.(string)
  25027. if !ok {
  25028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25029. }
  25030. m.SetRequest(v)
  25031. return nil
  25032. case usagedetail.FieldResponse:
  25033. v, ok := value.(string)
  25034. if !ok {
  25035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25036. }
  25037. m.SetResponse(v)
  25038. return nil
  25039. case usagedetail.FieldTotalTokens:
  25040. v, ok := value.(uint64)
  25041. if !ok {
  25042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25043. }
  25044. m.SetTotalTokens(v)
  25045. return nil
  25046. case usagedetail.FieldPromptTokens:
  25047. v, ok := value.(uint64)
  25048. if !ok {
  25049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25050. }
  25051. m.SetPromptTokens(v)
  25052. return nil
  25053. case usagedetail.FieldCompletionTokens:
  25054. v, ok := value.(uint64)
  25055. if !ok {
  25056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25057. }
  25058. m.SetCompletionTokens(v)
  25059. return nil
  25060. case usagedetail.FieldOrganizationID:
  25061. v, ok := value.(uint64)
  25062. if !ok {
  25063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25064. }
  25065. m.SetOrganizationID(v)
  25066. return nil
  25067. }
  25068. return fmt.Errorf("unknown UsageDetail field %s", name)
  25069. }
  25070. // AddedFields returns all numeric fields that were incremented/decremented during
  25071. // this mutation.
  25072. func (m *UsageDetailMutation) AddedFields() []string {
  25073. var fields []string
  25074. if m.addstatus != nil {
  25075. fields = append(fields, usagedetail.FieldStatus)
  25076. }
  25077. if m.add_type != nil {
  25078. fields = append(fields, usagedetail.FieldType)
  25079. }
  25080. if m.addapp != nil {
  25081. fields = append(fields, usagedetail.FieldApp)
  25082. }
  25083. if m.addsession_id != nil {
  25084. fields = append(fields, usagedetail.FieldSessionID)
  25085. }
  25086. if m.addtotal_tokens != nil {
  25087. fields = append(fields, usagedetail.FieldTotalTokens)
  25088. }
  25089. if m.addprompt_tokens != nil {
  25090. fields = append(fields, usagedetail.FieldPromptTokens)
  25091. }
  25092. if m.addcompletion_tokens != nil {
  25093. fields = append(fields, usagedetail.FieldCompletionTokens)
  25094. }
  25095. if m.addorganization_id != nil {
  25096. fields = append(fields, usagedetail.FieldOrganizationID)
  25097. }
  25098. return fields
  25099. }
  25100. // AddedField returns the numeric value that was incremented/decremented on a field
  25101. // with the given name. The second boolean return value indicates that this field
  25102. // was not set, or was not defined in the schema.
  25103. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  25104. switch name {
  25105. case usagedetail.FieldStatus:
  25106. return m.AddedStatus()
  25107. case usagedetail.FieldType:
  25108. return m.AddedType()
  25109. case usagedetail.FieldApp:
  25110. return m.AddedApp()
  25111. case usagedetail.FieldSessionID:
  25112. return m.AddedSessionID()
  25113. case usagedetail.FieldTotalTokens:
  25114. return m.AddedTotalTokens()
  25115. case usagedetail.FieldPromptTokens:
  25116. return m.AddedPromptTokens()
  25117. case usagedetail.FieldCompletionTokens:
  25118. return m.AddedCompletionTokens()
  25119. case usagedetail.FieldOrganizationID:
  25120. return m.AddedOrganizationID()
  25121. }
  25122. return nil, false
  25123. }
  25124. // AddField adds the value to the field with the given name. It returns an error if
  25125. // the field is not defined in the schema, or if the type mismatched the field
  25126. // type.
  25127. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  25128. switch name {
  25129. case usagedetail.FieldStatus:
  25130. v, ok := value.(int8)
  25131. if !ok {
  25132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25133. }
  25134. m.AddStatus(v)
  25135. return nil
  25136. case usagedetail.FieldType:
  25137. v, ok := value.(int)
  25138. if !ok {
  25139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25140. }
  25141. m.AddType(v)
  25142. return nil
  25143. case usagedetail.FieldApp:
  25144. v, ok := value.(int)
  25145. if !ok {
  25146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25147. }
  25148. m.AddApp(v)
  25149. return nil
  25150. case usagedetail.FieldSessionID:
  25151. v, ok := value.(int64)
  25152. if !ok {
  25153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25154. }
  25155. m.AddSessionID(v)
  25156. return nil
  25157. case usagedetail.FieldTotalTokens:
  25158. v, ok := value.(int64)
  25159. if !ok {
  25160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25161. }
  25162. m.AddTotalTokens(v)
  25163. return nil
  25164. case usagedetail.FieldPromptTokens:
  25165. v, ok := value.(int64)
  25166. if !ok {
  25167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25168. }
  25169. m.AddPromptTokens(v)
  25170. return nil
  25171. case usagedetail.FieldCompletionTokens:
  25172. v, ok := value.(int64)
  25173. if !ok {
  25174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25175. }
  25176. m.AddCompletionTokens(v)
  25177. return nil
  25178. case usagedetail.FieldOrganizationID:
  25179. v, ok := value.(int64)
  25180. if !ok {
  25181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25182. }
  25183. m.AddOrganizationID(v)
  25184. return nil
  25185. }
  25186. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  25187. }
  25188. // ClearedFields returns all nullable fields that were cleared during this
  25189. // mutation.
  25190. func (m *UsageDetailMutation) ClearedFields() []string {
  25191. var fields []string
  25192. if m.FieldCleared(usagedetail.FieldStatus) {
  25193. fields = append(fields, usagedetail.FieldStatus)
  25194. }
  25195. if m.FieldCleared(usagedetail.FieldType) {
  25196. fields = append(fields, usagedetail.FieldType)
  25197. }
  25198. if m.FieldCleared(usagedetail.FieldApp) {
  25199. fields = append(fields, usagedetail.FieldApp)
  25200. }
  25201. if m.FieldCleared(usagedetail.FieldSessionID) {
  25202. fields = append(fields, usagedetail.FieldSessionID)
  25203. }
  25204. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  25205. fields = append(fields, usagedetail.FieldTotalTokens)
  25206. }
  25207. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  25208. fields = append(fields, usagedetail.FieldPromptTokens)
  25209. }
  25210. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  25211. fields = append(fields, usagedetail.FieldCompletionTokens)
  25212. }
  25213. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  25214. fields = append(fields, usagedetail.FieldOrganizationID)
  25215. }
  25216. return fields
  25217. }
  25218. // FieldCleared returns a boolean indicating if a field with the given name was
  25219. // cleared in this mutation.
  25220. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  25221. _, ok := m.clearedFields[name]
  25222. return ok
  25223. }
  25224. // ClearField clears the value of the field with the given name. It returns an
  25225. // error if the field is not defined in the schema.
  25226. func (m *UsageDetailMutation) ClearField(name string) error {
  25227. switch name {
  25228. case usagedetail.FieldStatus:
  25229. m.ClearStatus()
  25230. return nil
  25231. case usagedetail.FieldType:
  25232. m.ClearType()
  25233. return nil
  25234. case usagedetail.FieldApp:
  25235. m.ClearApp()
  25236. return nil
  25237. case usagedetail.FieldSessionID:
  25238. m.ClearSessionID()
  25239. return nil
  25240. case usagedetail.FieldTotalTokens:
  25241. m.ClearTotalTokens()
  25242. return nil
  25243. case usagedetail.FieldPromptTokens:
  25244. m.ClearPromptTokens()
  25245. return nil
  25246. case usagedetail.FieldCompletionTokens:
  25247. m.ClearCompletionTokens()
  25248. return nil
  25249. case usagedetail.FieldOrganizationID:
  25250. m.ClearOrganizationID()
  25251. return nil
  25252. }
  25253. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  25254. }
  25255. // ResetField resets all changes in the mutation for the field with the given name.
  25256. // It returns an error if the field is not defined in the schema.
  25257. func (m *UsageDetailMutation) ResetField(name string) error {
  25258. switch name {
  25259. case usagedetail.FieldCreatedAt:
  25260. m.ResetCreatedAt()
  25261. return nil
  25262. case usagedetail.FieldUpdatedAt:
  25263. m.ResetUpdatedAt()
  25264. return nil
  25265. case usagedetail.FieldStatus:
  25266. m.ResetStatus()
  25267. return nil
  25268. case usagedetail.FieldType:
  25269. m.ResetType()
  25270. return nil
  25271. case usagedetail.FieldBotID:
  25272. m.ResetBotID()
  25273. return nil
  25274. case usagedetail.FieldReceiverID:
  25275. m.ResetReceiverID()
  25276. return nil
  25277. case usagedetail.FieldApp:
  25278. m.ResetApp()
  25279. return nil
  25280. case usagedetail.FieldSessionID:
  25281. m.ResetSessionID()
  25282. return nil
  25283. case usagedetail.FieldRequest:
  25284. m.ResetRequest()
  25285. return nil
  25286. case usagedetail.FieldResponse:
  25287. m.ResetResponse()
  25288. return nil
  25289. case usagedetail.FieldTotalTokens:
  25290. m.ResetTotalTokens()
  25291. return nil
  25292. case usagedetail.FieldPromptTokens:
  25293. m.ResetPromptTokens()
  25294. return nil
  25295. case usagedetail.FieldCompletionTokens:
  25296. m.ResetCompletionTokens()
  25297. return nil
  25298. case usagedetail.FieldOrganizationID:
  25299. m.ResetOrganizationID()
  25300. return nil
  25301. }
  25302. return fmt.Errorf("unknown UsageDetail field %s", name)
  25303. }
  25304. // AddedEdges returns all edge names that were set/added in this mutation.
  25305. func (m *UsageDetailMutation) AddedEdges() []string {
  25306. edges := make([]string, 0, 0)
  25307. return edges
  25308. }
  25309. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25310. // name in this mutation.
  25311. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  25312. return nil
  25313. }
  25314. // RemovedEdges returns all edge names that were removed in this mutation.
  25315. func (m *UsageDetailMutation) RemovedEdges() []string {
  25316. edges := make([]string, 0, 0)
  25317. return edges
  25318. }
  25319. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25320. // the given name in this mutation.
  25321. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  25322. return nil
  25323. }
  25324. // ClearedEdges returns all edge names that were cleared in this mutation.
  25325. func (m *UsageDetailMutation) ClearedEdges() []string {
  25326. edges := make([]string, 0, 0)
  25327. return edges
  25328. }
  25329. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25330. // was cleared in this mutation.
  25331. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  25332. return false
  25333. }
  25334. // ClearEdge clears the value of the edge with the given name. It returns an error
  25335. // if that edge is not defined in the schema.
  25336. func (m *UsageDetailMutation) ClearEdge(name string) error {
  25337. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  25338. }
  25339. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25340. // It returns an error if the edge is not defined in the schema.
  25341. func (m *UsageDetailMutation) ResetEdge(name string) error {
  25342. return fmt.Errorf("unknown UsageDetail edge %s", name)
  25343. }
  25344. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  25345. type UsageStatisticDayMutation struct {
  25346. config
  25347. op Op
  25348. typ string
  25349. id *uint64
  25350. created_at *time.Time
  25351. updated_at *time.Time
  25352. status *uint8
  25353. addstatus *int8
  25354. deleted_at *time.Time
  25355. addtime *uint64
  25356. addaddtime *int64
  25357. _type *int
  25358. add_type *int
  25359. bot_id *string
  25360. organization_id *uint64
  25361. addorganization_id *int64
  25362. ai_response *uint64
  25363. addai_response *int64
  25364. sop_run *uint64
  25365. addsop_run *int64
  25366. total_friend *uint64
  25367. addtotal_friend *int64
  25368. total_group *uint64
  25369. addtotal_group *int64
  25370. account_balance *uint64
  25371. addaccount_balance *int64
  25372. consume_token *uint64
  25373. addconsume_token *int64
  25374. active_user *uint64
  25375. addactive_user *int64
  25376. new_user *int64
  25377. addnew_user *int64
  25378. label_dist *[]custom_types.LabelDist
  25379. appendlabel_dist []custom_types.LabelDist
  25380. clearedFields map[string]struct{}
  25381. done bool
  25382. oldValue func(context.Context) (*UsageStatisticDay, error)
  25383. predicates []predicate.UsageStatisticDay
  25384. }
  25385. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  25386. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  25387. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  25388. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  25389. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  25390. m := &UsageStatisticDayMutation{
  25391. config: c,
  25392. op: op,
  25393. typ: TypeUsageStatisticDay,
  25394. clearedFields: make(map[string]struct{}),
  25395. }
  25396. for _, opt := range opts {
  25397. opt(m)
  25398. }
  25399. return m
  25400. }
  25401. // withUsageStatisticDayID sets the ID field of the mutation.
  25402. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  25403. return func(m *UsageStatisticDayMutation) {
  25404. var (
  25405. err error
  25406. once sync.Once
  25407. value *UsageStatisticDay
  25408. )
  25409. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  25410. once.Do(func() {
  25411. if m.done {
  25412. err = errors.New("querying old values post mutation is not allowed")
  25413. } else {
  25414. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  25415. }
  25416. })
  25417. return value, err
  25418. }
  25419. m.id = &id
  25420. }
  25421. }
  25422. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  25423. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  25424. return func(m *UsageStatisticDayMutation) {
  25425. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  25426. return node, nil
  25427. }
  25428. m.id = &node.ID
  25429. }
  25430. }
  25431. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25432. // executed in a transaction (ent.Tx), a transactional client is returned.
  25433. func (m UsageStatisticDayMutation) Client() *Client {
  25434. client := &Client{config: m.config}
  25435. client.init()
  25436. return client
  25437. }
  25438. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25439. // it returns an error otherwise.
  25440. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  25441. if _, ok := m.driver.(*txDriver); !ok {
  25442. return nil, errors.New("ent: mutation is not running in a transaction")
  25443. }
  25444. tx := &Tx{config: m.config}
  25445. tx.init()
  25446. return tx, nil
  25447. }
  25448. // SetID sets the value of the id field. Note that this
  25449. // operation is only accepted on creation of UsageStatisticDay entities.
  25450. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  25451. m.id = &id
  25452. }
  25453. // ID returns the ID value in the mutation. Note that the ID is only available
  25454. // if it was provided to the builder or after it was returned from the database.
  25455. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  25456. if m.id == nil {
  25457. return
  25458. }
  25459. return *m.id, true
  25460. }
  25461. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25462. // That means, if the mutation is applied within a transaction with an isolation level such
  25463. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25464. // or updated by the mutation.
  25465. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  25466. switch {
  25467. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25468. id, exists := m.ID()
  25469. if exists {
  25470. return []uint64{id}, nil
  25471. }
  25472. fallthrough
  25473. case m.op.Is(OpUpdate | OpDelete):
  25474. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  25475. default:
  25476. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25477. }
  25478. }
  25479. // SetCreatedAt sets the "created_at" field.
  25480. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  25481. m.created_at = &t
  25482. }
  25483. // CreatedAt returns the value of the "created_at" field in the mutation.
  25484. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  25485. v := m.created_at
  25486. if v == nil {
  25487. return
  25488. }
  25489. return *v, true
  25490. }
  25491. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  25492. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25494. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25495. if !m.op.Is(OpUpdateOne) {
  25496. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25497. }
  25498. if m.id == nil || m.oldValue == nil {
  25499. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25500. }
  25501. oldValue, err := m.oldValue(ctx)
  25502. if err != nil {
  25503. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25504. }
  25505. return oldValue.CreatedAt, nil
  25506. }
  25507. // ResetCreatedAt resets all changes to the "created_at" field.
  25508. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  25509. m.created_at = nil
  25510. }
  25511. // SetUpdatedAt sets the "updated_at" field.
  25512. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  25513. m.updated_at = &t
  25514. }
  25515. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25516. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  25517. v := m.updated_at
  25518. if v == nil {
  25519. return
  25520. }
  25521. return *v, true
  25522. }
  25523. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  25524. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25526. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25527. if !m.op.Is(OpUpdateOne) {
  25528. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25529. }
  25530. if m.id == nil || m.oldValue == nil {
  25531. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25532. }
  25533. oldValue, err := m.oldValue(ctx)
  25534. if err != nil {
  25535. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25536. }
  25537. return oldValue.UpdatedAt, nil
  25538. }
  25539. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25540. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  25541. m.updated_at = nil
  25542. }
  25543. // SetStatus sets the "status" field.
  25544. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  25545. m.status = &u
  25546. m.addstatus = nil
  25547. }
  25548. // Status returns the value of the "status" field in the mutation.
  25549. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  25550. v := m.status
  25551. if v == nil {
  25552. return
  25553. }
  25554. return *v, true
  25555. }
  25556. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  25557. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25559. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25560. if !m.op.Is(OpUpdateOne) {
  25561. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25562. }
  25563. if m.id == nil || m.oldValue == nil {
  25564. return v, errors.New("OldStatus requires an ID field in the mutation")
  25565. }
  25566. oldValue, err := m.oldValue(ctx)
  25567. if err != nil {
  25568. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25569. }
  25570. return oldValue.Status, nil
  25571. }
  25572. // AddStatus adds u to the "status" field.
  25573. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  25574. if m.addstatus != nil {
  25575. *m.addstatus += u
  25576. } else {
  25577. m.addstatus = &u
  25578. }
  25579. }
  25580. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25581. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  25582. v := m.addstatus
  25583. if v == nil {
  25584. return
  25585. }
  25586. return *v, true
  25587. }
  25588. // ClearStatus clears the value of the "status" field.
  25589. func (m *UsageStatisticDayMutation) ClearStatus() {
  25590. m.status = nil
  25591. m.addstatus = nil
  25592. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  25593. }
  25594. // StatusCleared returns if the "status" field was cleared in this mutation.
  25595. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  25596. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  25597. return ok
  25598. }
  25599. // ResetStatus resets all changes to the "status" field.
  25600. func (m *UsageStatisticDayMutation) ResetStatus() {
  25601. m.status = nil
  25602. m.addstatus = nil
  25603. delete(m.clearedFields, usagestatisticday.FieldStatus)
  25604. }
  25605. // SetDeletedAt sets the "deleted_at" field.
  25606. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  25607. m.deleted_at = &t
  25608. }
  25609. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25610. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  25611. v := m.deleted_at
  25612. if v == nil {
  25613. return
  25614. }
  25615. return *v, true
  25616. }
  25617. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  25618. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25620. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25621. if !m.op.Is(OpUpdateOne) {
  25622. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25623. }
  25624. if m.id == nil || m.oldValue == nil {
  25625. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25626. }
  25627. oldValue, err := m.oldValue(ctx)
  25628. if err != nil {
  25629. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25630. }
  25631. return oldValue.DeletedAt, nil
  25632. }
  25633. // ClearDeletedAt clears the value of the "deleted_at" field.
  25634. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  25635. m.deleted_at = nil
  25636. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  25637. }
  25638. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25639. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  25640. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  25641. return ok
  25642. }
  25643. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25644. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  25645. m.deleted_at = nil
  25646. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  25647. }
  25648. // SetAddtime sets the "addtime" field.
  25649. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  25650. m.addtime = &u
  25651. m.addaddtime = nil
  25652. }
  25653. // Addtime returns the value of the "addtime" field in the mutation.
  25654. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  25655. v := m.addtime
  25656. if v == nil {
  25657. return
  25658. }
  25659. return *v, true
  25660. }
  25661. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  25662. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25664. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  25665. if !m.op.Is(OpUpdateOne) {
  25666. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  25667. }
  25668. if m.id == nil || m.oldValue == nil {
  25669. return v, errors.New("OldAddtime requires an ID field in the mutation")
  25670. }
  25671. oldValue, err := m.oldValue(ctx)
  25672. if err != nil {
  25673. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  25674. }
  25675. return oldValue.Addtime, nil
  25676. }
  25677. // AddAddtime adds u to the "addtime" field.
  25678. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  25679. if m.addaddtime != nil {
  25680. *m.addaddtime += u
  25681. } else {
  25682. m.addaddtime = &u
  25683. }
  25684. }
  25685. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  25686. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  25687. v := m.addaddtime
  25688. if v == nil {
  25689. return
  25690. }
  25691. return *v, true
  25692. }
  25693. // ResetAddtime resets all changes to the "addtime" field.
  25694. func (m *UsageStatisticDayMutation) ResetAddtime() {
  25695. m.addtime = nil
  25696. m.addaddtime = nil
  25697. }
  25698. // SetType sets the "type" field.
  25699. func (m *UsageStatisticDayMutation) SetType(i int) {
  25700. m._type = &i
  25701. m.add_type = nil
  25702. }
  25703. // GetType returns the value of the "type" field in the mutation.
  25704. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  25705. v := m._type
  25706. if v == nil {
  25707. return
  25708. }
  25709. return *v, true
  25710. }
  25711. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  25712. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25714. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  25715. if !m.op.Is(OpUpdateOne) {
  25716. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25717. }
  25718. if m.id == nil || m.oldValue == nil {
  25719. return v, errors.New("OldType requires an ID field in the mutation")
  25720. }
  25721. oldValue, err := m.oldValue(ctx)
  25722. if err != nil {
  25723. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25724. }
  25725. return oldValue.Type, nil
  25726. }
  25727. // AddType adds i to the "type" field.
  25728. func (m *UsageStatisticDayMutation) AddType(i int) {
  25729. if m.add_type != nil {
  25730. *m.add_type += i
  25731. } else {
  25732. m.add_type = &i
  25733. }
  25734. }
  25735. // AddedType returns the value that was added to the "type" field in this mutation.
  25736. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  25737. v := m.add_type
  25738. if v == nil {
  25739. return
  25740. }
  25741. return *v, true
  25742. }
  25743. // ResetType resets all changes to the "type" field.
  25744. func (m *UsageStatisticDayMutation) ResetType() {
  25745. m._type = nil
  25746. m.add_type = nil
  25747. }
  25748. // SetBotID sets the "bot_id" field.
  25749. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  25750. m.bot_id = &s
  25751. }
  25752. // BotID returns the value of the "bot_id" field in the mutation.
  25753. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  25754. v := m.bot_id
  25755. if v == nil {
  25756. return
  25757. }
  25758. return *v, true
  25759. }
  25760. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  25761. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25763. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  25764. if !m.op.Is(OpUpdateOne) {
  25765. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25766. }
  25767. if m.id == nil || m.oldValue == nil {
  25768. return v, errors.New("OldBotID requires an ID field in the mutation")
  25769. }
  25770. oldValue, err := m.oldValue(ctx)
  25771. if err != nil {
  25772. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25773. }
  25774. return oldValue.BotID, nil
  25775. }
  25776. // ClearBotID clears the value of the "bot_id" field.
  25777. func (m *UsageStatisticDayMutation) ClearBotID() {
  25778. m.bot_id = nil
  25779. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  25780. }
  25781. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  25782. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  25783. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  25784. return ok
  25785. }
  25786. // ResetBotID resets all changes to the "bot_id" field.
  25787. func (m *UsageStatisticDayMutation) ResetBotID() {
  25788. m.bot_id = nil
  25789. delete(m.clearedFields, usagestatisticday.FieldBotID)
  25790. }
  25791. // SetOrganizationID sets the "organization_id" field.
  25792. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  25793. m.organization_id = &u
  25794. m.addorganization_id = nil
  25795. }
  25796. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25797. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  25798. v := m.organization_id
  25799. if v == nil {
  25800. return
  25801. }
  25802. return *v, true
  25803. }
  25804. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  25805. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25807. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25808. if !m.op.Is(OpUpdateOne) {
  25809. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25810. }
  25811. if m.id == nil || m.oldValue == nil {
  25812. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25813. }
  25814. oldValue, err := m.oldValue(ctx)
  25815. if err != nil {
  25816. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25817. }
  25818. return oldValue.OrganizationID, nil
  25819. }
  25820. // AddOrganizationID adds u to the "organization_id" field.
  25821. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  25822. if m.addorganization_id != nil {
  25823. *m.addorganization_id += u
  25824. } else {
  25825. m.addorganization_id = &u
  25826. }
  25827. }
  25828. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25829. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  25830. v := m.addorganization_id
  25831. if v == nil {
  25832. return
  25833. }
  25834. return *v, true
  25835. }
  25836. // ClearOrganizationID clears the value of the "organization_id" field.
  25837. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  25838. m.organization_id = nil
  25839. m.addorganization_id = nil
  25840. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  25841. }
  25842. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25843. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  25844. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  25845. return ok
  25846. }
  25847. // ResetOrganizationID resets all changes to the "organization_id" field.
  25848. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  25849. m.organization_id = nil
  25850. m.addorganization_id = nil
  25851. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  25852. }
  25853. // SetAiResponse sets the "ai_response" field.
  25854. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  25855. m.ai_response = &u
  25856. m.addai_response = nil
  25857. }
  25858. // AiResponse returns the value of the "ai_response" field in the mutation.
  25859. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  25860. v := m.ai_response
  25861. if v == nil {
  25862. return
  25863. }
  25864. return *v, true
  25865. }
  25866. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  25867. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25869. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  25870. if !m.op.Is(OpUpdateOne) {
  25871. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  25872. }
  25873. if m.id == nil || m.oldValue == nil {
  25874. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  25875. }
  25876. oldValue, err := m.oldValue(ctx)
  25877. if err != nil {
  25878. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  25879. }
  25880. return oldValue.AiResponse, nil
  25881. }
  25882. // AddAiResponse adds u to the "ai_response" field.
  25883. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  25884. if m.addai_response != nil {
  25885. *m.addai_response += u
  25886. } else {
  25887. m.addai_response = &u
  25888. }
  25889. }
  25890. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  25891. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  25892. v := m.addai_response
  25893. if v == nil {
  25894. return
  25895. }
  25896. return *v, true
  25897. }
  25898. // ResetAiResponse resets all changes to the "ai_response" field.
  25899. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  25900. m.ai_response = nil
  25901. m.addai_response = nil
  25902. }
  25903. // SetSopRun sets the "sop_run" field.
  25904. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  25905. m.sop_run = &u
  25906. m.addsop_run = nil
  25907. }
  25908. // SopRun returns the value of the "sop_run" field in the mutation.
  25909. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  25910. v := m.sop_run
  25911. if v == nil {
  25912. return
  25913. }
  25914. return *v, true
  25915. }
  25916. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  25917. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25919. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  25920. if !m.op.Is(OpUpdateOne) {
  25921. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  25922. }
  25923. if m.id == nil || m.oldValue == nil {
  25924. return v, errors.New("OldSopRun requires an ID field in the mutation")
  25925. }
  25926. oldValue, err := m.oldValue(ctx)
  25927. if err != nil {
  25928. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  25929. }
  25930. return oldValue.SopRun, nil
  25931. }
  25932. // AddSopRun adds u to the "sop_run" field.
  25933. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  25934. if m.addsop_run != nil {
  25935. *m.addsop_run += u
  25936. } else {
  25937. m.addsop_run = &u
  25938. }
  25939. }
  25940. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  25941. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  25942. v := m.addsop_run
  25943. if v == nil {
  25944. return
  25945. }
  25946. return *v, true
  25947. }
  25948. // ResetSopRun resets all changes to the "sop_run" field.
  25949. func (m *UsageStatisticDayMutation) ResetSopRun() {
  25950. m.sop_run = nil
  25951. m.addsop_run = nil
  25952. }
  25953. // SetTotalFriend sets the "total_friend" field.
  25954. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  25955. m.total_friend = &u
  25956. m.addtotal_friend = nil
  25957. }
  25958. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25959. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  25960. v := m.total_friend
  25961. if v == nil {
  25962. return
  25963. }
  25964. return *v, true
  25965. }
  25966. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  25967. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25969. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25970. if !m.op.Is(OpUpdateOne) {
  25971. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25972. }
  25973. if m.id == nil || m.oldValue == nil {
  25974. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25975. }
  25976. oldValue, err := m.oldValue(ctx)
  25977. if err != nil {
  25978. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25979. }
  25980. return oldValue.TotalFriend, nil
  25981. }
  25982. // AddTotalFriend adds u to the "total_friend" field.
  25983. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  25984. if m.addtotal_friend != nil {
  25985. *m.addtotal_friend += u
  25986. } else {
  25987. m.addtotal_friend = &u
  25988. }
  25989. }
  25990. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25991. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  25992. v := m.addtotal_friend
  25993. if v == nil {
  25994. return
  25995. }
  25996. return *v, true
  25997. }
  25998. // ResetTotalFriend resets all changes to the "total_friend" field.
  25999. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  26000. m.total_friend = nil
  26001. m.addtotal_friend = nil
  26002. }
  26003. // SetTotalGroup sets the "total_group" field.
  26004. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  26005. m.total_group = &u
  26006. m.addtotal_group = nil
  26007. }
  26008. // TotalGroup returns the value of the "total_group" field in the mutation.
  26009. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  26010. v := m.total_group
  26011. if v == nil {
  26012. return
  26013. }
  26014. return *v, true
  26015. }
  26016. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  26017. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26019. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  26020. if !m.op.Is(OpUpdateOne) {
  26021. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  26022. }
  26023. if m.id == nil || m.oldValue == nil {
  26024. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  26025. }
  26026. oldValue, err := m.oldValue(ctx)
  26027. if err != nil {
  26028. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  26029. }
  26030. return oldValue.TotalGroup, nil
  26031. }
  26032. // AddTotalGroup adds u to the "total_group" field.
  26033. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  26034. if m.addtotal_group != nil {
  26035. *m.addtotal_group += u
  26036. } else {
  26037. m.addtotal_group = &u
  26038. }
  26039. }
  26040. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  26041. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  26042. v := m.addtotal_group
  26043. if v == nil {
  26044. return
  26045. }
  26046. return *v, true
  26047. }
  26048. // ResetTotalGroup resets all changes to the "total_group" field.
  26049. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  26050. m.total_group = nil
  26051. m.addtotal_group = nil
  26052. }
  26053. // SetAccountBalance sets the "account_balance" field.
  26054. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  26055. m.account_balance = &u
  26056. m.addaccount_balance = nil
  26057. }
  26058. // AccountBalance returns the value of the "account_balance" field in the mutation.
  26059. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  26060. v := m.account_balance
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  26067. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26069. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  26075. }
  26076. oldValue, err := m.oldValue(ctx)
  26077. if err != nil {
  26078. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  26079. }
  26080. return oldValue.AccountBalance, nil
  26081. }
  26082. // AddAccountBalance adds u to the "account_balance" field.
  26083. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  26084. if m.addaccount_balance != nil {
  26085. *m.addaccount_balance += u
  26086. } else {
  26087. m.addaccount_balance = &u
  26088. }
  26089. }
  26090. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  26091. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  26092. v := m.addaccount_balance
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // ResetAccountBalance resets all changes to the "account_balance" field.
  26099. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  26100. m.account_balance = nil
  26101. m.addaccount_balance = nil
  26102. }
  26103. // SetConsumeToken sets the "consume_token" field.
  26104. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  26105. m.consume_token = &u
  26106. m.addconsume_token = nil
  26107. }
  26108. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  26109. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  26110. v := m.consume_token
  26111. if v == nil {
  26112. return
  26113. }
  26114. return *v, true
  26115. }
  26116. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  26117. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26119. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  26120. if !m.op.Is(OpUpdateOne) {
  26121. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  26122. }
  26123. if m.id == nil || m.oldValue == nil {
  26124. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  26125. }
  26126. oldValue, err := m.oldValue(ctx)
  26127. if err != nil {
  26128. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  26129. }
  26130. return oldValue.ConsumeToken, nil
  26131. }
  26132. // AddConsumeToken adds u to the "consume_token" field.
  26133. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  26134. if m.addconsume_token != nil {
  26135. *m.addconsume_token += u
  26136. } else {
  26137. m.addconsume_token = &u
  26138. }
  26139. }
  26140. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  26141. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  26142. v := m.addconsume_token
  26143. if v == nil {
  26144. return
  26145. }
  26146. return *v, true
  26147. }
  26148. // ResetConsumeToken resets all changes to the "consume_token" field.
  26149. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  26150. m.consume_token = nil
  26151. m.addconsume_token = nil
  26152. }
  26153. // SetActiveUser sets the "active_user" field.
  26154. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  26155. m.active_user = &u
  26156. m.addactive_user = nil
  26157. }
  26158. // ActiveUser returns the value of the "active_user" field in the mutation.
  26159. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  26160. v := m.active_user
  26161. if v == nil {
  26162. return
  26163. }
  26164. return *v, true
  26165. }
  26166. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  26167. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26169. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  26170. if !m.op.Is(OpUpdateOne) {
  26171. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  26172. }
  26173. if m.id == nil || m.oldValue == nil {
  26174. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  26175. }
  26176. oldValue, err := m.oldValue(ctx)
  26177. if err != nil {
  26178. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  26179. }
  26180. return oldValue.ActiveUser, nil
  26181. }
  26182. // AddActiveUser adds u to the "active_user" field.
  26183. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  26184. if m.addactive_user != nil {
  26185. *m.addactive_user += u
  26186. } else {
  26187. m.addactive_user = &u
  26188. }
  26189. }
  26190. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  26191. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  26192. v := m.addactive_user
  26193. if v == nil {
  26194. return
  26195. }
  26196. return *v, true
  26197. }
  26198. // ResetActiveUser resets all changes to the "active_user" field.
  26199. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  26200. m.active_user = nil
  26201. m.addactive_user = nil
  26202. }
  26203. // SetNewUser sets the "new_user" field.
  26204. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  26205. m.new_user = &i
  26206. m.addnew_user = nil
  26207. }
  26208. // NewUser returns the value of the "new_user" field in the mutation.
  26209. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  26210. v := m.new_user
  26211. if v == nil {
  26212. return
  26213. }
  26214. return *v, true
  26215. }
  26216. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  26217. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26219. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26220. if !m.op.Is(OpUpdateOne) {
  26221. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26222. }
  26223. if m.id == nil || m.oldValue == nil {
  26224. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26225. }
  26226. oldValue, err := m.oldValue(ctx)
  26227. if err != nil {
  26228. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26229. }
  26230. return oldValue.NewUser, nil
  26231. }
  26232. // AddNewUser adds i to the "new_user" field.
  26233. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  26234. if m.addnew_user != nil {
  26235. *m.addnew_user += i
  26236. } else {
  26237. m.addnew_user = &i
  26238. }
  26239. }
  26240. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26241. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  26242. v := m.addnew_user
  26243. if v == nil {
  26244. return
  26245. }
  26246. return *v, true
  26247. }
  26248. // ResetNewUser resets all changes to the "new_user" field.
  26249. func (m *UsageStatisticDayMutation) ResetNewUser() {
  26250. m.new_user = nil
  26251. m.addnew_user = nil
  26252. }
  26253. // SetLabelDist sets the "label_dist" field.
  26254. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  26255. m.label_dist = &ctd
  26256. m.appendlabel_dist = nil
  26257. }
  26258. // LabelDist returns the value of the "label_dist" field in the mutation.
  26259. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  26260. v := m.label_dist
  26261. if v == nil {
  26262. return
  26263. }
  26264. return *v, true
  26265. }
  26266. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  26267. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26269. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  26270. if !m.op.Is(OpUpdateOne) {
  26271. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  26272. }
  26273. if m.id == nil || m.oldValue == nil {
  26274. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  26275. }
  26276. oldValue, err := m.oldValue(ctx)
  26277. if err != nil {
  26278. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  26279. }
  26280. return oldValue.LabelDist, nil
  26281. }
  26282. // AppendLabelDist adds ctd to the "label_dist" field.
  26283. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  26284. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  26285. }
  26286. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  26287. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  26288. if len(m.appendlabel_dist) == 0 {
  26289. return nil, false
  26290. }
  26291. return m.appendlabel_dist, true
  26292. }
  26293. // ResetLabelDist resets all changes to the "label_dist" field.
  26294. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  26295. m.label_dist = nil
  26296. m.appendlabel_dist = nil
  26297. }
  26298. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  26299. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  26300. m.predicates = append(m.predicates, ps...)
  26301. }
  26302. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  26303. // users can use type-assertion to append predicates that do not depend on any generated package.
  26304. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  26305. p := make([]predicate.UsageStatisticDay, len(ps))
  26306. for i := range ps {
  26307. p[i] = ps[i]
  26308. }
  26309. m.Where(p...)
  26310. }
  26311. // Op returns the operation name.
  26312. func (m *UsageStatisticDayMutation) Op() Op {
  26313. return m.op
  26314. }
  26315. // SetOp allows setting the mutation operation.
  26316. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  26317. m.op = op
  26318. }
  26319. // Type returns the node type of this mutation (UsageStatisticDay).
  26320. func (m *UsageStatisticDayMutation) Type() string {
  26321. return m.typ
  26322. }
  26323. // Fields returns all fields that were changed during this mutation. Note that in
  26324. // order to get all numeric fields that were incremented/decremented, call
  26325. // AddedFields().
  26326. func (m *UsageStatisticDayMutation) Fields() []string {
  26327. fields := make([]string, 0, 17)
  26328. if m.created_at != nil {
  26329. fields = append(fields, usagestatisticday.FieldCreatedAt)
  26330. }
  26331. if m.updated_at != nil {
  26332. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  26333. }
  26334. if m.status != nil {
  26335. fields = append(fields, usagestatisticday.FieldStatus)
  26336. }
  26337. if m.deleted_at != nil {
  26338. fields = append(fields, usagestatisticday.FieldDeletedAt)
  26339. }
  26340. if m.addtime != nil {
  26341. fields = append(fields, usagestatisticday.FieldAddtime)
  26342. }
  26343. if m._type != nil {
  26344. fields = append(fields, usagestatisticday.FieldType)
  26345. }
  26346. if m.bot_id != nil {
  26347. fields = append(fields, usagestatisticday.FieldBotID)
  26348. }
  26349. if m.organization_id != nil {
  26350. fields = append(fields, usagestatisticday.FieldOrganizationID)
  26351. }
  26352. if m.ai_response != nil {
  26353. fields = append(fields, usagestatisticday.FieldAiResponse)
  26354. }
  26355. if m.sop_run != nil {
  26356. fields = append(fields, usagestatisticday.FieldSopRun)
  26357. }
  26358. if m.total_friend != nil {
  26359. fields = append(fields, usagestatisticday.FieldTotalFriend)
  26360. }
  26361. if m.total_group != nil {
  26362. fields = append(fields, usagestatisticday.FieldTotalGroup)
  26363. }
  26364. if m.account_balance != nil {
  26365. fields = append(fields, usagestatisticday.FieldAccountBalance)
  26366. }
  26367. if m.consume_token != nil {
  26368. fields = append(fields, usagestatisticday.FieldConsumeToken)
  26369. }
  26370. if m.active_user != nil {
  26371. fields = append(fields, usagestatisticday.FieldActiveUser)
  26372. }
  26373. if m.new_user != nil {
  26374. fields = append(fields, usagestatisticday.FieldNewUser)
  26375. }
  26376. if m.label_dist != nil {
  26377. fields = append(fields, usagestatisticday.FieldLabelDist)
  26378. }
  26379. return fields
  26380. }
  26381. // Field returns the value of a field with the given name. The second boolean
  26382. // return value indicates that this field was not set, or was not defined in the
  26383. // schema.
  26384. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  26385. switch name {
  26386. case usagestatisticday.FieldCreatedAt:
  26387. return m.CreatedAt()
  26388. case usagestatisticday.FieldUpdatedAt:
  26389. return m.UpdatedAt()
  26390. case usagestatisticday.FieldStatus:
  26391. return m.Status()
  26392. case usagestatisticday.FieldDeletedAt:
  26393. return m.DeletedAt()
  26394. case usagestatisticday.FieldAddtime:
  26395. return m.Addtime()
  26396. case usagestatisticday.FieldType:
  26397. return m.GetType()
  26398. case usagestatisticday.FieldBotID:
  26399. return m.BotID()
  26400. case usagestatisticday.FieldOrganizationID:
  26401. return m.OrganizationID()
  26402. case usagestatisticday.FieldAiResponse:
  26403. return m.AiResponse()
  26404. case usagestatisticday.FieldSopRun:
  26405. return m.SopRun()
  26406. case usagestatisticday.FieldTotalFriend:
  26407. return m.TotalFriend()
  26408. case usagestatisticday.FieldTotalGroup:
  26409. return m.TotalGroup()
  26410. case usagestatisticday.FieldAccountBalance:
  26411. return m.AccountBalance()
  26412. case usagestatisticday.FieldConsumeToken:
  26413. return m.ConsumeToken()
  26414. case usagestatisticday.FieldActiveUser:
  26415. return m.ActiveUser()
  26416. case usagestatisticday.FieldNewUser:
  26417. return m.NewUser()
  26418. case usagestatisticday.FieldLabelDist:
  26419. return m.LabelDist()
  26420. }
  26421. return nil, false
  26422. }
  26423. // OldField returns the old value of the field from the database. An error is
  26424. // returned if the mutation operation is not UpdateOne, or the query to the
  26425. // database failed.
  26426. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26427. switch name {
  26428. case usagestatisticday.FieldCreatedAt:
  26429. return m.OldCreatedAt(ctx)
  26430. case usagestatisticday.FieldUpdatedAt:
  26431. return m.OldUpdatedAt(ctx)
  26432. case usagestatisticday.FieldStatus:
  26433. return m.OldStatus(ctx)
  26434. case usagestatisticday.FieldDeletedAt:
  26435. return m.OldDeletedAt(ctx)
  26436. case usagestatisticday.FieldAddtime:
  26437. return m.OldAddtime(ctx)
  26438. case usagestatisticday.FieldType:
  26439. return m.OldType(ctx)
  26440. case usagestatisticday.FieldBotID:
  26441. return m.OldBotID(ctx)
  26442. case usagestatisticday.FieldOrganizationID:
  26443. return m.OldOrganizationID(ctx)
  26444. case usagestatisticday.FieldAiResponse:
  26445. return m.OldAiResponse(ctx)
  26446. case usagestatisticday.FieldSopRun:
  26447. return m.OldSopRun(ctx)
  26448. case usagestatisticday.FieldTotalFriend:
  26449. return m.OldTotalFriend(ctx)
  26450. case usagestatisticday.FieldTotalGroup:
  26451. return m.OldTotalGroup(ctx)
  26452. case usagestatisticday.FieldAccountBalance:
  26453. return m.OldAccountBalance(ctx)
  26454. case usagestatisticday.FieldConsumeToken:
  26455. return m.OldConsumeToken(ctx)
  26456. case usagestatisticday.FieldActiveUser:
  26457. return m.OldActiveUser(ctx)
  26458. case usagestatisticday.FieldNewUser:
  26459. return m.OldNewUser(ctx)
  26460. case usagestatisticday.FieldLabelDist:
  26461. return m.OldLabelDist(ctx)
  26462. }
  26463. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26464. }
  26465. // SetField sets the value of a field with the given name. It returns an error if
  26466. // the field is not defined in the schema, or if the type mismatched the field
  26467. // type.
  26468. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  26469. switch name {
  26470. case usagestatisticday.FieldCreatedAt:
  26471. v, ok := value.(time.Time)
  26472. if !ok {
  26473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26474. }
  26475. m.SetCreatedAt(v)
  26476. return nil
  26477. case usagestatisticday.FieldUpdatedAt:
  26478. v, ok := value.(time.Time)
  26479. if !ok {
  26480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26481. }
  26482. m.SetUpdatedAt(v)
  26483. return nil
  26484. case usagestatisticday.FieldStatus:
  26485. v, ok := value.(uint8)
  26486. if !ok {
  26487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26488. }
  26489. m.SetStatus(v)
  26490. return nil
  26491. case usagestatisticday.FieldDeletedAt:
  26492. v, ok := value.(time.Time)
  26493. if !ok {
  26494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26495. }
  26496. m.SetDeletedAt(v)
  26497. return nil
  26498. case usagestatisticday.FieldAddtime:
  26499. v, ok := value.(uint64)
  26500. if !ok {
  26501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26502. }
  26503. m.SetAddtime(v)
  26504. return nil
  26505. case usagestatisticday.FieldType:
  26506. v, ok := value.(int)
  26507. if !ok {
  26508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26509. }
  26510. m.SetType(v)
  26511. return nil
  26512. case usagestatisticday.FieldBotID:
  26513. v, ok := value.(string)
  26514. if !ok {
  26515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26516. }
  26517. m.SetBotID(v)
  26518. return nil
  26519. case usagestatisticday.FieldOrganizationID:
  26520. v, ok := value.(uint64)
  26521. if !ok {
  26522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26523. }
  26524. m.SetOrganizationID(v)
  26525. return nil
  26526. case usagestatisticday.FieldAiResponse:
  26527. v, ok := value.(uint64)
  26528. if !ok {
  26529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26530. }
  26531. m.SetAiResponse(v)
  26532. return nil
  26533. case usagestatisticday.FieldSopRun:
  26534. v, ok := value.(uint64)
  26535. if !ok {
  26536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26537. }
  26538. m.SetSopRun(v)
  26539. return nil
  26540. case usagestatisticday.FieldTotalFriend:
  26541. v, ok := value.(uint64)
  26542. if !ok {
  26543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26544. }
  26545. m.SetTotalFriend(v)
  26546. return nil
  26547. case usagestatisticday.FieldTotalGroup:
  26548. v, ok := value.(uint64)
  26549. if !ok {
  26550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26551. }
  26552. m.SetTotalGroup(v)
  26553. return nil
  26554. case usagestatisticday.FieldAccountBalance:
  26555. v, ok := value.(uint64)
  26556. if !ok {
  26557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26558. }
  26559. m.SetAccountBalance(v)
  26560. return nil
  26561. case usagestatisticday.FieldConsumeToken:
  26562. v, ok := value.(uint64)
  26563. if !ok {
  26564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26565. }
  26566. m.SetConsumeToken(v)
  26567. return nil
  26568. case usagestatisticday.FieldActiveUser:
  26569. v, ok := value.(uint64)
  26570. if !ok {
  26571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26572. }
  26573. m.SetActiveUser(v)
  26574. return nil
  26575. case usagestatisticday.FieldNewUser:
  26576. v, ok := value.(int64)
  26577. if !ok {
  26578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26579. }
  26580. m.SetNewUser(v)
  26581. return nil
  26582. case usagestatisticday.FieldLabelDist:
  26583. v, ok := value.([]custom_types.LabelDist)
  26584. if !ok {
  26585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26586. }
  26587. m.SetLabelDist(v)
  26588. return nil
  26589. }
  26590. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26591. }
  26592. // AddedFields returns all numeric fields that were incremented/decremented during
  26593. // this mutation.
  26594. func (m *UsageStatisticDayMutation) AddedFields() []string {
  26595. var fields []string
  26596. if m.addstatus != nil {
  26597. fields = append(fields, usagestatisticday.FieldStatus)
  26598. }
  26599. if m.addaddtime != nil {
  26600. fields = append(fields, usagestatisticday.FieldAddtime)
  26601. }
  26602. if m.add_type != nil {
  26603. fields = append(fields, usagestatisticday.FieldType)
  26604. }
  26605. if m.addorganization_id != nil {
  26606. fields = append(fields, usagestatisticday.FieldOrganizationID)
  26607. }
  26608. if m.addai_response != nil {
  26609. fields = append(fields, usagestatisticday.FieldAiResponse)
  26610. }
  26611. if m.addsop_run != nil {
  26612. fields = append(fields, usagestatisticday.FieldSopRun)
  26613. }
  26614. if m.addtotal_friend != nil {
  26615. fields = append(fields, usagestatisticday.FieldTotalFriend)
  26616. }
  26617. if m.addtotal_group != nil {
  26618. fields = append(fields, usagestatisticday.FieldTotalGroup)
  26619. }
  26620. if m.addaccount_balance != nil {
  26621. fields = append(fields, usagestatisticday.FieldAccountBalance)
  26622. }
  26623. if m.addconsume_token != nil {
  26624. fields = append(fields, usagestatisticday.FieldConsumeToken)
  26625. }
  26626. if m.addactive_user != nil {
  26627. fields = append(fields, usagestatisticday.FieldActiveUser)
  26628. }
  26629. if m.addnew_user != nil {
  26630. fields = append(fields, usagestatisticday.FieldNewUser)
  26631. }
  26632. return fields
  26633. }
  26634. // AddedField returns the numeric value that was incremented/decremented on a field
  26635. // with the given name. The second boolean return value indicates that this field
  26636. // was not set, or was not defined in the schema.
  26637. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  26638. switch name {
  26639. case usagestatisticday.FieldStatus:
  26640. return m.AddedStatus()
  26641. case usagestatisticday.FieldAddtime:
  26642. return m.AddedAddtime()
  26643. case usagestatisticday.FieldType:
  26644. return m.AddedType()
  26645. case usagestatisticday.FieldOrganizationID:
  26646. return m.AddedOrganizationID()
  26647. case usagestatisticday.FieldAiResponse:
  26648. return m.AddedAiResponse()
  26649. case usagestatisticday.FieldSopRun:
  26650. return m.AddedSopRun()
  26651. case usagestatisticday.FieldTotalFriend:
  26652. return m.AddedTotalFriend()
  26653. case usagestatisticday.FieldTotalGroup:
  26654. return m.AddedTotalGroup()
  26655. case usagestatisticday.FieldAccountBalance:
  26656. return m.AddedAccountBalance()
  26657. case usagestatisticday.FieldConsumeToken:
  26658. return m.AddedConsumeToken()
  26659. case usagestatisticday.FieldActiveUser:
  26660. return m.AddedActiveUser()
  26661. case usagestatisticday.FieldNewUser:
  26662. return m.AddedNewUser()
  26663. }
  26664. return nil, false
  26665. }
  26666. // AddField adds the value to the field with the given name. It returns an error if
  26667. // the field is not defined in the schema, or if the type mismatched the field
  26668. // type.
  26669. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  26670. switch name {
  26671. case usagestatisticday.FieldStatus:
  26672. v, ok := value.(int8)
  26673. if !ok {
  26674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26675. }
  26676. m.AddStatus(v)
  26677. return nil
  26678. case usagestatisticday.FieldAddtime:
  26679. v, ok := value.(int64)
  26680. if !ok {
  26681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26682. }
  26683. m.AddAddtime(v)
  26684. return nil
  26685. case usagestatisticday.FieldType:
  26686. v, ok := value.(int)
  26687. if !ok {
  26688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26689. }
  26690. m.AddType(v)
  26691. return nil
  26692. case usagestatisticday.FieldOrganizationID:
  26693. v, ok := value.(int64)
  26694. if !ok {
  26695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26696. }
  26697. m.AddOrganizationID(v)
  26698. return nil
  26699. case usagestatisticday.FieldAiResponse:
  26700. v, ok := value.(int64)
  26701. if !ok {
  26702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26703. }
  26704. m.AddAiResponse(v)
  26705. return nil
  26706. case usagestatisticday.FieldSopRun:
  26707. v, ok := value.(int64)
  26708. if !ok {
  26709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26710. }
  26711. m.AddSopRun(v)
  26712. return nil
  26713. case usagestatisticday.FieldTotalFriend:
  26714. v, ok := value.(int64)
  26715. if !ok {
  26716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26717. }
  26718. m.AddTotalFriend(v)
  26719. return nil
  26720. case usagestatisticday.FieldTotalGroup:
  26721. v, ok := value.(int64)
  26722. if !ok {
  26723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26724. }
  26725. m.AddTotalGroup(v)
  26726. return nil
  26727. case usagestatisticday.FieldAccountBalance:
  26728. v, ok := value.(int64)
  26729. if !ok {
  26730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26731. }
  26732. m.AddAccountBalance(v)
  26733. return nil
  26734. case usagestatisticday.FieldConsumeToken:
  26735. v, ok := value.(int64)
  26736. if !ok {
  26737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26738. }
  26739. m.AddConsumeToken(v)
  26740. return nil
  26741. case usagestatisticday.FieldActiveUser:
  26742. v, ok := value.(int64)
  26743. if !ok {
  26744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26745. }
  26746. m.AddActiveUser(v)
  26747. return nil
  26748. case usagestatisticday.FieldNewUser:
  26749. v, ok := value.(int64)
  26750. if !ok {
  26751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26752. }
  26753. m.AddNewUser(v)
  26754. return nil
  26755. }
  26756. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  26757. }
  26758. // ClearedFields returns all nullable fields that were cleared during this
  26759. // mutation.
  26760. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  26761. var fields []string
  26762. if m.FieldCleared(usagestatisticday.FieldStatus) {
  26763. fields = append(fields, usagestatisticday.FieldStatus)
  26764. }
  26765. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  26766. fields = append(fields, usagestatisticday.FieldDeletedAt)
  26767. }
  26768. if m.FieldCleared(usagestatisticday.FieldBotID) {
  26769. fields = append(fields, usagestatisticday.FieldBotID)
  26770. }
  26771. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  26772. fields = append(fields, usagestatisticday.FieldOrganizationID)
  26773. }
  26774. return fields
  26775. }
  26776. // FieldCleared returns a boolean indicating if a field with the given name was
  26777. // cleared in this mutation.
  26778. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  26779. _, ok := m.clearedFields[name]
  26780. return ok
  26781. }
  26782. // ClearField clears the value of the field with the given name. It returns an
  26783. // error if the field is not defined in the schema.
  26784. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  26785. switch name {
  26786. case usagestatisticday.FieldStatus:
  26787. m.ClearStatus()
  26788. return nil
  26789. case usagestatisticday.FieldDeletedAt:
  26790. m.ClearDeletedAt()
  26791. return nil
  26792. case usagestatisticday.FieldBotID:
  26793. m.ClearBotID()
  26794. return nil
  26795. case usagestatisticday.FieldOrganizationID:
  26796. m.ClearOrganizationID()
  26797. return nil
  26798. }
  26799. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  26800. }
  26801. // ResetField resets all changes in the mutation for the field with the given name.
  26802. // It returns an error if the field is not defined in the schema.
  26803. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  26804. switch name {
  26805. case usagestatisticday.FieldCreatedAt:
  26806. m.ResetCreatedAt()
  26807. return nil
  26808. case usagestatisticday.FieldUpdatedAt:
  26809. m.ResetUpdatedAt()
  26810. return nil
  26811. case usagestatisticday.FieldStatus:
  26812. m.ResetStatus()
  26813. return nil
  26814. case usagestatisticday.FieldDeletedAt:
  26815. m.ResetDeletedAt()
  26816. return nil
  26817. case usagestatisticday.FieldAddtime:
  26818. m.ResetAddtime()
  26819. return nil
  26820. case usagestatisticday.FieldType:
  26821. m.ResetType()
  26822. return nil
  26823. case usagestatisticday.FieldBotID:
  26824. m.ResetBotID()
  26825. return nil
  26826. case usagestatisticday.FieldOrganizationID:
  26827. m.ResetOrganizationID()
  26828. return nil
  26829. case usagestatisticday.FieldAiResponse:
  26830. m.ResetAiResponse()
  26831. return nil
  26832. case usagestatisticday.FieldSopRun:
  26833. m.ResetSopRun()
  26834. return nil
  26835. case usagestatisticday.FieldTotalFriend:
  26836. m.ResetTotalFriend()
  26837. return nil
  26838. case usagestatisticday.FieldTotalGroup:
  26839. m.ResetTotalGroup()
  26840. return nil
  26841. case usagestatisticday.FieldAccountBalance:
  26842. m.ResetAccountBalance()
  26843. return nil
  26844. case usagestatisticday.FieldConsumeToken:
  26845. m.ResetConsumeToken()
  26846. return nil
  26847. case usagestatisticday.FieldActiveUser:
  26848. m.ResetActiveUser()
  26849. return nil
  26850. case usagestatisticday.FieldNewUser:
  26851. m.ResetNewUser()
  26852. return nil
  26853. case usagestatisticday.FieldLabelDist:
  26854. m.ResetLabelDist()
  26855. return nil
  26856. }
  26857. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26858. }
  26859. // AddedEdges returns all edge names that were set/added in this mutation.
  26860. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  26861. edges := make([]string, 0, 0)
  26862. return edges
  26863. }
  26864. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26865. // name in this mutation.
  26866. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  26867. return nil
  26868. }
  26869. // RemovedEdges returns all edge names that were removed in this mutation.
  26870. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  26871. edges := make([]string, 0, 0)
  26872. return edges
  26873. }
  26874. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26875. // the given name in this mutation.
  26876. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  26877. return nil
  26878. }
  26879. // ClearedEdges returns all edge names that were cleared in this mutation.
  26880. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  26881. edges := make([]string, 0, 0)
  26882. return edges
  26883. }
  26884. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26885. // was cleared in this mutation.
  26886. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  26887. return false
  26888. }
  26889. // ClearEdge clears the value of the edge with the given name. It returns an error
  26890. // if that edge is not defined in the schema.
  26891. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  26892. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  26893. }
  26894. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26895. // It returns an error if the edge is not defined in the schema.
  26896. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  26897. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  26898. }
  26899. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  26900. type UsageStatisticHourMutation struct {
  26901. config
  26902. op Op
  26903. typ string
  26904. id *uint64
  26905. created_at *time.Time
  26906. updated_at *time.Time
  26907. status *uint8
  26908. addstatus *int8
  26909. deleted_at *time.Time
  26910. addtime *uint64
  26911. addaddtime *int64
  26912. _type *int
  26913. add_type *int
  26914. bot_id *string
  26915. organization_id *uint64
  26916. addorganization_id *int64
  26917. ai_response *uint64
  26918. addai_response *int64
  26919. sop_run *uint64
  26920. addsop_run *int64
  26921. total_friend *uint64
  26922. addtotal_friend *int64
  26923. total_group *uint64
  26924. addtotal_group *int64
  26925. account_balance *uint64
  26926. addaccount_balance *int64
  26927. consume_token *uint64
  26928. addconsume_token *int64
  26929. active_user *uint64
  26930. addactive_user *int64
  26931. new_user *int64
  26932. addnew_user *int64
  26933. label_dist *[]custom_types.LabelDist
  26934. appendlabel_dist []custom_types.LabelDist
  26935. clearedFields map[string]struct{}
  26936. done bool
  26937. oldValue func(context.Context) (*UsageStatisticHour, error)
  26938. predicates []predicate.UsageStatisticHour
  26939. }
  26940. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  26941. // usagestatistichourOption allows management of the mutation configuration using functional options.
  26942. type usagestatistichourOption func(*UsageStatisticHourMutation)
  26943. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  26944. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  26945. m := &UsageStatisticHourMutation{
  26946. config: c,
  26947. op: op,
  26948. typ: TypeUsageStatisticHour,
  26949. clearedFields: make(map[string]struct{}),
  26950. }
  26951. for _, opt := range opts {
  26952. opt(m)
  26953. }
  26954. return m
  26955. }
  26956. // withUsageStatisticHourID sets the ID field of the mutation.
  26957. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  26958. return func(m *UsageStatisticHourMutation) {
  26959. var (
  26960. err error
  26961. once sync.Once
  26962. value *UsageStatisticHour
  26963. )
  26964. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  26965. once.Do(func() {
  26966. if m.done {
  26967. err = errors.New("querying old values post mutation is not allowed")
  26968. } else {
  26969. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  26970. }
  26971. })
  26972. return value, err
  26973. }
  26974. m.id = &id
  26975. }
  26976. }
  26977. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  26978. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  26979. return func(m *UsageStatisticHourMutation) {
  26980. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  26981. return node, nil
  26982. }
  26983. m.id = &node.ID
  26984. }
  26985. }
  26986. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26987. // executed in a transaction (ent.Tx), a transactional client is returned.
  26988. func (m UsageStatisticHourMutation) Client() *Client {
  26989. client := &Client{config: m.config}
  26990. client.init()
  26991. return client
  26992. }
  26993. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26994. // it returns an error otherwise.
  26995. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  26996. if _, ok := m.driver.(*txDriver); !ok {
  26997. return nil, errors.New("ent: mutation is not running in a transaction")
  26998. }
  26999. tx := &Tx{config: m.config}
  27000. tx.init()
  27001. return tx, nil
  27002. }
  27003. // SetID sets the value of the id field. Note that this
  27004. // operation is only accepted on creation of UsageStatisticHour entities.
  27005. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  27006. m.id = &id
  27007. }
  27008. // ID returns the ID value in the mutation. Note that the ID is only available
  27009. // if it was provided to the builder or after it was returned from the database.
  27010. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  27011. if m.id == nil {
  27012. return
  27013. }
  27014. return *m.id, true
  27015. }
  27016. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27017. // That means, if the mutation is applied within a transaction with an isolation level such
  27018. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27019. // or updated by the mutation.
  27020. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  27021. switch {
  27022. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27023. id, exists := m.ID()
  27024. if exists {
  27025. return []uint64{id}, nil
  27026. }
  27027. fallthrough
  27028. case m.op.Is(OpUpdate | OpDelete):
  27029. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  27030. default:
  27031. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27032. }
  27033. }
  27034. // SetCreatedAt sets the "created_at" field.
  27035. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  27036. m.created_at = &t
  27037. }
  27038. // CreatedAt returns the value of the "created_at" field in the mutation.
  27039. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  27040. v := m.created_at
  27041. if v == nil {
  27042. return
  27043. }
  27044. return *v, true
  27045. }
  27046. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  27047. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27049. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27050. if !m.op.Is(OpUpdateOne) {
  27051. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27052. }
  27053. if m.id == nil || m.oldValue == nil {
  27054. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27055. }
  27056. oldValue, err := m.oldValue(ctx)
  27057. if err != nil {
  27058. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27059. }
  27060. return oldValue.CreatedAt, nil
  27061. }
  27062. // ResetCreatedAt resets all changes to the "created_at" field.
  27063. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  27064. m.created_at = nil
  27065. }
  27066. // SetUpdatedAt sets the "updated_at" field.
  27067. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  27068. m.updated_at = &t
  27069. }
  27070. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27071. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  27072. v := m.updated_at
  27073. if v == nil {
  27074. return
  27075. }
  27076. return *v, true
  27077. }
  27078. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  27079. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27081. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27082. if !m.op.Is(OpUpdateOne) {
  27083. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27084. }
  27085. if m.id == nil || m.oldValue == nil {
  27086. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27087. }
  27088. oldValue, err := m.oldValue(ctx)
  27089. if err != nil {
  27090. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27091. }
  27092. return oldValue.UpdatedAt, nil
  27093. }
  27094. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27095. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  27096. m.updated_at = nil
  27097. }
  27098. // SetStatus sets the "status" field.
  27099. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  27100. m.status = &u
  27101. m.addstatus = nil
  27102. }
  27103. // Status returns the value of the "status" field in the mutation.
  27104. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  27105. v := m.status
  27106. if v == nil {
  27107. return
  27108. }
  27109. return *v, true
  27110. }
  27111. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  27112. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27114. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27115. if !m.op.Is(OpUpdateOne) {
  27116. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27117. }
  27118. if m.id == nil || m.oldValue == nil {
  27119. return v, errors.New("OldStatus requires an ID field in the mutation")
  27120. }
  27121. oldValue, err := m.oldValue(ctx)
  27122. if err != nil {
  27123. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27124. }
  27125. return oldValue.Status, nil
  27126. }
  27127. // AddStatus adds u to the "status" field.
  27128. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  27129. if m.addstatus != nil {
  27130. *m.addstatus += u
  27131. } else {
  27132. m.addstatus = &u
  27133. }
  27134. }
  27135. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27136. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  27137. v := m.addstatus
  27138. if v == nil {
  27139. return
  27140. }
  27141. return *v, true
  27142. }
  27143. // ClearStatus clears the value of the "status" field.
  27144. func (m *UsageStatisticHourMutation) ClearStatus() {
  27145. m.status = nil
  27146. m.addstatus = nil
  27147. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  27148. }
  27149. // StatusCleared returns if the "status" field was cleared in this mutation.
  27150. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  27151. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  27152. return ok
  27153. }
  27154. // ResetStatus resets all changes to the "status" field.
  27155. func (m *UsageStatisticHourMutation) ResetStatus() {
  27156. m.status = nil
  27157. m.addstatus = nil
  27158. delete(m.clearedFields, usagestatistichour.FieldStatus)
  27159. }
  27160. // SetDeletedAt sets the "deleted_at" field.
  27161. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  27162. m.deleted_at = &t
  27163. }
  27164. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27165. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  27166. v := m.deleted_at
  27167. if v == nil {
  27168. return
  27169. }
  27170. return *v, true
  27171. }
  27172. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  27173. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27175. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27176. if !m.op.Is(OpUpdateOne) {
  27177. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27178. }
  27179. if m.id == nil || m.oldValue == nil {
  27180. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27181. }
  27182. oldValue, err := m.oldValue(ctx)
  27183. if err != nil {
  27184. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27185. }
  27186. return oldValue.DeletedAt, nil
  27187. }
  27188. // ClearDeletedAt clears the value of the "deleted_at" field.
  27189. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  27190. m.deleted_at = nil
  27191. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  27192. }
  27193. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27194. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  27195. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  27196. return ok
  27197. }
  27198. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27199. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  27200. m.deleted_at = nil
  27201. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  27202. }
  27203. // SetAddtime sets the "addtime" field.
  27204. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  27205. m.addtime = &u
  27206. m.addaddtime = nil
  27207. }
  27208. // Addtime returns the value of the "addtime" field in the mutation.
  27209. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  27210. v := m.addtime
  27211. if v == nil {
  27212. return
  27213. }
  27214. return *v, true
  27215. }
  27216. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  27217. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27219. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27220. if !m.op.Is(OpUpdateOne) {
  27221. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27222. }
  27223. if m.id == nil || m.oldValue == nil {
  27224. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27225. }
  27226. oldValue, err := m.oldValue(ctx)
  27227. if err != nil {
  27228. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27229. }
  27230. return oldValue.Addtime, nil
  27231. }
  27232. // AddAddtime adds u to the "addtime" field.
  27233. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  27234. if m.addaddtime != nil {
  27235. *m.addaddtime += u
  27236. } else {
  27237. m.addaddtime = &u
  27238. }
  27239. }
  27240. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27241. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  27242. v := m.addaddtime
  27243. if v == nil {
  27244. return
  27245. }
  27246. return *v, true
  27247. }
  27248. // ResetAddtime resets all changes to the "addtime" field.
  27249. func (m *UsageStatisticHourMutation) ResetAddtime() {
  27250. m.addtime = nil
  27251. m.addaddtime = nil
  27252. }
  27253. // SetType sets the "type" field.
  27254. func (m *UsageStatisticHourMutation) SetType(i int) {
  27255. m._type = &i
  27256. m.add_type = nil
  27257. }
  27258. // GetType returns the value of the "type" field in the mutation.
  27259. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  27260. v := m._type
  27261. if v == nil {
  27262. return
  27263. }
  27264. return *v, true
  27265. }
  27266. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  27267. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27269. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  27270. if !m.op.Is(OpUpdateOne) {
  27271. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27272. }
  27273. if m.id == nil || m.oldValue == nil {
  27274. return v, errors.New("OldType requires an ID field in the mutation")
  27275. }
  27276. oldValue, err := m.oldValue(ctx)
  27277. if err != nil {
  27278. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27279. }
  27280. return oldValue.Type, nil
  27281. }
  27282. // AddType adds i to the "type" field.
  27283. func (m *UsageStatisticHourMutation) AddType(i int) {
  27284. if m.add_type != nil {
  27285. *m.add_type += i
  27286. } else {
  27287. m.add_type = &i
  27288. }
  27289. }
  27290. // AddedType returns the value that was added to the "type" field in this mutation.
  27291. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  27292. v := m.add_type
  27293. if v == nil {
  27294. return
  27295. }
  27296. return *v, true
  27297. }
  27298. // ResetType resets all changes to the "type" field.
  27299. func (m *UsageStatisticHourMutation) ResetType() {
  27300. m._type = nil
  27301. m.add_type = nil
  27302. }
  27303. // SetBotID sets the "bot_id" field.
  27304. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  27305. m.bot_id = &s
  27306. }
  27307. // BotID returns the value of the "bot_id" field in the mutation.
  27308. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  27309. v := m.bot_id
  27310. if v == nil {
  27311. return
  27312. }
  27313. return *v, true
  27314. }
  27315. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  27316. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27318. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  27319. if !m.op.Is(OpUpdateOne) {
  27320. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27321. }
  27322. if m.id == nil || m.oldValue == nil {
  27323. return v, errors.New("OldBotID requires an ID field in the mutation")
  27324. }
  27325. oldValue, err := m.oldValue(ctx)
  27326. if err != nil {
  27327. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27328. }
  27329. return oldValue.BotID, nil
  27330. }
  27331. // ClearBotID clears the value of the "bot_id" field.
  27332. func (m *UsageStatisticHourMutation) ClearBotID() {
  27333. m.bot_id = nil
  27334. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  27335. }
  27336. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  27337. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  27338. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  27339. return ok
  27340. }
  27341. // ResetBotID resets all changes to the "bot_id" field.
  27342. func (m *UsageStatisticHourMutation) ResetBotID() {
  27343. m.bot_id = nil
  27344. delete(m.clearedFields, usagestatistichour.FieldBotID)
  27345. }
  27346. // SetOrganizationID sets the "organization_id" field.
  27347. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  27348. m.organization_id = &u
  27349. m.addorganization_id = nil
  27350. }
  27351. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27352. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  27353. v := m.organization_id
  27354. if v == nil {
  27355. return
  27356. }
  27357. return *v, true
  27358. }
  27359. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  27360. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27362. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27363. if !m.op.Is(OpUpdateOne) {
  27364. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27365. }
  27366. if m.id == nil || m.oldValue == nil {
  27367. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27368. }
  27369. oldValue, err := m.oldValue(ctx)
  27370. if err != nil {
  27371. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27372. }
  27373. return oldValue.OrganizationID, nil
  27374. }
  27375. // AddOrganizationID adds u to the "organization_id" field.
  27376. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  27377. if m.addorganization_id != nil {
  27378. *m.addorganization_id += u
  27379. } else {
  27380. m.addorganization_id = &u
  27381. }
  27382. }
  27383. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27384. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  27385. v := m.addorganization_id
  27386. if v == nil {
  27387. return
  27388. }
  27389. return *v, true
  27390. }
  27391. // ClearOrganizationID clears the value of the "organization_id" field.
  27392. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  27393. m.organization_id = nil
  27394. m.addorganization_id = nil
  27395. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  27396. }
  27397. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27398. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  27399. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  27400. return ok
  27401. }
  27402. // ResetOrganizationID resets all changes to the "organization_id" field.
  27403. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  27404. m.organization_id = nil
  27405. m.addorganization_id = nil
  27406. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  27407. }
  27408. // SetAiResponse sets the "ai_response" field.
  27409. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  27410. m.ai_response = &u
  27411. m.addai_response = nil
  27412. }
  27413. // AiResponse returns the value of the "ai_response" field in the mutation.
  27414. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  27415. v := m.ai_response
  27416. if v == nil {
  27417. return
  27418. }
  27419. return *v, true
  27420. }
  27421. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  27422. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27424. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  27425. if !m.op.Is(OpUpdateOne) {
  27426. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  27427. }
  27428. if m.id == nil || m.oldValue == nil {
  27429. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  27430. }
  27431. oldValue, err := m.oldValue(ctx)
  27432. if err != nil {
  27433. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  27434. }
  27435. return oldValue.AiResponse, nil
  27436. }
  27437. // AddAiResponse adds u to the "ai_response" field.
  27438. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  27439. if m.addai_response != nil {
  27440. *m.addai_response += u
  27441. } else {
  27442. m.addai_response = &u
  27443. }
  27444. }
  27445. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  27446. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  27447. v := m.addai_response
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // ResetAiResponse resets all changes to the "ai_response" field.
  27454. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  27455. m.ai_response = nil
  27456. m.addai_response = nil
  27457. }
  27458. // SetSopRun sets the "sop_run" field.
  27459. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  27460. m.sop_run = &u
  27461. m.addsop_run = nil
  27462. }
  27463. // SopRun returns the value of the "sop_run" field in the mutation.
  27464. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  27465. v := m.sop_run
  27466. if v == nil {
  27467. return
  27468. }
  27469. return *v, true
  27470. }
  27471. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  27472. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27474. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  27475. if !m.op.Is(OpUpdateOne) {
  27476. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  27477. }
  27478. if m.id == nil || m.oldValue == nil {
  27479. return v, errors.New("OldSopRun requires an ID field in the mutation")
  27480. }
  27481. oldValue, err := m.oldValue(ctx)
  27482. if err != nil {
  27483. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  27484. }
  27485. return oldValue.SopRun, nil
  27486. }
  27487. // AddSopRun adds u to the "sop_run" field.
  27488. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  27489. if m.addsop_run != nil {
  27490. *m.addsop_run += u
  27491. } else {
  27492. m.addsop_run = &u
  27493. }
  27494. }
  27495. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  27496. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  27497. v := m.addsop_run
  27498. if v == nil {
  27499. return
  27500. }
  27501. return *v, true
  27502. }
  27503. // ResetSopRun resets all changes to the "sop_run" field.
  27504. func (m *UsageStatisticHourMutation) ResetSopRun() {
  27505. m.sop_run = nil
  27506. m.addsop_run = nil
  27507. }
  27508. // SetTotalFriend sets the "total_friend" field.
  27509. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  27510. m.total_friend = &u
  27511. m.addtotal_friend = nil
  27512. }
  27513. // TotalFriend returns the value of the "total_friend" field in the mutation.
  27514. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  27515. v := m.total_friend
  27516. if v == nil {
  27517. return
  27518. }
  27519. return *v, true
  27520. }
  27521. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  27522. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27524. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  27525. if !m.op.Is(OpUpdateOne) {
  27526. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  27527. }
  27528. if m.id == nil || m.oldValue == nil {
  27529. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  27530. }
  27531. oldValue, err := m.oldValue(ctx)
  27532. if err != nil {
  27533. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  27534. }
  27535. return oldValue.TotalFriend, nil
  27536. }
  27537. // AddTotalFriend adds u to the "total_friend" field.
  27538. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  27539. if m.addtotal_friend != nil {
  27540. *m.addtotal_friend += u
  27541. } else {
  27542. m.addtotal_friend = &u
  27543. }
  27544. }
  27545. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  27546. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  27547. v := m.addtotal_friend
  27548. if v == nil {
  27549. return
  27550. }
  27551. return *v, true
  27552. }
  27553. // ResetTotalFriend resets all changes to the "total_friend" field.
  27554. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  27555. m.total_friend = nil
  27556. m.addtotal_friend = nil
  27557. }
  27558. // SetTotalGroup sets the "total_group" field.
  27559. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  27560. m.total_group = &u
  27561. m.addtotal_group = nil
  27562. }
  27563. // TotalGroup returns the value of the "total_group" field in the mutation.
  27564. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  27565. v := m.total_group
  27566. if v == nil {
  27567. return
  27568. }
  27569. return *v, true
  27570. }
  27571. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  27572. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27574. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  27575. if !m.op.Is(OpUpdateOne) {
  27576. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  27577. }
  27578. if m.id == nil || m.oldValue == nil {
  27579. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  27580. }
  27581. oldValue, err := m.oldValue(ctx)
  27582. if err != nil {
  27583. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  27584. }
  27585. return oldValue.TotalGroup, nil
  27586. }
  27587. // AddTotalGroup adds u to the "total_group" field.
  27588. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  27589. if m.addtotal_group != nil {
  27590. *m.addtotal_group += u
  27591. } else {
  27592. m.addtotal_group = &u
  27593. }
  27594. }
  27595. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  27596. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  27597. v := m.addtotal_group
  27598. if v == nil {
  27599. return
  27600. }
  27601. return *v, true
  27602. }
  27603. // ResetTotalGroup resets all changes to the "total_group" field.
  27604. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  27605. m.total_group = nil
  27606. m.addtotal_group = nil
  27607. }
  27608. // SetAccountBalance sets the "account_balance" field.
  27609. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  27610. m.account_balance = &u
  27611. m.addaccount_balance = nil
  27612. }
  27613. // AccountBalance returns the value of the "account_balance" field in the mutation.
  27614. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  27615. v := m.account_balance
  27616. if v == nil {
  27617. return
  27618. }
  27619. return *v, true
  27620. }
  27621. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  27622. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27624. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  27625. if !m.op.Is(OpUpdateOne) {
  27626. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  27627. }
  27628. if m.id == nil || m.oldValue == nil {
  27629. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  27630. }
  27631. oldValue, err := m.oldValue(ctx)
  27632. if err != nil {
  27633. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  27634. }
  27635. return oldValue.AccountBalance, nil
  27636. }
  27637. // AddAccountBalance adds u to the "account_balance" field.
  27638. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  27639. if m.addaccount_balance != nil {
  27640. *m.addaccount_balance += u
  27641. } else {
  27642. m.addaccount_balance = &u
  27643. }
  27644. }
  27645. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  27646. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  27647. v := m.addaccount_balance
  27648. if v == nil {
  27649. return
  27650. }
  27651. return *v, true
  27652. }
  27653. // ResetAccountBalance resets all changes to the "account_balance" field.
  27654. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  27655. m.account_balance = nil
  27656. m.addaccount_balance = nil
  27657. }
  27658. // SetConsumeToken sets the "consume_token" field.
  27659. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  27660. m.consume_token = &u
  27661. m.addconsume_token = nil
  27662. }
  27663. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  27664. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  27665. v := m.consume_token
  27666. if v == nil {
  27667. return
  27668. }
  27669. return *v, true
  27670. }
  27671. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  27672. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27674. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  27675. if !m.op.Is(OpUpdateOne) {
  27676. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  27677. }
  27678. if m.id == nil || m.oldValue == nil {
  27679. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  27680. }
  27681. oldValue, err := m.oldValue(ctx)
  27682. if err != nil {
  27683. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  27684. }
  27685. return oldValue.ConsumeToken, nil
  27686. }
  27687. // AddConsumeToken adds u to the "consume_token" field.
  27688. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  27689. if m.addconsume_token != nil {
  27690. *m.addconsume_token += u
  27691. } else {
  27692. m.addconsume_token = &u
  27693. }
  27694. }
  27695. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  27696. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  27697. v := m.addconsume_token
  27698. if v == nil {
  27699. return
  27700. }
  27701. return *v, true
  27702. }
  27703. // ResetConsumeToken resets all changes to the "consume_token" field.
  27704. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  27705. m.consume_token = nil
  27706. m.addconsume_token = nil
  27707. }
  27708. // SetActiveUser sets the "active_user" field.
  27709. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  27710. m.active_user = &u
  27711. m.addactive_user = nil
  27712. }
  27713. // ActiveUser returns the value of the "active_user" field in the mutation.
  27714. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  27715. v := m.active_user
  27716. if v == nil {
  27717. return
  27718. }
  27719. return *v, true
  27720. }
  27721. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  27722. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27724. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  27725. if !m.op.Is(OpUpdateOne) {
  27726. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  27727. }
  27728. if m.id == nil || m.oldValue == nil {
  27729. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  27730. }
  27731. oldValue, err := m.oldValue(ctx)
  27732. if err != nil {
  27733. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  27734. }
  27735. return oldValue.ActiveUser, nil
  27736. }
  27737. // AddActiveUser adds u to the "active_user" field.
  27738. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  27739. if m.addactive_user != nil {
  27740. *m.addactive_user += u
  27741. } else {
  27742. m.addactive_user = &u
  27743. }
  27744. }
  27745. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  27746. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  27747. v := m.addactive_user
  27748. if v == nil {
  27749. return
  27750. }
  27751. return *v, true
  27752. }
  27753. // ResetActiveUser resets all changes to the "active_user" field.
  27754. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  27755. m.active_user = nil
  27756. m.addactive_user = nil
  27757. }
  27758. // SetNewUser sets the "new_user" field.
  27759. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  27760. m.new_user = &i
  27761. m.addnew_user = nil
  27762. }
  27763. // NewUser returns the value of the "new_user" field in the mutation.
  27764. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  27765. v := m.new_user
  27766. if v == nil {
  27767. return
  27768. }
  27769. return *v, true
  27770. }
  27771. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  27772. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27774. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  27775. if !m.op.Is(OpUpdateOne) {
  27776. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  27777. }
  27778. if m.id == nil || m.oldValue == nil {
  27779. return v, errors.New("OldNewUser requires an ID field in the mutation")
  27780. }
  27781. oldValue, err := m.oldValue(ctx)
  27782. if err != nil {
  27783. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  27784. }
  27785. return oldValue.NewUser, nil
  27786. }
  27787. // AddNewUser adds i to the "new_user" field.
  27788. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  27789. if m.addnew_user != nil {
  27790. *m.addnew_user += i
  27791. } else {
  27792. m.addnew_user = &i
  27793. }
  27794. }
  27795. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  27796. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  27797. v := m.addnew_user
  27798. if v == nil {
  27799. return
  27800. }
  27801. return *v, true
  27802. }
  27803. // ResetNewUser resets all changes to the "new_user" field.
  27804. func (m *UsageStatisticHourMutation) ResetNewUser() {
  27805. m.new_user = nil
  27806. m.addnew_user = nil
  27807. }
  27808. // SetLabelDist sets the "label_dist" field.
  27809. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  27810. m.label_dist = &ctd
  27811. m.appendlabel_dist = nil
  27812. }
  27813. // LabelDist returns the value of the "label_dist" field in the mutation.
  27814. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  27815. v := m.label_dist
  27816. if v == nil {
  27817. return
  27818. }
  27819. return *v, true
  27820. }
  27821. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  27822. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27824. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  27825. if !m.op.Is(OpUpdateOne) {
  27826. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  27827. }
  27828. if m.id == nil || m.oldValue == nil {
  27829. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  27830. }
  27831. oldValue, err := m.oldValue(ctx)
  27832. if err != nil {
  27833. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  27834. }
  27835. return oldValue.LabelDist, nil
  27836. }
  27837. // AppendLabelDist adds ctd to the "label_dist" field.
  27838. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  27839. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  27840. }
  27841. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  27842. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  27843. if len(m.appendlabel_dist) == 0 {
  27844. return nil, false
  27845. }
  27846. return m.appendlabel_dist, true
  27847. }
  27848. // ResetLabelDist resets all changes to the "label_dist" field.
  27849. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  27850. m.label_dist = nil
  27851. m.appendlabel_dist = nil
  27852. }
  27853. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  27854. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  27855. m.predicates = append(m.predicates, ps...)
  27856. }
  27857. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  27858. // users can use type-assertion to append predicates that do not depend on any generated package.
  27859. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  27860. p := make([]predicate.UsageStatisticHour, len(ps))
  27861. for i := range ps {
  27862. p[i] = ps[i]
  27863. }
  27864. m.Where(p...)
  27865. }
  27866. // Op returns the operation name.
  27867. func (m *UsageStatisticHourMutation) Op() Op {
  27868. return m.op
  27869. }
  27870. // SetOp allows setting the mutation operation.
  27871. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  27872. m.op = op
  27873. }
  27874. // Type returns the node type of this mutation (UsageStatisticHour).
  27875. func (m *UsageStatisticHourMutation) Type() string {
  27876. return m.typ
  27877. }
  27878. // Fields returns all fields that were changed during this mutation. Note that in
  27879. // order to get all numeric fields that were incremented/decremented, call
  27880. // AddedFields().
  27881. func (m *UsageStatisticHourMutation) Fields() []string {
  27882. fields := make([]string, 0, 17)
  27883. if m.created_at != nil {
  27884. fields = append(fields, usagestatistichour.FieldCreatedAt)
  27885. }
  27886. if m.updated_at != nil {
  27887. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  27888. }
  27889. if m.status != nil {
  27890. fields = append(fields, usagestatistichour.FieldStatus)
  27891. }
  27892. if m.deleted_at != nil {
  27893. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27894. }
  27895. if m.addtime != nil {
  27896. fields = append(fields, usagestatistichour.FieldAddtime)
  27897. }
  27898. if m._type != nil {
  27899. fields = append(fields, usagestatistichour.FieldType)
  27900. }
  27901. if m.bot_id != nil {
  27902. fields = append(fields, usagestatistichour.FieldBotID)
  27903. }
  27904. if m.organization_id != nil {
  27905. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27906. }
  27907. if m.ai_response != nil {
  27908. fields = append(fields, usagestatistichour.FieldAiResponse)
  27909. }
  27910. if m.sop_run != nil {
  27911. fields = append(fields, usagestatistichour.FieldSopRun)
  27912. }
  27913. if m.total_friend != nil {
  27914. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27915. }
  27916. if m.total_group != nil {
  27917. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27918. }
  27919. if m.account_balance != nil {
  27920. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27921. }
  27922. if m.consume_token != nil {
  27923. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27924. }
  27925. if m.active_user != nil {
  27926. fields = append(fields, usagestatistichour.FieldActiveUser)
  27927. }
  27928. if m.new_user != nil {
  27929. fields = append(fields, usagestatistichour.FieldNewUser)
  27930. }
  27931. if m.label_dist != nil {
  27932. fields = append(fields, usagestatistichour.FieldLabelDist)
  27933. }
  27934. return fields
  27935. }
  27936. // Field returns the value of a field with the given name. The second boolean
  27937. // return value indicates that this field was not set, or was not defined in the
  27938. // schema.
  27939. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  27940. switch name {
  27941. case usagestatistichour.FieldCreatedAt:
  27942. return m.CreatedAt()
  27943. case usagestatistichour.FieldUpdatedAt:
  27944. return m.UpdatedAt()
  27945. case usagestatistichour.FieldStatus:
  27946. return m.Status()
  27947. case usagestatistichour.FieldDeletedAt:
  27948. return m.DeletedAt()
  27949. case usagestatistichour.FieldAddtime:
  27950. return m.Addtime()
  27951. case usagestatistichour.FieldType:
  27952. return m.GetType()
  27953. case usagestatistichour.FieldBotID:
  27954. return m.BotID()
  27955. case usagestatistichour.FieldOrganizationID:
  27956. return m.OrganizationID()
  27957. case usagestatistichour.FieldAiResponse:
  27958. return m.AiResponse()
  27959. case usagestatistichour.FieldSopRun:
  27960. return m.SopRun()
  27961. case usagestatistichour.FieldTotalFriend:
  27962. return m.TotalFriend()
  27963. case usagestatistichour.FieldTotalGroup:
  27964. return m.TotalGroup()
  27965. case usagestatistichour.FieldAccountBalance:
  27966. return m.AccountBalance()
  27967. case usagestatistichour.FieldConsumeToken:
  27968. return m.ConsumeToken()
  27969. case usagestatistichour.FieldActiveUser:
  27970. return m.ActiveUser()
  27971. case usagestatistichour.FieldNewUser:
  27972. return m.NewUser()
  27973. case usagestatistichour.FieldLabelDist:
  27974. return m.LabelDist()
  27975. }
  27976. return nil, false
  27977. }
  27978. // OldField returns the old value of the field from the database. An error is
  27979. // returned if the mutation operation is not UpdateOne, or the query to the
  27980. // database failed.
  27981. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27982. switch name {
  27983. case usagestatistichour.FieldCreatedAt:
  27984. return m.OldCreatedAt(ctx)
  27985. case usagestatistichour.FieldUpdatedAt:
  27986. return m.OldUpdatedAt(ctx)
  27987. case usagestatistichour.FieldStatus:
  27988. return m.OldStatus(ctx)
  27989. case usagestatistichour.FieldDeletedAt:
  27990. return m.OldDeletedAt(ctx)
  27991. case usagestatistichour.FieldAddtime:
  27992. return m.OldAddtime(ctx)
  27993. case usagestatistichour.FieldType:
  27994. return m.OldType(ctx)
  27995. case usagestatistichour.FieldBotID:
  27996. return m.OldBotID(ctx)
  27997. case usagestatistichour.FieldOrganizationID:
  27998. return m.OldOrganizationID(ctx)
  27999. case usagestatistichour.FieldAiResponse:
  28000. return m.OldAiResponse(ctx)
  28001. case usagestatistichour.FieldSopRun:
  28002. return m.OldSopRun(ctx)
  28003. case usagestatistichour.FieldTotalFriend:
  28004. return m.OldTotalFriend(ctx)
  28005. case usagestatistichour.FieldTotalGroup:
  28006. return m.OldTotalGroup(ctx)
  28007. case usagestatistichour.FieldAccountBalance:
  28008. return m.OldAccountBalance(ctx)
  28009. case usagestatistichour.FieldConsumeToken:
  28010. return m.OldConsumeToken(ctx)
  28011. case usagestatistichour.FieldActiveUser:
  28012. return m.OldActiveUser(ctx)
  28013. case usagestatistichour.FieldNewUser:
  28014. return m.OldNewUser(ctx)
  28015. case usagestatistichour.FieldLabelDist:
  28016. return m.OldLabelDist(ctx)
  28017. }
  28018. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  28019. }
  28020. // SetField sets the value of a field with the given name. It returns an error if
  28021. // the field is not defined in the schema, or if the type mismatched the field
  28022. // type.
  28023. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  28024. switch name {
  28025. case usagestatistichour.FieldCreatedAt:
  28026. v, ok := value.(time.Time)
  28027. if !ok {
  28028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28029. }
  28030. m.SetCreatedAt(v)
  28031. return nil
  28032. case usagestatistichour.FieldUpdatedAt:
  28033. v, ok := value.(time.Time)
  28034. if !ok {
  28035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28036. }
  28037. m.SetUpdatedAt(v)
  28038. return nil
  28039. case usagestatistichour.FieldStatus:
  28040. v, ok := value.(uint8)
  28041. if !ok {
  28042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28043. }
  28044. m.SetStatus(v)
  28045. return nil
  28046. case usagestatistichour.FieldDeletedAt:
  28047. v, ok := value.(time.Time)
  28048. if !ok {
  28049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28050. }
  28051. m.SetDeletedAt(v)
  28052. return nil
  28053. case usagestatistichour.FieldAddtime:
  28054. v, ok := value.(uint64)
  28055. if !ok {
  28056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28057. }
  28058. m.SetAddtime(v)
  28059. return nil
  28060. case usagestatistichour.FieldType:
  28061. v, ok := value.(int)
  28062. if !ok {
  28063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28064. }
  28065. m.SetType(v)
  28066. return nil
  28067. case usagestatistichour.FieldBotID:
  28068. v, ok := value.(string)
  28069. if !ok {
  28070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28071. }
  28072. m.SetBotID(v)
  28073. return nil
  28074. case usagestatistichour.FieldOrganizationID:
  28075. v, ok := value.(uint64)
  28076. if !ok {
  28077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28078. }
  28079. m.SetOrganizationID(v)
  28080. return nil
  28081. case usagestatistichour.FieldAiResponse:
  28082. v, ok := value.(uint64)
  28083. if !ok {
  28084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28085. }
  28086. m.SetAiResponse(v)
  28087. return nil
  28088. case usagestatistichour.FieldSopRun:
  28089. v, ok := value.(uint64)
  28090. if !ok {
  28091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28092. }
  28093. m.SetSopRun(v)
  28094. return nil
  28095. case usagestatistichour.FieldTotalFriend:
  28096. v, ok := value.(uint64)
  28097. if !ok {
  28098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28099. }
  28100. m.SetTotalFriend(v)
  28101. return nil
  28102. case usagestatistichour.FieldTotalGroup:
  28103. v, ok := value.(uint64)
  28104. if !ok {
  28105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28106. }
  28107. m.SetTotalGroup(v)
  28108. return nil
  28109. case usagestatistichour.FieldAccountBalance:
  28110. v, ok := value.(uint64)
  28111. if !ok {
  28112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28113. }
  28114. m.SetAccountBalance(v)
  28115. return nil
  28116. case usagestatistichour.FieldConsumeToken:
  28117. v, ok := value.(uint64)
  28118. if !ok {
  28119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28120. }
  28121. m.SetConsumeToken(v)
  28122. return nil
  28123. case usagestatistichour.FieldActiveUser:
  28124. v, ok := value.(uint64)
  28125. if !ok {
  28126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28127. }
  28128. m.SetActiveUser(v)
  28129. return nil
  28130. case usagestatistichour.FieldNewUser:
  28131. v, ok := value.(int64)
  28132. if !ok {
  28133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28134. }
  28135. m.SetNewUser(v)
  28136. return nil
  28137. case usagestatistichour.FieldLabelDist:
  28138. v, ok := value.([]custom_types.LabelDist)
  28139. if !ok {
  28140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28141. }
  28142. m.SetLabelDist(v)
  28143. return nil
  28144. }
  28145. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  28146. }
  28147. // AddedFields returns all numeric fields that were incremented/decremented during
  28148. // this mutation.
  28149. func (m *UsageStatisticHourMutation) AddedFields() []string {
  28150. var fields []string
  28151. if m.addstatus != nil {
  28152. fields = append(fields, usagestatistichour.FieldStatus)
  28153. }
  28154. if m.addaddtime != nil {
  28155. fields = append(fields, usagestatistichour.FieldAddtime)
  28156. }
  28157. if m.add_type != nil {
  28158. fields = append(fields, usagestatistichour.FieldType)
  28159. }
  28160. if m.addorganization_id != nil {
  28161. fields = append(fields, usagestatistichour.FieldOrganizationID)
  28162. }
  28163. if m.addai_response != nil {
  28164. fields = append(fields, usagestatistichour.FieldAiResponse)
  28165. }
  28166. if m.addsop_run != nil {
  28167. fields = append(fields, usagestatistichour.FieldSopRun)
  28168. }
  28169. if m.addtotal_friend != nil {
  28170. fields = append(fields, usagestatistichour.FieldTotalFriend)
  28171. }
  28172. if m.addtotal_group != nil {
  28173. fields = append(fields, usagestatistichour.FieldTotalGroup)
  28174. }
  28175. if m.addaccount_balance != nil {
  28176. fields = append(fields, usagestatistichour.FieldAccountBalance)
  28177. }
  28178. if m.addconsume_token != nil {
  28179. fields = append(fields, usagestatistichour.FieldConsumeToken)
  28180. }
  28181. if m.addactive_user != nil {
  28182. fields = append(fields, usagestatistichour.FieldActiveUser)
  28183. }
  28184. if m.addnew_user != nil {
  28185. fields = append(fields, usagestatistichour.FieldNewUser)
  28186. }
  28187. return fields
  28188. }
  28189. // AddedField returns the numeric value that was incremented/decremented on a field
  28190. // with the given name. The second boolean return value indicates that this field
  28191. // was not set, or was not defined in the schema.
  28192. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  28193. switch name {
  28194. case usagestatistichour.FieldStatus:
  28195. return m.AddedStatus()
  28196. case usagestatistichour.FieldAddtime:
  28197. return m.AddedAddtime()
  28198. case usagestatistichour.FieldType:
  28199. return m.AddedType()
  28200. case usagestatistichour.FieldOrganizationID:
  28201. return m.AddedOrganizationID()
  28202. case usagestatistichour.FieldAiResponse:
  28203. return m.AddedAiResponse()
  28204. case usagestatistichour.FieldSopRun:
  28205. return m.AddedSopRun()
  28206. case usagestatistichour.FieldTotalFriend:
  28207. return m.AddedTotalFriend()
  28208. case usagestatistichour.FieldTotalGroup:
  28209. return m.AddedTotalGroup()
  28210. case usagestatistichour.FieldAccountBalance:
  28211. return m.AddedAccountBalance()
  28212. case usagestatistichour.FieldConsumeToken:
  28213. return m.AddedConsumeToken()
  28214. case usagestatistichour.FieldActiveUser:
  28215. return m.AddedActiveUser()
  28216. case usagestatistichour.FieldNewUser:
  28217. return m.AddedNewUser()
  28218. }
  28219. return nil, false
  28220. }
  28221. // AddField adds the value to the field with the given name. It returns an error if
  28222. // the field is not defined in the schema, or if the type mismatched the field
  28223. // type.
  28224. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  28225. switch name {
  28226. case usagestatistichour.FieldStatus:
  28227. v, ok := value.(int8)
  28228. if !ok {
  28229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28230. }
  28231. m.AddStatus(v)
  28232. return nil
  28233. case usagestatistichour.FieldAddtime:
  28234. v, ok := value.(int64)
  28235. if !ok {
  28236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28237. }
  28238. m.AddAddtime(v)
  28239. return nil
  28240. case usagestatistichour.FieldType:
  28241. v, ok := value.(int)
  28242. if !ok {
  28243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28244. }
  28245. m.AddType(v)
  28246. return nil
  28247. case usagestatistichour.FieldOrganizationID:
  28248. v, ok := value.(int64)
  28249. if !ok {
  28250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28251. }
  28252. m.AddOrganizationID(v)
  28253. return nil
  28254. case usagestatistichour.FieldAiResponse:
  28255. v, ok := value.(int64)
  28256. if !ok {
  28257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28258. }
  28259. m.AddAiResponse(v)
  28260. return nil
  28261. case usagestatistichour.FieldSopRun:
  28262. v, ok := value.(int64)
  28263. if !ok {
  28264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28265. }
  28266. m.AddSopRun(v)
  28267. return nil
  28268. case usagestatistichour.FieldTotalFriend:
  28269. v, ok := value.(int64)
  28270. if !ok {
  28271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28272. }
  28273. m.AddTotalFriend(v)
  28274. return nil
  28275. case usagestatistichour.FieldTotalGroup:
  28276. v, ok := value.(int64)
  28277. if !ok {
  28278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28279. }
  28280. m.AddTotalGroup(v)
  28281. return nil
  28282. case usagestatistichour.FieldAccountBalance:
  28283. v, ok := value.(int64)
  28284. if !ok {
  28285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28286. }
  28287. m.AddAccountBalance(v)
  28288. return nil
  28289. case usagestatistichour.FieldConsumeToken:
  28290. v, ok := value.(int64)
  28291. if !ok {
  28292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28293. }
  28294. m.AddConsumeToken(v)
  28295. return nil
  28296. case usagestatistichour.FieldActiveUser:
  28297. v, ok := value.(int64)
  28298. if !ok {
  28299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28300. }
  28301. m.AddActiveUser(v)
  28302. return nil
  28303. case usagestatistichour.FieldNewUser:
  28304. v, ok := value.(int64)
  28305. if !ok {
  28306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28307. }
  28308. m.AddNewUser(v)
  28309. return nil
  28310. }
  28311. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  28312. }
  28313. // ClearedFields returns all nullable fields that were cleared during this
  28314. // mutation.
  28315. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  28316. var fields []string
  28317. if m.FieldCleared(usagestatistichour.FieldStatus) {
  28318. fields = append(fields, usagestatistichour.FieldStatus)
  28319. }
  28320. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  28321. fields = append(fields, usagestatistichour.FieldDeletedAt)
  28322. }
  28323. if m.FieldCleared(usagestatistichour.FieldBotID) {
  28324. fields = append(fields, usagestatistichour.FieldBotID)
  28325. }
  28326. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  28327. fields = append(fields, usagestatistichour.FieldOrganizationID)
  28328. }
  28329. return fields
  28330. }
  28331. // FieldCleared returns a boolean indicating if a field with the given name was
  28332. // cleared in this mutation.
  28333. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  28334. _, ok := m.clearedFields[name]
  28335. return ok
  28336. }
  28337. // ClearField clears the value of the field with the given name. It returns an
  28338. // error if the field is not defined in the schema.
  28339. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  28340. switch name {
  28341. case usagestatistichour.FieldStatus:
  28342. m.ClearStatus()
  28343. return nil
  28344. case usagestatistichour.FieldDeletedAt:
  28345. m.ClearDeletedAt()
  28346. return nil
  28347. case usagestatistichour.FieldBotID:
  28348. m.ClearBotID()
  28349. return nil
  28350. case usagestatistichour.FieldOrganizationID:
  28351. m.ClearOrganizationID()
  28352. return nil
  28353. }
  28354. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  28355. }
  28356. // ResetField resets all changes in the mutation for the field with the given name.
  28357. // It returns an error if the field is not defined in the schema.
  28358. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  28359. switch name {
  28360. case usagestatistichour.FieldCreatedAt:
  28361. m.ResetCreatedAt()
  28362. return nil
  28363. case usagestatistichour.FieldUpdatedAt:
  28364. m.ResetUpdatedAt()
  28365. return nil
  28366. case usagestatistichour.FieldStatus:
  28367. m.ResetStatus()
  28368. return nil
  28369. case usagestatistichour.FieldDeletedAt:
  28370. m.ResetDeletedAt()
  28371. return nil
  28372. case usagestatistichour.FieldAddtime:
  28373. m.ResetAddtime()
  28374. return nil
  28375. case usagestatistichour.FieldType:
  28376. m.ResetType()
  28377. return nil
  28378. case usagestatistichour.FieldBotID:
  28379. m.ResetBotID()
  28380. return nil
  28381. case usagestatistichour.FieldOrganizationID:
  28382. m.ResetOrganizationID()
  28383. return nil
  28384. case usagestatistichour.FieldAiResponse:
  28385. m.ResetAiResponse()
  28386. return nil
  28387. case usagestatistichour.FieldSopRun:
  28388. m.ResetSopRun()
  28389. return nil
  28390. case usagestatistichour.FieldTotalFriend:
  28391. m.ResetTotalFriend()
  28392. return nil
  28393. case usagestatistichour.FieldTotalGroup:
  28394. m.ResetTotalGroup()
  28395. return nil
  28396. case usagestatistichour.FieldAccountBalance:
  28397. m.ResetAccountBalance()
  28398. return nil
  28399. case usagestatistichour.FieldConsumeToken:
  28400. m.ResetConsumeToken()
  28401. return nil
  28402. case usagestatistichour.FieldActiveUser:
  28403. m.ResetActiveUser()
  28404. return nil
  28405. case usagestatistichour.FieldNewUser:
  28406. m.ResetNewUser()
  28407. return nil
  28408. case usagestatistichour.FieldLabelDist:
  28409. m.ResetLabelDist()
  28410. return nil
  28411. }
  28412. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  28413. }
  28414. // AddedEdges returns all edge names that were set/added in this mutation.
  28415. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  28416. edges := make([]string, 0, 0)
  28417. return edges
  28418. }
  28419. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28420. // name in this mutation.
  28421. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  28422. return nil
  28423. }
  28424. // RemovedEdges returns all edge names that were removed in this mutation.
  28425. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  28426. edges := make([]string, 0, 0)
  28427. return edges
  28428. }
  28429. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28430. // the given name in this mutation.
  28431. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  28432. return nil
  28433. }
  28434. // ClearedEdges returns all edge names that were cleared in this mutation.
  28435. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  28436. edges := make([]string, 0, 0)
  28437. return edges
  28438. }
  28439. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28440. // was cleared in this mutation.
  28441. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  28442. return false
  28443. }
  28444. // ClearEdge clears the value of the edge with the given name. It returns an error
  28445. // if that edge is not defined in the schema.
  28446. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  28447. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  28448. }
  28449. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28450. // It returns an error if the edge is not defined in the schema.
  28451. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  28452. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  28453. }
  28454. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  28455. type UsageStatisticMonthMutation struct {
  28456. config
  28457. op Op
  28458. typ string
  28459. id *uint64
  28460. created_at *time.Time
  28461. updated_at *time.Time
  28462. status *uint8
  28463. addstatus *int8
  28464. deleted_at *time.Time
  28465. addtime *uint64
  28466. addaddtime *int64
  28467. _type *int
  28468. add_type *int
  28469. bot_id *string
  28470. organization_id *uint64
  28471. addorganization_id *int64
  28472. ai_response *uint64
  28473. addai_response *int64
  28474. sop_run *uint64
  28475. addsop_run *int64
  28476. total_friend *uint64
  28477. addtotal_friend *int64
  28478. total_group *uint64
  28479. addtotal_group *int64
  28480. account_balance *uint64
  28481. addaccount_balance *int64
  28482. consume_token *uint64
  28483. addconsume_token *int64
  28484. active_user *uint64
  28485. addactive_user *int64
  28486. new_user *int64
  28487. addnew_user *int64
  28488. label_dist *[]custom_types.LabelDist
  28489. appendlabel_dist []custom_types.LabelDist
  28490. clearedFields map[string]struct{}
  28491. done bool
  28492. oldValue func(context.Context) (*UsageStatisticMonth, error)
  28493. predicates []predicate.UsageStatisticMonth
  28494. }
  28495. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  28496. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  28497. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  28498. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  28499. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  28500. m := &UsageStatisticMonthMutation{
  28501. config: c,
  28502. op: op,
  28503. typ: TypeUsageStatisticMonth,
  28504. clearedFields: make(map[string]struct{}),
  28505. }
  28506. for _, opt := range opts {
  28507. opt(m)
  28508. }
  28509. return m
  28510. }
  28511. // withUsageStatisticMonthID sets the ID field of the mutation.
  28512. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  28513. return func(m *UsageStatisticMonthMutation) {
  28514. var (
  28515. err error
  28516. once sync.Once
  28517. value *UsageStatisticMonth
  28518. )
  28519. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  28520. once.Do(func() {
  28521. if m.done {
  28522. err = errors.New("querying old values post mutation is not allowed")
  28523. } else {
  28524. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  28525. }
  28526. })
  28527. return value, err
  28528. }
  28529. m.id = &id
  28530. }
  28531. }
  28532. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  28533. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  28534. return func(m *UsageStatisticMonthMutation) {
  28535. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  28536. return node, nil
  28537. }
  28538. m.id = &node.ID
  28539. }
  28540. }
  28541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28542. // executed in a transaction (ent.Tx), a transactional client is returned.
  28543. func (m UsageStatisticMonthMutation) Client() *Client {
  28544. client := &Client{config: m.config}
  28545. client.init()
  28546. return client
  28547. }
  28548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28549. // it returns an error otherwise.
  28550. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  28551. if _, ok := m.driver.(*txDriver); !ok {
  28552. return nil, errors.New("ent: mutation is not running in a transaction")
  28553. }
  28554. tx := &Tx{config: m.config}
  28555. tx.init()
  28556. return tx, nil
  28557. }
  28558. // SetID sets the value of the id field. Note that this
  28559. // operation is only accepted on creation of UsageStatisticMonth entities.
  28560. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  28561. m.id = &id
  28562. }
  28563. // ID returns the ID value in the mutation. Note that the ID is only available
  28564. // if it was provided to the builder or after it was returned from the database.
  28565. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  28566. if m.id == nil {
  28567. return
  28568. }
  28569. return *m.id, true
  28570. }
  28571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28572. // That means, if the mutation is applied within a transaction with an isolation level such
  28573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28574. // or updated by the mutation.
  28575. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  28576. switch {
  28577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28578. id, exists := m.ID()
  28579. if exists {
  28580. return []uint64{id}, nil
  28581. }
  28582. fallthrough
  28583. case m.op.Is(OpUpdate | OpDelete):
  28584. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  28585. default:
  28586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28587. }
  28588. }
  28589. // SetCreatedAt sets the "created_at" field.
  28590. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  28591. m.created_at = &t
  28592. }
  28593. // CreatedAt returns the value of the "created_at" field in the mutation.
  28594. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  28595. v := m.created_at
  28596. if v == nil {
  28597. return
  28598. }
  28599. return *v, true
  28600. }
  28601. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  28602. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28604. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28605. if !m.op.Is(OpUpdateOne) {
  28606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28607. }
  28608. if m.id == nil || m.oldValue == nil {
  28609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28610. }
  28611. oldValue, err := m.oldValue(ctx)
  28612. if err != nil {
  28613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28614. }
  28615. return oldValue.CreatedAt, nil
  28616. }
  28617. // ResetCreatedAt resets all changes to the "created_at" field.
  28618. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  28619. m.created_at = nil
  28620. }
  28621. // SetUpdatedAt sets the "updated_at" field.
  28622. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  28623. m.updated_at = &t
  28624. }
  28625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28626. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  28627. v := m.updated_at
  28628. if v == nil {
  28629. return
  28630. }
  28631. return *v, true
  28632. }
  28633. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  28634. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28636. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28637. if !m.op.Is(OpUpdateOne) {
  28638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28639. }
  28640. if m.id == nil || m.oldValue == nil {
  28641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28642. }
  28643. oldValue, err := m.oldValue(ctx)
  28644. if err != nil {
  28645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28646. }
  28647. return oldValue.UpdatedAt, nil
  28648. }
  28649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28650. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  28651. m.updated_at = nil
  28652. }
  28653. // SetStatus sets the "status" field.
  28654. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  28655. m.status = &u
  28656. m.addstatus = nil
  28657. }
  28658. // Status returns the value of the "status" field in the mutation.
  28659. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  28660. v := m.status
  28661. if v == nil {
  28662. return
  28663. }
  28664. return *v, true
  28665. }
  28666. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  28667. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28669. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28670. if !m.op.Is(OpUpdateOne) {
  28671. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28672. }
  28673. if m.id == nil || m.oldValue == nil {
  28674. return v, errors.New("OldStatus requires an ID field in the mutation")
  28675. }
  28676. oldValue, err := m.oldValue(ctx)
  28677. if err != nil {
  28678. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28679. }
  28680. return oldValue.Status, nil
  28681. }
  28682. // AddStatus adds u to the "status" field.
  28683. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  28684. if m.addstatus != nil {
  28685. *m.addstatus += u
  28686. } else {
  28687. m.addstatus = &u
  28688. }
  28689. }
  28690. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28691. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  28692. v := m.addstatus
  28693. if v == nil {
  28694. return
  28695. }
  28696. return *v, true
  28697. }
  28698. // ClearStatus clears the value of the "status" field.
  28699. func (m *UsageStatisticMonthMutation) ClearStatus() {
  28700. m.status = nil
  28701. m.addstatus = nil
  28702. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  28703. }
  28704. // StatusCleared returns if the "status" field was cleared in this mutation.
  28705. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  28706. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  28707. return ok
  28708. }
  28709. // ResetStatus resets all changes to the "status" field.
  28710. func (m *UsageStatisticMonthMutation) ResetStatus() {
  28711. m.status = nil
  28712. m.addstatus = nil
  28713. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  28714. }
  28715. // SetDeletedAt sets the "deleted_at" field.
  28716. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  28717. m.deleted_at = &t
  28718. }
  28719. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28720. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  28721. v := m.deleted_at
  28722. if v == nil {
  28723. return
  28724. }
  28725. return *v, true
  28726. }
  28727. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  28728. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28730. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28731. if !m.op.Is(OpUpdateOne) {
  28732. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28733. }
  28734. if m.id == nil || m.oldValue == nil {
  28735. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28736. }
  28737. oldValue, err := m.oldValue(ctx)
  28738. if err != nil {
  28739. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28740. }
  28741. return oldValue.DeletedAt, nil
  28742. }
  28743. // ClearDeletedAt clears the value of the "deleted_at" field.
  28744. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  28745. m.deleted_at = nil
  28746. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  28747. }
  28748. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28749. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  28750. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  28751. return ok
  28752. }
  28753. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28754. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  28755. m.deleted_at = nil
  28756. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  28757. }
  28758. // SetAddtime sets the "addtime" field.
  28759. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  28760. m.addtime = &u
  28761. m.addaddtime = nil
  28762. }
  28763. // Addtime returns the value of the "addtime" field in the mutation.
  28764. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  28765. v := m.addtime
  28766. if v == nil {
  28767. return
  28768. }
  28769. return *v, true
  28770. }
  28771. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  28772. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28774. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28775. if !m.op.Is(OpUpdateOne) {
  28776. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28777. }
  28778. if m.id == nil || m.oldValue == nil {
  28779. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28780. }
  28781. oldValue, err := m.oldValue(ctx)
  28782. if err != nil {
  28783. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28784. }
  28785. return oldValue.Addtime, nil
  28786. }
  28787. // AddAddtime adds u to the "addtime" field.
  28788. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  28789. if m.addaddtime != nil {
  28790. *m.addaddtime += u
  28791. } else {
  28792. m.addaddtime = &u
  28793. }
  28794. }
  28795. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28796. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  28797. v := m.addaddtime
  28798. if v == nil {
  28799. return
  28800. }
  28801. return *v, true
  28802. }
  28803. // ResetAddtime resets all changes to the "addtime" field.
  28804. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  28805. m.addtime = nil
  28806. m.addaddtime = nil
  28807. }
  28808. // SetType sets the "type" field.
  28809. func (m *UsageStatisticMonthMutation) SetType(i int) {
  28810. m._type = &i
  28811. m.add_type = nil
  28812. }
  28813. // GetType returns the value of the "type" field in the mutation.
  28814. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  28815. v := m._type
  28816. if v == nil {
  28817. return
  28818. }
  28819. return *v, true
  28820. }
  28821. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  28822. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28824. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  28825. if !m.op.Is(OpUpdateOne) {
  28826. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28827. }
  28828. if m.id == nil || m.oldValue == nil {
  28829. return v, errors.New("OldType requires an ID field in the mutation")
  28830. }
  28831. oldValue, err := m.oldValue(ctx)
  28832. if err != nil {
  28833. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28834. }
  28835. return oldValue.Type, nil
  28836. }
  28837. // AddType adds i to the "type" field.
  28838. func (m *UsageStatisticMonthMutation) AddType(i int) {
  28839. if m.add_type != nil {
  28840. *m.add_type += i
  28841. } else {
  28842. m.add_type = &i
  28843. }
  28844. }
  28845. // AddedType returns the value that was added to the "type" field in this mutation.
  28846. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  28847. v := m.add_type
  28848. if v == nil {
  28849. return
  28850. }
  28851. return *v, true
  28852. }
  28853. // ResetType resets all changes to the "type" field.
  28854. func (m *UsageStatisticMonthMutation) ResetType() {
  28855. m._type = nil
  28856. m.add_type = nil
  28857. }
  28858. // SetBotID sets the "bot_id" field.
  28859. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  28860. m.bot_id = &s
  28861. }
  28862. // BotID returns the value of the "bot_id" field in the mutation.
  28863. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  28864. v := m.bot_id
  28865. if v == nil {
  28866. return
  28867. }
  28868. return *v, true
  28869. }
  28870. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  28871. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28873. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  28874. if !m.op.Is(OpUpdateOne) {
  28875. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28876. }
  28877. if m.id == nil || m.oldValue == nil {
  28878. return v, errors.New("OldBotID requires an ID field in the mutation")
  28879. }
  28880. oldValue, err := m.oldValue(ctx)
  28881. if err != nil {
  28882. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28883. }
  28884. return oldValue.BotID, nil
  28885. }
  28886. // ClearBotID clears the value of the "bot_id" field.
  28887. func (m *UsageStatisticMonthMutation) ClearBotID() {
  28888. m.bot_id = nil
  28889. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  28890. }
  28891. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28892. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  28893. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  28894. return ok
  28895. }
  28896. // ResetBotID resets all changes to the "bot_id" field.
  28897. func (m *UsageStatisticMonthMutation) ResetBotID() {
  28898. m.bot_id = nil
  28899. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  28900. }
  28901. // SetOrganizationID sets the "organization_id" field.
  28902. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  28903. m.organization_id = &u
  28904. m.addorganization_id = nil
  28905. }
  28906. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28907. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  28908. v := m.organization_id
  28909. if v == nil {
  28910. return
  28911. }
  28912. return *v, true
  28913. }
  28914. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  28915. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28917. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28918. if !m.op.Is(OpUpdateOne) {
  28919. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28920. }
  28921. if m.id == nil || m.oldValue == nil {
  28922. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28923. }
  28924. oldValue, err := m.oldValue(ctx)
  28925. if err != nil {
  28926. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28927. }
  28928. return oldValue.OrganizationID, nil
  28929. }
  28930. // AddOrganizationID adds u to the "organization_id" field.
  28931. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  28932. if m.addorganization_id != nil {
  28933. *m.addorganization_id += u
  28934. } else {
  28935. m.addorganization_id = &u
  28936. }
  28937. }
  28938. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28939. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  28940. v := m.addorganization_id
  28941. if v == nil {
  28942. return
  28943. }
  28944. return *v, true
  28945. }
  28946. // ClearOrganizationID clears the value of the "organization_id" field.
  28947. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  28948. m.organization_id = nil
  28949. m.addorganization_id = nil
  28950. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  28951. }
  28952. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28953. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  28954. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  28955. return ok
  28956. }
  28957. // ResetOrganizationID resets all changes to the "organization_id" field.
  28958. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  28959. m.organization_id = nil
  28960. m.addorganization_id = nil
  28961. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  28962. }
  28963. // SetAiResponse sets the "ai_response" field.
  28964. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  28965. m.ai_response = &u
  28966. m.addai_response = nil
  28967. }
  28968. // AiResponse returns the value of the "ai_response" field in the mutation.
  28969. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  28970. v := m.ai_response
  28971. if v == nil {
  28972. return
  28973. }
  28974. return *v, true
  28975. }
  28976. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  28977. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28979. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28980. if !m.op.Is(OpUpdateOne) {
  28981. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28982. }
  28983. if m.id == nil || m.oldValue == nil {
  28984. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28985. }
  28986. oldValue, err := m.oldValue(ctx)
  28987. if err != nil {
  28988. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28989. }
  28990. return oldValue.AiResponse, nil
  28991. }
  28992. // AddAiResponse adds u to the "ai_response" field.
  28993. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  28994. if m.addai_response != nil {
  28995. *m.addai_response += u
  28996. } else {
  28997. m.addai_response = &u
  28998. }
  28999. }
  29000. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29001. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  29002. v := m.addai_response
  29003. if v == nil {
  29004. return
  29005. }
  29006. return *v, true
  29007. }
  29008. // ResetAiResponse resets all changes to the "ai_response" field.
  29009. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  29010. m.ai_response = nil
  29011. m.addai_response = nil
  29012. }
  29013. // SetSopRun sets the "sop_run" field.
  29014. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  29015. m.sop_run = &u
  29016. m.addsop_run = nil
  29017. }
  29018. // SopRun returns the value of the "sop_run" field in the mutation.
  29019. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  29020. v := m.sop_run
  29021. if v == nil {
  29022. return
  29023. }
  29024. return *v, true
  29025. }
  29026. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  29027. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29029. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29030. if !m.op.Is(OpUpdateOne) {
  29031. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29032. }
  29033. if m.id == nil || m.oldValue == nil {
  29034. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29035. }
  29036. oldValue, err := m.oldValue(ctx)
  29037. if err != nil {
  29038. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29039. }
  29040. return oldValue.SopRun, nil
  29041. }
  29042. // AddSopRun adds u to the "sop_run" field.
  29043. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  29044. if m.addsop_run != nil {
  29045. *m.addsop_run += u
  29046. } else {
  29047. m.addsop_run = &u
  29048. }
  29049. }
  29050. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29051. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  29052. v := m.addsop_run
  29053. if v == nil {
  29054. return
  29055. }
  29056. return *v, true
  29057. }
  29058. // ResetSopRun resets all changes to the "sop_run" field.
  29059. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  29060. m.sop_run = nil
  29061. m.addsop_run = nil
  29062. }
  29063. // SetTotalFriend sets the "total_friend" field.
  29064. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  29065. m.total_friend = &u
  29066. m.addtotal_friend = nil
  29067. }
  29068. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29069. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  29070. v := m.total_friend
  29071. if v == nil {
  29072. return
  29073. }
  29074. return *v, true
  29075. }
  29076. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  29077. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29079. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29080. if !m.op.Is(OpUpdateOne) {
  29081. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29082. }
  29083. if m.id == nil || m.oldValue == nil {
  29084. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29085. }
  29086. oldValue, err := m.oldValue(ctx)
  29087. if err != nil {
  29088. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29089. }
  29090. return oldValue.TotalFriend, nil
  29091. }
  29092. // AddTotalFriend adds u to the "total_friend" field.
  29093. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  29094. if m.addtotal_friend != nil {
  29095. *m.addtotal_friend += u
  29096. } else {
  29097. m.addtotal_friend = &u
  29098. }
  29099. }
  29100. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29101. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  29102. v := m.addtotal_friend
  29103. if v == nil {
  29104. return
  29105. }
  29106. return *v, true
  29107. }
  29108. // ResetTotalFriend resets all changes to the "total_friend" field.
  29109. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  29110. m.total_friend = nil
  29111. m.addtotal_friend = nil
  29112. }
  29113. // SetTotalGroup sets the "total_group" field.
  29114. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  29115. m.total_group = &u
  29116. m.addtotal_group = nil
  29117. }
  29118. // TotalGroup returns the value of the "total_group" field in the mutation.
  29119. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  29120. v := m.total_group
  29121. if v == nil {
  29122. return
  29123. }
  29124. return *v, true
  29125. }
  29126. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  29127. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29129. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29130. if !m.op.Is(OpUpdateOne) {
  29131. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29132. }
  29133. if m.id == nil || m.oldValue == nil {
  29134. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29135. }
  29136. oldValue, err := m.oldValue(ctx)
  29137. if err != nil {
  29138. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29139. }
  29140. return oldValue.TotalGroup, nil
  29141. }
  29142. // AddTotalGroup adds u to the "total_group" field.
  29143. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  29144. if m.addtotal_group != nil {
  29145. *m.addtotal_group += u
  29146. } else {
  29147. m.addtotal_group = &u
  29148. }
  29149. }
  29150. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29151. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  29152. v := m.addtotal_group
  29153. if v == nil {
  29154. return
  29155. }
  29156. return *v, true
  29157. }
  29158. // ResetTotalGroup resets all changes to the "total_group" field.
  29159. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  29160. m.total_group = nil
  29161. m.addtotal_group = nil
  29162. }
  29163. // SetAccountBalance sets the "account_balance" field.
  29164. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  29165. m.account_balance = &u
  29166. m.addaccount_balance = nil
  29167. }
  29168. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29169. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  29170. v := m.account_balance
  29171. if v == nil {
  29172. return
  29173. }
  29174. return *v, true
  29175. }
  29176. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  29177. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29179. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29180. if !m.op.Is(OpUpdateOne) {
  29181. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29182. }
  29183. if m.id == nil || m.oldValue == nil {
  29184. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29185. }
  29186. oldValue, err := m.oldValue(ctx)
  29187. if err != nil {
  29188. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29189. }
  29190. return oldValue.AccountBalance, nil
  29191. }
  29192. // AddAccountBalance adds u to the "account_balance" field.
  29193. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  29194. if m.addaccount_balance != nil {
  29195. *m.addaccount_balance += u
  29196. } else {
  29197. m.addaccount_balance = &u
  29198. }
  29199. }
  29200. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29201. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  29202. v := m.addaccount_balance
  29203. if v == nil {
  29204. return
  29205. }
  29206. return *v, true
  29207. }
  29208. // ResetAccountBalance resets all changes to the "account_balance" field.
  29209. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  29210. m.account_balance = nil
  29211. m.addaccount_balance = nil
  29212. }
  29213. // SetConsumeToken sets the "consume_token" field.
  29214. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  29215. m.consume_token = &u
  29216. m.addconsume_token = nil
  29217. }
  29218. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29219. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  29220. v := m.consume_token
  29221. if v == nil {
  29222. return
  29223. }
  29224. return *v, true
  29225. }
  29226. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  29227. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29229. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29230. if !m.op.Is(OpUpdateOne) {
  29231. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29232. }
  29233. if m.id == nil || m.oldValue == nil {
  29234. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29235. }
  29236. oldValue, err := m.oldValue(ctx)
  29237. if err != nil {
  29238. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29239. }
  29240. return oldValue.ConsumeToken, nil
  29241. }
  29242. // AddConsumeToken adds u to the "consume_token" field.
  29243. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  29244. if m.addconsume_token != nil {
  29245. *m.addconsume_token += u
  29246. } else {
  29247. m.addconsume_token = &u
  29248. }
  29249. }
  29250. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29251. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  29252. v := m.addconsume_token
  29253. if v == nil {
  29254. return
  29255. }
  29256. return *v, true
  29257. }
  29258. // ResetConsumeToken resets all changes to the "consume_token" field.
  29259. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  29260. m.consume_token = nil
  29261. m.addconsume_token = nil
  29262. }
  29263. // SetActiveUser sets the "active_user" field.
  29264. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  29265. m.active_user = &u
  29266. m.addactive_user = nil
  29267. }
  29268. // ActiveUser returns the value of the "active_user" field in the mutation.
  29269. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  29270. v := m.active_user
  29271. if v == nil {
  29272. return
  29273. }
  29274. return *v, true
  29275. }
  29276. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  29277. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29279. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29280. if !m.op.Is(OpUpdateOne) {
  29281. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  29282. }
  29283. if m.id == nil || m.oldValue == nil {
  29284. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  29285. }
  29286. oldValue, err := m.oldValue(ctx)
  29287. if err != nil {
  29288. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  29289. }
  29290. return oldValue.ActiveUser, nil
  29291. }
  29292. // AddActiveUser adds u to the "active_user" field.
  29293. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  29294. if m.addactive_user != nil {
  29295. *m.addactive_user += u
  29296. } else {
  29297. m.addactive_user = &u
  29298. }
  29299. }
  29300. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  29301. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  29302. v := m.addactive_user
  29303. if v == nil {
  29304. return
  29305. }
  29306. return *v, true
  29307. }
  29308. // ResetActiveUser resets all changes to the "active_user" field.
  29309. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  29310. m.active_user = nil
  29311. m.addactive_user = nil
  29312. }
  29313. // SetNewUser sets the "new_user" field.
  29314. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  29315. m.new_user = &i
  29316. m.addnew_user = nil
  29317. }
  29318. // NewUser returns the value of the "new_user" field in the mutation.
  29319. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  29320. v := m.new_user
  29321. if v == nil {
  29322. return
  29323. }
  29324. return *v, true
  29325. }
  29326. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  29327. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29329. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  29330. if !m.op.Is(OpUpdateOne) {
  29331. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  29332. }
  29333. if m.id == nil || m.oldValue == nil {
  29334. return v, errors.New("OldNewUser requires an ID field in the mutation")
  29335. }
  29336. oldValue, err := m.oldValue(ctx)
  29337. if err != nil {
  29338. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  29339. }
  29340. return oldValue.NewUser, nil
  29341. }
  29342. // AddNewUser adds i to the "new_user" field.
  29343. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  29344. if m.addnew_user != nil {
  29345. *m.addnew_user += i
  29346. } else {
  29347. m.addnew_user = &i
  29348. }
  29349. }
  29350. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  29351. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  29352. v := m.addnew_user
  29353. if v == nil {
  29354. return
  29355. }
  29356. return *v, true
  29357. }
  29358. // ResetNewUser resets all changes to the "new_user" field.
  29359. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  29360. m.new_user = nil
  29361. m.addnew_user = nil
  29362. }
  29363. // SetLabelDist sets the "label_dist" field.
  29364. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  29365. m.label_dist = &ctd
  29366. m.appendlabel_dist = nil
  29367. }
  29368. // LabelDist returns the value of the "label_dist" field in the mutation.
  29369. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  29370. v := m.label_dist
  29371. if v == nil {
  29372. return
  29373. }
  29374. return *v, true
  29375. }
  29376. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  29377. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29380. if !m.op.Is(OpUpdateOne) {
  29381. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29382. }
  29383. if m.id == nil || m.oldValue == nil {
  29384. return v, errors.New("OldLabelDist 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 OldLabelDist: %w", err)
  29389. }
  29390. return oldValue.LabelDist, nil
  29391. }
  29392. // AppendLabelDist adds ctd to the "label_dist" field.
  29393. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29394. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29395. }
  29396. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29397. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29398. if len(m.appendlabel_dist) == 0 {
  29399. return nil, false
  29400. }
  29401. return m.appendlabel_dist, true
  29402. }
  29403. // ResetLabelDist resets all changes to the "label_dist" field.
  29404. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  29405. m.label_dist = nil
  29406. m.appendlabel_dist = nil
  29407. }
  29408. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  29409. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  29410. m.predicates = append(m.predicates, ps...)
  29411. }
  29412. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  29413. // users can use type-assertion to append predicates that do not depend on any generated package.
  29414. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  29415. p := make([]predicate.UsageStatisticMonth, len(ps))
  29416. for i := range ps {
  29417. p[i] = ps[i]
  29418. }
  29419. m.Where(p...)
  29420. }
  29421. // Op returns the operation name.
  29422. func (m *UsageStatisticMonthMutation) Op() Op {
  29423. return m.op
  29424. }
  29425. // SetOp allows setting the mutation operation.
  29426. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  29427. m.op = op
  29428. }
  29429. // Type returns the node type of this mutation (UsageStatisticMonth).
  29430. func (m *UsageStatisticMonthMutation) Type() string {
  29431. return m.typ
  29432. }
  29433. // Fields returns all fields that were changed during this mutation. Note that in
  29434. // order to get all numeric fields that were incremented/decremented, call
  29435. // AddedFields().
  29436. func (m *UsageStatisticMonthMutation) Fields() []string {
  29437. fields := make([]string, 0, 17)
  29438. if m.created_at != nil {
  29439. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  29440. }
  29441. if m.updated_at != nil {
  29442. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  29443. }
  29444. if m.status != nil {
  29445. fields = append(fields, usagestatisticmonth.FieldStatus)
  29446. }
  29447. if m.deleted_at != nil {
  29448. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  29449. }
  29450. if m.addtime != nil {
  29451. fields = append(fields, usagestatisticmonth.FieldAddtime)
  29452. }
  29453. if m._type != nil {
  29454. fields = append(fields, usagestatisticmonth.FieldType)
  29455. }
  29456. if m.bot_id != nil {
  29457. fields = append(fields, usagestatisticmonth.FieldBotID)
  29458. }
  29459. if m.organization_id != nil {
  29460. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29461. }
  29462. if m.ai_response != nil {
  29463. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  29464. }
  29465. if m.sop_run != nil {
  29466. fields = append(fields, usagestatisticmonth.FieldSopRun)
  29467. }
  29468. if m.total_friend != nil {
  29469. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  29470. }
  29471. if m.total_group != nil {
  29472. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  29473. }
  29474. if m.account_balance != nil {
  29475. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  29476. }
  29477. if m.consume_token != nil {
  29478. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  29479. }
  29480. if m.active_user != nil {
  29481. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  29482. }
  29483. if m.new_user != nil {
  29484. fields = append(fields, usagestatisticmonth.FieldNewUser)
  29485. }
  29486. if m.label_dist != nil {
  29487. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  29488. }
  29489. return fields
  29490. }
  29491. // Field returns the value of a field with the given name. The second boolean
  29492. // return value indicates that this field was not set, or was not defined in the
  29493. // schema.
  29494. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  29495. switch name {
  29496. case usagestatisticmonth.FieldCreatedAt:
  29497. return m.CreatedAt()
  29498. case usagestatisticmonth.FieldUpdatedAt:
  29499. return m.UpdatedAt()
  29500. case usagestatisticmonth.FieldStatus:
  29501. return m.Status()
  29502. case usagestatisticmonth.FieldDeletedAt:
  29503. return m.DeletedAt()
  29504. case usagestatisticmonth.FieldAddtime:
  29505. return m.Addtime()
  29506. case usagestatisticmonth.FieldType:
  29507. return m.GetType()
  29508. case usagestatisticmonth.FieldBotID:
  29509. return m.BotID()
  29510. case usagestatisticmonth.FieldOrganizationID:
  29511. return m.OrganizationID()
  29512. case usagestatisticmonth.FieldAiResponse:
  29513. return m.AiResponse()
  29514. case usagestatisticmonth.FieldSopRun:
  29515. return m.SopRun()
  29516. case usagestatisticmonth.FieldTotalFriend:
  29517. return m.TotalFriend()
  29518. case usagestatisticmonth.FieldTotalGroup:
  29519. return m.TotalGroup()
  29520. case usagestatisticmonth.FieldAccountBalance:
  29521. return m.AccountBalance()
  29522. case usagestatisticmonth.FieldConsumeToken:
  29523. return m.ConsumeToken()
  29524. case usagestatisticmonth.FieldActiveUser:
  29525. return m.ActiveUser()
  29526. case usagestatisticmonth.FieldNewUser:
  29527. return m.NewUser()
  29528. case usagestatisticmonth.FieldLabelDist:
  29529. return m.LabelDist()
  29530. }
  29531. return nil, false
  29532. }
  29533. // OldField returns the old value of the field from the database. An error is
  29534. // returned if the mutation operation is not UpdateOne, or the query to the
  29535. // database failed.
  29536. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29537. switch name {
  29538. case usagestatisticmonth.FieldCreatedAt:
  29539. return m.OldCreatedAt(ctx)
  29540. case usagestatisticmonth.FieldUpdatedAt:
  29541. return m.OldUpdatedAt(ctx)
  29542. case usagestatisticmonth.FieldStatus:
  29543. return m.OldStatus(ctx)
  29544. case usagestatisticmonth.FieldDeletedAt:
  29545. return m.OldDeletedAt(ctx)
  29546. case usagestatisticmonth.FieldAddtime:
  29547. return m.OldAddtime(ctx)
  29548. case usagestatisticmonth.FieldType:
  29549. return m.OldType(ctx)
  29550. case usagestatisticmonth.FieldBotID:
  29551. return m.OldBotID(ctx)
  29552. case usagestatisticmonth.FieldOrganizationID:
  29553. return m.OldOrganizationID(ctx)
  29554. case usagestatisticmonth.FieldAiResponse:
  29555. return m.OldAiResponse(ctx)
  29556. case usagestatisticmonth.FieldSopRun:
  29557. return m.OldSopRun(ctx)
  29558. case usagestatisticmonth.FieldTotalFriend:
  29559. return m.OldTotalFriend(ctx)
  29560. case usagestatisticmonth.FieldTotalGroup:
  29561. return m.OldTotalGroup(ctx)
  29562. case usagestatisticmonth.FieldAccountBalance:
  29563. return m.OldAccountBalance(ctx)
  29564. case usagestatisticmonth.FieldConsumeToken:
  29565. return m.OldConsumeToken(ctx)
  29566. case usagestatisticmonth.FieldActiveUser:
  29567. return m.OldActiveUser(ctx)
  29568. case usagestatisticmonth.FieldNewUser:
  29569. return m.OldNewUser(ctx)
  29570. case usagestatisticmonth.FieldLabelDist:
  29571. return m.OldLabelDist(ctx)
  29572. }
  29573. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29574. }
  29575. // SetField sets the value of a field with the given name. It returns an error if
  29576. // the field is not defined in the schema, or if the type mismatched the field
  29577. // type.
  29578. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  29579. switch name {
  29580. case usagestatisticmonth.FieldCreatedAt:
  29581. v, ok := value.(time.Time)
  29582. if !ok {
  29583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29584. }
  29585. m.SetCreatedAt(v)
  29586. return nil
  29587. case usagestatisticmonth.FieldUpdatedAt:
  29588. v, ok := value.(time.Time)
  29589. if !ok {
  29590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29591. }
  29592. m.SetUpdatedAt(v)
  29593. return nil
  29594. case usagestatisticmonth.FieldStatus:
  29595. v, ok := value.(uint8)
  29596. if !ok {
  29597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29598. }
  29599. m.SetStatus(v)
  29600. return nil
  29601. case usagestatisticmonth.FieldDeletedAt:
  29602. v, ok := value.(time.Time)
  29603. if !ok {
  29604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29605. }
  29606. m.SetDeletedAt(v)
  29607. return nil
  29608. case usagestatisticmonth.FieldAddtime:
  29609. v, ok := value.(uint64)
  29610. if !ok {
  29611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29612. }
  29613. m.SetAddtime(v)
  29614. return nil
  29615. case usagestatisticmonth.FieldType:
  29616. v, ok := value.(int)
  29617. if !ok {
  29618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29619. }
  29620. m.SetType(v)
  29621. return nil
  29622. case usagestatisticmonth.FieldBotID:
  29623. v, ok := value.(string)
  29624. if !ok {
  29625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29626. }
  29627. m.SetBotID(v)
  29628. return nil
  29629. case usagestatisticmonth.FieldOrganizationID:
  29630. v, ok := value.(uint64)
  29631. if !ok {
  29632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29633. }
  29634. m.SetOrganizationID(v)
  29635. return nil
  29636. case usagestatisticmonth.FieldAiResponse:
  29637. v, ok := value.(uint64)
  29638. if !ok {
  29639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29640. }
  29641. m.SetAiResponse(v)
  29642. return nil
  29643. case usagestatisticmonth.FieldSopRun:
  29644. v, ok := value.(uint64)
  29645. if !ok {
  29646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29647. }
  29648. m.SetSopRun(v)
  29649. return nil
  29650. case usagestatisticmonth.FieldTotalFriend:
  29651. v, ok := value.(uint64)
  29652. if !ok {
  29653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29654. }
  29655. m.SetTotalFriend(v)
  29656. return nil
  29657. case usagestatisticmonth.FieldTotalGroup:
  29658. v, ok := value.(uint64)
  29659. if !ok {
  29660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29661. }
  29662. m.SetTotalGroup(v)
  29663. return nil
  29664. case usagestatisticmonth.FieldAccountBalance:
  29665. v, ok := value.(uint64)
  29666. if !ok {
  29667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29668. }
  29669. m.SetAccountBalance(v)
  29670. return nil
  29671. case usagestatisticmonth.FieldConsumeToken:
  29672. v, ok := value.(uint64)
  29673. if !ok {
  29674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29675. }
  29676. m.SetConsumeToken(v)
  29677. return nil
  29678. case usagestatisticmonth.FieldActiveUser:
  29679. v, ok := value.(uint64)
  29680. if !ok {
  29681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29682. }
  29683. m.SetActiveUser(v)
  29684. return nil
  29685. case usagestatisticmonth.FieldNewUser:
  29686. v, ok := value.(int64)
  29687. if !ok {
  29688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29689. }
  29690. m.SetNewUser(v)
  29691. return nil
  29692. case usagestatisticmonth.FieldLabelDist:
  29693. v, ok := value.([]custom_types.LabelDist)
  29694. if !ok {
  29695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29696. }
  29697. m.SetLabelDist(v)
  29698. return nil
  29699. }
  29700. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29701. }
  29702. // AddedFields returns all numeric fields that were incremented/decremented during
  29703. // this mutation.
  29704. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  29705. var fields []string
  29706. if m.addstatus != nil {
  29707. fields = append(fields, usagestatisticmonth.FieldStatus)
  29708. }
  29709. if m.addaddtime != nil {
  29710. fields = append(fields, usagestatisticmonth.FieldAddtime)
  29711. }
  29712. if m.add_type != nil {
  29713. fields = append(fields, usagestatisticmonth.FieldType)
  29714. }
  29715. if m.addorganization_id != nil {
  29716. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29717. }
  29718. if m.addai_response != nil {
  29719. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  29720. }
  29721. if m.addsop_run != nil {
  29722. fields = append(fields, usagestatisticmonth.FieldSopRun)
  29723. }
  29724. if m.addtotal_friend != nil {
  29725. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  29726. }
  29727. if m.addtotal_group != nil {
  29728. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  29729. }
  29730. if m.addaccount_balance != nil {
  29731. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  29732. }
  29733. if m.addconsume_token != nil {
  29734. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  29735. }
  29736. if m.addactive_user != nil {
  29737. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  29738. }
  29739. if m.addnew_user != nil {
  29740. fields = append(fields, usagestatisticmonth.FieldNewUser)
  29741. }
  29742. return fields
  29743. }
  29744. // AddedField returns the numeric value that was incremented/decremented on a field
  29745. // with the given name. The second boolean return value indicates that this field
  29746. // was not set, or was not defined in the schema.
  29747. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  29748. switch name {
  29749. case usagestatisticmonth.FieldStatus:
  29750. return m.AddedStatus()
  29751. case usagestatisticmonth.FieldAddtime:
  29752. return m.AddedAddtime()
  29753. case usagestatisticmonth.FieldType:
  29754. return m.AddedType()
  29755. case usagestatisticmonth.FieldOrganizationID:
  29756. return m.AddedOrganizationID()
  29757. case usagestatisticmonth.FieldAiResponse:
  29758. return m.AddedAiResponse()
  29759. case usagestatisticmonth.FieldSopRun:
  29760. return m.AddedSopRun()
  29761. case usagestatisticmonth.FieldTotalFriend:
  29762. return m.AddedTotalFriend()
  29763. case usagestatisticmonth.FieldTotalGroup:
  29764. return m.AddedTotalGroup()
  29765. case usagestatisticmonth.FieldAccountBalance:
  29766. return m.AddedAccountBalance()
  29767. case usagestatisticmonth.FieldConsumeToken:
  29768. return m.AddedConsumeToken()
  29769. case usagestatisticmonth.FieldActiveUser:
  29770. return m.AddedActiveUser()
  29771. case usagestatisticmonth.FieldNewUser:
  29772. return m.AddedNewUser()
  29773. }
  29774. return nil, false
  29775. }
  29776. // AddField adds the value to the field with the given name. It returns an error if
  29777. // the field is not defined in the schema, or if the type mismatched the field
  29778. // type.
  29779. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  29780. switch name {
  29781. case usagestatisticmonth.FieldStatus:
  29782. v, ok := value.(int8)
  29783. if !ok {
  29784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29785. }
  29786. m.AddStatus(v)
  29787. return nil
  29788. case usagestatisticmonth.FieldAddtime:
  29789. v, ok := value.(int64)
  29790. if !ok {
  29791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29792. }
  29793. m.AddAddtime(v)
  29794. return nil
  29795. case usagestatisticmonth.FieldType:
  29796. v, ok := value.(int)
  29797. if !ok {
  29798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29799. }
  29800. m.AddType(v)
  29801. return nil
  29802. case usagestatisticmonth.FieldOrganizationID:
  29803. v, ok := value.(int64)
  29804. if !ok {
  29805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29806. }
  29807. m.AddOrganizationID(v)
  29808. return nil
  29809. case usagestatisticmonth.FieldAiResponse:
  29810. v, ok := value.(int64)
  29811. if !ok {
  29812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29813. }
  29814. m.AddAiResponse(v)
  29815. return nil
  29816. case usagestatisticmonth.FieldSopRun:
  29817. v, ok := value.(int64)
  29818. if !ok {
  29819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29820. }
  29821. m.AddSopRun(v)
  29822. return nil
  29823. case usagestatisticmonth.FieldTotalFriend:
  29824. v, ok := value.(int64)
  29825. if !ok {
  29826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29827. }
  29828. m.AddTotalFriend(v)
  29829. return nil
  29830. case usagestatisticmonth.FieldTotalGroup:
  29831. v, ok := value.(int64)
  29832. if !ok {
  29833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29834. }
  29835. m.AddTotalGroup(v)
  29836. return nil
  29837. case usagestatisticmonth.FieldAccountBalance:
  29838. v, ok := value.(int64)
  29839. if !ok {
  29840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29841. }
  29842. m.AddAccountBalance(v)
  29843. return nil
  29844. case usagestatisticmonth.FieldConsumeToken:
  29845. v, ok := value.(int64)
  29846. if !ok {
  29847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29848. }
  29849. m.AddConsumeToken(v)
  29850. return nil
  29851. case usagestatisticmonth.FieldActiveUser:
  29852. v, ok := value.(int64)
  29853. if !ok {
  29854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29855. }
  29856. m.AddActiveUser(v)
  29857. return nil
  29858. case usagestatisticmonth.FieldNewUser:
  29859. v, ok := value.(int64)
  29860. if !ok {
  29861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29862. }
  29863. m.AddNewUser(v)
  29864. return nil
  29865. }
  29866. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  29867. }
  29868. // ClearedFields returns all nullable fields that were cleared during this
  29869. // mutation.
  29870. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  29871. var fields []string
  29872. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  29873. fields = append(fields, usagestatisticmonth.FieldStatus)
  29874. }
  29875. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  29876. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  29877. }
  29878. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  29879. fields = append(fields, usagestatisticmonth.FieldBotID)
  29880. }
  29881. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  29882. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29883. }
  29884. return fields
  29885. }
  29886. // FieldCleared returns a boolean indicating if a field with the given name was
  29887. // cleared in this mutation.
  29888. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  29889. _, ok := m.clearedFields[name]
  29890. return ok
  29891. }
  29892. // ClearField clears the value of the field with the given name. It returns an
  29893. // error if the field is not defined in the schema.
  29894. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  29895. switch name {
  29896. case usagestatisticmonth.FieldStatus:
  29897. m.ClearStatus()
  29898. return nil
  29899. case usagestatisticmonth.FieldDeletedAt:
  29900. m.ClearDeletedAt()
  29901. return nil
  29902. case usagestatisticmonth.FieldBotID:
  29903. m.ClearBotID()
  29904. return nil
  29905. case usagestatisticmonth.FieldOrganizationID:
  29906. m.ClearOrganizationID()
  29907. return nil
  29908. }
  29909. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  29910. }
  29911. // ResetField resets all changes in the mutation for the field with the given name.
  29912. // It returns an error if the field is not defined in the schema.
  29913. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  29914. switch name {
  29915. case usagestatisticmonth.FieldCreatedAt:
  29916. m.ResetCreatedAt()
  29917. return nil
  29918. case usagestatisticmonth.FieldUpdatedAt:
  29919. m.ResetUpdatedAt()
  29920. return nil
  29921. case usagestatisticmonth.FieldStatus:
  29922. m.ResetStatus()
  29923. return nil
  29924. case usagestatisticmonth.FieldDeletedAt:
  29925. m.ResetDeletedAt()
  29926. return nil
  29927. case usagestatisticmonth.FieldAddtime:
  29928. m.ResetAddtime()
  29929. return nil
  29930. case usagestatisticmonth.FieldType:
  29931. m.ResetType()
  29932. return nil
  29933. case usagestatisticmonth.FieldBotID:
  29934. m.ResetBotID()
  29935. return nil
  29936. case usagestatisticmonth.FieldOrganizationID:
  29937. m.ResetOrganizationID()
  29938. return nil
  29939. case usagestatisticmonth.FieldAiResponse:
  29940. m.ResetAiResponse()
  29941. return nil
  29942. case usagestatisticmonth.FieldSopRun:
  29943. m.ResetSopRun()
  29944. return nil
  29945. case usagestatisticmonth.FieldTotalFriend:
  29946. m.ResetTotalFriend()
  29947. return nil
  29948. case usagestatisticmonth.FieldTotalGroup:
  29949. m.ResetTotalGroup()
  29950. return nil
  29951. case usagestatisticmonth.FieldAccountBalance:
  29952. m.ResetAccountBalance()
  29953. return nil
  29954. case usagestatisticmonth.FieldConsumeToken:
  29955. m.ResetConsumeToken()
  29956. return nil
  29957. case usagestatisticmonth.FieldActiveUser:
  29958. m.ResetActiveUser()
  29959. return nil
  29960. case usagestatisticmonth.FieldNewUser:
  29961. m.ResetNewUser()
  29962. return nil
  29963. case usagestatisticmonth.FieldLabelDist:
  29964. m.ResetLabelDist()
  29965. return nil
  29966. }
  29967. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29968. }
  29969. // AddedEdges returns all edge names that were set/added in this mutation.
  29970. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  29971. edges := make([]string, 0, 0)
  29972. return edges
  29973. }
  29974. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29975. // name in this mutation.
  29976. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  29977. return nil
  29978. }
  29979. // RemovedEdges returns all edge names that were removed in this mutation.
  29980. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  29981. edges := make([]string, 0, 0)
  29982. return edges
  29983. }
  29984. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29985. // the given name in this mutation.
  29986. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  29987. return nil
  29988. }
  29989. // ClearedEdges returns all edge names that were cleared in this mutation.
  29990. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  29991. edges := make([]string, 0, 0)
  29992. return edges
  29993. }
  29994. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29995. // was cleared in this mutation.
  29996. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  29997. return false
  29998. }
  29999. // ClearEdge clears the value of the edge with the given name. It returns an error
  30000. // if that edge is not defined in the schema.
  30001. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  30002. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  30003. }
  30004. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30005. // It returns an error if the edge is not defined in the schema.
  30006. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  30007. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  30008. }
  30009. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  30010. type UsageTotalMutation struct {
  30011. config
  30012. op Op
  30013. typ string
  30014. id *uint64
  30015. created_at *time.Time
  30016. updated_at *time.Time
  30017. status *uint8
  30018. addstatus *int8
  30019. _type *int
  30020. add_type *int
  30021. bot_id *string
  30022. total_tokens *uint64
  30023. addtotal_tokens *int64
  30024. start_index *uint64
  30025. addstart_index *int64
  30026. end_index *uint64
  30027. addend_index *int64
  30028. organization_id *uint64
  30029. addorganization_id *int64
  30030. clearedFields map[string]struct{}
  30031. done bool
  30032. oldValue func(context.Context) (*UsageTotal, error)
  30033. predicates []predicate.UsageTotal
  30034. }
  30035. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  30036. // usagetotalOption allows management of the mutation configuration using functional options.
  30037. type usagetotalOption func(*UsageTotalMutation)
  30038. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  30039. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  30040. m := &UsageTotalMutation{
  30041. config: c,
  30042. op: op,
  30043. typ: TypeUsageTotal,
  30044. clearedFields: make(map[string]struct{}),
  30045. }
  30046. for _, opt := range opts {
  30047. opt(m)
  30048. }
  30049. return m
  30050. }
  30051. // withUsageTotalID sets the ID field of the mutation.
  30052. func withUsageTotalID(id uint64) usagetotalOption {
  30053. return func(m *UsageTotalMutation) {
  30054. var (
  30055. err error
  30056. once sync.Once
  30057. value *UsageTotal
  30058. )
  30059. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  30060. once.Do(func() {
  30061. if m.done {
  30062. err = errors.New("querying old values post mutation is not allowed")
  30063. } else {
  30064. value, err = m.Client().UsageTotal.Get(ctx, id)
  30065. }
  30066. })
  30067. return value, err
  30068. }
  30069. m.id = &id
  30070. }
  30071. }
  30072. // withUsageTotal sets the old UsageTotal of the mutation.
  30073. func withUsageTotal(node *UsageTotal) usagetotalOption {
  30074. return func(m *UsageTotalMutation) {
  30075. m.oldValue = func(context.Context) (*UsageTotal, error) {
  30076. return node, nil
  30077. }
  30078. m.id = &node.ID
  30079. }
  30080. }
  30081. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30082. // executed in a transaction (ent.Tx), a transactional client is returned.
  30083. func (m UsageTotalMutation) Client() *Client {
  30084. client := &Client{config: m.config}
  30085. client.init()
  30086. return client
  30087. }
  30088. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30089. // it returns an error otherwise.
  30090. func (m UsageTotalMutation) Tx() (*Tx, error) {
  30091. if _, ok := m.driver.(*txDriver); !ok {
  30092. return nil, errors.New("ent: mutation is not running in a transaction")
  30093. }
  30094. tx := &Tx{config: m.config}
  30095. tx.init()
  30096. return tx, nil
  30097. }
  30098. // SetID sets the value of the id field. Note that this
  30099. // operation is only accepted on creation of UsageTotal entities.
  30100. func (m *UsageTotalMutation) SetID(id uint64) {
  30101. m.id = &id
  30102. }
  30103. // ID returns the ID value in the mutation. Note that the ID is only available
  30104. // if it was provided to the builder or after it was returned from the database.
  30105. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  30106. if m.id == nil {
  30107. return
  30108. }
  30109. return *m.id, true
  30110. }
  30111. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30112. // That means, if the mutation is applied within a transaction with an isolation level such
  30113. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30114. // or updated by the mutation.
  30115. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  30116. switch {
  30117. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30118. id, exists := m.ID()
  30119. if exists {
  30120. return []uint64{id}, nil
  30121. }
  30122. fallthrough
  30123. case m.op.Is(OpUpdate | OpDelete):
  30124. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  30125. default:
  30126. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30127. }
  30128. }
  30129. // SetCreatedAt sets the "created_at" field.
  30130. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  30131. m.created_at = &t
  30132. }
  30133. // CreatedAt returns the value of the "created_at" field in the mutation.
  30134. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  30135. v := m.created_at
  30136. if v == nil {
  30137. return
  30138. }
  30139. return *v, true
  30140. }
  30141. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  30142. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30144. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30145. if !m.op.Is(OpUpdateOne) {
  30146. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30147. }
  30148. if m.id == nil || m.oldValue == nil {
  30149. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30150. }
  30151. oldValue, err := m.oldValue(ctx)
  30152. if err != nil {
  30153. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30154. }
  30155. return oldValue.CreatedAt, nil
  30156. }
  30157. // ResetCreatedAt resets all changes to the "created_at" field.
  30158. func (m *UsageTotalMutation) ResetCreatedAt() {
  30159. m.created_at = nil
  30160. }
  30161. // SetUpdatedAt sets the "updated_at" field.
  30162. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  30163. m.updated_at = &t
  30164. }
  30165. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30166. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  30167. v := m.updated_at
  30168. if v == nil {
  30169. return
  30170. }
  30171. return *v, true
  30172. }
  30173. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  30174. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30176. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30177. if !m.op.Is(OpUpdateOne) {
  30178. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30179. }
  30180. if m.id == nil || m.oldValue == nil {
  30181. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30182. }
  30183. oldValue, err := m.oldValue(ctx)
  30184. if err != nil {
  30185. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30186. }
  30187. return oldValue.UpdatedAt, nil
  30188. }
  30189. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30190. func (m *UsageTotalMutation) ResetUpdatedAt() {
  30191. m.updated_at = nil
  30192. }
  30193. // SetStatus sets the "status" field.
  30194. func (m *UsageTotalMutation) SetStatus(u uint8) {
  30195. m.status = &u
  30196. m.addstatus = nil
  30197. }
  30198. // Status returns the value of the "status" field in the mutation.
  30199. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  30200. v := m.status
  30201. if v == nil {
  30202. return
  30203. }
  30204. return *v, true
  30205. }
  30206. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  30207. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30209. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30210. if !m.op.Is(OpUpdateOne) {
  30211. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30212. }
  30213. if m.id == nil || m.oldValue == nil {
  30214. return v, errors.New("OldStatus requires an ID field in the mutation")
  30215. }
  30216. oldValue, err := m.oldValue(ctx)
  30217. if err != nil {
  30218. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30219. }
  30220. return oldValue.Status, nil
  30221. }
  30222. // AddStatus adds u to the "status" field.
  30223. func (m *UsageTotalMutation) AddStatus(u int8) {
  30224. if m.addstatus != nil {
  30225. *m.addstatus += u
  30226. } else {
  30227. m.addstatus = &u
  30228. }
  30229. }
  30230. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30231. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  30232. v := m.addstatus
  30233. if v == nil {
  30234. return
  30235. }
  30236. return *v, true
  30237. }
  30238. // ClearStatus clears the value of the "status" field.
  30239. func (m *UsageTotalMutation) ClearStatus() {
  30240. m.status = nil
  30241. m.addstatus = nil
  30242. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  30243. }
  30244. // StatusCleared returns if the "status" field was cleared in this mutation.
  30245. func (m *UsageTotalMutation) StatusCleared() bool {
  30246. _, ok := m.clearedFields[usagetotal.FieldStatus]
  30247. return ok
  30248. }
  30249. // ResetStatus resets all changes to the "status" field.
  30250. func (m *UsageTotalMutation) ResetStatus() {
  30251. m.status = nil
  30252. m.addstatus = nil
  30253. delete(m.clearedFields, usagetotal.FieldStatus)
  30254. }
  30255. // SetType sets the "type" field.
  30256. func (m *UsageTotalMutation) SetType(i int) {
  30257. m._type = &i
  30258. m.add_type = nil
  30259. }
  30260. // GetType returns the value of the "type" field in the mutation.
  30261. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  30262. v := m._type
  30263. if v == nil {
  30264. return
  30265. }
  30266. return *v, true
  30267. }
  30268. // OldType returns the old "type" field's value of the UsageTotal entity.
  30269. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30271. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  30272. if !m.op.Is(OpUpdateOne) {
  30273. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30274. }
  30275. if m.id == nil || m.oldValue == nil {
  30276. return v, errors.New("OldType requires an ID field in the mutation")
  30277. }
  30278. oldValue, err := m.oldValue(ctx)
  30279. if err != nil {
  30280. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30281. }
  30282. return oldValue.Type, nil
  30283. }
  30284. // AddType adds i to the "type" field.
  30285. func (m *UsageTotalMutation) AddType(i int) {
  30286. if m.add_type != nil {
  30287. *m.add_type += i
  30288. } else {
  30289. m.add_type = &i
  30290. }
  30291. }
  30292. // AddedType returns the value that was added to the "type" field in this mutation.
  30293. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  30294. v := m.add_type
  30295. if v == nil {
  30296. return
  30297. }
  30298. return *v, true
  30299. }
  30300. // ClearType clears the value of the "type" field.
  30301. func (m *UsageTotalMutation) ClearType() {
  30302. m._type = nil
  30303. m.add_type = nil
  30304. m.clearedFields[usagetotal.FieldType] = struct{}{}
  30305. }
  30306. // TypeCleared returns if the "type" field was cleared in this mutation.
  30307. func (m *UsageTotalMutation) TypeCleared() bool {
  30308. _, ok := m.clearedFields[usagetotal.FieldType]
  30309. return ok
  30310. }
  30311. // ResetType resets all changes to the "type" field.
  30312. func (m *UsageTotalMutation) ResetType() {
  30313. m._type = nil
  30314. m.add_type = nil
  30315. delete(m.clearedFields, usagetotal.FieldType)
  30316. }
  30317. // SetBotID sets the "bot_id" field.
  30318. func (m *UsageTotalMutation) SetBotID(s string) {
  30319. m.bot_id = &s
  30320. }
  30321. // BotID returns the value of the "bot_id" field in the mutation.
  30322. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  30323. v := m.bot_id
  30324. if v == nil {
  30325. return
  30326. }
  30327. return *v, true
  30328. }
  30329. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  30330. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30332. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  30333. if !m.op.Is(OpUpdateOne) {
  30334. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30335. }
  30336. if m.id == nil || m.oldValue == nil {
  30337. return v, errors.New("OldBotID requires an ID field in the mutation")
  30338. }
  30339. oldValue, err := m.oldValue(ctx)
  30340. if err != nil {
  30341. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30342. }
  30343. return oldValue.BotID, nil
  30344. }
  30345. // ResetBotID resets all changes to the "bot_id" field.
  30346. func (m *UsageTotalMutation) ResetBotID() {
  30347. m.bot_id = nil
  30348. }
  30349. // SetTotalTokens sets the "total_tokens" field.
  30350. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  30351. m.total_tokens = &u
  30352. m.addtotal_tokens = nil
  30353. }
  30354. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  30355. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  30356. v := m.total_tokens
  30357. if v == nil {
  30358. return
  30359. }
  30360. return *v, true
  30361. }
  30362. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  30363. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30365. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  30366. if !m.op.Is(OpUpdateOne) {
  30367. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  30368. }
  30369. if m.id == nil || m.oldValue == nil {
  30370. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  30371. }
  30372. oldValue, err := m.oldValue(ctx)
  30373. if err != nil {
  30374. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  30375. }
  30376. return oldValue.TotalTokens, nil
  30377. }
  30378. // AddTotalTokens adds u to the "total_tokens" field.
  30379. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  30380. if m.addtotal_tokens != nil {
  30381. *m.addtotal_tokens += u
  30382. } else {
  30383. m.addtotal_tokens = &u
  30384. }
  30385. }
  30386. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  30387. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  30388. v := m.addtotal_tokens
  30389. if v == nil {
  30390. return
  30391. }
  30392. return *v, true
  30393. }
  30394. // ClearTotalTokens clears the value of the "total_tokens" field.
  30395. func (m *UsageTotalMutation) ClearTotalTokens() {
  30396. m.total_tokens = nil
  30397. m.addtotal_tokens = nil
  30398. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  30399. }
  30400. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  30401. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  30402. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  30403. return ok
  30404. }
  30405. // ResetTotalTokens resets all changes to the "total_tokens" field.
  30406. func (m *UsageTotalMutation) ResetTotalTokens() {
  30407. m.total_tokens = nil
  30408. m.addtotal_tokens = nil
  30409. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  30410. }
  30411. // SetStartIndex sets the "start_index" field.
  30412. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  30413. m.start_index = &u
  30414. m.addstart_index = nil
  30415. }
  30416. // StartIndex returns the value of the "start_index" field in the mutation.
  30417. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  30418. v := m.start_index
  30419. if v == nil {
  30420. return
  30421. }
  30422. return *v, true
  30423. }
  30424. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  30425. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30427. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  30428. if !m.op.Is(OpUpdateOne) {
  30429. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  30430. }
  30431. if m.id == nil || m.oldValue == nil {
  30432. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  30433. }
  30434. oldValue, err := m.oldValue(ctx)
  30435. if err != nil {
  30436. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  30437. }
  30438. return oldValue.StartIndex, nil
  30439. }
  30440. // AddStartIndex adds u to the "start_index" field.
  30441. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  30442. if m.addstart_index != nil {
  30443. *m.addstart_index += u
  30444. } else {
  30445. m.addstart_index = &u
  30446. }
  30447. }
  30448. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  30449. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  30450. v := m.addstart_index
  30451. if v == nil {
  30452. return
  30453. }
  30454. return *v, true
  30455. }
  30456. // ClearStartIndex clears the value of the "start_index" field.
  30457. func (m *UsageTotalMutation) ClearStartIndex() {
  30458. m.start_index = nil
  30459. m.addstart_index = nil
  30460. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  30461. }
  30462. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  30463. func (m *UsageTotalMutation) StartIndexCleared() bool {
  30464. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  30465. return ok
  30466. }
  30467. // ResetStartIndex resets all changes to the "start_index" field.
  30468. func (m *UsageTotalMutation) ResetStartIndex() {
  30469. m.start_index = nil
  30470. m.addstart_index = nil
  30471. delete(m.clearedFields, usagetotal.FieldStartIndex)
  30472. }
  30473. // SetEndIndex sets the "end_index" field.
  30474. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  30475. m.end_index = &u
  30476. m.addend_index = nil
  30477. }
  30478. // EndIndex returns the value of the "end_index" field in the mutation.
  30479. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  30480. v := m.end_index
  30481. if v == nil {
  30482. return
  30483. }
  30484. return *v, true
  30485. }
  30486. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  30487. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30489. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  30490. if !m.op.Is(OpUpdateOne) {
  30491. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  30492. }
  30493. if m.id == nil || m.oldValue == nil {
  30494. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  30495. }
  30496. oldValue, err := m.oldValue(ctx)
  30497. if err != nil {
  30498. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  30499. }
  30500. return oldValue.EndIndex, nil
  30501. }
  30502. // AddEndIndex adds u to the "end_index" field.
  30503. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  30504. if m.addend_index != nil {
  30505. *m.addend_index += u
  30506. } else {
  30507. m.addend_index = &u
  30508. }
  30509. }
  30510. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  30511. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  30512. v := m.addend_index
  30513. if v == nil {
  30514. return
  30515. }
  30516. return *v, true
  30517. }
  30518. // ClearEndIndex clears the value of the "end_index" field.
  30519. func (m *UsageTotalMutation) ClearEndIndex() {
  30520. m.end_index = nil
  30521. m.addend_index = nil
  30522. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  30523. }
  30524. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  30525. func (m *UsageTotalMutation) EndIndexCleared() bool {
  30526. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  30527. return ok
  30528. }
  30529. // ResetEndIndex resets all changes to the "end_index" field.
  30530. func (m *UsageTotalMutation) ResetEndIndex() {
  30531. m.end_index = nil
  30532. m.addend_index = nil
  30533. delete(m.clearedFields, usagetotal.FieldEndIndex)
  30534. }
  30535. // SetOrganizationID sets the "organization_id" field.
  30536. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  30537. m.organization_id = &u
  30538. m.addorganization_id = nil
  30539. }
  30540. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30541. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  30542. v := m.organization_id
  30543. if v == nil {
  30544. return
  30545. }
  30546. return *v, true
  30547. }
  30548. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  30549. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30551. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30552. if !m.op.Is(OpUpdateOne) {
  30553. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30554. }
  30555. if m.id == nil || m.oldValue == nil {
  30556. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30557. }
  30558. oldValue, err := m.oldValue(ctx)
  30559. if err != nil {
  30560. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30561. }
  30562. return oldValue.OrganizationID, nil
  30563. }
  30564. // AddOrganizationID adds u to the "organization_id" field.
  30565. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  30566. if m.addorganization_id != nil {
  30567. *m.addorganization_id += u
  30568. } else {
  30569. m.addorganization_id = &u
  30570. }
  30571. }
  30572. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30573. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  30574. v := m.addorganization_id
  30575. if v == nil {
  30576. return
  30577. }
  30578. return *v, true
  30579. }
  30580. // ClearOrganizationID clears the value of the "organization_id" field.
  30581. func (m *UsageTotalMutation) ClearOrganizationID() {
  30582. m.organization_id = nil
  30583. m.addorganization_id = nil
  30584. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  30585. }
  30586. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30587. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  30588. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  30589. return ok
  30590. }
  30591. // ResetOrganizationID resets all changes to the "organization_id" field.
  30592. func (m *UsageTotalMutation) ResetOrganizationID() {
  30593. m.organization_id = nil
  30594. m.addorganization_id = nil
  30595. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  30596. }
  30597. // Where appends a list predicates to the UsageTotalMutation builder.
  30598. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  30599. m.predicates = append(m.predicates, ps...)
  30600. }
  30601. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  30602. // users can use type-assertion to append predicates that do not depend on any generated package.
  30603. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  30604. p := make([]predicate.UsageTotal, len(ps))
  30605. for i := range ps {
  30606. p[i] = ps[i]
  30607. }
  30608. m.Where(p...)
  30609. }
  30610. // Op returns the operation name.
  30611. func (m *UsageTotalMutation) Op() Op {
  30612. return m.op
  30613. }
  30614. // SetOp allows setting the mutation operation.
  30615. func (m *UsageTotalMutation) SetOp(op Op) {
  30616. m.op = op
  30617. }
  30618. // Type returns the node type of this mutation (UsageTotal).
  30619. func (m *UsageTotalMutation) Type() string {
  30620. return m.typ
  30621. }
  30622. // Fields returns all fields that were changed during this mutation. Note that in
  30623. // order to get all numeric fields that were incremented/decremented, call
  30624. // AddedFields().
  30625. func (m *UsageTotalMutation) Fields() []string {
  30626. fields := make([]string, 0, 9)
  30627. if m.created_at != nil {
  30628. fields = append(fields, usagetotal.FieldCreatedAt)
  30629. }
  30630. if m.updated_at != nil {
  30631. fields = append(fields, usagetotal.FieldUpdatedAt)
  30632. }
  30633. if m.status != nil {
  30634. fields = append(fields, usagetotal.FieldStatus)
  30635. }
  30636. if m._type != nil {
  30637. fields = append(fields, usagetotal.FieldType)
  30638. }
  30639. if m.bot_id != nil {
  30640. fields = append(fields, usagetotal.FieldBotID)
  30641. }
  30642. if m.total_tokens != nil {
  30643. fields = append(fields, usagetotal.FieldTotalTokens)
  30644. }
  30645. if m.start_index != nil {
  30646. fields = append(fields, usagetotal.FieldStartIndex)
  30647. }
  30648. if m.end_index != nil {
  30649. fields = append(fields, usagetotal.FieldEndIndex)
  30650. }
  30651. if m.organization_id != nil {
  30652. fields = append(fields, usagetotal.FieldOrganizationID)
  30653. }
  30654. return fields
  30655. }
  30656. // Field returns the value of a field with the given name. The second boolean
  30657. // return value indicates that this field was not set, or was not defined in the
  30658. // schema.
  30659. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  30660. switch name {
  30661. case usagetotal.FieldCreatedAt:
  30662. return m.CreatedAt()
  30663. case usagetotal.FieldUpdatedAt:
  30664. return m.UpdatedAt()
  30665. case usagetotal.FieldStatus:
  30666. return m.Status()
  30667. case usagetotal.FieldType:
  30668. return m.GetType()
  30669. case usagetotal.FieldBotID:
  30670. return m.BotID()
  30671. case usagetotal.FieldTotalTokens:
  30672. return m.TotalTokens()
  30673. case usagetotal.FieldStartIndex:
  30674. return m.StartIndex()
  30675. case usagetotal.FieldEndIndex:
  30676. return m.EndIndex()
  30677. case usagetotal.FieldOrganizationID:
  30678. return m.OrganizationID()
  30679. }
  30680. return nil, false
  30681. }
  30682. // OldField returns the old value of the field from the database. An error is
  30683. // returned if the mutation operation is not UpdateOne, or the query to the
  30684. // database failed.
  30685. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30686. switch name {
  30687. case usagetotal.FieldCreatedAt:
  30688. return m.OldCreatedAt(ctx)
  30689. case usagetotal.FieldUpdatedAt:
  30690. return m.OldUpdatedAt(ctx)
  30691. case usagetotal.FieldStatus:
  30692. return m.OldStatus(ctx)
  30693. case usagetotal.FieldType:
  30694. return m.OldType(ctx)
  30695. case usagetotal.FieldBotID:
  30696. return m.OldBotID(ctx)
  30697. case usagetotal.FieldTotalTokens:
  30698. return m.OldTotalTokens(ctx)
  30699. case usagetotal.FieldStartIndex:
  30700. return m.OldStartIndex(ctx)
  30701. case usagetotal.FieldEndIndex:
  30702. return m.OldEndIndex(ctx)
  30703. case usagetotal.FieldOrganizationID:
  30704. return m.OldOrganizationID(ctx)
  30705. }
  30706. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  30707. }
  30708. // SetField sets the value of a field with the given name. It returns an error if
  30709. // the field is not defined in the schema, or if the type mismatched the field
  30710. // type.
  30711. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  30712. switch name {
  30713. case usagetotal.FieldCreatedAt:
  30714. v, ok := value.(time.Time)
  30715. if !ok {
  30716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30717. }
  30718. m.SetCreatedAt(v)
  30719. return nil
  30720. case usagetotal.FieldUpdatedAt:
  30721. v, ok := value.(time.Time)
  30722. if !ok {
  30723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30724. }
  30725. m.SetUpdatedAt(v)
  30726. return nil
  30727. case usagetotal.FieldStatus:
  30728. v, ok := value.(uint8)
  30729. if !ok {
  30730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30731. }
  30732. m.SetStatus(v)
  30733. return nil
  30734. case usagetotal.FieldType:
  30735. v, ok := value.(int)
  30736. if !ok {
  30737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30738. }
  30739. m.SetType(v)
  30740. return nil
  30741. case usagetotal.FieldBotID:
  30742. v, ok := value.(string)
  30743. if !ok {
  30744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30745. }
  30746. m.SetBotID(v)
  30747. return nil
  30748. case usagetotal.FieldTotalTokens:
  30749. v, ok := value.(uint64)
  30750. if !ok {
  30751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30752. }
  30753. m.SetTotalTokens(v)
  30754. return nil
  30755. case usagetotal.FieldStartIndex:
  30756. v, ok := value.(uint64)
  30757. if !ok {
  30758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30759. }
  30760. m.SetStartIndex(v)
  30761. return nil
  30762. case usagetotal.FieldEndIndex:
  30763. v, ok := value.(uint64)
  30764. if !ok {
  30765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30766. }
  30767. m.SetEndIndex(v)
  30768. return nil
  30769. case usagetotal.FieldOrganizationID:
  30770. v, ok := value.(uint64)
  30771. if !ok {
  30772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30773. }
  30774. m.SetOrganizationID(v)
  30775. return nil
  30776. }
  30777. return fmt.Errorf("unknown UsageTotal field %s", name)
  30778. }
  30779. // AddedFields returns all numeric fields that were incremented/decremented during
  30780. // this mutation.
  30781. func (m *UsageTotalMutation) AddedFields() []string {
  30782. var fields []string
  30783. if m.addstatus != nil {
  30784. fields = append(fields, usagetotal.FieldStatus)
  30785. }
  30786. if m.add_type != nil {
  30787. fields = append(fields, usagetotal.FieldType)
  30788. }
  30789. if m.addtotal_tokens != nil {
  30790. fields = append(fields, usagetotal.FieldTotalTokens)
  30791. }
  30792. if m.addstart_index != nil {
  30793. fields = append(fields, usagetotal.FieldStartIndex)
  30794. }
  30795. if m.addend_index != nil {
  30796. fields = append(fields, usagetotal.FieldEndIndex)
  30797. }
  30798. if m.addorganization_id != nil {
  30799. fields = append(fields, usagetotal.FieldOrganizationID)
  30800. }
  30801. return fields
  30802. }
  30803. // AddedField returns the numeric value that was incremented/decremented on a field
  30804. // with the given name. The second boolean return value indicates that this field
  30805. // was not set, or was not defined in the schema.
  30806. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  30807. switch name {
  30808. case usagetotal.FieldStatus:
  30809. return m.AddedStatus()
  30810. case usagetotal.FieldType:
  30811. return m.AddedType()
  30812. case usagetotal.FieldTotalTokens:
  30813. return m.AddedTotalTokens()
  30814. case usagetotal.FieldStartIndex:
  30815. return m.AddedStartIndex()
  30816. case usagetotal.FieldEndIndex:
  30817. return m.AddedEndIndex()
  30818. case usagetotal.FieldOrganizationID:
  30819. return m.AddedOrganizationID()
  30820. }
  30821. return nil, false
  30822. }
  30823. // AddField adds the value to the field with the given name. It returns an error if
  30824. // the field is not defined in the schema, or if the type mismatched the field
  30825. // type.
  30826. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  30827. switch name {
  30828. case usagetotal.FieldStatus:
  30829. v, ok := value.(int8)
  30830. if !ok {
  30831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30832. }
  30833. m.AddStatus(v)
  30834. return nil
  30835. case usagetotal.FieldType:
  30836. v, ok := value.(int)
  30837. if !ok {
  30838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30839. }
  30840. m.AddType(v)
  30841. return nil
  30842. case usagetotal.FieldTotalTokens:
  30843. v, ok := value.(int64)
  30844. if !ok {
  30845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30846. }
  30847. m.AddTotalTokens(v)
  30848. return nil
  30849. case usagetotal.FieldStartIndex:
  30850. v, ok := value.(int64)
  30851. if !ok {
  30852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30853. }
  30854. m.AddStartIndex(v)
  30855. return nil
  30856. case usagetotal.FieldEndIndex:
  30857. v, ok := value.(int64)
  30858. if !ok {
  30859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30860. }
  30861. m.AddEndIndex(v)
  30862. return nil
  30863. case usagetotal.FieldOrganizationID:
  30864. v, ok := value.(int64)
  30865. if !ok {
  30866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30867. }
  30868. m.AddOrganizationID(v)
  30869. return nil
  30870. }
  30871. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  30872. }
  30873. // ClearedFields returns all nullable fields that were cleared during this
  30874. // mutation.
  30875. func (m *UsageTotalMutation) ClearedFields() []string {
  30876. var fields []string
  30877. if m.FieldCleared(usagetotal.FieldStatus) {
  30878. fields = append(fields, usagetotal.FieldStatus)
  30879. }
  30880. if m.FieldCleared(usagetotal.FieldType) {
  30881. fields = append(fields, usagetotal.FieldType)
  30882. }
  30883. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  30884. fields = append(fields, usagetotal.FieldTotalTokens)
  30885. }
  30886. if m.FieldCleared(usagetotal.FieldStartIndex) {
  30887. fields = append(fields, usagetotal.FieldStartIndex)
  30888. }
  30889. if m.FieldCleared(usagetotal.FieldEndIndex) {
  30890. fields = append(fields, usagetotal.FieldEndIndex)
  30891. }
  30892. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  30893. fields = append(fields, usagetotal.FieldOrganizationID)
  30894. }
  30895. return fields
  30896. }
  30897. // FieldCleared returns a boolean indicating if a field with the given name was
  30898. // cleared in this mutation.
  30899. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  30900. _, ok := m.clearedFields[name]
  30901. return ok
  30902. }
  30903. // ClearField clears the value of the field with the given name. It returns an
  30904. // error if the field is not defined in the schema.
  30905. func (m *UsageTotalMutation) ClearField(name string) error {
  30906. switch name {
  30907. case usagetotal.FieldStatus:
  30908. m.ClearStatus()
  30909. return nil
  30910. case usagetotal.FieldType:
  30911. m.ClearType()
  30912. return nil
  30913. case usagetotal.FieldTotalTokens:
  30914. m.ClearTotalTokens()
  30915. return nil
  30916. case usagetotal.FieldStartIndex:
  30917. m.ClearStartIndex()
  30918. return nil
  30919. case usagetotal.FieldEndIndex:
  30920. m.ClearEndIndex()
  30921. return nil
  30922. case usagetotal.FieldOrganizationID:
  30923. m.ClearOrganizationID()
  30924. return nil
  30925. }
  30926. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  30927. }
  30928. // ResetField resets all changes in the mutation for the field with the given name.
  30929. // It returns an error if the field is not defined in the schema.
  30930. func (m *UsageTotalMutation) ResetField(name string) error {
  30931. switch name {
  30932. case usagetotal.FieldCreatedAt:
  30933. m.ResetCreatedAt()
  30934. return nil
  30935. case usagetotal.FieldUpdatedAt:
  30936. m.ResetUpdatedAt()
  30937. return nil
  30938. case usagetotal.FieldStatus:
  30939. m.ResetStatus()
  30940. return nil
  30941. case usagetotal.FieldType:
  30942. m.ResetType()
  30943. return nil
  30944. case usagetotal.FieldBotID:
  30945. m.ResetBotID()
  30946. return nil
  30947. case usagetotal.FieldTotalTokens:
  30948. m.ResetTotalTokens()
  30949. return nil
  30950. case usagetotal.FieldStartIndex:
  30951. m.ResetStartIndex()
  30952. return nil
  30953. case usagetotal.FieldEndIndex:
  30954. m.ResetEndIndex()
  30955. return nil
  30956. case usagetotal.FieldOrganizationID:
  30957. m.ResetOrganizationID()
  30958. return nil
  30959. }
  30960. return fmt.Errorf("unknown UsageTotal field %s", name)
  30961. }
  30962. // AddedEdges returns all edge names that were set/added in this mutation.
  30963. func (m *UsageTotalMutation) AddedEdges() []string {
  30964. edges := make([]string, 0, 0)
  30965. return edges
  30966. }
  30967. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30968. // name in this mutation.
  30969. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  30970. return nil
  30971. }
  30972. // RemovedEdges returns all edge names that were removed in this mutation.
  30973. func (m *UsageTotalMutation) RemovedEdges() []string {
  30974. edges := make([]string, 0, 0)
  30975. return edges
  30976. }
  30977. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30978. // the given name in this mutation.
  30979. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  30980. return nil
  30981. }
  30982. // ClearedEdges returns all edge names that were cleared in this mutation.
  30983. func (m *UsageTotalMutation) ClearedEdges() []string {
  30984. edges := make([]string, 0, 0)
  30985. return edges
  30986. }
  30987. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30988. // was cleared in this mutation.
  30989. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  30990. return false
  30991. }
  30992. // ClearEdge clears the value of the edge with the given name. It returns an error
  30993. // if that edge is not defined in the schema.
  30994. func (m *UsageTotalMutation) ClearEdge(name string) error {
  30995. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  30996. }
  30997. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30998. // It returns an error if the edge is not defined in the schema.
  30999. func (m *UsageTotalMutation) ResetEdge(name string) error {
  31000. return fmt.Errorf("unknown UsageTotal edge %s", name)
  31001. }
  31002. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  31003. type WorkExperienceMutation struct {
  31004. config
  31005. op Op
  31006. typ string
  31007. id *uint64
  31008. created_at *time.Time
  31009. updated_at *time.Time
  31010. deleted_at *time.Time
  31011. start_date *time.Time
  31012. end_date *time.Time
  31013. company *string
  31014. experience *string
  31015. organization_id *uint64
  31016. addorganization_id *int64
  31017. clearedFields map[string]struct{}
  31018. employee *uint64
  31019. clearedemployee bool
  31020. done bool
  31021. oldValue func(context.Context) (*WorkExperience, error)
  31022. predicates []predicate.WorkExperience
  31023. }
  31024. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  31025. // workexperienceOption allows management of the mutation configuration using functional options.
  31026. type workexperienceOption func(*WorkExperienceMutation)
  31027. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  31028. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  31029. m := &WorkExperienceMutation{
  31030. config: c,
  31031. op: op,
  31032. typ: TypeWorkExperience,
  31033. clearedFields: make(map[string]struct{}),
  31034. }
  31035. for _, opt := range opts {
  31036. opt(m)
  31037. }
  31038. return m
  31039. }
  31040. // withWorkExperienceID sets the ID field of the mutation.
  31041. func withWorkExperienceID(id uint64) workexperienceOption {
  31042. return func(m *WorkExperienceMutation) {
  31043. var (
  31044. err error
  31045. once sync.Once
  31046. value *WorkExperience
  31047. )
  31048. m.oldValue = func(ctx context.Context) (*WorkExperience, 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().WorkExperience.Get(ctx, id)
  31054. }
  31055. })
  31056. return value, err
  31057. }
  31058. m.id = &id
  31059. }
  31060. }
  31061. // withWorkExperience sets the old WorkExperience of the mutation.
  31062. func withWorkExperience(node *WorkExperience) workexperienceOption {
  31063. return func(m *WorkExperienceMutation) {
  31064. m.oldValue = func(context.Context) (*WorkExperience, 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 WorkExperienceMutation) 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 WorkExperienceMutation) 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 WorkExperience entities.
  31089. func (m *WorkExperienceMutation) 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 *WorkExperienceMutation) 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 *WorkExperienceMutation) 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().WorkExperience.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 *WorkExperienceMutation) 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 *WorkExperienceMutation) 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 WorkExperience entity.
  31131. // If the WorkExperience 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 *WorkExperienceMutation) 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 *WorkExperienceMutation) ResetCreatedAt() {
  31148. m.created_at = nil
  31149. }
  31150. // SetUpdatedAt sets the "updated_at" field.
  31151. func (m *WorkExperienceMutation) 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 *WorkExperienceMutation) 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 WorkExperience entity.
  31163. // If the WorkExperience 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 *WorkExperienceMutation) 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 *WorkExperienceMutation) ResetUpdatedAt() {
  31180. m.updated_at = nil
  31181. }
  31182. // SetDeletedAt sets the "deleted_at" field.
  31183. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  31184. m.deleted_at = &t
  31185. }
  31186. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31187. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  31188. v := m.deleted_at
  31189. if v == nil {
  31190. return
  31191. }
  31192. return *v, true
  31193. }
  31194. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  31195. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31197. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31198. if !m.op.Is(OpUpdateOne) {
  31199. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31200. }
  31201. if m.id == nil || m.oldValue == nil {
  31202. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31203. }
  31204. oldValue, err := m.oldValue(ctx)
  31205. if err != nil {
  31206. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31207. }
  31208. return oldValue.DeletedAt, nil
  31209. }
  31210. // ClearDeletedAt clears the value of the "deleted_at" field.
  31211. func (m *WorkExperienceMutation) ClearDeletedAt() {
  31212. m.deleted_at = nil
  31213. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  31214. }
  31215. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31216. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  31217. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  31218. return ok
  31219. }
  31220. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31221. func (m *WorkExperienceMutation) ResetDeletedAt() {
  31222. m.deleted_at = nil
  31223. delete(m.clearedFields, workexperience.FieldDeletedAt)
  31224. }
  31225. // SetEmployeeID sets the "employee_id" field.
  31226. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  31227. m.employee = &u
  31228. }
  31229. // EmployeeID returns the value of the "employee_id" field in the mutation.
  31230. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  31231. v := m.employee
  31232. if v == nil {
  31233. return
  31234. }
  31235. return *v, true
  31236. }
  31237. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  31238. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31240. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  31241. if !m.op.Is(OpUpdateOne) {
  31242. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  31243. }
  31244. if m.id == nil || m.oldValue == nil {
  31245. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  31246. }
  31247. oldValue, err := m.oldValue(ctx)
  31248. if err != nil {
  31249. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  31250. }
  31251. return oldValue.EmployeeID, nil
  31252. }
  31253. // ResetEmployeeID resets all changes to the "employee_id" field.
  31254. func (m *WorkExperienceMutation) ResetEmployeeID() {
  31255. m.employee = nil
  31256. }
  31257. // SetStartDate sets the "start_date" field.
  31258. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  31259. m.start_date = &t
  31260. }
  31261. // StartDate returns the value of the "start_date" field in the mutation.
  31262. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  31263. v := m.start_date
  31264. if v == nil {
  31265. return
  31266. }
  31267. return *v, true
  31268. }
  31269. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  31270. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31272. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  31273. if !m.op.Is(OpUpdateOne) {
  31274. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  31275. }
  31276. if m.id == nil || m.oldValue == nil {
  31277. return v, errors.New("OldStartDate requires an ID field in the mutation")
  31278. }
  31279. oldValue, err := m.oldValue(ctx)
  31280. if err != nil {
  31281. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  31282. }
  31283. return oldValue.StartDate, nil
  31284. }
  31285. // ResetStartDate resets all changes to the "start_date" field.
  31286. func (m *WorkExperienceMutation) ResetStartDate() {
  31287. m.start_date = nil
  31288. }
  31289. // SetEndDate sets the "end_date" field.
  31290. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  31291. m.end_date = &t
  31292. }
  31293. // EndDate returns the value of the "end_date" field in the mutation.
  31294. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  31295. v := m.end_date
  31296. if v == nil {
  31297. return
  31298. }
  31299. return *v, true
  31300. }
  31301. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  31302. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31304. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  31305. if !m.op.Is(OpUpdateOne) {
  31306. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  31307. }
  31308. if m.id == nil || m.oldValue == nil {
  31309. return v, errors.New("OldEndDate requires an ID field in the mutation")
  31310. }
  31311. oldValue, err := m.oldValue(ctx)
  31312. if err != nil {
  31313. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  31314. }
  31315. return oldValue.EndDate, nil
  31316. }
  31317. // ResetEndDate resets all changes to the "end_date" field.
  31318. func (m *WorkExperienceMutation) ResetEndDate() {
  31319. m.end_date = nil
  31320. }
  31321. // SetCompany sets the "company" field.
  31322. func (m *WorkExperienceMutation) SetCompany(s string) {
  31323. m.company = &s
  31324. }
  31325. // Company returns the value of the "company" field in the mutation.
  31326. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  31327. v := m.company
  31328. if v == nil {
  31329. return
  31330. }
  31331. return *v, true
  31332. }
  31333. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  31334. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31336. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  31337. if !m.op.Is(OpUpdateOne) {
  31338. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  31339. }
  31340. if m.id == nil || m.oldValue == nil {
  31341. return v, errors.New("OldCompany requires an ID field in the mutation")
  31342. }
  31343. oldValue, err := m.oldValue(ctx)
  31344. if err != nil {
  31345. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  31346. }
  31347. return oldValue.Company, nil
  31348. }
  31349. // ResetCompany resets all changes to the "company" field.
  31350. func (m *WorkExperienceMutation) ResetCompany() {
  31351. m.company = nil
  31352. }
  31353. // SetExperience sets the "experience" field.
  31354. func (m *WorkExperienceMutation) SetExperience(s string) {
  31355. m.experience = &s
  31356. }
  31357. // Experience returns the value of the "experience" field in the mutation.
  31358. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  31359. v := m.experience
  31360. if v == nil {
  31361. return
  31362. }
  31363. return *v, true
  31364. }
  31365. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  31366. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31368. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  31369. if !m.op.Is(OpUpdateOne) {
  31370. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  31371. }
  31372. if m.id == nil || m.oldValue == nil {
  31373. return v, errors.New("OldExperience requires an ID field in the mutation")
  31374. }
  31375. oldValue, err := m.oldValue(ctx)
  31376. if err != nil {
  31377. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  31378. }
  31379. return oldValue.Experience, nil
  31380. }
  31381. // ResetExperience resets all changes to the "experience" field.
  31382. func (m *WorkExperienceMutation) ResetExperience() {
  31383. m.experience = nil
  31384. }
  31385. // SetOrganizationID sets the "organization_id" field.
  31386. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  31387. m.organization_id = &u
  31388. m.addorganization_id = nil
  31389. }
  31390. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31391. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  31392. v := m.organization_id
  31393. if v == nil {
  31394. return
  31395. }
  31396. return *v, true
  31397. }
  31398. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  31399. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31401. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31402. if !m.op.Is(OpUpdateOne) {
  31403. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31404. }
  31405. if m.id == nil || m.oldValue == nil {
  31406. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31407. }
  31408. oldValue, err := m.oldValue(ctx)
  31409. if err != nil {
  31410. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31411. }
  31412. return oldValue.OrganizationID, nil
  31413. }
  31414. // AddOrganizationID adds u to the "organization_id" field.
  31415. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  31416. if m.addorganization_id != nil {
  31417. *m.addorganization_id += u
  31418. } else {
  31419. m.addorganization_id = &u
  31420. }
  31421. }
  31422. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31423. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  31424. v := m.addorganization_id
  31425. if v == nil {
  31426. return
  31427. }
  31428. return *v, true
  31429. }
  31430. // ResetOrganizationID resets all changes to the "organization_id" field.
  31431. func (m *WorkExperienceMutation) ResetOrganizationID() {
  31432. m.organization_id = nil
  31433. m.addorganization_id = nil
  31434. }
  31435. // ClearEmployee clears the "employee" edge to the Employee entity.
  31436. func (m *WorkExperienceMutation) ClearEmployee() {
  31437. m.clearedemployee = true
  31438. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  31439. }
  31440. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  31441. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  31442. return m.clearedemployee
  31443. }
  31444. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  31445. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31446. // EmployeeID instead. It exists only for internal usage by the builders.
  31447. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  31448. if id := m.employee; id != nil {
  31449. ids = append(ids, *id)
  31450. }
  31451. return
  31452. }
  31453. // ResetEmployee resets all changes to the "employee" edge.
  31454. func (m *WorkExperienceMutation) ResetEmployee() {
  31455. m.employee = nil
  31456. m.clearedemployee = false
  31457. }
  31458. // Where appends a list predicates to the WorkExperienceMutation builder.
  31459. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  31460. m.predicates = append(m.predicates, ps...)
  31461. }
  31462. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  31463. // users can use type-assertion to append predicates that do not depend on any generated package.
  31464. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  31465. p := make([]predicate.WorkExperience, len(ps))
  31466. for i := range ps {
  31467. p[i] = ps[i]
  31468. }
  31469. m.Where(p...)
  31470. }
  31471. // Op returns the operation name.
  31472. func (m *WorkExperienceMutation) Op() Op {
  31473. return m.op
  31474. }
  31475. // SetOp allows setting the mutation operation.
  31476. func (m *WorkExperienceMutation) SetOp(op Op) {
  31477. m.op = op
  31478. }
  31479. // Type returns the node type of this mutation (WorkExperience).
  31480. func (m *WorkExperienceMutation) Type() string {
  31481. return m.typ
  31482. }
  31483. // Fields returns all fields that were changed during this mutation. Note that in
  31484. // order to get all numeric fields that were incremented/decremented, call
  31485. // AddedFields().
  31486. func (m *WorkExperienceMutation) Fields() []string {
  31487. fields := make([]string, 0, 9)
  31488. if m.created_at != nil {
  31489. fields = append(fields, workexperience.FieldCreatedAt)
  31490. }
  31491. if m.updated_at != nil {
  31492. fields = append(fields, workexperience.FieldUpdatedAt)
  31493. }
  31494. if m.deleted_at != nil {
  31495. fields = append(fields, workexperience.FieldDeletedAt)
  31496. }
  31497. if m.employee != nil {
  31498. fields = append(fields, workexperience.FieldEmployeeID)
  31499. }
  31500. if m.start_date != nil {
  31501. fields = append(fields, workexperience.FieldStartDate)
  31502. }
  31503. if m.end_date != nil {
  31504. fields = append(fields, workexperience.FieldEndDate)
  31505. }
  31506. if m.company != nil {
  31507. fields = append(fields, workexperience.FieldCompany)
  31508. }
  31509. if m.experience != nil {
  31510. fields = append(fields, workexperience.FieldExperience)
  31511. }
  31512. if m.organization_id != nil {
  31513. fields = append(fields, workexperience.FieldOrganizationID)
  31514. }
  31515. return fields
  31516. }
  31517. // Field returns the value of a field with the given name. The second boolean
  31518. // return value indicates that this field was not set, or was not defined in the
  31519. // schema.
  31520. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  31521. switch name {
  31522. case workexperience.FieldCreatedAt:
  31523. return m.CreatedAt()
  31524. case workexperience.FieldUpdatedAt:
  31525. return m.UpdatedAt()
  31526. case workexperience.FieldDeletedAt:
  31527. return m.DeletedAt()
  31528. case workexperience.FieldEmployeeID:
  31529. return m.EmployeeID()
  31530. case workexperience.FieldStartDate:
  31531. return m.StartDate()
  31532. case workexperience.FieldEndDate:
  31533. return m.EndDate()
  31534. case workexperience.FieldCompany:
  31535. return m.Company()
  31536. case workexperience.FieldExperience:
  31537. return m.Experience()
  31538. case workexperience.FieldOrganizationID:
  31539. return m.OrganizationID()
  31540. }
  31541. return nil, false
  31542. }
  31543. // OldField returns the old value of the field from the database. An error is
  31544. // returned if the mutation operation is not UpdateOne, or the query to the
  31545. // database failed.
  31546. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31547. switch name {
  31548. case workexperience.FieldCreatedAt:
  31549. return m.OldCreatedAt(ctx)
  31550. case workexperience.FieldUpdatedAt:
  31551. return m.OldUpdatedAt(ctx)
  31552. case workexperience.FieldDeletedAt:
  31553. return m.OldDeletedAt(ctx)
  31554. case workexperience.FieldEmployeeID:
  31555. return m.OldEmployeeID(ctx)
  31556. case workexperience.FieldStartDate:
  31557. return m.OldStartDate(ctx)
  31558. case workexperience.FieldEndDate:
  31559. return m.OldEndDate(ctx)
  31560. case workexperience.FieldCompany:
  31561. return m.OldCompany(ctx)
  31562. case workexperience.FieldExperience:
  31563. return m.OldExperience(ctx)
  31564. case workexperience.FieldOrganizationID:
  31565. return m.OldOrganizationID(ctx)
  31566. }
  31567. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  31568. }
  31569. // SetField sets the value of a field with the given name. It returns an error if
  31570. // the field is not defined in the schema, or if the type mismatched the field
  31571. // type.
  31572. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  31573. switch name {
  31574. case workexperience.FieldCreatedAt:
  31575. v, ok := value.(time.Time)
  31576. if !ok {
  31577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31578. }
  31579. m.SetCreatedAt(v)
  31580. return nil
  31581. case workexperience.FieldUpdatedAt:
  31582. v, ok := value.(time.Time)
  31583. if !ok {
  31584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31585. }
  31586. m.SetUpdatedAt(v)
  31587. return nil
  31588. case workexperience.FieldDeletedAt:
  31589. v, ok := value.(time.Time)
  31590. if !ok {
  31591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31592. }
  31593. m.SetDeletedAt(v)
  31594. return nil
  31595. case workexperience.FieldEmployeeID:
  31596. v, ok := value.(uint64)
  31597. if !ok {
  31598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31599. }
  31600. m.SetEmployeeID(v)
  31601. return nil
  31602. case workexperience.FieldStartDate:
  31603. v, ok := value.(time.Time)
  31604. if !ok {
  31605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31606. }
  31607. m.SetStartDate(v)
  31608. return nil
  31609. case workexperience.FieldEndDate:
  31610. v, ok := value.(time.Time)
  31611. if !ok {
  31612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31613. }
  31614. m.SetEndDate(v)
  31615. return nil
  31616. case workexperience.FieldCompany:
  31617. v, ok := value.(string)
  31618. if !ok {
  31619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31620. }
  31621. m.SetCompany(v)
  31622. return nil
  31623. case workexperience.FieldExperience:
  31624. v, ok := value.(string)
  31625. if !ok {
  31626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31627. }
  31628. m.SetExperience(v)
  31629. return nil
  31630. case workexperience.FieldOrganizationID:
  31631. v, ok := value.(uint64)
  31632. if !ok {
  31633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31634. }
  31635. m.SetOrganizationID(v)
  31636. return nil
  31637. }
  31638. return fmt.Errorf("unknown WorkExperience field %s", name)
  31639. }
  31640. // AddedFields returns all numeric fields that were incremented/decremented during
  31641. // this mutation.
  31642. func (m *WorkExperienceMutation) AddedFields() []string {
  31643. var fields []string
  31644. if m.addorganization_id != nil {
  31645. fields = append(fields, workexperience.FieldOrganizationID)
  31646. }
  31647. return fields
  31648. }
  31649. // AddedField returns the numeric value that was incremented/decremented on a field
  31650. // with the given name. The second boolean return value indicates that this field
  31651. // was not set, or was not defined in the schema.
  31652. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  31653. switch name {
  31654. case workexperience.FieldOrganizationID:
  31655. return m.AddedOrganizationID()
  31656. }
  31657. return nil, false
  31658. }
  31659. // AddField adds the value to the field with the given name. It returns an error if
  31660. // the field is not defined in the schema, or if the type mismatched the field
  31661. // type.
  31662. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  31663. switch name {
  31664. case workexperience.FieldOrganizationID:
  31665. v, ok := value.(int64)
  31666. if !ok {
  31667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31668. }
  31669. m.AddOrganizationID(v)
  31670. return nil
  31671. }
  31672. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  31673. }
  31674. // ClearedFields returns all nullable fields that were cleared during this
  31675. // mutation.
  31676. func (m *WorkExperienceMutation) ClearedFields() []string {
  31677. var fields []string
  31678. if m.FieldCleared(workexperience.FieldDeletedAt) {
  31679. fields = append(fields, workexperience.FieldDeletedAt)
  31680. }
  31681. return fields
  31682. }
  31683. // FieldCleared returns a boolean indicating if a field with the given name was
  31684. // cleared in this mutation.
  31685. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  31686. _, ok := m.clearedFields[name]
  31687. return ok
  31688. }
  31689. // ClearField clears the value of the field with the given name. It returns an
  31690. // error if the field is not defined in the schema.
  31691. func (m *WorkExperienceMutation) ClearField(name string) error {
  31692. switch name {
  31693. case workexperience.FieldDeletedAt:
  31694. m.ClearDeletedAt()
  31695. return nil
  31696. }
  31697. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  31698. }
  31699. // ResetField resets all changes in the mutation for the field with the given name.
  31700. // It returns an error if the field is not defined in the schema.
  31701. func (m *WorkExperienceMutation) ResetField(name string) error {
  31702. switch name {
  31703. case workexperience.FieldCreatedAt:
  31704. m.ResetCreatedAt()
  31705. return nil
  31706. case workexperience.FieldUpdatedAt:
  31707. m.ResetUpdatedAt()
  31708. return nil
  31709. case workexperience.FieldDeletedAt:
  31710. m.ResetDeletedAt()
  31711. return nil
  31712. case workexperience.FieldEmployeeID:
  31713. m.ResetEmployeeID()
  31714. return nil
  31715. case workexperience.FieldStartDate:
  31716. m.ResetStartDate()
  31717. return nil
  31718. case workexperience.FieldEndDate:
  31719. m.ResetEndDate()
  31720. return nil
  31721. case workexperience.FieldCompany:
  31722. m.ResetCompany()
  31723. return nil
  31724. case workexperience.FieldExperience:
  31725. m.ResetExperience()
  31726. return nil
  31727. case workexperience.FieldOrganizationID:
  31728. m.ResetOrganizationID()
  31729. return nil
  31730. }
  31731. return fmt.Errorf("unknown WorkExperience field %s", name)
  31732. }
  31733. // AddedEdges returns all edge names that were set/added in this mutation.
  31734. func (m *WorkExperienceMutation) AddedEdges() []string {
  31735. edges := make([]string, 0, 1)
  31736. if m.employee != nil {
  31737. edges = append(edges, workexperience.EdgeEmployee)
  31738. }
  31739. return edges
  31740. }
  31741. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31742. // name in this mutation.
  31743. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  31744. switch name {
  31745. case workexperience.EdgeEmployee:
  31746. if id := m.employee; id != nil {
  31747. return []ent.Value{*id}
  31748. }
  31749. }
  31750. return nil
  31751. }
  31752. // RemovedEdges returns all edge names that were removed in this mutation.
  31753. func (m *WorkExperienceMutation) RemovedEdges() []string {
  31754. edges := make([]string, 0, 1)
  31755. return edges
  31756. }
  31757. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31758. // the given name in this mutation.
  31759. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  31760. return nil
  31761. }
  31762. // ClearedEdges returns all edge names that were cleared in this mutation.
  31763. func (m *WorkExperienceMutation) ClearedEdges() []string {
  31764. edges := make([]string, 0, 1)
  31765. if m.clearedemployee {
  31766. edges = append(edges, workexperience.EdgeEmployee)
  31767. }
  31768. return edges
  31769. }
  31770. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31771. // was cleared in this mutation.
  31772. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  31773. switch name {
  31774. case workexperience.EdgeEmployee:
  31775. return m.clearedemployee
  31776. }
  31777. return false
  31778. }
  31779. // ClearEdge clears the value of the edge with the given name. It returns an error
  31780. // if that edge is not defined in the schema.
  31781. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  31782. switch name {
  31783. case workexperience.EdgeEmployee:
  31784. m.ClearEmployee()
  31785. return nil
  31786. }
  31787. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  31788. }
  31789. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31790. // It returns an error if the edge is not defined in the schema.
  31791. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  31792. switch name {
  31793. case workexperience.EdgeEmployee:
  31794. m.ResetEmployee()
  31795. return nil
  31796. }
  31797. return fmt.Errorf("unknown WorkExperience edge %s", name)
  31798. }
  31799. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  31800. type WpChatroomMutation struct {
  31801. config
  31802. op Op
  31803. typ string
  31804. id *uint64
  31805. created_at *time.Time
  31806. updated_at *time.Time
  31807. status *uint8
  31808. addstatus *int8
  31809. wx_wxid *string
  31810. chatroom_id *string
  31811. nickname *string
  31812. owner *string
  31813. avatar *string
  31814. member_list *[]string
  31815. appendmember_list []string
  31816. clearedFields map[string]struct{}
  31817. done bool
  31818. oldValue func(context.Context) (*WpChatroom, error)
  31819. predicates []predicate.WpChatroom
  31820. }
  31821. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  31822. // wpchatroomOption allows management of the mutation configuration using functional options.
  31823. type wpchatroomOption func(*WpChatroomMutation)
  31824. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  31825. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  31826. m := &WpChatroomMutation{
  31827. config: c,
  31828. op: op,
  31829. typ: TypeWpChatroom,
  31830. clearedFields: make(map[string]struct{}),
  31831. }
  31832. for _, opt := range opts {
  31833. opt(m)
  31834. }
  31835. return m
  31836. }
  31837. // withWpChatroomID sets the ID field of the mutation.
  31838. func withWpChatroomID(id uint64) wpchatroomOption {
  31839. return func(m *WpChatroomMutation) {
  31840. var (
  31841. err error
  31842. once sync.Once
  31843. value *WpChatroom
  31844. )
  31845. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  31846. once.Do(func() {
  31847. if m.done {
  31848. err = errors.New("querying old values post mutation is not allowed")
  31849. } else {
  31850. value, err = m.Client().WpChatroom.Get(ctx, id)
  31851. }
  31852. })
  31853. return value, err
  31854. }
  31855. m.id = &id
  31856. }
  31857. }
  31858. // withWpChatroom sets the old WpChatroom of the mutation.
  31859. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  31860. return func(m *WpChatroomMutation) {
  31861. m.oldValue = func(context.Context) (*WpChatroom, error) {
  31862. return node, nil
  31863. }
  31864. m.id = &node.ID
  31865. }
  31866. }
  31867. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31868. // executed in a transaction (ent.Tx), a transactional client is returned.
  31869. func (m WpChatroomMutation) Client() *Client {
  31870. client := &Client{config: m.config}
  31871. client.init()
  31872. return client
  31873. }
  31874. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31875. // it returns an error otherwise.
  31876. func (m WpChatroomMutation) Tx() (*Tx, error) {
  31877. if _, ok := m.driver.(*txDriver); !ok {
  31878. return nil, errors.New("ent: mutation is not running in a transaction")
  31879. }
  31880. tx := &Tx{config: m.config}
  31881. tx.init()
  31882. return tx, nil
  31883. }
  31884. // SetID sets the value of the id field. Note that this
  31885. // operation is only accepted on creation of WpChatroom entities.
  31886. func (m *WpChatroomMutation) SetID(id uint64) {
  31887. m.id = &id
  31888. }
  31889. // ID returns the ID value in the mutation. Note that the ID is only available
  31890. // if it was provided to the builder or after it was returned from the database.
  31891. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  31892. if m.id == nil {
  31893. return
  31894. }
  31895. return *m.id, true
  31896. }
  31897. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31898. // That means, if the mutation is applied within a transaction with an isolation level such
  31899. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31900. // or updated by the mutation.
  31901. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  31902. switch {
  31903. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31904. id, exists := m.ID()
  31905. if exists {
  31906. return []uint64{id}, nil
  31907. }
  31908. fallthrough
  31909. case m.op.Is(OpUpdate | OpDelete):
  31910. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  31911. default:
  31912. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31913. }
  31914. }
  31915. // SetCreatedAt sets the "created_at" field.
  31916. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  31917. m.created_at = &t
  31918. }
  31919. // CreatedAt returns the value of the "created_at" field in the mutation.
  31920. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  31921. v := m.created_at
  31922. if v == nil {
  31923. return
  31924. }
  31925. return *v, true
  31926. }
  31927. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  31928. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31930. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31931. if !m.op.Is(OpUpdateOne) {
  31932. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31933. }
  31934. if m.id == nil || m.oldValue == nil {
  31935. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31936. }
  31937. oldValue, err := m.oldValue(ctx)
  31938. if err != nil {
  31939. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31940. }
  31941. return oldValue.CreatedAt, nil
  31942. }
  31943. // ResetCreatedAt resets all changes to the "created_at" field.
  31944. func (m *WpChatroomMutation) ResetCreatedAt() {
  31945. m.created_at = nil
  31946. }
  31947. // SetUpdatedAt sets the "updated_at" field.
  31948. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  31949. m.updated_at = &t
  31950. }
  31951. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31952. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  31953. v := m.updated_at
  31954. if v == nil {
  31955. return
  31956. }
  31957. return *v, true
  31958. }
  31959. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  31960. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31962. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31963. if !m.op.Is(OpUpdateOne) {
  31964. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31965. }
  31966. if m.id == nil || m.oldValue == nil {
  31967. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31968. }
  31969. oldValue, err := m.oldValue(ctx)
  31970. if err != nil {
  31971. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31972. }
  31973. return oldValue.UpdatedAt, nil
  31974. }
  31975. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31976. func (m *WpChatroomMutation) ResetUpdatedAt() {
  31977. m.updated_at = nil
  31978. }
  31979. // SetStatus sets the "status" field.
  31980. func (m *WpChatroomMutation) SetStatus(u uint8) {
  31981. m.status = &u
  31982. m.addstatus = nil
  31983. }
  31984. // Status returns the value of the "status" field in the mutation.
  31985. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  31986. v := m.status
  31987. if v == nil {
  31988. return
  31989. }
  31990. return *v, true
  31991. }
  31992. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  31993. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31995. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31996. if !m.op.Is(OpUpdateOne) {
  31997. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31998. }
  31999. if m.id == nil || m.oldValue == nil {
  32000. return v, errors.New("OldStatus requires an ID field in the mutation")
  32001. }
  32002. oldValue, err := m.oldValue(ctx)
  32003. if err != nil {
  32004. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32005. }
  32006. return oldValue.Status, nil
  32007. }
  32008. // AddStatus adds u to the "status" field.
  32009. func (m *WpChatroomMutation) AddStatus(u int8) {
  32010. if m.addstatus != nil {
  32011. *m.addstatus += u
  32012. } else {
  32013. m.addstatus = &u
  32014. }
  32015. }
  32016. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32017. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  32018. v := m.addstatus
  32019. if v == nil {
  32020. return
  32021. }
  32022. return *v, true
  32023. }
  32024. // ClearStatus clears the value of the "status" field.
  32025. func (m *WpChatroomMutation) ClearStatus() {
  32026. m.status = nil
  32027. m.addstatus = nil
  32028. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  32029. }
  32030. // StatusCleared returns if the "status" field was cleared in this mutation.
  32031. func (m *WpChatroomMutation) StatusCleared() bool {
  32032. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  32033. return ok
  32034. }
  32035. // ResetStatus resets all changes to the "status" field.
  32036. func (m *WpChatroomMutation) ResetStatus() {
  32037. m.status = nil
  32038. m.addstatus = nil
  32039. delete(m.clearedFields, wpchatroom.FieldStatus)
  32040. }
  32041. // SetWxWxid sets the "wx_wxid" field.
  32042. func (m *WpChatroomMutation) SetWxWxid(s string) {
  32043. m.wx_wxid = &s
  32044. }
  32045. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  32046. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  32047. v := m.wx_wxid
  32048. if v == nil {
  32049. return
  32050. }
  32051. return *v, true
  32052. }
  32053. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  32054. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32056. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  32057. if !m.op.Is(OpUpdateOne) {
  32058. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  32059. }
  32060. if m.id == nil || m.oldValue == nil {
  32061. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  32062. }
  32063. oldValue, err := m.oldValue(ctx)
  32064. if err != nil {
  32065. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  32066. }
  32067. return oldValue.WxWxid, nil
  32068. }
  32069. // ResetWxWxid resets all changes to the "wx_wxid" field.
  32070. func (m *WpChatroomMutation) ResetWxWxid() {
  32071. m.wx_wxid = nil
  32072. }
  32073. // SetChatroomID sets the "chatroom_id" field.
  32074. func (m *WpChatroomMutation) SetChatroomID(s string) {
  32075. m.chatroom_id = &s
  32076. }
  32077. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  32078. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  32079. v := m.chatroom_id
  32080. if v == nil {
  32081. return
  32082. }
  32083. return *v, true
  32084. }
  32085. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  32086. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32088. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  32089. if !m.op.Is(OpUpdateOne) {
  32090. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  32091. }
  32092. if m.id == nil || m.oldValue == nil {
  32093. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  32094. }
  32095. oldValue, err := m.oldValue(ctx)
  32096. if err != nil {
  32097. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  32098. }
  32099. return oldValue.ChatroomID, nil
  32100. }
  32101. // ResetChatroomID resets all changes to the "chatroom_id" field.
  32102. func (m *WpChatroomMutation) ResetChatroomID() {
  32103. m.chatroom_id = nil
  32104. }
  32105. // SetNickname sets the "nickname" field.
  32106. func (m *WpChatroomMutation) SetNickname(s string) {
  32107. m.nickname = &s
  32108. }
  32109. // Nickname returns the value of the "nickname" field in the mutation.
  32110. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  32111. v := m.nickname
  32112. if v == nil {
  32113. return
  32114. }
  32115. return *v, true
  32116. }
  32117. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  32118. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32120. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  32121. if !m.op.Is(OpUpdateOne) {
  32122. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32123. }
  32124. if m.id == nil || m.oldValue == nil {
  32125. return v, errors.New("OldNickname requires an ID field in the mutation")
  32126. }
  32127. oldValue, err := m.oldValue(ctx)
  32128. if err != nil {
  32129. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32130. }
  32131. return oldValue.Nickname, nil
  32132. }
  32133. // ResetNickname resets all changes to the "nickname" field.
  32134. func (m *WpChatroomMutation) ResetNickname() {
  32135. m.nickname = nil
  32136. }
  32137. // SetOwner sets the "owner" field.
  32138. func (m *WpChatroomMutation) SetOwner(s string) {
  32139. m.owner = &s
  32140. }
  32141. // Owner returns the value of the "owner" field in the mutation.
  32142. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  32143. v := m.owner
  32144. if v == nil {
  32145. return
  32146. }
  32147. return *v, true
  32148. }
  32149. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  32150. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32152. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  32153. if !m.op.Is(OpUpdateOne) {
  32154. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  32155. }
  32156. if m.id == nil || m.oldValue == nil {
  32157. return v, errors.New("OldOwner requires an ID field in the mutation")
  32158. }
  32159. oldValue, err := m.oldValue(ctx)
  32160. if err != nil {
  32161. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  32162. }
  32163. return oldValue.Owner, nil
  32164. }
  32165. // ResetOwner resets all changes to the "owner" field.
  32166. func (m *WpChatroomMutation) ResetOwner() {
  32167. m.owner = nil
  32168. }
  32169. // SetAvatar sets the "avatar" field.
  32170. func (m *WpChatroomMutation) SetAvatar(s string) {
  32171. m.avatar = &s
  32172. }
  32173. // Avatar returns the value of the "avatar" field in the mutation.
  32174. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  32175. v := m.avatar
  32176. if v == nil {
  32177. return
  32178. }
  32179. return *v, true
  32180. }
  32181. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  32182. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32184. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  32185. if !m.op.Is(OpUpdateOne) {
  32186. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  32187. }
  32188. if m.id == nil || m.oldValue == nil {
  32189. return v, errors.New("OldAvatar requires an ID field in the mutation")
  32190. }
  32191. oldValue, err := m.oldValue(ctx)
  32192. if err != nil {
  32193. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  32194. }
  32195. return oldValue.Avatar, nil
  32196. }
  32197. // ResetAvatar resets all changes to the "avatar" field.
  32198. func (m *WpChatroomMutation) ResetAvatar() {
  32199. m.avatar = nil
  32200. }
  32201. // SetMemberList sets the "member_list" field.
  32202. func (m *WpChatroomMutation) SetMemberList(s []string) {
  32203. m.member_list = &s
  32204. m.appendmember_list = nil
  32205. }
  32206. // MemberList returns the value of the "member_list" field in the mutation.
  32207. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  32208. v := m.member_list
  32209. if v == nil {
  32210. return
  32211. }
  32212. return *v, true
  32213. }
  32214. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  32215. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32217. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  32218. if !m.op.Is(OpUpdateOne) {
  32219. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  32220. }
  32221. if m.id == nil || m.oldValue == nil {
  32222. return v, errors.New("OldMemberList requires an ID field in the mutation")
  32223. }
  32224. oldValue, err := m.oldValue(ctx)
  32225. if err != nil {
  32226. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  32227. }
  32228. return oldValue.MemberList, nil
  32229. }
  32230. // AppendMemberList adds s to the "member_list" field.
  32231. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  32232. m.appendmember_list = append(m.appendmember_list, s...)
  32233. }
  32234. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  32235. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  32236. if len(m.appendmember_list) == 0 {
  32237. return nil, false
  32238. }
  32239. return m.appendmember_list, true
  32240. }
  32241. // ResetMemberList resets all changes to the "member_list" field.
  32242. func (m *WpChatroomMutation) ResetMemberList() {
  32243. m.member_list = nil
  32244. m.appendmember_list = nil
  32245. }
  32246. // Where appends a list predicates to the WpChatroomMutation builder.
  32247. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  32248. m.predicates = append(m.predicates, ps...)
  32249. }
  32250. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  32251. // users can use type-assertion to append predicates that do not depend on any generated package.
  32252. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  32253. p := make([]predicate.WpChatroom, len(ps))
  32254. for i := range ps {
  32255. p[i] = ps[i]
  32256. }
  32257. m.Where(p...)
  32258. }
  32259. // Op returns the operation name.
  32260. func (m *WpChatroomMutation) Op() Op {
  32261. return m.op
  32262. }
  32263. // SetOp allows setting the mutation operation.
  32264. func (m *WpChatroomMutation) SetOp(op Op) {
  32265. m.op = op
  32266. }
  32267. // Type returns the node type of this mutation (WpChatroom).
  32268. func (m *WpChatroomMutation) Type() string {
  32269. return m.typ
  32270. }
  32271. // Fields returns all fields that were changed during this mutation. Note that in
  32272. // order to get all numeric fields that were incremented/decremented, call
  32273. // AddedFields().
  32274. func (m *WpChatroomMutation) Fields() []string {
  32275. fields := make([]string, 0, 9)
  32276. if m.created_at != nil {
  32277. fields = append(fields, wpchatroom.FieldCreatedAt)
  32278. }
  32279. if m.updated_at != nil {
  32280. fields = append(fields, wpchatroom.FieldUpdatedAt)
  32281. }
  32282. if m.status != nil {
  32283. fields = append(fields, wpchatroom.FieldStatus)
  32284. }
  32285. if m.wx_wxid != nil {
  32286. fields = append(fields, wpchatroom.FieldWxWxid)
  32287. }
  32288. if m.chatroom_id != nil {
  32289. fields = append(fields, wpchatroom.FieldChatroomID)
  32290. }
  32291. if m.nickname != nil {
  32292. fields = append(fields, wpchatroom.FieldNickname)
  32293. }
  32294. if m.owner != nil {
  32295. fields = append(fields, wpchatroom.FieldOwner)
  32296. }
  32297. if m.avatar != nil {
  32298. fields = append(fields, wpchatroom.FieldAvatar)
  32299. }
  32300. if m.member_list != nil {
  32301. fields = append(fields, wpchatroom.FieldMemberList)
  32302. }
  32303. return fields
  32304. }
  32305. // Field returns the value of a field with the given name. The second boolean
  32306. // return value indicates that this field was not set, or was not defined in the
  32307. // schema.
  32308. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  32309. switch name {
  32310. case wpchatroom.FieldCreatedAt:
  32311. return m.CreatedAt()
  32312. case wpchatroom.FieldUpdatedAt:
  32313. return m.UpdatedAt()
  32314. case wpchatroom.FieldStatus:
  32315. return m.Status()
  32316. case wpchatroom.FieldWxWxid:
  32317. return m.WxWxid()
  32318. case wpchatroom.FieldChatroomID:
  32319. return m.ChatroomID()
  32320. case wpchatroom.FieldNickname:
  32321. return m.Nickname()
  32322. case wpchatroom.FieldOwner:
  32323. return m.Owner()
  32324. case wpchatroom.FieldAvatar:
  32325. return m.Avatar()
  32326. case wpchatroom.FieldMemberList:
  32327. return m.MemberList()
  32328. }
  32329. return nil, false
  32330. }
  32331. // OldField returns the old value of the field from the database. An error is
  32332. // returned if the mutation operation is not UpdateOne, or the query to the
  32333. // database failed.
  32334. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32335. switch name {
  32336. case wpchatroom.FieldCreatedAt:
  32337. return m.OldCreatedAt(ctx)
  32338. case wpchatroom.FieldUpdatedAt:
  32339. return m.OldUpdatedAt(ctx)
  32340. case wpchatroom.FieldStatus:
  32341. return m.OldStatus(ctx)
  32342. case wpchatroom.FieldWxWxid:
  32343. return m.OldWxWxid(ctx)
  32344. case wpchatroom.FieldChatroomID:
  32345. return m.OldChatroomID(ctx)
  32346. case wpchatroom.FieldNickname:
  32347. return m.OldNickname(ctx)
  32348. case wpchatroom.FieldOwner:
  32349. return m.OldOwner(ctx)
  32350. case wpchatroom.FieldAvatar:
  32351. return m.OldAvatar(ctx)
  32352. case wpchatroom.FieldMemberList:
  32353. return m.OldMemberList(ctx)
  32354. }
  32355. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  32356. }
  32357. // SetField sets the value of a field with the given name. It returns an error if
  32358. // the field is not defined in the schema, or if the type mismatched the field
  32359. // type.
  32360. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  32361. switch name {
  32362. case wpchatroom.FieldCreatedAt:
  32363. v, ok := value.(time.Time)
  32364. if !ok {
  32365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32366. }
  32367. m.SetCreatedAt(v)
  32368. return nil
  32369. case wpchatroom.FieldUpdatedAt:
  32370. v, ok := value.(time.Time)
  32371. if !ok {
  32372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32373. }
  32374. m.SetUpdatedAt(v)
  32375. return nil
  32376. case wpchatroom.FieldStatus:
  32377. v, ok := value.(uint8)
  32378. if !ok {
  32379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32380. }
  32381. m.SetStatus(v)
  32382. return nil
  32383. case wpchatroom.FieldWxWxid:
  32384. v, ok := value.(string)
  32385. if !ok {
  32386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32387. }
  32388. m.SetWxWxid(v)
  32389. return nil
  32390. case wpchatroom.FieldChatroomID:
  32391. v, ok := value.(string)
  32392. if !ok {
  32393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32394. }
  32395. m.SetChatroomID(v)
  32396. return nil
  32397. case wpchatroom.FieldNickname:
  32398. v, ok := value.(string)
  32399. if !ok {
  32400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32401. }
  32402. m.SetNickname(v)
  32403. return nil
  32404. case wpchatroom.FieldOwner:
  32405. v, ok := value.(string)
  32406. if !ok {
  32407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32408. }
  32409. m.SetOwner(v)
  32410. return nil
  32411. case wpchatroom.FieldAvatar:
  32412. v, ok := value.(string)
  32413. if !ok {
  32414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32415. }
  32416. m.SetAvatar(v)
  32417. return nil
  32418. case wpchatroom.FieldMemberList:
  32419. v, ok := value.([]string)
  32420. if !ok {
  32421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32422. }
  32423. m.SetMemberList(v)
  32424. return nil
  32425. }
  32426. return fmt.Errorf("unknown WpChatroom field %s", name)
  32427. }
  32428. // AddedFields returns all numeric fields that were incremented/decremented during
  32429. // this mutation.
  32430. func (m *WpChatroomMutation) AddedFields() []string {
  32431. var fields []string
  32432. if m.addstatus != nil {
  32433. fields = append(fields, wpchatroom.FieldStatus)
  32434. }
  32435. return fields
  32436. }
  32437. // AddedField returns the numeric value that was incremented/decremented on a field
  32438. // with the given name. The second boolean return value indicates that this field
  32439. // was not set, or was not defined in the schema.
  32440. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  32441. switch name {
  32442. case wpchatroom.FieldStatus:
  32443. return m.AddedStatus()
  32444. }
  32445. return nil, false
  32446. }
  32447. // AddField adds the value to the field with the given name. It returns an error if
  32448. // the field is not defined in the schema, or if the type mismatched the field
  32449. // type.
  32450. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  32451. switch name {
  32452. case wpchatroom.FieldStatus:
  32453. v, ok := value.(int8)
  32454. if !ok {
  32455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32456. }
  32457. m.AddStatus(v)
  32458. return nil
  32459. }
  32460. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  32461. }
  32462. // ClearedFields returns all nullable fields that were cleared during this
  32463. // mutation.
  32464. func (m *WpChatroomMutation) ClearedFields() []string {
  32465. var fields []string
  32466. if m.FieldCleared(wpchatroom.FieldStatus) {
  32467. fields = append(fields, wpchatroom.FieldStatus)
  32468. }
  32469. return fields
  32470. }
  32471. // FieldCleared returns a boolean indicating if a field with the given name was
  32472. // cleared in this mutation.
  32473. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  32474. _, ok := m.clearedFields[name]
  32475. return ok
  32476. }
  32477. // ClearField clears the value of the field with the given name. It returns an
  32478. // error if the field is not defined in the schema.
  32479. func (m *WpChatroomMutation) ClearField(name string) error {
  32480. switch name {
  32481. case wpchatroom.FieldStatus:
  32482. m.ClearStatus()
  32483. return nil
  32484. }
  32485. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  32486. }
  32487. // ResetField resets all changes in the mutation for the field with the given name.
  32488. // It returns an error if the field is not defined in the schema.
  32489. func (m *WpChatroomMutation) ResetField(name string) error {
  32490. switch name {
  32491. case wpchatroom.FieldCreatedAt:
  32492. m.ResetCreatedAt()
  32493. return nil
  32494. case wpchatroom.FieldUpdatedAt:
  32495. m.ResetUpdatedAt()
  32496. return nil
  32497. case wpchatroom.FieldStatus:
  32498. m.ResetStatus()
  32499. return nil
  32500. case wpchatroom.FieldWxWxid:
  32501. m.ResetWxWxid()
  32502. return nil
  32503. case wpchatroom.FieldChatroomID:
  32504. m.ResetChatroomID()
  32505. return nil
  32506. case wpchatroom.FieldNickname:
  32507. m.ResetNickname()
  32508. return nil
  32509. case wpchatroom.FieldOwner:
  32510. m.ResetOwner()
  32511. return nil
  32512. case wpchatroom.FieldAvatar:
  32513. m.ResetAvatar()
  32514. return nil
  32515. case wpchatroom.FieldMemberList:
  32516. m.ResetMemberList()
  32517. return nil
  32518. }
  32519. return fmt.Errorf("unknown WpChatroom field %s", name)
  32520. }
  32521. // AddedEdges returns all edge names that were set/added in this mutation.
  32522. func (m *WpChatroomMutation) AddedEdges() []string {
  32523. edges := make([]string, 0, 0)
  32524. return edges
  32525. }
  32526. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32527. // name in this mutation.
  32528. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  32529. return nil
  32530. }
  32531. // RemovedEdges returns all edge names that were removed in this mutation.
  32532. func (m *WpChatroomMutation) RemovedEdges() []string {
  32533. edges := make([]string, 0, 0)
  32534. return edges
  32535. }
  32536. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32537. // the given name in this mutation.
  32538. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  32539. return nil
  32540. }
  32541. // ClearedEdges returns all edge names that were cleared in this mutation.
  32542. func (m *WpChatroomMutation) ClearedEdges() []string {
  32543. edges := make([]string, 0, 0)
  32544. return edges
  32545. }
  32546. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32547. // was cleared in this mutation.
  32548. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  32549. return false
  32550. }
  32551. // ClearEdge clears the value of the edge with the given name. It returns an error
  32552. // if that edge is not defined in the schema.
  32553. func (m *WpChatroomMutation) ClearEdge(name string) error {
  32554. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  32555. }
  32556. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32557. // It returns an error if the edge is not defined in the schema.
  32558. func (m *WpChatroomMutation) ResetEdge(name string) error {
  32559. return fmt.Errorf("unknown WpChatroom edge %s", name)
  32560. }
  32561. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  32562. type WpChatroomMemberMutation struct {
  32563. config
  32564. op Op
  32565. typ string
  32566. id *uint64
  32567. created_at *time.Time
  32568. updated_at *time.Time
  32569. status *uint8
  32570. addstatus *int8
  32571. wx_wxid *string
  32572. wxid *string
  32573. nickname *string
  32574. avatar *string
  32575. clearedFields map[string]struct{}
  32576. done bool
  32577. oldValue func(context.Context) (*WpChatroomMember, error)
  32578. predicates []predicate.WpChatroomMember
  32579. }
  32580. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  32581. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  32582. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  32583. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  32584. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  32585. m := &WpChatroomMemberMutation{
  32586. config: c,
  32587. op: op,
  32588. typ: TypeWpChatroomMember,
  32589. clearedFields: make(map[string]struct{}),
  32590. }
  32591. for _, opt := range opts {
  32592. opt(m)
  32593. }
  32594. return m
  32595. }
  32596. // withWpChatroomMemberID sets the ID field of the mutation.
  32597. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  32598. return func(m *WpChatroomMemberMutation) {
  32599. var (
  32600. err error
  32601. once sync.Once
  32602. value *WpChatroomMember
  32603. )
  32604. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  32605. once.Do(func() {
  32606. if m.done {
  32607. err = errors.New("querying old values post mutation is not allowed")
  32608. } else {
  32609. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  32610. }
  32611. })
  32612. return value, err
  32613. }
  32614. m.id = &id
  32615. }
  32616. }
  32617. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  32618. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  32619. return func(m *WpChatroomMemberMutation) {
  32620. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  32621. return node, nil
  32622. }
  32623. m.id = &node.ID
  32624. }
  32625. }
  32626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32627. // executed in a transaction (ent.Tx), a transactional client is returned.
  32628. func (m WpChatroomMemberMutation) Client() *Client {
  32629. client := &Client{config: m.config}
  32630. client.init()
  32631. return client
  32632. }
  32633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32634. // it returns an error otherwise.
  32635. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  32636. if _, ok := m.driver.(*txDriver); !ok {
  32637. return nil, errors.New("ent: mutation is not running in a transaction")
  32638. }
  32639. tx := &Tx{config: m.config}
  32640. tx.init()
  32641. return tx, nil
  32642. }
  32643. // SetID sets the value of the id field. Note that this
  32644. // operation is only accepted on creation of WpChatroomMember entities.
  32645. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  32646. m.id = &id
  32647. }
  32648. // ID returns the ID value in the mutation. Note that the ID is only available
  32649. // if it was provided to the builder or after it was returned from the database.
  32650. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  32651. if m.id == nil {
  32652. return
  32653. }
  32654. return *m.id, true
  32655. }
  32656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32657. // That means, if the mutation is applied within a transaction with an isolation level such
  32658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32659. // or updated by the mutation.
  32660. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  32661. switch {
  32662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32663. id, exists := m.ID()
  32664. if exists {
  32665. return []uint64{id}, nil
  32666. }
  32667. fallthrough
  32668. case m.op.Is(OpUpdate | OpDelete):
  32669. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  32670. default:
  32671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32672. }
  32673. }
  32674. // SetCreatedAt sets the "created_at" field.
  32675. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  32676. m.created_at = &t
  32677. }
  32678. // CreatedAt returns the value of the "created_at" field in the mutation.
  32679. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  32680. v := m.created_at
  32681. if v == nil {
  32682. return
  32683. }
  32684. return *v, true
  32685. }
  32686. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  32687. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32689. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32690. if !m.op.Is(OpUpdateOne) {
  32691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32692. }
  32693. if m.id == nil || m.oldValue == nil {
  32694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32695. }
  32696. oldValue, err := m.oldValue(ctx)
  32697. if err != nil {
  32698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32699. }
  32700. return oldValue.CreatedAt, nil
  32701. }
  32702. // ResetCreatedAt resets all changes to the "created_at" field.
  32703. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  32704. m.created_at = nil
  32705. }
  32706. // SetUpdatedAt sets the "updated_at" field.
  32707. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  32708. m.updated_at = &t
  32709. }
  32710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32711. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  32712. v := m.updated_at
  32713. if v == nil {
  32714. return
  32715. }
  32716. return *v, true
  32717. }
  32718. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  32719. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32721. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32722. if !m.op.Is(OpUpdateOne) {
  32723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32724. }
  32725. if m.id == nil || m.oldValue == nil {
  32726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32727. }
  32728. oldValue, err := m.oldValue(ctx)
  32729. if err != nil {
  32730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32731. }
  32732. return oldValue.UpdatedAt, nil
  32733. }
  32734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32735. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  32736. m.updated_at = nil
  32737. }
  32738. // SetStatus sets the "status" field.
  32739. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  32740. m.status = &u
  32741. m.addstatus = nil
  32742. }
  32743. // Status returns the value of the "status" field in the mutation.
  32744. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  32745. v := m.status
  32746. if v == nil {
  32747. return
  32748. }
  32749. return *v, true
  32750. }
  32751. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  32752. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32754. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32755. if !m.op.Is(OpUpdateOne) {
  32756. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32757. }
  32758. if m.id == nil || m.oldValue == nil {
  32759. return v, errors.New("OldStatus requires an ID field in the mutation")
  32760. }
  32761. oldValue, err := m.oldValue(ctx)
  32762. if err != nil {
  32763. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32764. }
  32765. return oldValue.Status, nil
  32766. }
  32767. // AddStatus adds u to the "status" field.
  32768. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  32769. if m.addstatus != nil {
  32770. *m.addstatus += u
  32771. } else {
  32772. m.addstatus = &u
  32773. }
  32774. }
  32775. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32776. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  32777. v := m.addstatus
  32778. if v == nil {
  32779. return
  32780. }
  32781. return *v, true
  32782. }
  32783. // ClearStatus clears the value of the "status" field.
  32784. func (m *WpChatroomMemberMutation) ClearStatus() {
  32785. m.status = nil
  32786. m.addstatus = nil
  32787. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  32788. }
  32789. // StatusCleared returns if the "status" field was cleared in this mutation.
  32790. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  32791. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  32792. return ok
  32793. }
  32794. // ResetStatus resets all changes to the "status" field.
  32795. func (m *WpChatroomMemberMutation) ResetStatus() {
  32796. m.status = nil
  32797. m.addstatus = nil
  32798. delete(m.clearedFields, wpchatroommember.FieldStatus)
  32799. }
  32800. // SetWxWxid sets the "wx_wxid" field.
  32801. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  32802. m.wx_wxid = &s
  32803. }
  32804. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  32805. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  32806. v := m.wx_wxid
  32807. if v == nil {
  32808. return
  32809. }
  32810. return *v, true
  32811. }
  32812. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  32813. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32815. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  32816. if !m.op.Is(OpUpdateOne) {
  32817. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  32818. }
  32819. if m.id == nil || m.oldValue == nil {
  32820. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  32821. }
  32822. oldValue, err := m.oldValue(ctx)
  32823. if err != nil {
  32824. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  32825. }
  32826. return oldValue.WxWxid, nil
  32827. }
  32828. // ResetWxWxid resets all changes to the "wx_wxid" field.
  32829. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  32830. m.wx_wxid = nil
  32831. }
  32832. // SetWxid sets the "wxid" field.
  32833. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  32834. m.wxid = &s
  32835. }
  32836. // Wxid returns the value of the "wxid" field in the mutation.
  32837. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  32838. v := m.wxid
  32839. if v == nil {
  32840. return
  32841. }
  32842. return *v, true
  32843. }
  32844. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  32845. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32847. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  32848. if !m.op.Is(OpUpdateOne) {
  32849. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  32850. }
  32851. if m.id == nil || m.oldValue == nil {
  32852. return v, errors.New("OldWxid requires an ID field in the mutation")
  32853. }
  32854. oldValue, err := m.oldValue(ctx)
  32855. if err != nil {
  32856. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  32857. }
  32858. return oldValue.Wxid, nil
  32859. }
  32860. // ResetWxid resets all changes to the "wxid" field.
  32861. func (m *WpChatroomMemberMutation) ResetWxid() {
  32862. m.wxid = nil
  32863. }
  32864. // SetNickname sets the "nickname" field.
  32865. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  32866. m.nickname = &s
  32867. }
  32868. // Nickname returns the value of the "nickname" field in the mutation.
  32869. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  32870. v := m.nickname
  32871. if v == nil {
  32872. return
  32873. }
  32874. return *v, true
  32875. }
  32876. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  32877. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32879. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  32880. if !m.op.Is(OpUpdateOne) {
  32881. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32882. }
  32883. if m.id == nil || m.oldValue == nil {
  32884. return v, errors.New("OldNickname requires an ID field in the mutation")
  32885. }
  32886. oldValue, err := m.oldValue(ctx)
  32887. if err != nil {
  32888. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32889. }
  32890. return oldValue.Nickname, nil
  32891. }
  32892. // ResetNickname resets all changes to the "nickname" field.
  32893. func (m *WpChatroomMemberMutation) ResetNickname() {
  32894. m.nickname = nil
  32895. }
  32896. // SetAvatar sets the "avatar" field.
  32897. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  32898. m.avatar = &s
  32899. }
  32900. // Avatar returns the value of the "avatar" field in the mutation.
  32901. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  32902. v := m.avatar
  32903. if v == nil {
  32904. return
  32905. }
  32906. return *v, true
  32907. }
  32908. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  32909. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32911. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  32912. if !m.op.Is(OpUpdateOne) {
  32913. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  32914. }
  32915. if m.id == nil || m.oldValue == nil {
  32916. return v, errors.New("OldAvatar requires an ID field in the mutation")
  32917. }
  32918. oldValue, err := m.oldValue(ctx)
  32919. if err != nil {
  32920. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  32921. }
  32922. return oldValue.Avatar, nil
  32923. }
  32924. // ResetAvatar resets all changes to the "avatar" field.
  32925. func (m *WpChatroomMemberMutation) ResetAvatar() {
  32926. m.avatar = nil
  32927. }
  32928. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  32929. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  32930. m.predicates = append(m.predicates, ps...)
  32931. }
  32932. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  32933. // users can use type-assertion to append predicates that do not depend on any generated package.
  32934. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  32935. p := make([]predicate.WpChatroomMember, len(ps))
  32936. for i := range ps {
  32937. p[i] = ps[i]
  32938. }
  32939. m.Where(p...)
  32940. }
  32941. // Op returns the operation name.
  32942. func (m *WpChatroomMemberMutation) Op() Op {
  32943. return m.op
  32944. }
  32945. // SetOp allows setting the mutation operation.
  32946. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  32947. m.op = op
  32948. }
  32949. // Type returns the node type of this mutation (WpChatroomMember).
  32950. func (m *WpChatroomMemberMutation) Type() string {
  32951. return m.typ
  32952. }
  32953. // Fields returns all fields that were changed during this mutation. Note that in
  32954. // order to get all numeric fields that were incremented/decremented, call
  32955. // AddedFields().
  32956. func (m *WpChatroomMemberMutation) Fields() []string {
  32957. fields := make([]string, 0, 7)
  32958. if m.created_at != nil {
  32959. fields = append(fields, wpchatroommember.FieldCreatedAt)
  32960. }
  32961. if m.updated_at != nil {
  32962. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  32963. }
  32964. if m.status != nil {
  32965. fields = append(fields, wpchatroommember.FieldStatus)
  32966. }
  32967. if m.wx_wxid != nil {
  32968. fields = append(fields, wpchatroommember.FieldWxWxid)
  32969. }
  32970. if m.wxid != nil {
  32971. fields = append(fields, wpchatroommember.FieldWxid)
  32972. }
  32973. if m.nickname != nil {
  32974. fields = append(fields, wpchatroommember.FieldNickname)
  32975. }
  32976. if m.avatar != nil {
  32977. fields = append(fields, wpchatroommember.FieldAvatar)
  32978. }
  32979. return fields
  32980. }
  32981. // Field returns the value of a field with the given name. The second boolean
  32982. // return value indicates that this field was not set, or was not defined in the
  32983. // schema.
  32984. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  32985. switch name {
  32986. case wpchatroommember.FieldCreatedAt:
  32987. return m.CreatedAt()
  32988. case wpchatroommember.FieldUpdatedAt:
  32989. return m.UpdatedAt()
  32990. case wpchatroommember.FieldStatus:
  32991. return m.Status()
  32992. case wpchatroommember.FieldWxWxid:
  32993. return m.WxWxid()
  32994. case wpchatroommember.FieldWxid:
  32995. return m.Wxid()
  32996. case wpchatroommember.FieldNickname:
  32997. return m.Nickname()
  32998. case wpchatroommember.FieldAvatar:
  32999. return m.Avatar()
  33000. }
  33001. return nil, false
  33002. }
  33003. // OldField returns the old value of the field from the database. An error is
  33004. // returned if the mutation operation is not UpdateOne, or the query to the
  33005. // database failed.
  33006. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33007. switch name {
  33008. case wpchatroommember.FieldCreatedAt:
  33009. return m.OldCreatedAt(ctx)
  33010. case wpchatroommember.FieldUpdatedAt:
  33011. return m.OldUpdatedAt(ctx)
  33012. case wpchatroommember.FieldStatus:
  33013. return m.OldStatus(ctx)
  33014. case wpchatroommember.FieldWxWxid:
  33015. return m.OldWxWxid(ctx)
  33016. case wpchatroommember.FieldWxid:
  33017. return m.OldWxid(ctx)
  33018. case wpchatroommember.FieldNickname:
  33019. return m.OldNickname(ctx)
  33020. case wpchatroommember.FieldAvatar:
  33021. return m.OldAvatar(ctx)
  33022. }
  33023. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  33024. }
  33025. // SetField sets the value of a field with the given name. It returns an error if
  33026. // the field is not defined in the schema, or if the type mismatched the field
  33027. // type.
  33028. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  33029. switch name {
  33030. case wpchatroommember.FieldCreatedAt:
  33031. v, ok := value.(time.Time)
  33032. if !ok {
  33033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33034. }
  33035. m.SetCreatedAt(v)
  33036. return nil
  33037. case wpchatroommember.FieldUpdatedAt:
  33038. v, ok := value.(time.Time)
  33039. if !ok {
  33040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33041. }
  33042. m.SetUpdatedAt(v)
  33043. return nil
  33044. case wpchatroommember.FieldStatus:
  33045. v, ok := value.(uint8)
  33046. if !ok {
  33047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33048. }
  33049. m.SetStatus(v)
  33050. return nil
  33051. case wpchatroommember.FieldWxWxid:
  33052. v, ok := value.(string)
  33053. if !ok {
  33054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33055. }
  33056. m.SetWxWxid(v)
  33057. return nil
  33058. case wpchatroommember.FieldWxid:
  33059. v, ok := value.(string)
  33060. if !ok {
  33061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33062. }
  33063. m.SetWxid(v)
  33064. return nil
  33065. case wpchatroommember.FieldNickname:
  33066. v, ok := value.(string)
  33067. if !ok {
  33068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33069. }
  33070. m.SetNickname(v)
  33071. return nil
  33072. case wpchatroommember.FieldAvatar:
  33073. v, ok := value.(string)
  33074. if !ok {
  33075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33076. }
  33077. m.SetAvatar(v)
  33078. return nil
  33079. }
  33080. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  33081. }
  33082. // AddedFields returns all numeric fields that were incremented/decremented during
  33083. // this mutation.
  33084. func (m *WpChatroomMemberMutation) AddedFields() []string {
  33085. var fields []string
  33086. if m.addstatus != nil {
  33087. fields = append(fields, wpchatroommember.FieldStatus)
  33088. }
  33089. return fields
  33090. }
  33091. // AddedField returns the numeric value that was incremented/decremented on a field
  33092. // with the given name. The second boolean return value indicates that this field
  33093. // was not set, or was not defined in the schema.
  33094. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  33095. switch name {
  33096. case wpchatroommember.FieldStatus:
  33097. return m.AddedStatus()
  33098. }
  33099. return nil, false
  33100. }
  33101. // AddField adds the value to the field with the given name. It returns an error if
  33102. // the field is not defined in the schema, or if the type mismatched the field
  33103. // type.
  33104. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  33105. switch name {
  33106. case wpchatroommember.FieldStatus:
  33107. v, ok := value.(int8)
  33108. if !ok {
  33109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33110. }
  33111. m.AddStatus(v)
  33112. return nil
  33113. }
  33114. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  33115. }
  33116. // ClearedFields returns all nullable fields that were cleared during this
  33117. // mutation.
  33118. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  33119. var fields []string
  33120. if m.FieldCleared(wpchatroommember.FieldStatus) {
  33121. fields = append(fields, wpchatroommember.FieldStatus)
  33122. }
  33123. return fields
  33124. }
  33125. // FieldCleared returns a boolean indicating if a field with the given name was
  33126. // cleared in this mutation.
  33127. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  33128. _, ok := m.clearedFields[name]
  33129. return ok
  33130. }
  33131. // ClearField clears the value of the field with the given name. It returns an
  33132. // error if the field is not defined in the schema.
  33133. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  33134. switch name {
  33135. case wpchatroommember.FieldStatus:
  33136. m.ClearStatus()
  33137. return nil
  33138. }
  33139. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  33140. }
  33141. // ResetField resets all changes in the mutation for the field with the given name.
  33142. // It returns an error if the field is not defined in the schema.
  33143. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  33144. switch name {
  33145. case wpchatroommember.FieldCreatedAt:
  33146. m.ResetCreatedAt()
  33147. return nil
  33148. case wpchatroommember.FieldUpdatedAt:
  33149. m.ResetUpdatedAt()
  33150. return nil
  33151. case wpchatroommember.FieldStatus:
  33152. m.ResetStatus()
  33153. return nil
  33154. case wpchatroommember.FieldWxWxid:
  33155. m.ResetWxWxid()
  33156. return nil
  33157. case wpchatroommember.FieldWxid:
  33158. m.ResetWxid()
  33159. return nil
  33160. case wpchatroommember.FieldNickname:
  33161. m.ResetNickname()
  33162. return nil
  33163. case wpchatroommember.FieldAvatar:
  33164. m.ResetAvatar()
  33165. return nil
  33166. }
  33167. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  33168. }
  33169. // AddedEdges returns all edge names that were set/added in this mutation.
  33170. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  33171. edges := make([]string, 0, 0)
  33172. return edges
  33173. }
  33174. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33175. // name in this mutation.
  33176. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  33177. return nil
  33178. }
  33179. // RemovedEdges returns all edge names that were removed in this mutation.
  33180. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  33181. edges := make([]string, 0, 0)
  33182. return edges
  33183. }
  33184. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33185. // the given name in this mutation.
  33186. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  33187. return nil
  33188. }
  33189. // ClearedEdges returns all edge names that were cleared in this mutation.
  33190. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  33191. edges := make([]string, 0, 0)
  33192. return edges
  33193. }
  33194. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33195. // was cleared in this mutation.
  33196. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  33197. return false
  33198. }
  33199. // ClearEdge clears the value of the edge with the given name. It returns an error
  33200. // if that edge is not defined in the schema.
  33201. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  33202. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  33203. }
  33204. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33205. // It returns an error if the edge is not defined in the schema.
  33206. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  33207. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  33208. }
  33209. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  33210. type WxMutation struct {
  33211. config
  33212. op Op
  33213. typ string
  33214. id *uint64
  33215. created_at *time.Time
  33216. updated_at *time.Time
  33217. status *uint8
  33218. addstatus *int8
  33219. deleted_at *time.Time
  33220. port *string
  33221. process_id *string
  33222. callback *string
  33223. wxid *string
  33224. account *string
  33225. nickname *string
  33226. tel *string
  33227. head_big *string
  33228. organization_id *uint64
  33229. addorganization_id *int64
  33230. api_base *string
  33231. api_key *string
  33232. allow_list *[]string
  33233. appendallow_list []string
  33234. group_allow_list *[]string
  33235. appendgroup_allow_list []string
  33236. block_list *[]string
  33237. appendblock_list []string
  33238. group_block_list *[]string
  33239. appendgroup_block_list []string
  33240. clearedFields map[string]struct{}
  33241. server *uint64
  33242. clearedserver bool
  33243. agent *uint64
  33244. clearedagent bool
  33245. done bool
  33246. oldValue func(context.Context) (*Wx, error)
  33247. predicates []predicate.Wx
  33248. }
  33249. var _ ent.Mutation = (*WxMutation)(nil)
  33250. // wxOption allows management of the mutation configuration using functional options.
  33251. type wxOption func(*WxMutation)
  33252. // newWxMutation creates new mutation for the Wx entity.
  33253. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  33254. m := &WxMutation{
  33255. config: c,
  33256. op: op,
  33257. typ: TypeWx,
  33258. clearedFields: make(map[string]struct{}),
  33259. }
  33260. for _, opt := range opts {
  33261. opt(m)
  33262. }
  33263. return m
  33264. }
  33265. // withWxID sets the ID field of the mutation.
  33266. func withWxID(id uint64) wxOption {
  33267. return func(m *WxMutation) {
  33268. var (
  33269. err error
  33270. once sync.Once
  33271. value *Wx
  33272. )
  33273. m.oldValue = func(ctx context.Context) (*Wx, error) {
  33274. once.Do(func() {
  33275. if m.done {
  33276. err = errors.New("querying old values post mutation is not allowed")
  33277. } else {
  33278. value, err = m.Client().Wx.Get(ctx, id)
  33279. }
  33280. })
  33281. return value, err
  33282. }
  33283. m.id = &id
  33284. }
  33285. }
  33286. // withWx sets the old Wx of the mutation.
  33287. func withWx(node *Wx) wxOption {
  33288. return func(m *WxMutation) {
  33289. m.oldValue = func(context.Context) (*Wx, error) {
  33290. return node, nil
  33291. }
  33292. m.id = &node.ID
  33293. }
  33294. }
  33295. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33296. // executed in a transaction (ent.Tx), a transactional client is returned.
  33297. func (m WxMutation) Client() *Client {
  33298. client := &Client{config: m.config}
  33299. client.init()
  33300. return client
  33301. }
  33302. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33303. // it returns an error otherwise.
  33304. func (m WxMutation) Tx() (*Tx, error) {
  33305. if _, ok := m.driver.(*txDriver); !ok {
  33306. return nil, errors.New("ent: mutation is not running in a transaction")
  33307. }
  33308. tx := &Tx{config: m.config}
  33309. tx.init()
  33310. return tx, nil
  33311. }
  33312. // SetID sets the value of the id field. Note that this
  33313. // operation is only accepted on creation of Wx entities.
  33314. func (m *WxMutation) SetID(id uint64) {
  33315. m.id = &id
  33316. }
  33317. // ID returns the ID value in the mutation. Note that the ID is only available
  33318. // if it was provided to the builder or after it was returned from the database.
  33319. func (m *WxMutation) ID() (id uint64, exists bool) {
  33320. if m.id == nil {
  33321. return
  33322. }
  33323. return *m.id, true
  33324. }
  33325. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33326. // That means, if the mutation is applied within a transaction with an isolation level such
  33327. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33328. // or updated by the mutation.
  33329. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  33330. switch {
  33331. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33332. id, exists := m.ID()
  33333. if exists {
  33334. return []uint64{id}, nil
  33335. }
  33336. fallthrough
  33337. case m.op.Is(OpUpdate | OpDelete):
  33338. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  33339. default:
  33340. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33341. }
  33342. }
  33343. // SetCreatedAt sets the "created_at" field.
  33344. func (m *WxMutation) SetCreatedAt(t time.Time) {
  33345. m.created_at = &t
  33346. }
  33347. // CreatedAt returns the value of the "created_at" field in the mutation.
  33348. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  33349. v := m.created_at
  33350. if v == nil {
  33351. return
  33352. }
  33353. return *v, true
  33354. }
  33355. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  33356. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33358. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33359. if !m.op.Is(OpUpdateOne) {
  33360. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33361. }
  33362. if m.id == nil || m.oldValue == nil {
  33363. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33364. }
  33365. oldValue, err := m.oldValue(ctx)
  33366. if err != nil {
  33367. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33368. }
  33369. return oldValue.CreatedAt, nil
  33370. }
  33371. // ResetCreatedAt resets all changes to the "created_at" field.
  33372. func (m *WxMutation) ResetCreatedAt() {
  33373. m.created_at = nil
  33374. }
  33375. // SetUpdatedAt sets the "updated_at" field.
  33376. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  33377. m.updated_at = &t
  33378. }
  33379. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33380. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  33381. v := m.updated_at
  33382. if v == nil {
  33383. return
  33384. }
  33385. return *v, true
  33386. }
  33387. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  33388. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33390. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33391. if !m.op.Is(OpUpdateOne) {
  33392. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33393. }
  33394. if m.id == nil || m.oldValue == nil {
  33395. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33396. }
  33397. oldValue, err := m.oldValue(ctx)
  33398. if err != nil {
  33399. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33400. }
  33401. return oldValue.UpdatedAt, nil
  33402. }
  33403. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33404. func (m *WxMutation) ResetUpdatedAt() {
  33405. m.updated_at = nil
  33406. }
  33407. // SetStatus sets the "status" field.
  33408. func (m *WxMutation) SetStatus(u uint8) {
  33409. m.status = &u
  33410. m.addstatus = nil
  33411. }
  33412. // Status returns the value of the "status" field in the mutation.
  33413. func (m *WxMutation) Status() (r uint8, exists bool) {
  33414. v := m.status
  33415. if v == nil {
  33416. return
  33417. }
  33418. return *v, true
  33419. }
  33420. // OldStatus returns the old "status" field's value of the Wx entity.
  33421. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33423. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33424. if !m.op.Is(OpUpdateOne) {
  33425. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33426. }
  33427. if m.id == nil || m.oldValue == nil {
  33428. return v, errors.New("OldStatus requires an ID field in the mutation")
  33429. }
  33430. oldValue, err := m.oldValue(ctx)
  33431. if err != nil {
  33432. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33433. }
  33434. return oldValue.Status, nil
  33435. }
  33436. // AddStatus adds u to the "status" field.
  33437. func (m *WxMutation) AddStatus(u int8) {
  33438. if m.addstatus != nil {
  33439. *m.addstatus += u
  33440. } else {
  33441. m.addstatus = &u
  33442. }
  33443. }
  33444. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33445. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  33446. v := m.addstatus
  33447. if v == nil {
  33448. return
  33449. }
  33450. return *v, true
  33451. }
  33452. // ClearStatus clears the value of the "status" field.
  33453. func (m *WxMutation) ClearStatus() {
  33454. m.status = nil
  33455. m.addstatus = nil
  33456. m.clearedFields[wx.FieldStatus] = struct{}{}
  33457. }
  33458. // StatusCleared returns if the "status" field was cleared in this mutation.
  33459. func (m *WxMutation) StatusCleared() bool {
  33460. _, ok := m.clearedFields[wx.FieldStatus]
  33461. return ok
  33462. }
  33463. // ResetStatus resets all changes to the "status" field.
  33464. func (m *WxMutation) ResetStatus() {
  33465. m.status = nil
  33466. m.addstatus = nil
  33467. delete(m.clearedFields, wx.FieldStatus)
  33468. }
  33469. // SetDeletedAt sets the "deleted_at" field.
  33470. func (m *WxMutation) SetDeletedAt(t time.Time) {
  33471. m.deleted_at = &t
  33472. }
  33473. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33474. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  33475. v := m.deleted_at
  33476. if v == nil {
  33477. return
  33478. }
  33479. return *v, true
  33480. }
  33481. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  33482. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33484. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33485. if !m.op.Is(OpUpdateOne) {
  33486. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33487. }
  33488. if m.id == nil || m.oldValue == nil {
  33489. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33490. }
  33491. oldValue, err := m.oldValue(ctx)
  33492. if err != nil {
  33493. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33494. }
  33495. return oldValue.DeletedAt, nil
  33496. }
  33497. // ClearDeletedAt clears the value of the "deleted_at" field.
  33498. func (m *WxMutation) ClearDeletedAt() {
  33499. m.deleted_at = nil
  33500. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  33501. }
  33502. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33503. func (m *WxMutation) DeletedAtCleared() bool {
  33504. _, ok := m.clearedFields[wx.FieldDeletedAt]
  33505. return ok
  33506. }
  33507. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33508. func (m *WxMutation) ResetDeletedAt() {
  33509. m.deleted_at = nil
  33510. delete(m.clearedFields, wx.FieldDeletedAt)
  33511. }
  33512. // SetServerID sets the "server_id" field.
  33513. func (m *WxMutation) SetServerID(u uint64) {
  33514. m.server = &u
  33515. }
  33516. // ServerID returns the value of the "server_id" field in the mutation.
  33517. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  33518. v := m.server
  33519. if v == nil {
  33520. return
  33521. }
  33522. return *v, true
  33523. }
  33524. // OldServerID returns the old "server_id" field's value of the Wx entity.
  33525. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33527. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  33528. if !m.op.Is(OpUpdateOne) {
  33529. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  33530. }
  33531. if m.id == nil || m.oldValue == nil {
  33532. return v, errors.New("OldServerID requires an ID field in the mutation")
  33533. }
  33534. oldValue, err := m.oldValue(ctx)
  33535. if err != nil {
  33536. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  33537. }
  33538. return oldValue.ServerID, nil
  33539. }
  33540. // ClearServerID clears the value of the "server_id" field.
  33541. func (m *WxMutation) ClearServerID() {
  33542. m.server = nil
  33543. m.clearedFields[wx.FieldServerID] = struct{}{}
  33544. }
  33545. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  33546. func (m *WxMutation) ServerIDCleared() bool {
  33547. _, ok := m.clearedFields[wx.FieldServerID]
  33548. return ok
  33549. }
  33550. // ResetServerID resets all changes to the "server_id" field.
  33551. func (m *WxMutation) ResetServerID() {
  33552. m.server = nil
  33553. delete(m.clearedFields, wx.FieldServerID)
  33554. }
  33555. // SetPort sets the "port" field.
  33556. func (m *WxMutation) SetPort(s string) {
  33557. m.port = &s
  33558. }
  33559. // Port returns the value of the "port" field in the mutation.
  33560. func (m *WxMutation) Port() (r string, exists bool) {
  33561. v := m.port
  33562. if v == nil {
  33563. return
  33564. }
  33565. return *v, true
  33566. }
  33567. // OldPort returns the old "port" field's value of the Wx entity.
  33568. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33570. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  33571. if !m.op.Is(OpUpdateOne) {
  33572. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  33573. }
  33574. if m.id == nil || m.oldValue == nil {
  33575. return v, errors.New("OldPort requires an ID field in the mutation")
  33576. }
  33577. oldValue, err := m.oldValue(ctx)
  33578. if err != nil {
  33579. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  33580. }
  33581. return oldValue.Port, nil
  33582. }
  33583. // ResetPort resets all changes to the "port" field.
  33584. func (m *WxMutation) ResetPort() {
  33585. m.port = nil
  33586. }
  33587. // SetProcessID sets the "process_id" field.
  33588. func (m *WxMutation) SetProcessID(s string) {
  33589. m.process_id = &s
  33590. }
  33591. // ProcessID returns the value of the "process_id" field in the mutation.
  33592. func (m *WxMutation) ProcessID() (r string, exists bool) {
  33593. v := m.process_id
  33594. if v == nil {
  33595. return
  33596. }
  33597. return *v, true
  33598. }
  33599. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  33600. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33602. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  33603. if !m.op.Is(OpUpdateOne) {
  33604. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  33605. }
  33606. if m.id == nil || m.oldValue == nil {
  33607. return v, errors.New("OldProcessID requires an ID field in the mutation")
  33608. }
  33609. oldValue, err := m.oldValue(ctx)
  33610. if err != nil {
  33611. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  33612. }
  33613. return oldValue.ProcessID, nil
  33614. }
  33615. // ResetProcessID resets all changes to the "process_id" field.
  33616. func (m *WxMutation) ResetProcessID() {
  33617. m.process_id = nil
  33618. }
  33619. // SetCallback sets the "callback" field.
  33620. func (m *WxMutation) SetCallback(s string) {
  33621. m.callback = &s
  33622. }
  33623. // Callback returns the value of the "callback" field in the mutation.
  33624. func (m *WxMutation) Callback() (r string, exists bool) {
  33625. v := m.callback
  33626. if v == nil {
  33627. return
  33628. }
  33629. return *v, true
  33630. }
  33631. // OldCallback returns the old "callback" field's value of the Wx entity.
  33632. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33634. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  33635. if !m.op.Is(OpUpdateOne) {
  33636. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  33637. }
  33638. if m.id == nil || m.oldValue == nil {
  33639. return v, errors.New("OldCallback requires an ID field in the mutation")
  33640. }
  33641. oldValue, err := m.oldValue(ctx)
  33642. if err != nil {
  33643. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  33644. }
  33645. return oldValue.Callback, nil
  33646. }
  33647. // ResetCallback resets all changes to the "callback" field.
  33648. func (m *WxMutation) ResetCallback() {
  33649. m.callback = nil
  33650. }
  33651. // SetWxid sets the "wxid" field.
  33652. func (m *WxMutation) SetWxid(s string) {
  33653. m.wxid = &s
  33654. }
  33655. // Wxid returns the value of the "wxid" field in the mutation.
  33656. func (m *WxMutation) Wxid() (r string, exists bool) {
  33657. v := m.wxid
  33658. if v == nil {
  33659. return
  33660. }
  33661. return *v, true
  33662. }
  33663. // OldWxid returns the old "wxid" field's value of the Wx entity.
  33664. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33666. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  33667. if !m.op.Is(OpUpdateOne) {
  33668. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  33669. }
  33670. if m.id == nil || m.oldValue == nil {
  33671. return v, errors.New("OldWxid requires an ID field in the mutation")
  33672. }
  33673. oldValue, err := m.oldValue(ctx)
  33674. if err != nil {
  33675. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  33676. }
  33677. return oldValue.Wxid, nil
  33678. }
  33679. // ResetWxid resets all changes to the "wxid" field.
  33680. func (m *WxMutation) ResetWxid() {
  33681. m.wxid = nil
  33682. }
  33683. // SetAccount sets the "account" field.
  33684. func (m *WxMutation) SetAccount(s string) {
  33685. m.account = &s
  33686. }
  33687. // Account returns the value of the "account" field in the mutation.
  33688. func (m *WxMutation) Account() (r string, exists bool) {
  33689. v := m.account
  33690. if v == nil {
  33691. return
  33692. }
  33693. return *v, true
  33694. }
  33695. // OldAccount returns the old "account" field's value of the Wx entity.
  33696. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33698. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  33699. if !m.op.Is(OpUpdateOne) {
  33700. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  33701. }
  33702. if m.id == nil || m.oldValue == nil {
  33703. return v, errors.New("OldAccount requires an ID field in the mutation")
  33704. }
  33705. oldValue, err := m.oldValue(ctx)
  33706. if err != nil {
  33707. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  33708. }
  33709. return oldValue.Account, nil
  33710. }
  33711. // ResetAccount resets all changes to the "account" field.
  33712. func (m *WxMutation) ResetAccount() {
  33713. m.account = nil
  33714. }
  33715. // SetNickname sets the "nickname" field.
  33716. func (m *WxMutation) SetNickname(s string) {
  33717. m.nickname = &s
  33718. }
  33719. // Nickname returns the value of the "nickname" field in the mutation.
  33720. func (m *WxMutation) Nickname() (r string, exists bool) {
  33721. v := m.nickname
  33722. if v == nil {
  33723. return
  33724. }
  33725. return *v, true
  33726. }
  33727. // OldNickname returns the old "nickname" field's value of the Wx entity.
  33728. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33730. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  33731. if !m.op.Is(OpUpdateOne) {
  33732. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  33733. }
  33734. if m.id == nil || m.oldValue == nil {
  33735. return v, errors.New("OldNickname requires an ID field in the mutation")
  33736. }
  33737. oldValue, err := m.oldValue(ctx)
  33738. if err != nil {
  33739. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  33740. }
  33741. return oldValue.Nickname, nil
  33742. }
  33743. // ResetNickname resets all changes to the "nickname" field.
  33744. func (m *WxMutation) ResetNickname() {
  33745. m.nickname = nil
  33746. }
  33747. // SetTel sets the "tel" field.
  33748. func (m *WxMutation) SetTel(s string) {
  33749. m.tel = &s
  33750. }
  33751. // Tel returns the value of the "tel" field in the mutation.
  33752. func (m *WxMutation) Tel() (r string, exists bool) {
  33753. v := m.tel
  33754. if v == nil {
  33755. return
  33756. }
  33757. return *v, true
  33758. }
  33759. // OldTel returns the old "tel" field's value of the Wx entity.
  33760. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33762. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  33763. if !m.op.Is(OpUpdateOne) {
  33764. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  33765. }
  33766. if m.id == nil || m.oldValue == nil {
  33767. return v, errors.New("OldTel requires an ID field in the mutation")
  33768. }
  33769. oldValue, err := m.oldValue(ctx)
  33770. if err != nil {
  33771. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  33772. }
  33773. return oldValue.Tel, nil
  33774. }
  33775. // ResetTel resets all changes to the "tel" field.
  33776. func (m *WxMutation) ResetTel() {
  33777. m.tel = nil
  33778. }
  33779. // SetHeadBig sets the "head_big" field.
  33780. func (m *WxMutation) SetHeadBig(s string) {
  33781. m.head_big = &s
  33782. }
  33783. // HeadBig returns the value of the "head_big" field in the mutation.
  33784. func (m *WxMutation) HeadBig() (r string, exists bool) {
  33785. v := m.head_big
  33786. if v == nil {
  33787. return
  33788. }
  33789. return *v, true
  33790. }
  33791. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  33792. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33794. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  33795. if !m.op.Is(OpUpdateOne) {
  33796. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  33797. }
  33798. if m.id == nil || m.oldValue == nil {
  33799. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  33800. }
  33801. oldValue, err := m.oldValue(ctx)
  33802. if err != nil {
  33803. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  33804. }
  33805. return oldValue.HeadBig, nil
  33806. }
  33807. // ResetHeadBig resets all changes to the "head_big" field.
  33808. func (m *WxMutation) ResetHeadBig() {
  33809. m.head_big = nil
  33810. }
  33811. // SetOrganizationID sets the "organization_id" field.
  33812. func (m *WxMutation) SetOrganizationID(u uint64) {
  33813. m.organization_id = &u
  33814. m.addorganization_id = nil
  33815. }
  33816. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33817. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  33818. v := m.organization_id
  33819. if v == nil {
  33820. return
  33821. }
  33822. return *v, true
  33823. }
  33824. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  33825. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33827. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33828. if !m.op.Is(OpUpdateOne) {
  33829. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33830. }
  33831. if m.id == nil || m.oldValue == nil {
  33832. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33833. }
  33834. oldValue, err := m.oldValue(ctx)
  33835. if err != nil {
  33836. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33837. }
  33838. return oldValue.OrganizationID, nil
  33839. }
  33840. // AddOrganizationID adds u to the "organization_id" field.
  33841. func (m *WxMutation) AddOrganizationID(u int64) {
  33842. if m.addorganization_id != nil {
  33843. *m.addorganization_id += u
  33844. } else {
  33845. m.addorganization_id = &u
  33846. }
  33847. }
  33848. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33849. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  33850. v := m.addorganization_id
  33851. if v == nil {
  33852. return
  33853. }
  33854. return *v, true
  33855. }
  33856. // ClearOrganizationID clears the value of the "organization_id" field.
  33857. func (m *WxMutation) ClearOrganizationID() {
  33858. m.organization_id = nil
  33859. m.addorganization_id = nil
  33860. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  33861. }
  33862. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33863. func (m *WxMutation) OrganizationIDCleared() bool {
  33864. _, ok := m.clearedFields[wx.FieldOrganizationID]
  33865. return ok
  33866. }
  33867. // ResetOrganizationID resets all changes to the "organization_id" field.
  33868. func (m *WxMutation) ResetOrganizationID() {
  33869. m.organization_id = nil
  33870. m.addorganization_id = nil
  33871. delete(m.clearedFields, wx.FieldOrganizationID)
  33872. }
  33873. // SetAgentID sets the "agent_id" field.
  33874. func (m *WxMutation) SetAgentID(u uint64) {
  33875. m.agent = &u
  33876. }
  33877. // AgentID returns the value of the "agent_id" field in the mutation.
  33878. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  33879. v := m.agent
  33880. if v == nil {
  33881. return
  33882. }
  33883. return *v, true
  33884. }
  33885. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  33886. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33888. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  33889. if !m.op.Is(OpUpdateOne) {
  33890. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  33891. }
  33892. if m.id == nil || m.oldValue == nil {
  33893. return v, errors.New("OldAgentID requires an ID field in the mutation")
  33894. }
  33895. oldValue, err := m.oldValue(ctx)
  33896. if err != nil {
  33897. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  33898. }
  33899. return oldValue.AgentID, nil
  33900. }
  33901. // ResetAgentID resets all changes to the "agent_id" field.
  33902. func (m *WxMutation) ResetAgentID() {
  33903. m.agent = nil
  33904. }
  33905. // SetAPIBase sets the "api_base" field.
  33906. func (m *WxMutation) SetAPIBase(s string) {
  33907. m.api_base = &s
  33908. }
  33909. // APIBase returns the value of the "api_base" field in the mutation.
  33910. func (m *WxMutation) APIBase() (r string, exists bool) {
  33911. v := m.api_base
  33912. if v == nil {
  33913. return
  33914. }
  33915. return *v, true
  33916. }
  33917. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  33918. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33920. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  33921. if !m.op.Is(OpUpdateOne) {
  33922. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  33923. }
  33924. if m.id == nil || m.oldValue == nil {
  33925. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  33926. }
  33927. oldValue, err := m.oldValue(ctx)
  33928. if err != nil {
  33929. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  33930. }
  33931. return oldValue.APIBase, nil
  33932. }
  33933. // ClearAPIBase clears the value of the "api_base" field.
  33934. func (m *WxMutation) ClearAPIBase() {
  33935. m.api_base = nil
  33936. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  33937. }
  33938. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  33939. func (m *WxMutation) APIBaseCleared() bool {
  33940. _, ok := m.clearedFields[wx.FieldAPIBase]
  33941. return ok
  33942. }
  33943. // ResetAPIBase resets all changes to the "api_base" field.
  33944. func (m *WxMutation) ResetAPIBase() {
  33945. m.api_base = nil
  33946. delete(m.clearedFields, wx.FieldAPIBase)
  33947. }
  33948. // SetAPIKey sets the "api_key" field.
  33949. func (m *WxMutation) SetAPIKey(s string) {
  33950. m.api_key = &s
  33951. }
  33952. // APIKey returns the value of the "api_key" field in the mutation.
  33953. func (m *WxMutation) APIKey() (r string, exists bool) {
  33954. v := m.api_key
  33955. if v == nil {
  33956. return
  33957. }
  33958. return *v, true
  33959. }
  33960. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  33961. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33963. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33964. if !m.op.Is(OpUpdateOne) {
  33965. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33966. }
  33967. if m.id == nil || m.oldValue == nil {
  33968. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33969. }
  33970. oldValue, err := m.oldValue(ctx)
  33971. if err != nil {
  33972. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33973. }
  33974. return oldValue.APIKey, nil
  33975. }
  33976. // ClearAPIKey clears the value of the "api_key" field.
  33977. func (m *WxMutation) ClearAPIKey() {
  33978. m.api_key = nil
  33979. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  33980. }
  33981. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33982. func (m *WxMutation) APIKeyCleared() bool {
  33983. _, ok := m.clearedFields[wx.FieldAPIKey]
  33984. return ok
  33985. }
  33986. // ResetAPIKey resets all changes to the "api_key" field.
  33987. func (m *WxMutation) ResetAPIKey() {
  33988. m.api_key = nil
  33989. delete(m.clearedFields, wx.FieldAPIKey)
  33990. }
  33991. // SetAllowList sets the "allow_list" field.
  33992. func (m *WxMutation) SetAllowList(s []string) {
  33993. m.allow_list = &s
  33994. m.appendallow_list = nil
  33995. }
  33996. // AllowList returns the value of the "allow_list" field in the mutation.
  33997. func (m *WxMutation) AllowList() (r []string, exists bool) {
  33998. v := m.allow_list
  33999. if v == nil {
  34000. return
  34001. }
  34002. return *v, true
  34003. }
  34004. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  34005. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34007. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34008. if !m.op.Is(OpUpdateOne) {
  34009. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34010. }
  34011. if m.id == nil || m.oldValue == nil {
  34012. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34013. }
  34014. oldValue, err := m.oldValue(ctx)
  34015. if err != nil {
  34016. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34017. }
  34018. return oldValue.AllowList, nil
  34019. }
  34020. // AppendAllowList adds s to the "allow_list" field.
  34021. func (m *WxMutation) AppendAllowList(s []string) {
  34022. m.appendallow_list = append(m.appendallow_list, s...)
  34023. }
  34024. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34025. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  34026. if len(m.appendallow_list) == 0 {
  34027. return nil, false
  34028. }
  34029. return m.appendallow_list, true
  34030. }
  34031. // ResetAllowList resets all changes to the "allow_list" field.
  34032. func (m *WxMutation) ResetAllowList() {
  34033. m.allow_list = nil
  34034. m.appendallow_list = nil
  34035. }
  34036. // SetGroupAllowList sets the "group_allow_list" field.
  34037. func (m *WxMutation) SetGroupAllowList(s []string) {
  34038. m.group_allow_list = &s
  34039. m.appendgroup_allow_list = nil
  34040. }
  34041. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34042. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  34043. v := m.group_allow_list
  34044. if v == nil {
  34045. return
  34046. }
  34047. return *v, true
  34048. }
  34049. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  34050. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34052. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34053. if !m.op.Is(OpUpdateOne) {
  34054. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34055. }
  34056. if m.id == nil || m.oldValue == nil {
  34057. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34058. }
  34059. oldValue, err := m.oldValue(ctx)
  34060. if err != nil {
  34061. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34062. }
  34063. return oldValue.GroupAllowList, nil
  34064. }
  34065. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34066. func (m *WxMutation) AppendGroupAllowList(s []string) {
  34067. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34068. }
  34069. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34070. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  34071. if len(m.appendgroup_allow_list) == 0 {
  34072. return nil, false
  34073. }
  34074. return m.appendgroup_allow_list, true
  34075. }
  34076. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34077. func (m *WxMutation) ResetGroupAllowList() {
  34078. m.group_allow_list = nil
  34079. m.appendgroup_allow_list = nil
  34080. }
  34081. // SetBlockList sets the "block_list" field.
  34082. func (m *WxMutation) SetBlockList(s []string) {
  34083. m.block_list = &s
  34084. m.appendblock_list = nil
  34085. }
  34086. // BlockList returns the value of the "block_list" field in the mutation.
  34087. func (m *WxMutation) BlockList() (r []string, exists bool) {
  34088. v := m.block_list
  34089. if v == nil {
  34090. return
  34091. }
  34092. return *v, true
  34093. }
  34094. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  34095. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34097. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34098. if !m.op.Is(OpUpdateOne) {
  34099. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34100. }
  34101. if m.id == nil || m.oldValue == nil {
  34102. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34103. }
  34104. oldValue, err := m.oldValue(ctx)
  34105. if err != nil {
  34106. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34107. }
  34108. return oldValue.BlockList, nil
  34109. }
  34110. // AppendBlockList adds s to the "block_list" field.
  34111. func (m *WxMutation) AppendBlockList(s []string) {
  34112. m.appendblock_list = append(m.appendblock_list, s...)
  34113. }
  34114. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34115. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  34116. if len(m.appendblock_list) == 0 {
  34117. return nil, false
  34118. }
  34119. return m.appendblock_list, true
  34120. }
  34121. // ResetBlockList resets all changes to the "block_list" field.
  34122. func (m *WxMutation) ResetBlockList() {
  34123. m.block_list = nil
  34124. m.appendblock_list = nil
  34125. }
  34126. // SetGroupBlockList sets the "group_block_list" field.
  34127. func (m *WxMutation) SetGroupBlockList(s []string) {
  34128. m.group_block_list = &s
  34129. m.appendgroup_block_list = nil
  34130. }
  34131. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34132. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  34133. v := m.group_block_list
  34134. if v == nil {
  34135. return
  34136. }
  34137. return *v, true
  34138. }
  34139. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  34140. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34142. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34143. if !m.op.Is(OpUpdateOne) {
  34144. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34145. }
  34146. if m.id == nil || m.oldValue == nil {
  34147. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34148. }
  34149. oldValue, err := m.oldValue(ctx)
  34150. if err != nil {
  34151. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34152. }
  34153. return oldValue.GroupBlockList, nil
  34154. }
  34155. // AppendGroupBlockList adds s to the "group_block_list" field.
  34156. func (m *WxMutation) AppendGroupBlockList(s []string) {
  34157. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34158. }
  34159. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34160. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  34161. if len(m.appendgroup_block_list) == 0 {
  34162. return nil, false
  34163. }
  34164. return m.appendgroup_block_list, true
  34165. }
  34166. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34167. func (m *WxMutation) ResetGroupBlockList() {
  34168. m.group_block_list = nil
  34169. m.appendgroup_block_list = nil
  34170. }
  34171. // ClearServer clears the "server" edge to the Server entity.
  34172. func (m *WxMutation) ClearServer() {
  34173. m.clearedserver = true
  34174. m.clearedFields[wx.FieldServerID] = struct{}{}
  34175. }
  34176. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  34177. func (m *WxMutation) ServerCleared() bool {
  34178. return m.ServerIDCleared() || m.clearedserver
  34179. }
  34180. // ServerIDs returns the "server" edge IDs in the mutation.
  34181. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34182. // ServerID instead. It exists only for internal usage by the builders.
  34183. func (m *WxMutation) ServerIDs() (ids []uint64) {
  34184. if id := m.server; id != nil {
  34185. ids = append(ids, *id)
  34186. }
  34187. return
  34188. }
  34189. // ResetServer resets all changes to the "server" edge.
  34190. func (m *WxMutation) ResetServer() {
  34191. m.server = nil
  34192. m.clearedserver = false
  34193. }
  34194. // ClearAgent clears the "agent" edge to the Agent entity.
  34195. func (m *WxMutation) ClearAgent() {
  34196. m.clearedagent = true
  34197. m.clearedFields[wx.FieldAgentID] = struct{}{}
  34198. }
  34199. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34200. func (m *WxMutation) AgentCleared() bool {
  34201. return m.clearedagent
  34202. }
  34203. // AgentIDs returns the "agent" edge IDs in the mutation.
  34204. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34205. // AgentID instead. It exists only for internal usage by the builders.
  34206. func (m *WxMutation) AgentIDs() (ids []uint64) {
  34207. if id := m.agent; id != nil {
  34208. ids = append(ids, *id)
  34209. }
  34210. return
  34211. }
  34212. // ResetAgent resets all changes to the "agent" edge.
  34213. func (m *WxMutation) ResetAgent() {
  34214. m.agent = nil
  34215. m.clearedagent = false
  34216. }
  34217. // Where appends a list predicates to the WxMutation builder.
  34218. func (m *WxMutation) Where(ps ...predicate.Wx) {
  34219. m.predicates = append(m.predicates, ps...)
  34220. }
  34221. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  34222. // users can use type-assertion to append predicates that do not depend on any generated package.
  34223. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  34224. p := make([]predicate.Wx, len(ps))
  34225. for i := range ps {
  34226. p[i] = ps[i]
  34227. }
  34228. m.Where(p...)
  34229. }
  34230. // Op returns the operation name.
  34231. func (m *WxMutation) Op() Op {
  34232. return m.op
  34233. }
  34234. // SetOp allows setting the mutation operation.
  34235. func (m *WxMutation) SetOp(op Op) {
  34236. m.op = op
  34237. }
  34238. // Type returns the node type of this mutation (Wx).
  34239. func (m *WxMutation) Type() string {
  34240. return m.typ
  34241. }
  34242. // Fields returns all fields that were changed during this mutation. Note that in
  34243. // order to get all numeric fields that were incremented/decremented, call
  34244. // AddedFields().
  34245. func (m *WxMutation) Fields() []string {
  34246. fields := make([]string, 0, 21)
  34247. if m.created_at != nil {
  34248. fields = append(fields, wx.FieldCreatedAt)
  34249. }
  34250. if m.updated_at != nil {
  34251. fields = append(fields, wx.FieldUpdatedAt)
  34252. }
  34253. if m.status != nil {
  34254. fields = append(fields, wx.FieldStatus)
  34255. }
  34256. if m.deleted_at != nil {
  34257. fields = append(fields, wx.FieldDeletedAt)
  34258. }
  34259. if m.server != nil {
  34260. fields = append(fields, wx.FieldServerID)
  34261. }
  34262. if m.port != nil {
  34263. fields = append(fields, wx.FieldPort)
  34264. }
  34265. if m.process_id != nil {
  34266. fields = append(fields, wx.FieldProcessID)
  34267. }
  34268. if m.callback != nil {
  34269. fields = append(fields, wx.FieldCallback)
  34270. }
  34271. if m.wxid != nil {
  34272. fields = append(fields, wx.FieldWxid)
  34273. }
  34274. if m.account != nil {
  34275. fields = append(fields, wx.FieldAccount)
  34276. }
  34277. if m.nickname != nil {
  34278. fields = append(fields, wx.FieldNickname)
  34279. }
  34280. if m.tel != nil {
  34281. fields = append(fields, wx.FieldTel)
  34282. }
  34283. if m.head_big != nil {
  34284. fields = append(fields, wx.FieldHeadBig)
  34285. }
  34286. if m.organization_id != nil {
  34287. fields = append(fields, wx.FieldOrganizationID)
  34288. }
  34289. if m.agent != nil {
  34290. fields = append(fields, wx.FieldAgentID)
  34291. }
  34292. if m.api_base != nil {
  34293. fields = append(fields, wx.FieldAPIBase)
  34294. }
  34295. if m.api_key != nil {
  34296. fields = append(fields, wx.FieldAPIKey)
  34297. }
  34298. if m.allow_list != nil {
  34299. fields = append(fields, wx.FieldAllowList)
  34300. }
  34301. if m.group_allow_list != nil {
  34302. fields = append(fields, wx.FieldGroupAllowList)
  34303. }
  34304. if m.block_list != nil {
  34305. fields = append(fields, wx.FieldBlockList)
  34306. }
  34307. if m.group_block_list != nil {
  34308. fields = append(fields, wx.FieldGroupBlockList)
  34309. }
  34310. return fields
  34311. }
  34312. // Field returns the value of a field with the given name. The second boolean
  34313. // return value indicates that this field was not set, or was not defined in the
  34314. // schema.
  34315. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  34316. switch name {
  34317. case wx.FieldCreatedAt:
  34318. return m.CreatedAt()
  34319. case wx.FieldUpdatedAt:
  34320. return m.UpdatedAt()
  34321. case wx.FieldStatus:
  34322. return m.Status()
  34323. case wx.FieldDeletedAt:
  34324. return m.DeletedAt()
  34325. case wx.FieldServerID:
  34326. return m.ServerID()
  34327. case wx.FieldPort:
  34328. return m.Port()
  34329. case wx.FieldProcessID:
  34330. return m.ProcessID()
  34331. case wx.FieldCallback:
  34332. return m.Callback()
  34333. case wx.FieldWxid:
  34334. return m.Wxid()
  34335. case wx.FieldAccount:
  34336. return m.Account()
  34337. case wx.FieldNickname:
  34338. return m.Nickname()
  34339. case wx.FieldTel:
  34340. return m.Tel()
  34341. case wx.FieldHeadBig:
  34342. return m.HeadBig()
  34343. case wx.FieldOrganizationID:
  34344. return m.OrganizationID()
  34345. case wx.FieldAgentID:
  34346. return m.AgentID()
  34347. case wx.FieldAPIBase:
  34348. return m.APIBase()
  34349. case wx.FieldAPIKey:
  34350. return m.APIKey()
  34351. case wx.FieldAllowList:
  34352. return m.AllowList()
  34353. case wx.FieldGroupAllowList:
  34354. return m.GroupAllowList()
  34355. case wx.FieldBlockList:
  34356. return m.BlockList()
  34357. case wx.FieldGroupBlockList:
  34358. return m.GroupBlockList()
  34359. }
  34360. return nil, false
  34361. }
  34362. // OldField returns the old value of the field from the database. An error is
  34363. // returned if the mutation operation is not UpdateOne, or the query to the
  34364. // database failed.
  34365. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34366. switch name {
  34367. case wx.FieldCreatedAt:
  34368. return m.OldCreatedAt(ctx)
  34369. case wx.FieldUpdatedAt:
  34370. return m.OldUpdatedAt(ctx)
  34371. case wx.FieldStatus:
  34372. return m.OldStatus(ctx)
  34373. case wx.FieldDeletedAt:
  34374. return m.OldDeletedAt(ctx)
  34375. case wx.FieldServerID:
  34376. return m.OldServerID(ctx)
  34377. case wx.FieldPort:
  34378. return m.OldPort(ctx)
  34379. case wx.FieldProcessID:
  34380. return m.OldProcessID(ctx)
  34381. case wx.FieldCallback:
  34382. return m.OldCallback(ctx)
  34383. case wx.FieldWxid:
  34384. return m.OldWxid(ctx)
  34385. case wx.FieldAccount:
  34386. return m.OldAccount(ctx)
  34387. case wx.FieldNickname:
  34388. return m.OldNickname(ctx)
  34389. case wx.FieldTel:
  34390. return m.OldTel(ctx)
  34391. case wx.FieldHeadBig:
  34392. return m.OldHeadBig(ctx)
  34393. case wx.FieldOrganizationID:
  34394. return m.OldOrganizationID(ctx)
  34395. case wx.FieldAgentID:
  34396. return m.OldAgentID(ctx)
  34397. case wx.FieldAPIBase:
  34398. return m.OldAPIBase(ctx)
  34399. case wx.FieldAPIKey:
  34400. return m.OldAPIKey(ctx)
  34401. case wx.FieldAllowList:
  34402. return m.OldAllowList(ctx)
  34403. case wx.FieldGroupAllowList:
  34404. return m.OldGroupAllowList(ctx)
  34405. case wx.FieldBlockList:
  34406. return m.OldBlockList(ctx)
  34407. case wx.FieldGroupBlockList:
  34408. return m.OldGroupBlockList(ctx)
  34409. }
  34410. return nil, fmt.Errorf("unknown Wx field %s", name)
  34411. }
  34412. // SetField sets the value of a field with the given name. It returns an error if
  34413. // the field is not defined in the schema, or if the type mismatched the field
  34414. // type.
  34415. func (m *WxMutation) SetField(name string, value ent.Value) error {
  34416. switch name {
  34417. case wx.FieldCreatedAt:
  34418. v, ok := value.(time.Time)
  34419. if !ok {
  34420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34421. }
  34422. m.SetCreatedAt(v)
  34423. return nil
  34424. case wx.FieldUpdatedAt:
  34425. v, ok := value.(time.Time)
  34426. if !ok {
  34427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34428. }
  34429. m.SetUpdatedAt(v)
  34430. return nil
  34431. case wx.FieldStatus:
  34432. v, ok := value.(uint8)
  34433. if !ok {
  34434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34435. }
  34436. m.SetStatus(v)
  34437. return nil
  34438. case wx.FieldDeletedAt:
  34439. v, ok := value.(time.Time)
  34440. if !ok {
  34441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34442. }
  34443. m.SetDeletedAt(v)
  34444. return nil
  34445. case wx.FieldServerID:
  34446. v, ok := value.(uint64)
  34447. if !ok {
  34448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34449. }
  34450. m.SetServerID(v)
  34451. return nil
  34452. case wx.FieldPort:
  34453. v, ok := value.(string)
  34454. if !ok {
  34455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34456. }
  34457. m.SetPort(v)
  34458. return nil
  34459. case wx.FieldProcessID:
  34460. v, ok := value.(string)
  34461. if !ok {
  34462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34463. }
  34464. m.SetProcessID(v)
  34465. return nil
  34466. case wx.FieldCallback:
  34467. v, ok := value.(string)
  34468. if !ok {
  34469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34470. }
  34471. m.SetCallback(v)
  34472. return nil
  34473. case wx.FieldWxid:
  34474. v, ok := value.(string)
  34475. if !ok {
  34476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34477. }
  34478. m.SetWxid(v)
  34479. return nil
  34480. case wx.FieldAccount:
  34481. v, ok := value.(string)
  34482. if !ok {
  34483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34484. }
  34485. m.SetAccount(v)
  34486. return nil
  34487. case wx.FieldNickname:
  34488. v, ok := value.(string)
  34489. if !ok {
  34490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34491. }
  34492. m.SetNickname(v)
  34493. return nil
  34494. case wx.FieldTel:
  34495. v, ok := value.(string)
  34496. if !ok {
  34497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34498. }
  34499. m.SetTel(v)
  34500. return nil
  34501. case wx.FieldHeadBig:
  34502. v, ok := value.(string)
  34503. if !ok {
  34504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34505. }
  34506. m.SetHeadBig(v)
  34507. return nil
  34508. case wx.FieldOrganizationID:
  34509. v, ok := value.(uint64)
  34510. if !ok {
  34511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34512. }
  34513. m.SetOrganizationID(v)
  34514. return nil
  34515. case wx.FieldAgentID:
  34516. v, ok := value.(uint64)
  34517. if !ok {
  34518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34519. }
  34520. m.SetAgentID(v)
  34521. return nil
  34522. case wx.FieldAPIBase:
  34523. v, ok := value.(string)
  34524. if !ok {
  34525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34526. }
  34527. m.SetAPIBase(v)
  34528. return nil
  34529. case wx.FieldAPIKey:
  34530. v, ok := value.(string)
  34531. if !ok {
  34532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34533. }
  34534. m.SetAPIKey(v)
  34535. return nil
  34536. case wx.FieldAllowList:
  34537. v, ok := value.([]string)
  34538. if !ok {
  34539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34540. }
  34541. m.SetAllowList(v)
  34542. return nil
  34543. case wx.FieldGroupAllowList:
  34544. v, ok := value.([]string)
  34545. if !ok {
  34546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34547. }
  34548. m.SetGroupAllowList(v)
  34549. return nil
  34550. case wx.FieldBlockList:
  34551. v, ok := value.([]string)
  34552. if !ok {
  34553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34554. }
  34555. m.SetBlockList(v)
  34556. return nil
  34557. case wx.FieldGroupBlockList:
  34558. v, ok := value.([]string)
  34559. if !ok {
  34560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34561. }
  34562. m.SetGroupBlockList(v)
  34563. return nil
  34564. }
  34565. return fmt.Errorf("unknown Wx field %s", name)
  34566. }
  34567. // AddedFields returns all numeric fields that were incremented/decremented during
  34568. // this mutation.
  34569. func (m *WxMutation) AddedFields() []string {
  34570. var fields []string
  34571. if m.addstatus != nil {
  34572. fields = append(fields, wx.FieldStatus)
  34573. }
  34574. if m.addorganization_id != nil {
  34575. fields = append(fields, wx.FieldOrganizationID)
  34576. }
  34577. return fields
  34578. }
  34579. // AddedField returns the numeric value that was incremented/decremented on a field
  34580. // with the given name. The second boolean return value indicates that this field
  34581. // was not set, or was not defined in the schema.
  34582. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  34583. switch name {
  34584. case wx.FieldStatus:
  34585. return m.AddedStatus()
  34586. case wx.FieldOrganizationID:
  34587. return m.AddedOrganizationID()
  34588. }
  34589. return nil, false
  34590. }
  34591. // AddField adds the value to the field with the given name. It returns an error if
  34592. // the field is not defined in the schema, or if the type mismatched the field
  34593. // type.
  34594. func (m *WxMutation) AddField(name string, value ent.Value) error {
  34595. switch name {
  34596. case wx.FieldStatus:
  34597. v, ok := value.(int8)
  34598. if !ok {
  34599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34600. }
  34601. m.AddStatus(v)
  34602. return nil
  34603. case wx.FieldOrganizationID:
  34604. v, ok := value.(int64)
  34605. if !ok {
  34606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34607. }
  34608. m.AddOrganizationID(v)
  34609. return nil
  34610. }
  34611. return fmt.Errorf("unknown Wx numeric field %s", name)
  34612. }
  34613. // ClearedFields returns all nullable fields that were cleared during this
  34614. // mutation.
  34615. func (m *WxMutation) ClearedFields() []string {
  34616. var fields []string
  34617. if m.FieldCleared(wx.FieldStatus) {
  34618. fields = append(fields, wx.FieldStatus)
  34619. }
  34620. if m.FieldCleared(wx.FieldDeletedAt) {
  34621. fields = append(fields, wx.FieldDeletedAt)
  34622. }
  34623. if m.FieldCleared(wx.FieldServerID) {
  34624. fields = append(fields, wx.FieldServerID)
  34625. }
  34626. if m.FieldCleared(wx.FieldOrganizationID) {
  34627. fields = append(fields, wx.FieldOrganizationID)
  34628. }
  34629. if m.FieldCleared(wx.FieldAPIBase) {
  34630. fields = append(fields, wx.FieldAPIBase)
  34631. }
  34632. if m.FieldCleared(wx.FieldAPIKey) {
  34633. fields = append(fields, wx.FieldAPIKey)
  34634. }
  34635. return fields
  34636. }
  34637. // FieldCleared returns a boolean indicating if a field with the given name was
  34638. // cleared in this mutation.
  34639. func (m *WxMutation) FieldCleared(name string) bool {
  34640. _, ok := m.clearedFields[name]
  34641. return ok
  34642. }
  34643. // ClearField clears the value of the field with the given name. It returns an
  34644. // error if the field is not defined in the schema.
  34645. func (m *WxMutation) ClearField(name string) error {
  34646. switch name {
  34647. case wx.FieldStatus:
  34648. m.ClearStatus()
  34649. return nil
  34650. case wx.FieldDeletedAt:
  34651. m.ClearDeletedAt()
  34652. return nil
  34653. case wx.FieldServerID:
  34654. m.ClearServerID()
  34655. return nil
  34656. case wx.FieldOrganizationID:
  34657. m.ClearOrganizationID()
  34658. return nil
  34659. case wx.FieldAPIBase:
  34660. m.ClearAPIBase()
  34661. return nil
  34662. case wx.FieldAPIKey:
  34663. m.ClearAPIKey()
  34664. return nil
  34665. }
  34666. return fmt.Errorf("unknown Wx nullable field %s", name)
  34667. }
  34668. // ResetField resets all changes in the mutation for the field with the given name.
  34669. // It returns an error if the field is not defined in the schema.
  34670. func (m *WxMutation) ResetField(name string) error {
  34671. switch name {
  34672. case wx.FieldCreatedAt:
  34673. m.ResetCreatedAt()
  34674. return nil
  34675. case wx.FieldUpdatedAt:
  34676. m.ResetUpdatedAt()
  34677. return nil
  34678. case wx.FieldStatus:
  34679. m.ResetStatus()
  34680. return nil
  34681. case wx.FieldDeletedAt:
  34682. m.ResetDeletedAt()
  34683. return nil
  34684. case wx.FieldServerID:
  34685. m.ResetServerID()
  34686. return nil
  34687. case wx.FieldPort:
  34688. m.ResetPort()
  34689. return nil
  34690. case wx.FieldProcessID:
  34691. m.ResetProcessID()
  34692. return nil
  34693. case wx.FieldCallback:
  34694. m.ResetCallback()
  34695. return nil
  34696. case wx.FieldWxid:
  34697. m.ResetWxid()
  34698. return nil
  34699. case wx.FieldAccount:
  34700. m.ResetAccount()
  34701. return nil
  34702. case wx.FieldNickname:
  34703. m.ResetNickname()
  34704. return nil
  34705. case wx.FieldTel:
  34706. m.ResetTel()
  34707. return nil
  34708. case wx.FieldHeadBig:
  34709. m.ResetHeadBig()
  34710. return nil
  34711. case wx.FieldOrganizationID:
  34712. m.ResetOrganizationID()
  34713. return nil
  34714. case wx.FieldAgentID:
  34715. m.ResetAgentID()
  34716. return nil
  34717. case wx.FieldAPIBase:
  34718. m.ResetAPIBase()
  34719. return nil
  34720. case wx.FieldAPIKey:
  34721. m.ResetAPIKey()
  34722. return nil
  34723. case wx.FieldAllowList:
  34724. m.ResetAllowList()
  34725. return nil
  34726. case wx.FieldGroupAllowList:
  34727. m.ResetGroupAllowList()
  34728. return nil
  34729. case wx.FieldBlockList:
  34730. m.ResetBlockList()
  34731. return nil
  34732. case wx.FieldGroupBlockList:
  34733. m.ResetGroupBlockList()
  34734. return nil
  34735. }
  34736. return fmt.Errorf("unknown Wx field %s", name)
  34737. }
  34738. // AddedEdges returns all edge names that were set/added in this mutation.
  34739. func (m *WxMutation) AddedEdges() []string {
  34740. edges := make([]string, 0, 2)
  34741. if m.server != nil {
  34742. edges = append(edges, wx.EdgeServer)
  34743. }
  34744. if m.agent != nil {
  34745. edges = append(edges, wx.EdgeAgent)
  34746. }
  34747. return edges
  34748. }
  34749. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34750. // name in this mutation.
  34751. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  34752. switch name {
  34753. case wx.EdgeServer:
  34754. if id := m.server; id != nil {
  34755. return []ent.Value{*id}
  34756. }
  34757. case wx.EdgeAgent:
  34758. if id := m.agent; id != nil {
  34759. return []ent.Value{*id}
  34760. }
  34761. }
  34762. return nil
  34763. }
  34764. // RemovedEdges returns all edge names that were removed in this mutation.
  34765. func (m *WxMutation) RemovedEdges() []string {
  34766. edges := make([]string, 0, 2)
  34767. return edges
  34768. }
  34769. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34770. // the given name in this mutation.
  34771. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  34772. return nil
  34773. }
  34774. // ClearedEdges returns all edge names that were cleared in this mutation.
  34775. func (m *WxMutation) ClearedEdges() []string {
  34776. edges := make([]string, 0, 2)
  34777. if m.clearedserver {
  34778. edges = append(edges, wx.EdgeServer)
  34779. }
  34780. if m.clearedagent {
  34781. edges = append(edges, wx.EdgeAgent)
  34782. }
  34783. return edges
  34784. }
  34785. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34786. // was cleared in this mutation.
  34787. func (m *WxMutation) EdgeCleared(name string) bool {
  34788. switch name {
  34789. case wx.EdgeServer:
  34790. return m.clearedserver
  34791. case wx.EdgeAgent:
  34792. return m.clearedagent
  34793. }
  34794. return false
  34795. }
  34796. // ClearEdge clears the value of the edge with the given name. It returns an error
  34797. // if that edge is not defined in the schema.
  34798. func (m *WxMutation) ClearEdge(name string) error {
  34799. switch name {
  34800. case wx.EdgeServer:
  34801. m.ClearServer()
  34802. return nil
  34803. case wx.EdgeAgent:
  34804. m.ClearAgent()
  34805. return nil
  34806. }
  34807. return fmt.Errorf("unknown Wx unique edge %s", name)
  34808. }
  34809. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34810. // It returns an error if the edge is not defined in the schema.
  34811. func (m *WxMutation) ResetEdge(name string) error {
  34812. switch name {
  34813. case wx.EdgeServer:
  34814. m.ResetServer()
  34815. return nil
  34816. case wx.EdgeAgent:
  34817. m.ResetAgent()
  34818. return nil
  34819. }
  34820. return fmt.Errorf("unknown Wx edge %s", name)
  34821. }
  34822. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  34823. type WxCardMutation struct {
  34824. config
  34825. op Op
  34826. typ string
  34827. id *uint64
  34828. created_at *time.Time
  34829. updated_at *time.Time
  34830. deleted_at *time.Time
  34831. user_id *uint64
  34832. adduser_id *int64
  34833. wx_user_id *uint64
  34834. addwx_user_id *int64
  34835. avatar *string
  34836. logo *string
  34837. name *string
  34838. company *string
  34839. address *string
  34840. phone *string
  34841. official_account *string
  34842. wechat_account *string
  34843. email *string
  34844. api_base *string
  34845. api_key *string
  34846. ai_info *string
  34847. intro *string
  34848. clearedFields map[string]struct{}
  34849. done bool
  34850. oldValue func(context.Context) (*WxCard, error)
  34851. predicates []predicate.WxCard
  34852. }
  34853. var _ ent.Mutation = (*WxCardMutation)(nil)
  34854. // wxcardOption allows management of the mutation configuration using functional options.
  34855. type wxcardOption func(*WxCardMutation)
  34856. // newWxCardMutation creates new mutation for the WxCard entity.
  34857. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  34858. m := &WxCardMutation{
  34859. config: c,
  34860. op: op,
  34861. typ: TypeWxCard,
  34862. clearedFields: make(map[string]struct{}),
  34863. }
  34864. for _, opt := range opts {
  34865. opt(m)
  34866. }
  34867. return m
  34868. }
  34869. // withWxCardID sets the ID field of the mutation.
  34870. func withWxCardID(id uint64) wxcardOption {
  34871. return func(m *WxCardMutation) {
  34872. var (
  34873. err error
  34874. once sync.Once
  34875. value *WxCard
  34876. )
  34877. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  34878. once.Do(func() {
  34879. if m.done {
  34880. err = errors.New("querying old values post mutation is not allowed")
  34881. } else {
  34882. value, err = m.Client().WxCard.Get(ctx, id)
  34883. }
  34884. })
  34885. return value, err
  34886. }
  34887. m.id = &id
  34888. }
  34889. }
  34890. // withWxCard sets the old WxCard of the mutation.
  34891. func withWxCard(node *WxCard) wxcardOption {
  34892. return func(m *WxCardMutation) {
  34893. m.oldValue = func(context.Context) (*WxCard, error) {
  34894. return node, nil
  34895. }
  34896. m.id = &node.ID
  34897. }
  34898. }
  34899. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34900. // executed in a transaction (ent.Tx), a transactional client is returned.
  34901. func (m WxCardMutation) Client() *Client {
  34902. client := &Client{config: m.config}
  34903. client.init()
  34904. return client
  34905. }
  34906. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34907. // it returns an error otherwise.
  34908. func (m WxCardMutation) Tx() (*Tx, error) {
  34909. if _, ok := m.driver.(*txDriver); !ok {
  34910. return nil, errors.New("ent: mutation is not running in a transaction")
  34911. }
  34912. tx := &Tx{config: m.config}
  34913. tx.init()
  34914. return tx, nil
  34915. }
  34916. // SetID sets the value of the id field. Note that this
  34917. // operation is only accepted on creation of WxCard entities.
  34918. func (m *WxCardMutation) SetID(id uint64) {
  34919. m.id = &id
  34920. }
  34921. // ID returns the ID value in the mutation. Note that the ID is only available
  34922. // if it was provided to the builder or after it was returned from the database.
  34923. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  34924. if m.id == nil {
  34925. return
  34926. }
  34927. return *m.id, true
  34928. }
  34929. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34930. // That means, if the mutation is applied within a transaction with an isolation level such
  34931. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34932. // or updated by the mutation.
  34933. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  34934. switch {
  34935. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34936. id, exists := m.ID()
  34937. if exists {
  34938. return []uint64{id}, nil
  34939. }
  34940. fallthrough
  34941. case m.op.Is(OpUpdate | OpDelete):
  34942. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  34943. default:
  34944. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34945. }
  34946. }
  34947. // SetCreatedAt sets the "created_at" field.
  34948. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  34949. m.created_at = &t
  34950. }
  34951. // CreatedAt returns the value of the "created_at" field in the mutation.
  34952. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  34953. v := m.created_at
  34954. if v == nil {
  34955. return
  34956. }
  34957. return *v, true
  34958. }
  34959. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  34960. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34962. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34963. if !m.op.Is(OpUpdateOne) {
  34964. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34965. }
  34966. if m.id == nil || m.oldValue == nil {
  34967. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34968. }
  34969. oldValue, err := m.oldValue(ctx)
  34970. if err != nil {
  34971. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34972. }
  34973. return oldValue.CreatedAt, nil
  34974. }
  34975. // ResetCreatedAt resets all changes to the "created_at" field.
  34976. func (m *WxCardMutation) ResetCreatedAt() {
  34977. m.created_at = nil
  34978. }
  34979. // SetUpdatedAt sets the "updated_at" field.
  34980. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  34981. m.updated_at = &t
  34982. }
  34983. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34984. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  34985. v := m.updated_at
  34986. if v == nil {
  34987. return
  34988. }
  34989. return *v, true
  34990. }
  34991. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  34992. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34994. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34995. if !m.op.Is(OpUpdateOne) {
  34996. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34997. }
  34998. if m.id == nil || m.oldValue == nil {
  34999. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35000. }
  35001. oldValue, err := m.oldValue(ctx)
  35002. if err != nil {
  35003. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35004. }
  35005. return oldValue.UpdatedAt, nil
  35006. }
  35007. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35008. func (m *WxCardMutation) ResetUpdatedAt() {
  35009. m.updated_at = nil
  35010. }
  35011. // SetDeletedAt sets the "deleted_at" field.
  35012. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  35013. m.deleted_at = &t
  35014. }
  35015. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35016. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  35017. v := m.deleted_at
  35018. if v == nil {
  35019. return
  35020. }
  35021. return *v, true
  35022. }
  35023. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  35024. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35026. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35027. if !m.op.Is(OpUpdateOne) {
  35028. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35029. }
  35030. if m.id == nil || m.oldValue == nil {
  35031. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35032. }
  35033. oldValue, err := m.oldValue(ctx)
  35034. if err != nil {
  35035. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35036. }
  35037. return oldValue.DeletedAt, nil
  35038. }
  35039. // ClearDeletedAt clears the value of the "deleted_at" field.
  35040. func (m *WxCardMutation) ClearDeletedAt() {
  35041. m.deleted_at = nil
  35042. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  35043. }
  35044. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35045. func (m *WxCardMutation) DeletedAtCleared() bool {
  35046. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  35047. return ok
  35048. }
  35049. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35050. func (m *WxCardMutation) ResetDeletedAt() {
  35051. m.deleted_at = nil
  35052. delete(m.clearedFields, wxcard.FieldDeletedAt)
  35053. }
  35054. // SetUserID sets the "user_id" field.
  35055. func (m *WxCardMutation) SetUserID(u uint64) {
  35056. m.user_id = &u
  35057. m.adduser_id = nil
  35058. }
  35059. // UserID returns the value of the "user_id" field in the mutation.
  35060. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  35061. v := m.user_id
  35062. if v == nil {
  35063. return
  35064. }
  35065. return *v, true
  35066. }
  35067. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  35068. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35070. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  35071. if !m.op.Is(OpUpdateOne) {
  35072. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  35073. }
  35074. if m.id == nil || m.oldValue == nil {
  35075. return v, errors.New("OldUserID requires an ID field in the mutation")
  35076. }
  35077. oldValue, err := m.oldValue(ctx)
  35078. if err != nil {
  35079. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  35080. }
  35081. return oldValue.UserID, nil
  35082. }
  35083. // AddUserID adds u to the "user_id" field.
  35084. func (m *WxCardMutation) AddUserID(u int64) {
  35085. if m.adduser_id != nil {
  35086. *m.adduser_id += u
  35087. } else {
  35088. m.adduser_id = &u
  35089. }
  35090. }
  35091. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  35092. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  35093. v := m.adduser_id
  35094. if v == nil {
  35095. return
  35096. }
  35097. return *v, true
  35098. }
  35099. // ClearUserID clears the value of the "user_id" field.
  35100. func (m *WxCardMutation) ClearUserID() {
  35101. m.user_id = nil
  35102. m.adduser_id = nil
  35103. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  35104. }
  35105. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  35106. func (m *WxCardMutation) UserIDCleared() bool {
  35107. _, ok := m.clearedFields[wxcard.FieldUserID]
  35108. return ok
  35109. }
  35110. // ResetUserID resets all changes to the "user_id" field.
  35111. func (m *WxCardMutation) ResetUserID() {
  35112. m.user_id = nil
  35113. m.adduser_id = nil
  35114. delete(m.clearedFields, wxcard.FieldUserID)
  35115. }
  35116. // SetWxUserID sets the "wx_user_id" field.
  35117. func (m *WxCardMutation) SetWxUserID(u uint64) {
  35118. m.wx_user_id = &u
  35119. m.addwx_user_id = nil
  35120. }
  35121. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  35122. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  35123. v := m.wx_user_id
  35124. if v == nil {
  35125. return
  35126. }
  35127. return *v, true
  35128. }
  35129. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  35130. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35132. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  35133. if !m.op.Is(OpUpdateOne) {
  35134. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  35135. }
  35136. if m.id == nil || m.oldValue == nil {
  35137. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  35138. }
  35139. oldValue, err := m.oldValue(ctx)
  35140. if err != nil {
  35141. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  35142. }
  35143. return oldValue.WxUserID, nil
  35144. }
  35145. // AddWxUserID adds u to the "wx_user_id" field.
  35146. func (m *WxCardMutation) AddWxUserID(u int64) {
  35147. if m.addwx_user_id != nil {
  35148. *m.addwx_user_id += u
  35149. } else {
  35150. m.addwx_user_id = &u
  35151. }
  35152. }
  35153. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  35154. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  35155. v := m.addwx_user_id
  35156. if v == nil {
  35157. return
  35158. }
  35159. return *v, true
  35160. }
  35161. // ClearWxUserID clears the value of the "wx_user_id" field.
  35162. func (m *WxCardMutation) ClearWxUserID() {
  35163. m.wx_user_id = nil
  35164. m.addwx_user_id = nil
  35165. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  35166. }
  35167. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  35168. func (m *WxCardMutation) WxUserIDCleared() bool {
  35169. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  35170. return ok
  35171. }
  35172. // ResetWxUserID resets all changes to the "wx_user_id" field.
  35173. func (m *WxCardMutation) ResetWxUserID() {
  35174. m.wx_user_id = nil
  35175. m.addwx_user_id = nil
  35176. delete(m.clearedFields, wxcard.FieldWxUserID)
  35177. }
  35178. // SetAvatar sets the "avatar" field.
  35179. func (m *WxCardMutation) SetAvatar(s string) {
  35180. m.avatar = &s
  35181. }
  35182. // Avatar returns the value of the "avatar" field in the mutation.
  35183. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  35184. v := m.avatar
  35185. if v == nil {
  35186. return
  35187. }
  35188. return *v, true
  35189. }
  35190. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  35191. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35193. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35194. if !m.op.Is(OpUpdateOne) {
  35195. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35196. }
  35197. if m.id == nil || m.oldValue == nil {
  35198. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35199. }
  35200. oldValue, err := m.oldValue(ctx)
  35201. if err != nil {
  35202. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35203. }
  35204. return oldValue.Avatar, nil
  35205. }
  35206. // ResetAvatar resets all changes to the "avatar" field.
  35207. func (m *WxCardMutation) ResetAvatar() {
  35208. m.avatar = nil
  35209. }
  35210. // SetLogo sets the "logo" field.
  35211. func (m *WxCardMutation) SetLogo(s string) {
  35212. m.logo = &s
  35213. }
  35214. // Logo returns the value of the "logo" field in the mutation.
  35215. func (m *WxCardMutation) Logo() (r string, exists bool) {
  35216. v := m.logo
  35217. if v == nil {
  35218. return
  35219. }
  35220. return *v, true
  35221. }
  35222. // OldLogo returns the old "logo" field's value of the WxCard entity.
  35223. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35225. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  35226. if !m.op.Is(OpUpdateOne) {
  35227. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  35228. }
  35229. if m.id == nil || m.oldValue == nil {
  35230. return v, errors.New("OldLogo requires an ID field in the mutation")
  35231. }
  35232. oldValue, err := m.oldValue(ctx)
  35233. if err != nil {
  35234. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  35235. }
  35236. return oldValue.Logo, nil
  35237. }
  35238. // ResetLogo resets all changes to the "logo" field.
  35239. func (m *WxCardMutation) ResetLogo() {
  35240. m.logo = nil
  35241. }
  35242. // SetName sets the "name" field.
  35243. func (m *WxCardMutation) SetName(s string) {
  35244. m.name = &s
  35245. }
  35246. // Name returns the value of the "name" field in the mutation.
  35247. func (m *WxCardMutation) Name() (r string, exists bool) {
  35248. v := m.name
  35249. if v == nil {
  35250. return
  35251. }
  35252. return *v, true
  35253. }
  35254. // OldName returns the old "name" field's value of the WxCard entity.
  35255. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35257. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  35258. if !m.op.Is(OpUpdateOne) {
  35259. return v, errors.New("OldName is only allowed on UpdateOne operations")
  35260. }
  35261. if m.id == nil || m.oldValue == nil {
  35262. return v, errors.New("OldName requires an ID field in the mutation")
  35263. }
  35264. oldValue, err := m.oldValue(ctx)
  35265. if err != nil {
  35266. return v, fmt.Errorf("querying old value for OldName: %w", err)
  35267. }
  35268. return oldValue.Name, nil
  35269. }
  35270. // ResetName resets all changes to the "name" field.
  35271. func (m *WxCardMutation) ResetName() {
  35272. m.name = nil
  35273. }
  35274. // SetCompany sets the "company" field.
  35275. func (m *WxCardMutation) SetCompany(s string) {
  35276. m.company = &s
  35277. }
  35278. // Company returns the value of the "company" field in the mutation.
  35279. func (m *WxCardMutation) Company() (r string, exists bool) {
  35280. v := m.company
  35281. if v == nil {
  35282. return
  35283. }
  35284. return *v, true
  35285. }
  35286. // OldCompany returns the old "company" field's value of the WxCard entity.
  35287. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35289. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  35290. if !m.op.Is(OpUpdateOne) {
  35291. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35292. }
  35293. if m.id == nil || m.oldValue == nil {
  35294. return v, errors.New("OldCompany requires an ID field in the mutation")
  35295. }
  35296. oldValue, err := m.oldValue(ctx)
  35297. if err != nil {
  35298. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35299. }
  35300. return oldValue.Company, nil
  35301. }
  35302. // ResetCompany resets all changes to the "company" field.
  35303. func (m *WxCardMutation) ResetCompany() {
  35304. m.company = nil
  35305. }
  35306. // SetAddress sets the "address" field.
  35307. func (m *WxCardMutation) SetAddress(s string) {
  35308. m.address = &s
  35309. }
  35310. // Address returns the value of the "address" field in the mutation.
  35311. func (m *WxCardMutation) Address() (r string, exists bool) {
  35312. v := m.address
  35313. if v == nil {
  35314. return
  35315. }
  35316. return *v, true
  35317. }
  35318. // OldAddress returns the old "address" field's value of the WxCard entity.
  35319. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35321. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  35322. if !m.op.Is(OpUpdateOne) {
  35323. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  35324. }
  35325. if m.id == nil || m.oldValue == nil {
  35326. return v, errors.New("OldAddress requires an ID field in the mutation")
  35327. }
  35328. oldValue, err := m.oldValue(ctx)
  35329. if err != nil {
  35330. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  35331. }
  35332. return oldValue.Address, nil
  35333. }
  35334. // ResetAddress resets all changes to the "address" field.
  35335. func (m *WxCardMutation) ResetAddress() {
  35336. m.address = nil
  35337. }
  35338. // SetPhone sets the "phone" field.
  35339. func (m *WxCardMutation) SetPhone(s string) {
  35340. m.phone = &s
  35341. }
  35342. // Phone returns the value of the "phone" field in the mutation.
  35343. func (m *WxCardMutation) Phone() (r string, exists bool) {
  35344. v := m.phone
  35345. if v == nil {
  35346. return
  35347. }
  35348. return *v, true
  35349. }
  35350. // OldPhone returns the old "phone" field's value of the WxCard entity.
  35351. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35353. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  35354. if !m.op.Is(OpUpdateOne) {
  35355. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35356. }
  35357. if m.id == nil || m.oldValue == nil {
  35358. return v, errors.New("OldPhone requires an ID field in the mutation")
  35359. }
  35360. oldValue, err := m.oldValue(ctx)
  35361. if err != nil {
  35362. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35363. }
  35364. return oldValue.Phone, nil
  35365. }
  35366. // ResetPhone resets all changes to the "phone" field.
  35367. func (m *WxCardMutation) ResetPhone() {
  35368. m.phone = nil
  35369. }
  35370. // SetOfficialAccount sets the "official_account" field.
  35371. func (m *WxCardMutation) SetOfficialAccount(s string) {
  35372. m.official_account = &s
  35373. }
  35374. // OfficialAccount returns the value of the "official_account" field in the mutation.
  35375. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  35376. v := m.official_account
  35377. if v == nil {
  35378. return
  35379. }
  35380. return *v, true
  35381. }
  35382. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  35383. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35385. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  35386. if !m.op.Is(OpUpdateOne) {
  35387. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  35388. }
  35389. if m.id == nil || m.oldValue == nil {
  35390. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  35391. }
  35392. oldValue, err := m.oldValue(ctx)
  35393. if err != nil {
  35394. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  35395. }
  35396. return oldValue.OfficialAccount, nil
  35397. }
  35398. // ResetOfficialAccount resets all changes to the "official_account" field.
  35399. func (m *WxCardMutation) ResetOfficialAccount() {
  35400. m.official_account = nil
  35401. }
  35402. // SetWechatAccount sets the "wechat_account" field.
  35403. func (m *WxCardMutation) SetWechatAccount(s string) {
  35404. m.wechat_account = &s
  35405. }
  35406. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  35407. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  35408. v := m.wechat_account
  35409. if v == nil {
  35410. return
  35411. }
  35412. return *v, true
  35413. }
  35414. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  35415. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35417. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  35418. if !m.op.Is(OpUpdateOne) {
  35419. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  35420. }
  35421. if m.id == nil || m.oldValue == nil {
  35422. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  35423. }
  35424. oldValue, err := m.oldValue(ctx)
  35425. if err != nil {
  35426. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  35427. }
  35428. return oldValue.WechatAccount, nil
  35429. }
  35430. // ResetWechatAccount resets all changes to the "wechat_account" field.
  35431. func (m *WxCardMutation) ResetWechatAccount() {
  35432. m.wechat_account = nil
  35433. }
  35434. // SetEmail sets the "email" field.
  35435. func (m *WxCardMutation) SetEmail(s string) {
  35436. m.email = &s
  35437. }
  35438. // Email returns the value of the "email" field in the mutation.
  35439. func (m *WxCardMutation) Email() (r string, exists bool) {
  35440. v := m.email
  35441. if v == nil {
  35442. return
  35443. }
  35444. return *v, true
  35445. }
  35446. // OldEmail returns the old "email" field's value of the WxCard entity.
  35447. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35449. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  35450. if !m.op.Is(OpUpdateOne) {
  35451. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  35452. }
  35453. if m.id == nil || m.oldValue == nil {
  35454. return v, errors.New("OldEmail requires an ID field in the mutation")
  35455. }
  35456. oldValue, err := m.oldValue(ctx)
  35457. if err != nil {
  35458. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  35459. }
  35460. return oldValue.Email, nil
  35461. }
  35462. // ClearEmail clears the value of the "email" field.
  35463. func (m *WxCardMutation) ClearEmail() {
  35464. m.email = nil
  35465. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  35466. }
  35467. // EmailCleared returns if the "email" field was cleared in this mutation.
  35468. func (m *WxCardMutation) EmailCleared() bool {
  35469. _, ok := m.clearedFields[wxcard.FieldEmail]
  35470. return ok
  35471. }
  35472. // ResetEmail resets all changes to the "email" field.
  35473. func (m *WxCardMutation) ResetEmail() {
  35474. m.email = nil
  35475. delete(m.clearedFields, wxcard.FieldEmail)
  35476. }
  35477. // SetAPIBase sets the "api_base" field.
  35478. func (m *WxCardMutation) SetAPIBase(s string) {
  35479. m.api_base = &s
  35480. }
  35481. // APIBase returns the value of the "api_base" field in the mutation.
  35482. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  35483. v := m.api_base
  35484. if v == nil {
  35485. return
  35486. }
  35487. return *v, true
  35488. }
  35489. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  35490. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35492. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35493. if !m.op.Is(OpUpdateOne) {
  35494. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35495. }
  35496. if m.id == nil || m.oldValue == nil {
  35497. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35498. }
  35499. oldValue, err := m.oldValue(ctx)
  35500. if err != nil {
  35501. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35502. }
  35503. return oldValue.APIBase, nil
  35504. }
  35505. // ClearAPIBase clears the value of the "api_base" field.
  35506. func (m *WxCardMutation) ClearAPIBase() {
  35507. m.api_base = nil
  35508. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  35509. }
  35510. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35511. func (m *WxCardMutation) APIBaseCleared() bool {
  35512. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  35513. return ok
  35514. }
  35515. // ResetAPIBase resets all changes to the "api_base" field.
  35516. func (m *WxCardMutation) ResetAPIBase() {
  35517. m.api_base = nil
  35518. delete(m.clearedFields, wxcard.FieldAPIBase)
  35519. }
  35520. // SetAPIKey sets the "api_key" field.
  35521. func (m *WxCardMutation) SetAPIKey(s string) {
  35522. m.api_key = &s
  35523. }
  35524. // APIKey returns the value of the "api_key" field in the mutation.
  35525. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  35526. v := m.api_key
  35527. if v == nil {
  35528. return
  35529. }
  35530. return *v, true
  35531. }
  35532. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  35533. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35535. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35536. if !m.op.Is(OpUpdateOne) {
  35537. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35538. }
  35539. if m.id == nil || m.oldValue == nil {
  35540. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35541. }
  35542. oldValue, err := m.oldValue(ctx)
  35543. if err != nil {
  35544. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35545. }
  35546. return oldValue.APIKey, nil
  35547. }
  35548. // ClearAPIKey clears the value of the "api_key" field.
  35549. func (m *WxCardMutation) ClearAPIKey() {
  35550. m.api_key = nil
  35551. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  35552. }
  35553. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35554. func (m *WxCardMutation) APIKeyCleared() bool {
  35555. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  35556. return ok
  35557. }
  35558. // ResetAPIKey resets all changes to the "api_key" field.
  35559. func (m *WxCardMutation) ResetAPIKey() {
  35560. m.api_key = nil
  35561. delete(m.clearedFields, wxcard.FieldAPIKey)
  35562. }
  35563. // SetAiInfo sets the "ai_info" field.
  35564. func (m *WxCardMutation) SetAiInfo(s string) {
  35565. m.ai_info = &s
  35566. }
  35567. // AiInfo returns the value of the "ai_info" field in the mutation.
  35568. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  35569. v := m.ai_info
  35570. if v == nil {
  35571. return
  35572. }
  35573. return *v, true
  35574. }
  35575. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  35576. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35578. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  35579. if !m.op.Is(OpUpdateOne) {
  35580. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  35581. }
  35582. if m.id == nil || m.oldValue == nil {
  35583. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  35584. }
  35585. oldValue, err := m.oldValue(ctx)
  35586. if err != nil {
  35587. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  35588. }
  35589. return oldValue.AiInfo, nil
  35590. }
  35591. // ClearAiInfo clears the value of the "ai_info" field.
  35592. func (m *WxCardMutation) ClearAiInfo() {
  35593. m.ai_info = nil
  35594. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  35595. }
  35596. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  35597. func (m *WxCardMutation) AiInfoCleared() bool {
  35598. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  35599. return ok
  35600. }
  35601. // ResetAiInfo resets all changes to the "ai_info" field.
  35602. func (m *WxCardMutation) ResetAiInfo() {
  35603. m.ai_info = nil
  35604. delete(m.clearedFields, wxcard.FieldAiInfo)
  35605. }
  35606. // SetIntro sets the "intro" field.
  35607. func (m *WxCardMutation) SetIntro(s string) {
  35608. m.intro = &s
  35609. }
  35610. // Intro returns the value of the "intro" field in the mutation.
  35611. func (m *WxCardMutation) Intro() (r string, exists bool) {
  35612. v := m.intro
  35613. if v == nil {
  35614. return
  35615. }
  35616. return *v, true
  35617. }
  35618. // OldIntro returns the old "intro" field's value of the WxCard entity.
  35619. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35621. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  35622. if !m.op.Is(OpUpdateOne) {
  35623. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  35624. }
  35625. if m.id == nil || m.oldValue == nil {
  35626. return v, errors.New("OldIntro requires an ID field in the mutation")
  35627. }
  35628. oldValue, err := m.oldValue(ctx)
  35629. if err != nil {
  35630. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  35631. }
  35632. return oldValue.Intro, nil
  35633. }
  35634. // ClearIntro clears the value of the "intro" field.
  35635. func (m *WxCardMutation) ClearIntro() {
  35636. m.intro = nil
  35637. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  35638. }
  35639. // IntroCleared returns if the "intro" field was cleared in this mutation.
  35640. func (m *WxCardMutation) IntroCleared() bool {
  35641. _, ok := m.clearedFields[wxcard.FieldIntro]
  35642. return ok
  35643. }
  35644. // ResetIntro resets all changes to the "intro" field.
  35645. func (m *WxCardMutation) ResetIntro() {
  35646. m.intro = nil
  35647. delete(m.clearedFields, wxcard.FieldIntro)
  35648. }
  35649. // Where appends a list predicates to the WxCardMutation builder.
  35650. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  35651. m.predicates = append(m.predicates, ps...)
  35652. }
  35653. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  35654. // users can use type-assertion to append predicates that do not depend on any generated package.
  35655. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  35656. p := make([]predicate.WxCard, len(ps))
  35657. for i := range ps {
  35658. p[i] = ps[i]
  35659. }
  35660. m.Where(p...)
  35661. }
  35662. // Op returns the operation name.
  35663. func (m *WxCardMutation) Op() Op {
  35664. return m.op
  35665. }
  35666. // SetOp allows setting the mutation operation.
  35667. func (m *WxCardMutation) SetOp(op Op) {
  35668. m.op = op
  35669. }
  35670. // Type returns the node type of this mutation (WxCard).
  35671. func (m *WxCardMutation) Type() string {
  35672. return m.typ
  35673. }
  35674. // Fields returns all fields that were changed during this mutation. Note that in
  35675. // order to get all numeric fields that were incremented/decremented, call
  35676. // AddedFields().
  35677. func (m *WxCardMutation) Fields() []string {
  35678. fields := make([]string, 0, 18)
  35679. if m.created_at != nil {
  35680. fields = append(fields, wxcard.FieldCreatedAt)
  35681. }
  35682. if m.updated_at != nil {
  35683. fields = append(fields, wxcard.FieldUpdatedAt)
  35684. }
  35685. if m.deleted_at != nil {
  35686. fields = append(fields, wxcard.FieldDeletedAt)
  35687. }
  35688. if m.user_id != nil {
  35689. fields = append(fields, wxcard.FieldUserID)
  35690. }
  35691. if m.wx_user_id != nil {
  35692. fields = append(fields, wxcard.FieldWxUserID)
  35693. }
  35694. if m.avatar != nil {
  35695. fields = append(fields, wxcard.FieldAvatar)
  35696. }
  35697. if m.logo != nil {
  35698. fields = append(fields, wxcard.FieldLogo)
  35699. }
  35700. if m.name != nil {
  35701. fields = append(fields, wxcard.FieldName)
  35702. }
  35703. if m.company != nil {
  35704. fields = append(fields, wxcard.FieldCompany)
  35705. }
  35706. if m.address != nil {
  35707. fields = append(fields, wxcard.FieldAddress)
  35708. }
  35709. if m.phone != nil {
  35710. fields = append(fields, wxcard.FieldPhone)
  35711. }
  35712. if m.official_account != nil {
  35713. fields = append(fields, wxcard.FieldOfficialAccount)
  35714. }
  35715. if m.wechat_account != nil {
  35716. fields = append(fields, wxcard.FieldWechatAccount)
  35717. }
  35718. if m.email != nil {
  35719. fields = append(fields, wxcard.FieldEmail)
  35720. }
  35721. if m.api_base != nil {
  35722. fields = append(fields, wxcard.FieldAPIBase)
  35723. }
  35724. if m.api_key != nil {
  35725. fields = append(fields, wxcard.FieldAPIKey)
  35726. }
  35727. if m.ai_info != nil {
  35728. fields = append(fields, wxcard.FieldAiInfo)
  35729. }
  35730. if m.intro != nil {
  35731. fields = append(fields, wxcard.FieldIntro)
  35732. }
  35733. return fields
  35734. }
  35735. // Field returns the value of a field with the given name. The second boolean
  35736. // return value indicates that this field was not set, or was not defined in the
  35737. // schema.
  35738. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  35739. switch name {
  35740. case wxcard.FieldCreatedAt:
  35741. return m.CreatedAt()
  35742. case wxcard.FieldUpdatedAt:
  35743. return m.UpdatedAt()
  35744. case wxcard.FieldDeletedAt:
  35745. return m.DeletedAt()
  35746. case wxcard.FieldUserID:
  35747. return m.UserID()
  35748. case wxcard.FieldWxUserID:
  35749. return m.WxUserID()
  35750. case wxcard.FieldAvatar:
  35751. return m.Avatar()
  35752. case wxcard.FieldLogo:
  35753. return m.Logo()
  35754. case wxcard.FieldName:
  35755. return m.Name()
  35756. case wxcard.FieldCompany:
  35757. return m.Company()
  35758. case wxcard.FieldAddress:
  35759. return m.Address()
  35760. case wxcard.FieldPhone:
  35761. return m.Phone()
  35762. case wxcard.FieldOfficialAccount:
  35763. return m.OfficialAccount()
  35764. case wxcard.FieldWechatAccount:
  35765. return m.WechatAccount()
  35766. case wxcard.FieldEmail:
  35767. return m.Email()
  35768. case wxcard.FieldAPIBase:
  35769. return m.APIBase()
  35770. case wxcard.FieldAPIKey:
  35771. return m.APIKey()
  35772. case wxcard.FieldAiInfo:
  35773. return m.AiInfo()
  35774. case wxcard.FieldIntro:
  35775. return m.Intro()
  35776. }
  35777. return nil, false
  35778. }
  35779. // OldField returns the old value of the field from the database. An error is
  35780. // returned if the mutation operation is not UpdateOne, or the query to the
  35781. // database failed.
  35782. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35783. switch name {
  35784. case wxcard.FieldCreatedAt:
  35785. return m.OldCreatedAt(ctx)
  35786. case wxcard.FieldUpdatedAt:
  35787. return m.OldUpdatedAt(ctx)
  35788. case wxcard.FieldDeletedAt:
  35789. return m.OldDeletedAt(ctx)
  35790. case wxcard.FieldUserID:
  35791. return m.OldUserID(ctx)
  35792. case wxcard.FieldWxUserID:
  35793. return m.OldWxUserID(ctx)
  35794. case wxcard.FieldAvatar:
  35795. return m.OldAvatar(ctx)
  35796. case wxcard.FieldLogo:
  35797. return m.OldLogo(ctx)
  35798. case wxcard.FieldName:
  35799. return m.OldName(ctx)
  35800. case wxcard.FieldCompany:
  35801. return m.OldCompany(ctx)
  35802. case wxcard.FieldAddress:
  35803. return m.OldAddress(ctx)
  35804. case wxcard.FieldPhone:
  35805. return m.OldPhone(ctx)
  35806. case wxcard.FieldOfficialAccount:
  35807. return m.OldOfficialAccount(ctx)
  35808. case wxcard.FieldWechatAccount:
  35809. return m.OldWechatAccount(ctx)
  35810. case wxcard.FieldEmail:
  35811. return m.OldEmail(ctx)
  35812. case wxcard.FieldAPIBase:
  35813. return m.OldAPIBase(ctx)
  35814. case wxcard.FieldAPIKey:
  35815. return m.OldAPIKey(ctx)
  35816. case wxcard.FieldAiInfo:
  35817. return m.OldAiInfo(ctx)
  35818. case wxcard.FieldIntro:
  35819. return m.OldIntro(ctx)
  35820. }
  35821. return nil, fmt.Errorf("unknown WxCard field %s", name)
  35822. }
  35823. // SetField sets the value of a field with the given name. It returns an error if
  35824. // the field is not defined in the schema, or if the type mismatched the field
  35825. // type.
  35826. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  35827. switch name {
  35828. case wxcard.FieldCreatedAt:
  35829. v, ok := value.(time.Time)
  35830. if !ok {
  35831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35832. }
  35833. m.SetCreatedAt(v)
  35834. return nil
  35835. case wxcard.FieldUpdatedAt:
  35836. v, ok := value.(time.Time)
  35837. if !ok {
  35838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35839. }
  35840. m.SetUpdatedAt(v)
  35841. return nil
  35842. case wxcard.FieldDeletedAt:
  35843. v, ok := value.(time.Time)
  35844. if !ok {
  35845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35846. }
  35847. m.SetDeletedAt(v)
  35848. return nil
  35849. case wxcard.FieldUserID:
  35850. v, ok := value.(uint64)
  35851. if !ok {
  35852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35853. }
  35854. m.SetUserID(v)
  35855. return nil
  35856. case wxcard.FieldWxUserID:
  35857. v, ok := value.(uint64)
  35858. if !ok {
  35859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35860. }
  35861. m.SetWxUserID(v)
  35862. return nil
  35863. case wxcard.FieldAvatar:
  35864. v, ok := value.(string)
  35865. if !ok {
  35866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35867. }
  35868. m.SetAvatar(v)
  35869. return nil
  35870. case wxcard.FieldLogo:
  35871. v, ok := value.(string)
  35872. if !ok {
  35873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35874. }
  35875. m.SetLogo(v)
  35876. return nil
  35877. case wxcard.FieldName:
  35878. v, ok := value.(string)
  35879. if !ok {
  35880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35881. }
  35882. m.SetName(v)
  35883. return nil
  35884. case wxcard.FieldCompany:
  35885. v, ok := value.(string)
  35886. if !ok {
  35887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35888. }
  35889. m.SetCompany(v)
  35890. return nil
  35891. case wxcard.FieldAddress:
  35892. v, ok := value.(string)
  35893. if !ok {
  35894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35895. }
  35896. m.SetAddress(v)
  35897. return nil
  35898. case wxcard.FieldPhone:
  35899. v, ok := value.(string)
  35900. if !ok {
  35901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35902. }
  35903. m.SetPhone(v)
  35904. return nil
  35905. case wxcard.FieldOfficialAccount:
  35906. v, ok := value.(string)
  35907. if !ok {
  35908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35909. }
  35910. m.SetOfficialAccount(v)
  35911. return nil
  35912. case wxcard.FieldWechatAccount:
  35913. v, ok := value.(string)
  35914. if !ok {
  35915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35916. }
  35917. m.SetWechatAccount(v)
  35918. return nil
  35919. case wxcard.FieldEmail:
  35920. v, ok := value.(string)
  35921. if !ok {
  35922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35923. }
  35924. m.SetEmail(v)
  35925. return nil
  35926. case wxcard.FieldAPIBase:
  35927. v, ok := value.(string)
  35928. if !ok {
  35929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35930. }
  35931. m.SetAPIBase(v)
  35932. return nil
  35933. case wxcard.FieldAPIKey:
  35934. v, ok := value.(string)
  35935. if !ok {
  35936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35937. }
  35938. m.SetAPIKey(v)
  35939. return nil
  35940. case wxcard.FieldAiInfo:
  35941. v, ok := value.(string)
  35942. if !ok {
  35943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35944. }
  35945. m.SetAiInfo(v)
  35946. return nil
  35947. case wxcard.FieldIntro:
  35948. v, ok := value.(string)
  35949. if !ok {
  35950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35951. }
  35952. m.SetIntro(v)
  35953. return nil
  35954. }
  35955. return fmt.Errorf("unknown WxCard field %s", name)
  35956. }
  35957. // AddedFields returns all numeric fields that were incremented/decremented during
  35958. // this mutation.
  35959. func (m *WxCardMutation) AddedFields() []string {
  35960. var fields []string
  35961. if m.adduser_id != nil {
  35962. fields = append(fields, wxcard.FieldUserID)
  35963. }
  35964. if m.addwx_user_id != nil {
  35965. fields = append(fields, wxcard.FieldWxUserID)
  35966. }
  35967. return fields
  35968. }
  35969. // AddedField returns the numeric value that was incremented/decremented on a field
  35970. // with the given name. The second boolean return value indicates that this field
  35971. // was not set, or was not defined in the schema.
  35972. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  35973. switch name {
  35974. case wxcard.FieldUserID:
  35975. return m.AddedUserID()
  35976. case wxcard.FieldWxUserID:
  35977. return m.AddedWxUserID()
  35978. }
  35979. return nil, false
  35980. }
  35981. // AddField adds the value to the field with the given name. It returns an error if
  35982. // the field is not defined in the schema, or if the type mismatched the field
  35983. // type.
  35984. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  35985. switch name {
  35986. case wxcard.FieldUserID:
  35987. v, ok := value.(int64)
  35988. if !ok {
  35989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35990. }
  35991. m.AddUserID(v)
  35992. return nil
  35993. case wxcard.FieldWxUserID:
  35994. v, ok := value.(int64)
  35995. if !ok {
  35996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35997. }
  35998. m.AddWxUserID(v)
  35999. return nil
  36000. }
  36001. return fmt.Errorf("unknown WxCard numeric field %s", name)
  36002. }
  36003. // ClearedFields returns all nullable fields that were cleared during this
  36004. // mutation.
  36005. func (m *WxCardMutation) ClearedFields() []string {
  36006. var fields []string
  36007. if m.FieldCleared(wxcard.FieldDeletedAt) {
  36008. fields = append(fields, wxcard.FieldDeletedAt)
  36009. }
  36010. if m.FieldCleared(wxcard.FieldUserID) {
  36011. fields = append(fields, wxcard.FieldUserID)
  36012. }
  36013. if m.FieldCleared(wxcard.FieldWxUserID) {
  36014. fields = append(fields, wxcard.FieldWxUserID)
  36015. }
  36016. if m.FieldCleared(wxcard.FieldEmail) {
  36017. fields = append(fields, wxcard.FieldEmail)
  36018. }
  36019. if m.FieldCleared(wxcard.FieldAPIBase) {
  36020. fields = append(fields, wxcard.FieldAPIBase)
  36021. }
  36022. if m.FieldCleared(wxcard.FieldAPIKey) {
  36023. fields = append(fields, wxcard.FieldAPIKey)
  36024. }
  36025. if m.FieldCleared(wxcard.FieldAiInfo) {
  36026. fields = append(fields, wxcard.FieldAiInfo)
  36027. }
  36028. if m.FieldCleared(wxcard.FieldIntro) {
  36029. fields = append(fields, wxcard.FieldIntro)
  36030. }
  36031. return fields
  36032. }
  36033. // FieldCleared returns a boolean indicating if a field with the given name was
  36034. // cleared in this mutation.
  36035. func (m *WxCardMutation) FieldCleared(name string) bool {
  36036. _, ok := m.clearedFields[name]
  36037. return ok
  36038. }
  36039. // ClearField clears the value of the field with the given name. It returns an
  36040. // error if the field is not defined in the schema.
  36041. func (m *WxCardMutation) ClearField(name string) error {
  36042. switch name {
  36043. case wxcard.FieldDeletedAt:
  36044. m.ClearDeletedAt()
  36045. return nil
  36046. case wxcard.FieldUserID:
  36047. m.ClearUserID()
  36048. return nil
  36049. case wxcard.FieldWxUserID:
  36050. m.ClearWxUserID()
  36051. return nil
  36052. case wxcard.FieldEmail:
  36053. m.ClearEmail()
  36054. return nil
  36055. case wxcard.FieldAPIBase:
  36056. m.ClearAPIBase()
  36057. return nil
  36058. case wxcard.FieldAPIKey:
  36059. m.ClearAPIKey()
  36060. return nil
  36061. case wxcard.FieldAiInfo:
  36062. m.ClearAiInfo()
  36063. return nil
  36064. case wxcard.FieldIntro:
  36065. m.ClearIntro()
  36066. return nil
  36067. }
  36068. return fmt.Errorf("unknown WxCard nullable field %s", name)
  36069. }
  36070. // ResetField resets all changes in the mutation for the field with the given name.
  36071. // It returns an error if the field is not defined in the schema.
  36072. func (m *WxCardMutation) ResetField(name string) error {
  36073. switch name {
  36074. case wxcard.FieldCreatedAt:
  36075. m.ResetCreatedAt()
  36076. return nil
  36077. case wxcard.FieldUpdatedAt:
  36078. m.ResetUpdatedAt()
  36079. return nil
  36080. case wxcard.FieldDeletedAt:
  36081. m.ResetDeletedAt()
  36082. return nil
  36083. case wxcard.FieldUserID:
  36084. m.ResetUserID()
  36085. return nil
  36086. case wxcard.FieldWxUserID:
  36087. m.ResetWxUserID()
  36088. return nil
  36089. case wxcard.FieldAvatar:
  36090. m.ResetAvatar()
  36091. return nil
  36092. case wxcard.FieldLogo:
  36093. m.ResetLogo()
  36094. return nil
  36095. case wxcard.FieldName:
  36096. m.ResetName()
  36097. return nil
  36098. case wxcard.FieldCompany:
  36099. m.ResetCompany()
  36100. return nil
  36101. case wxcard.FieldAddress:
  36102. m.ResetAddress()
  36103. return nil
  36104. case wxcard.FieldPhone:
  36105. m.ResetPhone()
  36106. return nil
  36107. case wxcard.FieldOfficialAccount:
  36108. m.ResetOfficialAccount()
  36109. return nil
  36110. case wxcard.FieldWechatAccount:
  36111. m.ResetWechatAccount()
  36112. return nil
  36113. case wxcard.FieldEmail:
  36114. m.ResetEmail()
  36115. return nil
  36116. case wxcard.FieldAPIBase:
  36117. m.ResetAPIBase()
  36118. return nil
  36119. case wxcard.FieldAPIKey:
  36120. m.ResetAPIKey()
  36121. return nil
  36122. case wxcard.FieldAiInfo:
  36123. m.ResetAiInfo()
  36124. return nil
  36125. case wxcard.FieldIntro:
  36126. m.ResetIntro()
  36127. return nil
  36128. }
  36129. return fmt.Errorf("unknown WxCard field %s", name)
  36130. }
  36131. // AddedEdges returns all edge names that were set/added in this mutation.
  36132. func (m *WxCardMutation) AddedEdges() []string {
  36133. edges := make([]string, 0, 0)
  36134. return edges
  36135. }
  36136. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36137. // name in this mutation.
  36138. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  36139. return nil
  36140. }
  36141. // RemovedEdges returns all edge names that were removed in this mutation.
  36142. func (m *WxCardMutation) RemovedEdges() []string {
  36143. edges := make([]string, 0, 0)
  36144. return edges
  36145. }
  36146. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36147. // the given name in this mutation.
  36148. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  36149. return nil
  36150. }
  36151. // ClearedEdges returns all edge names that were cleared in this mutation.
  36152. func (m *WxCardMutation) ClearedEdges() []string {
  36153. edges := make([]string, 0, 0)
  36154. return edges
  36155. }
  36156. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36157. // was cleared in this mutation.
  36158. func (m *WxCardMutation) EdgeCleared(name string) bool {
  36159. return false
  36160. }
  36161. // ClearEdge clears the value of the edge with the given name. It returns an error
  36162. // if that edge is not defined in the schema.
  36163. func (m *WxCardMutation) ClearEdge(name string) error {
  36164. return fmt.Errorf("unknown WxCard unique edge %s", name)
  36165. }
  36166. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36167. // It returns an error if the edge is not defined in the schema.
  36168. func (m *WxCardMutation) ResetEdge(name string) error {
  36169. return fmt.Errorf("unknown WxCard edge %s", name)
  36170. }
  36171. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  36172. type WxCardUserMutation struct {
  36173. config
  36174. op Op
  36175. typ string
  36176. id *uint64
  36177. created_at *time.Time
  36178. updated_at *time.Time
  36179. deleted_at *time.Time
  36180. wxid *string
  36181. account *string
  36182. avatar *string
  36183. nickname *string
  36184. remark *string
  36185. phone *string
  36186. open_id *string
  36187. union_id *string
  36188. session_key *string
  36189. is_vip *int
  36190. addis_vip *int
  36191. clearedFields map[string]struct{}
  36192. done bool
  36193. oldValue func(context.Context) (*WxCardUser, error)
  36194. predicates []predicate.WxCardUser
  36195. }
  36196. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  36197. // wxcarduserOption allows management of the mutation configuration using functional options.
  36198. type wxcarduserOption func(*WxCardUserMutation)
  36199. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  36200. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  36201. m := &WxCardUserMutation{
  36202. config: c,
  36203. op: op,
  36204. typ: TypeWxCardUser,
  36205. clearedFields: make(map[string]struct{}),
  36206. }
  36207. for _, opt := range opts {
  36208. opt(m)
  36209. }
  36210. return m
  36211. }
  36212. // withWxCardUserID sets the ID field of the mutation.
  36213. func withWxCardUserID(id uint64) wxcarduserOption {
  36214. return func(m *WxCardUserMutation) {
  36215. var (
  36216. err error
  36217. once sync.Once
  36218. value *WxCardUser
  36219. )
  36220. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  36221. once.Do(func() {
  36222. if m.done {
  36223. err = errors.New("querying old values post mutation is not allowed")
  36224. } else {
  36225. value, err = m.Client().WxCardUser.Get(ctx, id)
  36226. }
  36227. })
  36228. return value, err
  36229. }
  36230. m.id = &id
  36231. }
  36232. }
  36233. // withWxCardUser sets the old WxCardUser of the mutation.
  36234. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  36235. return func(m *WxCardUserMutation) {
  36236. m.oldValue = func(context.Context) (*WxCardUser, error) {
  36237. return node, nil
  36238. }
  36239. m.id = &node.ID
  36240. }
  36241. }
  36242. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36243. // executed in a transaction (ent.Tx), a transactional client is returned.
  36244. func (m WxCardUserMutation) Client() *Client {
  36245. client := &Client{config: m.config}
  36246. client.init()
  36247. return client
  36248. }
  36249. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36250. // it returns an error otherwise.
  36251. func (m WxCardUserMutation) Tx() (*Tx, error) {
  36252. if _, ok := m.driver.(*txDriver); !ok {
  36253. return nil, errors.New("ent: mutation is not running in a transaction")
  36254. }
  36255. tx := &Tx{config: m.config}
  36256. tx.init()
  36257. return tx, nil
  36258. }
  36259. // SetID sets the value of the id field. Note that this
  36260. // operation is only accepted on creation of WxCardUser entities.
  36261. func (m *WxCardUserMutation) SetID(id uint64) {
  36262. m.id = &id
  36263. }
  36264. // ID returns the ID value in the mutation. Note that the ID is only available
  36265. // if it was provided to the builder or after it was returned from the database.
  36266. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  36267. if m.id == nil {
  36268. return
  36269. }
  36270. return *m.id, true
  36271. }
  36272. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36273. // That means, if the mutation is applied within a transaction with an isolation level such
  36274. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36275. // or updated by the mutation.
  36276. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  36277. switch {
  36278. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36279. id, exists := m.ID()
  36280. if exists {
  36281. return []uint64{id}, nil
  36282. }
  36283. fallthrough
  36284. case m.op.Is(OpUpdate | OpDelete):
  36285. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  36286. default:
  36287. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36288. }
  36289. }
  36290. // SetCreatedAt sets the "created_at" field.
  36291. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  36292. m.created_at = &t
  36293. }
  36294. // CreatedAt returns the value of the "created_at" field in the mutation.
  36295. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  36296. v := m.created_at
  36297. if v == nil {
  36298. return
  36299. }
  36300. return *v, true
  36301. }
  36302. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  36303. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36305. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36306. if !m.op.Is(OpUpdateOne) {
  36307. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36308. }
  36309. if m.id == nil || m.oldValue == nil {
  36310. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36311. }
  36312. oldValue, err := m.oldValue(ctx)
  36313. if err != nil {
  36314. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36315. }
  36316. return oldValue.CreatedAt, nil
  36317. }
  36318. // ResetCreatedAt resets all changes to the "created_at" field.
  36319. func (m *WxCardUserMutation) ResetCreatedAt() {
  36320. m.created_at = nil
  36321. }
  36322. // SetUpdatedAt sets the "updated_at" field.
  36323. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  36324. m.updated_at = &t
  36325. }
  36326. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36327. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  36328. v := m.updated_at
  36329. if v == nil {
  36330. return
  36331. }
  36332. return *v, true
  36333. }
  36334. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  36335. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36337. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36338. if !m.op.Is(OpUpdateOne) {
  36339. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36340. }
  36341. if m.id == nil || m.oldValue == nil {
  36342. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36343. }
  36344. oldValue, err := m.oldValue(ctx)
  36345. if err != nil {
  36346. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36347. }
  36348. return oldValue.UpdatedAt, nil
  36349. }
  36350. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36351. func (m *WxCardUserMutation) ResetUpdatedAt() {
  36352. m.updated_at = nil
  36353. }
  36354. // SetDeletedAt sets the "deleted_at" field.
  36355. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  36356. m.deleted_at = &t
  36357. }
  36358. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36359. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  36360. v := m.deleted_at
  36361. if v == nil {
  36362. return
  36363. }
  36364. return *v, true
  36365. }
  36366. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  36367. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36369. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36370. if !m.op.Is(OpUpdateOne) {
  36371. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36372. }
  36373. if m.id == nil || m.oldValue == nil {
  36374. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36375. }
  36376. oldValue, err := m.oldValue(ctx)
  36377. if err != nil {
  36378. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36379. }
  36380. return oldValue.DeletedAt, nil
  36381. }
  36382. // ClearDeletedAt clears the value of the "deleted_at" field.
  36383. func (m *WxCardUserMutation) ClearDeletedAt() {
  36384. m.deleted_at = nil
  36385. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  36386. }
  36387. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36388. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  36389. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  36390. return ok
  36391. }
  36392. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36393. func (m *WxCardUserMutation) ResetDeletedAt() {
  36394. m.deleted_at = nil
  36395. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  36396. }
  36397. // SetWxid sets the "wxid" field.
  36398. func (m *WxCardUserMutation) SetWxid(s string) {
  36399. m.wxid = &s
  36400. }
  36401. // Wxid returns the value of the "wxid" field in the mutation.
  36402. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  36403. v := m.wxid
  36404. if v == nil {
  36405. return
  36406. }
  36407. return *v, true
  36408. }
  36409. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  36410. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36412. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  36413. if !m.op.Is(OpUpdateOne) {
  36414. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36415. }
  36416. if m.id == nil || m.oldValue == nil {
  36417. return v, errors.New("OldWxid requires an ID field in the mutation")
  36418. }
  36419. oldValue, err := m.oldValue(ctx)
  36420. if err != nil {
  36421. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36422. }
  36423. return oldValue.Wxid, nil
  36424. }
  36425. // ResetWxid resets all changes to the "wxid" field.
  36426. func (m *WxCardUserMutation) ResetWxid() {
  36427. m.wxid = nil
  36428. }
  36429. // SetAccount sets the "account" field.
  36430. func (m *WxCardUserMutation) SetAccount(s string) {
  36431. m.account = &s
  36432. }
  36433. // Account returns the value of the "account" field in the mutation.
  36434. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  36435. v := m.account
  36436. if v == nil {
  36437. return
  36438. }
  36439. return *v, true
  36440. }
  36441. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  36442. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36444. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  36445. if !m.op.Is(OpUpdateOne) {
  36446. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36447. }
  36448. if m.id == nil || m.oldValue == nil {
  36449. return v, errors.New("OldAccount requires an ID field in the mutation")
  36450. }
  36451. oldValue, err := m.oldValue(ctx)
  36452. if err != nil {
  36453. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36454. }
  36455. return oldValue.Account, nil
  36456. }
  36457. // ResetAccount resets all changes to the "account" field.
  36458. func (m *WxCardUserMutation) ResetAccount() {
  36459. m.account = nil
  36460. }
  36461. // SetAvatar sets the "avatar" field.
  36462. func (m *WxCardUserMutation) SetAvatar(s string) {
  36463. m.avatar = &s
  36464. }
  36465. // Avatar returns the value of the "avatar" field in the mutation.
  36466. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  36467. v := m.avatar
  36468. if v == nil {
  36469. return
  36470. }
  36471. return *v, true
  36472. }
  36473. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  36474. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36476. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36477. if !m.op.Is(OpUpdateOne) {
  36478. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36479. }
  36480. if m.id == nil || m.oldValue == nil {
  36481. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36482. }
  36483. oldValue, err := m.oldValue(ctx)
  36484. if err != nil {
  36485. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36486. }
  36487. return oldValue.Avatar, nil
  36488. }
  36489. // ResetAvatar resets all changes to the "avatar" field.
  36490. func (m *WxCardUserMutation) ResetAvatar() {
  36491. m.avatar = nil
  36492. }
  36493. // SetNickname sets the "nickname" field.
  36494. func (m *WxCardUserMutation) SetNickname(s string) {
  36495. m.nickname = &s
  36496. }
  36497. // Nickname returns the value of the "nickname" field in the mutation.
  36498. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  36499. v := m.nickname
  36500. if v == nil {
  36501. return
  36502. }
  36503. return *v, true
  36504. }
  36505. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  36506. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36508. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  36509. if !m.op.Is(OpUpdateOne) {
  36510. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36511. }
  36512. if m.id == nil || m.oldValue == nil {
  36513. return v, errors.New("OldNickname requires an ID field in the mutation")
  36514. }
  36515. oldValue, err := m.oldValue(ctx)
  36516. if err != nil {
  36517. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36518. }
  36519. return oldValue.Nickname, nil
  36520. }
  36521. // ResetNickname resets all changes to the "nickname" field.
  36522. func (m *WxCardUserMutation) ResetNickname() {
  36523. m.nickname = nil
  36524. }
  36525. // SetRemark sets the "remark" field.
  36526. func (m *WxCardUserMutation) SetRemark(s string) {
  36527. m.remark = &s
  36528. }
  36529. // Remark returns the value of the "remark" field in the mutation.
  36530. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  36531. v := m.remark
  36532. if v == nil {
  36533. return
  36534. }
  36535. return *v, true
  36536. }
  36537. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  36538. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36540. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  36541. if !m.op.Is(OpUpdateOne) {
  36542. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  36543. }
  36544. if m.id == nil || m.oldValue == nil {
  36545. return v, errors.New("OldRemark requires an ID field in the mutation")
  36546. }
  36547. oldValue, err := m.oldValue(ctx)
  36548. if err != nil {
  36549. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  36550. }
  36551. return oldValue.Remark, nil
  36552. }
  36553. // ResetRemark resets all changes to the "remark" field.
  36554. func (m *WxCardUserMutation) ResetRemark() {
  36555. m.remark = nil
  36556. }
  36557. // SetPhone sets the "phone" field.
  36558. func (m *WxCardUserMutation) SetPhone(s string) {
  36559. m.phone = &s
  36560. }
  36561. // Phone returns the value of the "phone" field in the mutation.
  36562. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  36563. v := m.phone
  36564. if v == nil {
  36565. return
  36566. }
  36567. return *v, true
  36568. }
  36569. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  36570. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36572. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  36573. if !m.op.Is(OpUpdateOne) {
  36574. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36575. }
  36576. if m.id == nil || m.oldValue == nil {
  36577. return v, errors.New("OldPhone requires an ID field in the mutation")
  36578. }
  36579. oldValue, err := m.oldValue(ctx)
  36580. if err != nil {
  36581. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36582. }
  36583. return oldValue.Phone, nil
  36584. }
  36585. // ResetPhone resets all changes to the "phone" field.
  36586. func (m *WxCardUserMutation) ResetPhone() {
  36587. m.phone = nil
  36588. }
  36589. // SetOpenID sets the "open_id" field.
  36590. func (m *WxCardUserMutation) SetOpenID(s string) {
  36591. m.open_id = &s
  36592. }
  36593. // OpenID returns the value of the "open_id" field in the mutation.
  36594. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  36595. v := m.open_id
  36596. if v == nil {
  36597. return
  36598. }
  36599. return *v, true
  36600. }
  36601. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  36602. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36604. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  36605. if !m.op.Is(OpUpdateOne) {
  36606. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  36607. }
  36608. if m.id == nil || m.oldValue == nil {
  36609. return v, errors.New("OldOpenID requires an ID field in the mutation")
  36610. }
  36611. oldValue, err := m.oldValue(ctx)
  36612. if err != nil {
  36613. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  36614. }
  36615. return oldValue.OpenID, nil
  36616. }
  36617. // ResetOpenID resets all changes to the "open_id" field.
  36618. func (m *WxCardUserMutation) ResetOpenID() {
  36619. m.open_id = nil
  36620. }
  36621. // SetUnionID sets the "union_id" field.
  36622. func (m *WxCardUserMutation) SetUnionID(s string) {
  36623. m.union_id = &s
  36624. }
  36625. // UnionID returns the value of the "union_id" field in the mutation.
  36626. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  36627. v := m.union_id
  36628. if v == nil {
  36629. return
  36630. }
  36631. return *v, true
  36632. }
  36633. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  36634. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36636. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  36637. if !m.op.Is(OpUpdateOne) {
  36638. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  36639. }
  36640. if m.id == nil || m.oldValue == nil {
  36641. return v, errors.New("OldUnionID requires an ID field in the mutation")
  36642. }
  36643. oldValue, err := m.oldValue(ctx)
  36644. if err != nil {
  36645. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  36646. }
  36647. return oldValue.UnionID, nil
  36648. }
  36649. // ResetUnionID resets all changes to the "union_id" field.
  36650. func (m *WxCardUserMutation) ResetUnionID() {
  36651. m.union_id = nil
  36652. }
  36653. // SetSessionKey sets the "session_key" field.
  36654. func (m *WxCardUserMutation) SetSessionKey(s string) {
  36655. m.session_key = &s
  36656. }
  36657. // SessionKey returns the value of the "session_key" field in the mutation.
  36658. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  36659. v := m.session_key
  36660. if v == nil {
  36661. return
  36662. }
  36663. return *v, true
  36664. }
  36665. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  36666. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36668. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  36669. if !m.op.Is(OpUpdateOne) {
  36670. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  36671. }
  36672. if m.id == nil || m.oldValue == nil {
  36673. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  36674. }
  36675. oldValue, err := m.oldValue(ctx)
  36676. if err != nil {
  36677. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  36678. }
  36679. return oldValue.SessionKey, nil
  36680. }
  36681. // ResetSessionKey resets all changes to the "session_key" field.
  36682. func (m *WxCardUserMutation) ResetSessionKey() {
  36683. m.session_key = nil
  36684. }
  36685. // SetIsVip sets the "is_vip" field.
  36686. func (m *WxCardUserMutation) SetIsVip(i int) {
  36687. m.is_vip = &i
  36688. m.addis_vip = nil
  36689. }
  36690. // IsVip returns the value of the "is_vip" field in the mutation.
  36691. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  36692. v := m.is_vip
  36693. if v == nil {
  36694. return
  36695. }
  36696. return *v, true
  36697. }
  36698. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  36699. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36701. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  36702. if !m.op.Is(OpUpdateOne) {
  36703. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  36704. }
  36705. if m.id == nil || m.oldValue == nil {
  36706. return v, errors.New("OldIsVip requires an ID field in the mutation")
  36707. }
  36708. oldValue, err := m.oldValue(ctx)
  36709. if err != nil {
  36710. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  36711. }
  36712. return oldValue.IsVip, nil
  36713. }
  36714. // AddIsVip adds i to the "is_vip" field.
  36715. func (m *WxCardUserMutation) AddIsVip(i int) {
  36716. if m.addis_vip != nil {
  36717. *m.addis_vip += i
  36718. } else {
  36719. m.addis_vip = &i
  36720. }
  36721. }
  36722. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  36723. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  36724. v := m.addis_vip
  36725. if v == nil {
  36726. return
  36727. }
  36728. return *v, true
  36729. }
  36730. // ResetIsVip resets all changes to the "is_vip" field.
  36731. func (m *WxCardUserMutation) ResetIsVip() {
  36732. m.is_vip = nil
  36733. m.addis_vip = nil
  36734. }
  36735. // Where appends a list predicates to the WxCardUserMutation builder.
  36736. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  36737. m.predicates = append(m.predicates, ps...)
  36738. }
  36739. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  36740. // users can use type-assertion to append predicates that do not depend on any generated package.
  36741. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  36742. p := make([]predicate.WxCardUser, len(ps))
  36743. for i := range ps {
  36744. p[i] = ps[i]
  36745. }
  36746. m.Where(p...)
  36747. }
  36748. // Op returns the operation name.
  36749. func (m *WxCardUserMutation) Op() Op {
  36750. return m.op
  36751. }
  36752. // SetOp allows setting the mutation operation.
  36753. func (m *WxCardUserMutation) SetOp(op Op) {
  36754. m.op = op
  36755. }
  36756. // Type returns the node type of this mutation (WxCardUser).
  36757. func (m *WxCardUserMutation) Type() string {
  36758. return m.typ
  36759. }
  36760. // Fields returns all fields that were changed during this mutation. Note that in
  36761. // order to get all numeric fields that were incremented/decremented, call
  36762. // AddedFields().
  36763. func (m *WxCardUserMutation) Fields() []string {
  36764. fields := make([]string, 0, 13)
  36765. if m.created_at != nil {
  36766. fields = append(fields, wxcarduser.FieldCreatedAt)
  36767. }
  36768. if m.updated_at != nil {
  36769. fields = append(fields, wxcarduser.FieldUpdatedAt)
  36770. }
  36771. if m.deleted_at != nil {
  36772. fields = append(fields, wxcarduser.FieldDeletedAt)
  36773. }
  36774. if m.wxid != nil {
  36775. fields = append(fields, wxcarduser.FieldWxid)
  36776. }
  36777. if m.account != nil {
  36778. fields = append(fields, wxcarduser.FieldAccount)
  36779. }
  36780. if m.avatar != nil {
  36781. fields = append(fields, wxcarduser.FieldAvatar)
  36782. }
  36783. if m.nickname != nil {
  36784. fields = append(fields, wxcarduser.FieldNickname)
  36785. }
  36786. if m.remark != nil {
  36787. fields = append(fields, wxcarduser.FieldRemark)
  36788. }
  36789. if m.phone != nil {
  36790. fields = append(fields, wxcarduser.FieldPhone)
  36791. }
  36792. if m.open_id != nil {
  36793. fields = append(fields, wxcarduser.FieldOpenID)
  36794. }
  36795. if m.union_id != nil {
  36796. fields = append(fields, wxcarduser.FieldUnionID)
  36797. }
  36798. if m.session_key != nil {
  36799. fields = append(fields, wxcarduser.FieldSessionKey)
  36800. }
  36801. if m.is_vip != nil {
  36802. fields = append(fields, wxcarduser.FieldIsVip)
  36803. }
  36804. return fields
  36805. }
  36806. // Field returns the value of a field with the given name. The second boolean
  36807. // return value indicates that this field was not set, or was not defined in the
  36808. // schema.
  36809. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  36810. switch name {
  36811. case wxcarduser.FieldCreatedAt:
  36812. return m.CreatedAt()
  36813. case wxcarduser.FieldUpdatedAt:
  36814. return m.UpdatedAt()
  36815. case wxcarduser.FieldDeletedAt:
  36816. return m.DeletedAt()
  36817. case wxcarduser.FieldWxid:
  36818. return m.Wxid()
  36819. case wxcarduser.FieldAccount:
  36820. return m.Account()
  36821. case wxcarduser.FieldAvatar:
  36822. return m.Avatar()
  36823. case wxcarduser.FieldNickname:
  36824. return m.Nickname()
  36825. case wxcarduser.FieldRemark:
  36826. return m.Remark()
  36827. case wxcarduser.FieldPhone:
  36828. return m.Phone()
  36829. case wxcarduser.FieldOpenID:
  36830. return m.OpenID()
  36831. case wxcarduser.FieldUnionID:
  36832. return m.UnionID()
  36833. case wxcarduser.FieldSessionKey:
  36834. return m.SessionKey()
  36835. case wxcarduser.FieldIsVip:
  36836. return m.IsVip()
  36837. }
  36838. return nil, false
  36839. }
  36840. // OldField returns the old value of the field from the database. An error is
  36841. // returned if the mutation operation is not UpdateOne, or the query to the
  36842. // database failed.
  36843. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36844. switch name {
  36845. case wxcarduser.FieldCreatedAt:
  36846. return m.OldCreatedAt(ctx)
  36847. case wxcarduser.FieldUpdatedAt:
  36848. return m.OldUpdatedAt(ctx)
  36849. case wxcarduser.FieldDeletedAt:
  36850. return m.OldDeletedAt(ctx)
  36851. case wxcarduser.FieldWxid:
  36852. return m.OldWxid(ctx)
  36853. case wxcarduser.FieldAccount:
  36854. return m.OldAccount(ctx)
  36855. case wxcarduser.FieldAvatar:
  36856. return m.OldAvatar(ctx)
  36857. case wxcarduser.FieldNickname:
  36858. return m.OldNickname(ctx)
  36859. case wxcarduser.FieldRemark:
  36860. return m.OldRemark(ctx)
  36861. case wxcarduser.FieldPhone:
  36862. return m.OldPhone(ctx)
  36863. case wxcarduser.FieldOpenID:
  36864. return m.OldOpenID(ctx)
  36865. case wxcarduser.FieldUnionID:
  36866. return m.OldUnionID(ctx)
  36867. case wxcarduser.FieldSessionKey:
  36868. return m.OldSessionKey(ctx)
  36869. case wxcarduser.FieldIsVip:
  36870. return m.OldIsVip(ctx)
  36871. }
  36872. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  36873. }
  36874. // SetField sets the value of a field with the given name. It returns an error if
  36875. // the field is not defined in the schema, or if the type mismatched the field
  36876. // type.
  36877. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  36878. switch name {
  36879. case wxcarduser.FieldCreatedAt:
  36880. v, ok := value.(time.Time)
  36881. if !ok {
  36882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36883. }
  36884. m.SetCreatedAt(v)
  36885. return nil
  36886. case wxcarduser.FieldUpdatedAt:
  36887. v, ok := value.(time.Time)
  36888. if !ok {
  36889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36890. }
  36891. m.SetUpdatedAt(v)
  36892. return nil
  36893. case wxcarduser.FieldDeletedAt:
  36894. v, ok := value.(time.Time)
  36895. if !ok {
  36896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36897. }
  36898. m.SetDeletedAt(v)
  36899. return nil
  36900. case wxcarduser.FieldWxid:
  36901. v, ok := value.(string)
  36902. if !ok {
  36903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36904. }
  36905. m.SetWxid(v)
  36906. return nil
  36907. case wxcarduser.FieldAccount:
  36908. v, ok := value.(string)
  36909. if !ok {
  36910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36911. }
  36912. m.SetAccount(v)
  36913. return nil
  36914. case wxcarduser.FieldAvatar:
  36915. v, ok := value.(string)
  36916. if !ok {
  36917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36918. }
  36919. m.SetAvatar(v)
  36920. return nil
  36921. case wxcarduser.FieldNickname:
  36922. v, ok := value.(string)
  36923. if !ok {
  36924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36925. }
  36926. m.SetNickname(v)
  36927. return nil
  36928. case wxcarduser.FieldRemark:
  36929. v, ok := value.(string)
  36930. if !ok {
  36931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36932. }
  36933. m.SetRemark(v)
  36934. return nil
  36935. case wxcarduser.FieldPhone:
  36936. v, ok := value.(string)
  36937. if !ok {
  36938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36939. }
  36940. m.SetPhone(v)
  36941. return nil
  36942. case wxcarduser.FieldOpenID:
  36943. v, ok := value.(string)
  36944. if !ok {
  36945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36946. }
  36947. m.SetOpenID(v)
  36948. return nil
  36949. case wxcarduser.FieldUnionID:
  36950. v, ok := value.(string)
  36951. if !ok {
  36952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36953. }
  36954. m.SetUnionID(v)
  36955. return nil
  36956. case wxcarduser.FieldSessionKey:
  36957. v, ok := value.(string)
  36958. if !ok {
  36959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36960. }
  36961. m.SetSessionKey(v)
  36962. return nil
  36963. case wxcarduser.FieldIsVip:
  36964. v, ok := value.(int)
  36965. if !ok {
  36966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36967. }
  36968. m.SetIsVip(v)
  36969. return nil
  36970. }
  36971. return fmt.Errorf("unknown WxCardUser field %s", name)
  36972. }
  36973. // AddedFields returns all numeric fields that were incremented/decremented during
  36974. // this mutation.
  36975. func (m *WxCardUserMutation) AddedFields() []string {
  36976. var fields []string
  36977. if m.addis_vip != nil {
  36978. fields = append(fields, wxcarduser.FieldIsVip)
  36979. }
  36980. return fields
  36981. }
  36982. // AddedField returns the numeric value that was incremented/decremented on a field
  36983. // with the given name. The second boolean return value indicates that this field
  36984. // was not set, or was not defined in the schema.
  36985. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  36986. switch name {
  36987. case wxcarduser.FieldIsVip:
  36988. return m.AddedIsVip()
  36989. }
  36990. return nil, false
  36991. }
  36992. // AddField adds the value to the field with the given name. It returns an error if
  36993. // the field is not defined in the schema, or if the type mismatched the field
  36994. // type.
  36995. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  36996. switch name {
  36997. case wxcarduser.FieldIsVip:
  36998. v, ok := value.(int)
  36999. if !ok {
  37000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37001. }
  37002. m.AddIsVip(v)
  37003. return nil
  37004. }
  37005. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  37006. }
  37007. // ClearedFields returns all nullable fields that were cleared during this
  37008. // mutation.
  37009. func (m *WxCardUserMutation) ClearedFields() []string {
  37010. var fields []string
  37011. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  37012. fields = append(fields, wxcarduser.FieldDeletedAt)
  37013. }
  37014. return fields
  37015. }
  37016. // FieldCleared returns a boolean indicating if a field with the given name was
  37017. // cleared in this mutation.
  37018. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  37019. _, ok := m.clearedFields[name]
  37020. return ok
  37021. }
  37022. // ClearField clears the value of the field with the given name. It returns an
  37023. // error if the field is not defined in the schema.
  37024. func (m *WxCardUserMutation) ClearField(name string) error {
  37025. switch name {
  37026. case wxcarduser.FieldDeletedAt:
  37027. m.ClearDeletedAt()
  37028. return nil
  37029. }
  37030. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  37031. }
  37032. // ResetField resets all changes in the mutation for the field with the given name.
  37033. // It returns an error if the field is not defined in the schema.
  37034. func (m *WxCardUserMutation) ResetField(name string) error {
  37035. switch name {
  37036. case wxcarduser.FieldCreatedAt:
  37037. m.ResetCreatedAt()
  37038. return nil
  37039. case wxcarduser.FieldUpdatedAt:
  37040. m.ResetUpdatedAt()
  37041. return nil
  37042. case wxcarduser.FieldDeletedAt:
  37043. m.ResetDeletedAt()
  37044. return nil
  37045. case wxcarduser.FieldWxid:
  37046. m.ResetWxid()
  37047. return nil
  37048. case wxcarduser.FieldAccount:
  37049. m.ResetAccount()
  37050. return nil
  37051. case wxcarduser.FieldAvatar:
  37052. m.ResetAvatar()
  37053. return nil
  37054. case wxcarduser.FieldNickname:
  37055. m.ResetNickname()
  37056. return nil
  37057. case wxcarduser.FieldRemark:
  37058. m.ResetRemark()
  37059. return nil
  37060. case wxcarduser.FieldPhone:
  37061. m.ResetPhone()
  37062. return nil
  37063. case wxcarduser.FieldOpenID:
  37064. m.ResetOpenID()
  37065. return nil
  37066. case wxcarduser.FieldUnionID:
  37067. m.ResetUnionID()
  37068. return nil
  37069. case wxcarduser.FieldSessionKey:
  37070. m.ResetSessionKey()
  37071. return nil
  37072. case wxcarduser.FieldIsVip:
  37073. m.ResetIsVip()
  37074. return nil
  37075. }
  37076. return fmt.Errorf("unknown WxCardUser field %s", name)
  37077. }
  37078. // AddedEdges returns all edge names that were set/added in this mutation.
  37079. func (m *WxCardUserMutation) AddedEdges() []string {
  37080. edges := make([]string, 0, 0)
  37081. return edges
  37082. }
  37083. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37084. // name in this mutation.
  37085. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  37086. return nil
  37087. }
  37088. // RemovedEdges returns all edge names that were removed in this mutation.
  37089. func (m *WxCardUserMutation) RemovedEdges() []string {
  37090. edges := make([]string, 0, 0)
  37091. return edges
  37092. }
  37093. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37094. // the given name in this mutation.
  37095. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  37096. return nil
  37097. }
  37098. // ClearedEdges returns all edge names that were cleared in this mutation.
  37099. func (m *WxCardUserMutation) ClearedEdges() []string {
  37100. edges := make([]string, 0, 0)
  37101. return edges
  37102. }
  37103. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37104. // was cleared in this mutation.
  37105. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  37106. return false
  37107. }
  37108. // ClearEdge clears the value of the edge with the given name. It returns an error
  37109. // if that edge is not defined in the schema.
  37110. func (m *WxCardUserMutation) ClearEdge(name string) error {
  37111. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  37112. }
  37113. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37114. // It returns an error if the edge is not defined in the schema.
  37115. func (m *WxCardUserMutation) ResetEdge(name string) error {
  37116. return fmt.Errorf("unknown WxCardUser edge %s", name)
  37117. }
  37118. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  37119. type WxCardVisitMutation struct {
  37120. config
  37121. op Op
  37122. typ string
  37123. id *uint64
  37124. created_at *time.Time
  37125. updated_at *time.Time
  37126. deleted_at *time.Time
  37127. user_id *uint64
  37128. adduser_id *int64
  37129. bot_id *uint64
  37130. addbot_id *int64
  37131. bot_type *uint8
  37132. addbot_type *int8
  37133. clearedFields map[string]struct{}
  37134. done bool
  37135. oldValue func(context.Context) (*WxCardVisit, error)
  37136. predicates []predicate.WxCardVisit
  37137. }
  37138. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  37139. // wxcardvisitOption allows management of the mutation configuration using functional options.
  37140. type wxcardvisitOption func(*WxCardVisitMutation)
  37141. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  37142. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  37143. m := &WxCardVisitMutation{
  37144. config: c,
  37145. op: op,
  37146. typ: TypeWxCardVisit,
  37147. clearedFields: make(map[string]struct{}),
  37148. }
  37149. for _, opt := range opts {
  37150. opt(m)
  37151. }
  37152. return m
  37153. }
  37154. // withWxCardVisitID sets the ID field of the mutation.
  37155. func withWxCardVisitID(id uint64) wxcardvisitOption {
  37156. return func(m *WxCardVisitMutation) {
  37157. var (
  37158. err error
  37159. once sync.Once
  37160. value *WxCardVisit
  37161. )
  37162. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  37163. once.Do(func() {
  37164. if m.done {
  37165. err = errors.New("querying old values post mutation is not allowed")
  37166. } else {
  37167. value, err = m.Client().WxCardVisit.Get(ctx, id)
  37168. }
  37169. })
  37170. return value, err
  37171. }
  37172. m.id = &id
  37173. }
  37174. }
  37175. // withWxCardVisit sets the old WxCardVisit of the mutation.
  37176. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  37177. return func(m *WxCardVisitMutation) {
  37178. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  37179. return node, nil
  37180. }
  37181. m.id = &node.ID
  37182. }
  37183. }
  37184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37185. // executed in a transaction (ent.Tx), a transactional client is returned.
  37186. func (m WxCardVisitMutation) Client() *Client {
  37187. client := &Client{config: m.config}
  37188. client.init()
  37189. return client
  37190. }
  37191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37192. // it returns an error otherwise.
  37193. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  37194. if _, ok := m.driver.(*txDriver); !ok {
  37195. return nil, errors.New("ent: mutation is not running in a transaction")
  37196. }
  37197. tx := &Tx{config: m.config}
  37198. tx.init()
  37199. return tx, nil
  37200. }
  37201. // SetID sets the value of the id field. Note that this
  37202. // operation is only accepted on creation of WxCardVisit entities.
  37203. func (m *WxCardVisitMutation) SetID(id uint64) {
  37204. m.id = &id
  37205. }
  37206. // ID returns the ID value in the mutation. Note that the ID is only available
  37207. // if it was provided to the builder or after it was returned from the database.
  37208. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  37209. if m.id == nil {
  37210. return
  37211. }
  37212. return *m.id, true
  37213. }
  37214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37215. // That means, if the mutation is applied within a transaction with an isolation level such
  37216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37217. // or updated by the mutation.
  37218. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  37219. switch {
  37220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37221. id, exists := m.ID()
  37222. if exists {
  37223. return []uint64{id}, nil
  37224. }
  37225. fallthrough
  37226. case m.op.Is(OpUpdate | OpDelete):
  37227. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  37228. default:
  37229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37230. }
  37231. }
  37232. // SetCreatedAt sets the "created_at" field.
  37233. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  37234. m.created_at = &t
  37235. }
  37236. // CreatedAt returns the value of the "created_at" field in the mutation.
  37237. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  37238. v := m.created_at
  37239. if v == nil {
  37240. return
  37241. }
  37242. return *v, true
  37243. }
  37244. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  37245. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37247. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37248. if !m.op.Is(OpUpdateOne) {
  37249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37250. }
  37251. if m.id == nil || m.oldValue == nil {
  37252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37253. }
  37254. oldValue, err := m.oldValue(ctx)
  37255. if err != nil {
  37256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37257. }
  37258. return oldValue.CreatedAt, nil
  37259. }
  37260. // ResetCreatedAt resets all changes to the "created_at" field.
  37261. func (m *WxCardVisitMutation) ResetCreatedAt() {
  37262. m.created_at = nil
  37263. }
  37264. // SetUpdatedAt sets the "updated_at" field.
  37265. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  37266. m.updated_at = &t
  37267. }
  37268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37269. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  37270. v := m.updated_at
  37271. if v == nil {
  37272. return
  37273. }
  37274. return *v, true
  37275. }
  37276. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  37277. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37279. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37280. if !m.op.Is(OpUpdateOne) {
  37281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37282. }
  37283. if m.id == nil || m.oldValue == nil {
  37284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37285. }
  37286. oldValue, err := m.oldValue(ctx)
  37287. if err != nil {
  37288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37289. }
  37290. return oldValue.UpdatedAt, nil
  37291. }
  37292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37293. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  37294. m.updated_at = nil
  37295. }
  37296. // SetDeletedAt sets the "deleted_at" field.
  37297. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  37298. m.deleted_at = &t
  37299. }
  37300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37301. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  37302. v := m.deleted_at
  37303. if v == nil {
  37304. return
  37305. }
  37306. return *v, true
  37307. }
  37308. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  37309. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37311. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37312. if !m.op.Is(OpUpdateOne) {
  37313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37314. }
  37315. if m.id == nil || m.oldValue == nil {
  37316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37317. }
  37318. oldValue, err := m.oldValue(ctx)
  37319. if err != nil {
  37320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37321. }
  37322. return oldValue.DeletedAt, nil
  37323. }
  37324. // ClearDeletedAt clears the value of the "deleted_at" field.
  37325. func (m *WxCardVisitMutation) ClearDeletedAt() {
  37326. m.deleted_at = nil
  37327. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  37328. }
  37329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37330. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  37331. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  37332. return ok
  37333. }
  37334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37335. func (m *WxCardVisitMutation) ResetDeletedAt() {
  37336. m.deleted_at = nil
  37337. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  37338. }
  37339. // SetUserID sets the "user_id" field.
  37340. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  37341. m.user_id = &u
  37342. m.adduser_id = nil
  37343. }
  37344. // UserID returns the value of the "user_id" field in the mutation.
  37345. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  37346. v := m.user_id
  37347. if v == nil {
  37348. return
  37349. }
  37350. return *v, true
  37351. }
  37352. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  37353. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37355. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  37356. if !m.op.Is(OpUpdateOne) {
  37357. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  37358. }
  37359. if m.id == nil || m.oldValue == nil {
  37360. return v, errors.New("OldUserID requires an ID field in the mutation")
  37361. }
  37362. oldValue, err := m.oldValue(ctx)
  37363. if err != nil {
  37364. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  37365. }
  37366. return oldValue.UserID, nil
  37367. }
  37368. // AddUserID adds u to the "user_id" field.
  37369. func (m *WxCardVisitMutation) AddUserID(u int64) {
  37370. if m.adduser_id != nil {
  37371. *m.adduser_id += u
  37372. } else {
  37373. m.adduser_id = &u
  37374. }
  37375. }
  37376. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  37377. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  37378. v := m.adduser_id
  37379. if v == nil {
  37380. return
  37381. }
  37382. return *v, true
  37383. }
  37384. // ClearUserID clears the value of the "user_id" field.
  37385. func (m *WxCardVisitMutation) ClearUserID() {
  37386. m.user_id = nil
  37387. m.adduser_id = nil
  37388. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  37389. }
  37390. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  37391. func (m *WxCardVisitMutation) UserIDCleared() bool {
  37392. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  37393. return ok
  37394. }
  37395. // ResetUserID resets all changes to the "user_id" field.
  37396. func (m *WxCardVisitMutation) ResetUserID() {
  37397. m.user_id = nil
  37398. m.adduser_id = nil
  37399. delete(m.clearedFields, wxcardvisit.FieldUserID)
  37400. }
  37401. // SetBotID sets the "bot_id" field.
  37402. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  37403. m.bot_id = &u
  37404. m.addbot_id = nil
  37405. }
  37406. // BotID returns the value of the "bot_id" field in the mutation.
  37407. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  37408. v := m.bot_id
  37409. if v == nil {
  37410. return
  37411. }
  37412. return *v, true
  37413. }
  37414. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  37415. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37417. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  37418. if !m.op.Is(OpUpdateOne) {
  37419. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37420. }
  37421. if m.id == nil || m.oldValue == nil {
  37422. return v, errors.New("OldBotID requires an ID field in the mutation")
  37423. }
  37424. oldValue, err := m.oldValue(ctx)
  37425. if err != nil {
  37426. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37427. }
  37428. return oldValue.BotID, nil
  37429. }
  37430. // AddBotID adds u to the "bot_id" field.
  37431. func (m *WxCardVisitMutation) AddBotID(u int64) {
  37432. if m.addbot_id != nil {
  37433. *m.addbot_id += u
  37434. } else {
  37435. m.addbot_id = &u
  37436. }
  37437. }
  37438. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  37439. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  37440. v := m.addbot_id
  37441. if v == nil {
  37442. return
  37443. }
  37444. return *v, true
  37445. }
  37446. // ResetBotID resets all changes to the "bot_id" field.
  37447. func (m *WxCardVisitMutation) ResetBotID() {
  37448. m.bot_id = nil
  37449. m.addbot_id = nil
  37450. }
  37451. // SetBotType sets the "bot_type" field.
  37452. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  37453. m.bot_type = &u
  37454. m.addbot_type = nil
  37455. }
  37456. // BotType returns the value of the "bot_type" field in the mutation.
  37457. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  37458. v := m.bot_type
  37459. if v == nil {
  37460. return
  37461. }
  37462. return *v, true
  37463. }
  37464. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  37465. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37467. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  37468. if !m.op.Is(OpUpdateOne) {
  37469. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  37470. }
  37471. if m.id == nil || m.oldValue == nil {
  37472. return v, errors.New("OldBotType requires an ID field in the mutation")
  37473. }
  37474. oldValue, err := m.oldValue(ctx)
  37475. if err != nil {
  37476. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  37477. }
  37478. return oldValue.BotType, nil
  37479. }
  37480. // AddBotType adds u to the "bot_type" field.
  37481. func (m *WxCardVisitMutation) AddBotType(u int8) {
  37482. if m.addbot_type != nil {
  37483. *m.addbot_type += u
  37484. } else {
  37485. m.addbot_type = &u
  37486. }
  37487. }
  37488. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  37489. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  37490. v := m.addbot_type
  37491. if v == nil {
  37492. return
  37493. }
  37494. return *v, true
  37495. }
  37496. // ResetBotType resets all changes to the "bot_type" field.
  37497. func (m *WxCardVisitMutation) ResetBotType() {
  37498. m.bot_type = nil
  37499. m.addbot_type = nil
  37500. }
  37501. // Where appends a list predicates to the WxCardVisitMutation builder.
  37502. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  37503. m.predicates = append(m.predicates, ps...)
  37504. }
  37505. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  37506. // users can use type-assertion to append predicates that do not depend on any generated package.
  37507. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  37508. p := make([]predicate.WxCardVisit, len(ps))
  37509. for i := range ps {
  37510. p[i] = ps[i]
  37511. }
  37512. m.Where(p...)
  37513. }
  37514. // Op returns the operation name.
  37515. func (m *WxCardVisitMutation) Op() Op {
  37516. return m.op
  37517. }
  37518. // SetOp allows setting the mutation operation.
  37519. func (m *WxCardVisitMutation) SetOp(op Op) {
  37520. m.op = op
  37521. }
  37522. // Type returns the node type of this mutation (WxCardVisit).
  37523. func (m *WxCardVisitMutation) Type() string {
  37524. return m.typ
  37525. }
  37526. // Fields returns all fields that were changed during this mutation. Note that in
  37527. // order to get all numeric fields that were incremented/decremented, call
  37528. // AddedFields().
  37529. func (m *WxCardVisitMutation) Fields() []string {
  37530. fields := make([]string, 0, 6)
  37531. if m.created_at != nil {
  37532. fields = append(fields, wxcardvisit.FieldCreatedAt)
  37533. }
  37534. if m.updated_at != nil {
  37535. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  37536. }
  37537. if m.deleted_at != nil {
  37538. fields = append(fields, wxcardvisit.FieldDeletedAt)
  37539. }
  37540. if m.user_id != nil {
  37541. fields = append(fields, wxcardvisit.FieldUserID)
  37542. }
  37543. if m.bot_id != nil {
  37544. fields = append(fields, wxcardvisit.FieldBotID)
  37545. }
  37546. if m.bot_type != nil {
  37547. fields = append(fields, wxcardvisit.FieldBotType)
  37548. }
  37549. return fields
  37550. }
  37551. // Field returns the value of a field with the given name. The second boolean
  37552. // return value indicates that this field was not set, or was not defined in the
  37553. // schema.
  37554. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  37555. switch name {
  37556. case wxcardvisit.FieldCreatedAt:
  37557. return m.CreatedAt()
  37558. case wxcardvisit.FieldUpdatedAt:
  37559. return m.UpdatedAt()
  37560. case wxcardvisit.FieldDeletedAt:
  37561. return m.DeletedAt()
  37562. case wxcardvisit.FieldUserID:
  37563. return m.UserID()
  37564. case wxcardvisit.FieldBotID:
  37565. return m.BotID()
  37566. case wxcardvisit.FieldBotType:
  37567. return m.BotType()
  37568. }
  37569. return nil, false
  37570. }
  37571. // OldField returns the old value of the field from the database. An error is
  37572. // returned if the mutation operation is not UpdateOne, or the query to the
  37573. // database failed.
  37574. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37575. switch name {
  37576. case wxcardvisit.FieldCreatedAt:
  37577. return m.OldCreatedAt(ctx)
  37578. case wxcardvisit.FieldUpdatedAt:
  37579. return m.OldUpdatedAt(ctx)
  37580. case wxcardvisit.FieldDeletedAt:
  37581. return m.OldDeletedAt(ctx)
  37582. case wxcardvisit.FieldUserID:
  37583. return m.OldUserID(ctx)
  37584. case wxcardvisit.FieldBotID:
  37585. return m.OldBotID(ctx)
  37586. case wxcardvisit.FieldBotType:
  37587. return m.OldBotType(ctx)
  37588. }
  37589. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  37590. }
  37591. // SetField sets the value of a field with the given name. It returns an error if
  37592. // the field is not defined in the schema, or if the type mismatched the field
  37593. // type.
  37594. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  37595. switch name {
  37596. case wxcardvisit.FieldCreatedAt:
  37597. v, ok := value.(time.Time)
  37598. if !ok {
  37599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37600. }
  37601. m.SetCreatedAt(v)
  37602. return nil
  37603. case wxcardvisit.FieldUpdatedAt:
  37604. v, ok := value.(time.Time)
  37605. if !ok {
  37606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37607. }
  37608. m.SetUpdatedAt(v)
  37609. return nil
  37610. case wxcardvisit.FieldDeletedAt:
  37611. v, ok := value.(time.Time)
  37612. if !ok {
  37613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37614. }
  37615. m.SetDeletedAt(v)
  37616. return nil
  37617. case wxcardvisit.FieldUserID:
  37618. v, ok := value.(uint64)
  37619. if !ok {
  37620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37621. }
  37622. m.SetUserID(v)
  37623. return nil
  37624. case wxcardvisit.FieldBotID:
  37625. v, ok := value.(uint64)
  37626. if !ok {
  37627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37628. }
  37629. m.SetBotID(v)
  37630. return nil
  37631. case wxcardvisit.FieldBotType:
  37632. v, ok := value.(uint8)
  37633. if !ok {
  37634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37635. }
  37636. m.SetBotType(v)
  37637. return nil
  37638. }
  37639. return fmt.Errorf("unknown WxCardVisit field %s", name)
  37640. }
  37641. // AddedFields returns all numeric fields that were incremented/decremented during
  37642. // this mutation.
  37643. func (m *WxCardVisitMutation) AddedFields() []string {
  37644. var fields []string
  37645. if m.adduser_id != nil {
  37646. fields = append(fields, wxcardvisit.FieldUserID)
  37647. }
  37648. if m.addbot_id != nil {
  37649. fields = append(fields, wxcardvisit.FieldBotID)
  37650. }
  37651. if m.addbot_type != nil {
  37652. fields = append(fields, wxcardvisit.FieldBotType)
  37653. }
  37654. return fields
  37655. }
  37656. // AddedField returns the numeric value that was incremented/decremented on a field
  37657. // with the given name. The second boolean return value indicates that this field
  37658. // was not set, or was not defined in the schema.
  37659. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  37660. switch name {
  37661. case wxcardvisit.FieldUserID:
  37662. return m.AddedUserID()
  37663. case wxcardvisit.FieldBotID:
  37664. return m.AddedBotID()
  37665. case wxcardvisit.FieldBotType:
  37666. return m.AddedBotType()
  37667. }
  37668. return nil, false
  37669. }
  37670. // AddField adds the value to the field with the given name. It returns an error if
  37671. // the field is not defined in the schema, or if the type mismatched the field
  37672. // type.
  37673. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  37674. switch name {
  37675. case wxcardvisit.FieldUserID:
  37676. v, ok := value.(int64)
  37677. if !ok {
  37678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37679. }
  37680. m.AddUserID(v)
  37681. return nil
  37682. case wxcardvisit.FieldBotID:
  37683. v, ok := value.(int64)
  37684. if !ok {
  37685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37686. }
  37687. m.AddBotID(v)
  37688. return nil
  37689. case wxcardvisit.FieldBotType:
  37690. v, ok := value.(int8)
  37691. if !ok {
  37692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37693. }
  37694. m.AddBotType(v)
  37695. return nil
  37696. }
  37697. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  37698. }
  37699. // ClearedFields returns all nullable fields that were cleared during this
  37700. // mutation.
  37701. func (m *WxCardVisitMutation) ClearedFields() []string {
  37702. var fields []string
  37703. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  37704. fields = append(fields, wxcardvisit.FieldDeletedAt)
  37705. }
  37706. if m.FieldCleared(wxcardvisit.FieldUserID) {
  37707. fields = append(fields, wxcardvisit.FieldUserID)
  37708. }
  37709. return fields
  37710. }
  37711. // FieldCleared returns a boolean indicating if a field with the given name was
  37712. // cleared in this mutation.
  37713. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  37714. _, ok := m.clearedFields[name]
  37715. return ok
  37716. }
  37717. // ClearField clears the value of the field with the given name. It returns an
  37718. // error if the field is not defined in the schema.
  37719. func (m *WxCardVisitMutation) ClearField(name string) error {
  37720. switch name {
  37721. case wxcardvisit.FieldDeletedAt:
  37722. m.ClearDeletedAt()
  37723. return nil
  37724. case wxcardvisit.FieldUserID:
  37725. m.ClearUserID()
  37726. return nil
  37727. }
  37728. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  37729. }
  37730. // ResetField resets all changes in the mutation for the field with the given name.
  37731. // It returns an error if the field is not defined in the schema.
  37732. func (m *WxCardVisitMutation) ResetField(name string) error {
  37733. switch name {
  37734. case wxcardvisit.FieldCreatedAt:
  37735. m.ResetCreatedAt()
  37736. return nil
  37737. case wxcardvisit.FieldUpdatedAt:
  37738. m.ResetUpdatedAt()
  37739. return nil
  37740. case wxcardvisit.FieldDeletedAt:
  37741. m.ResetDeletedAt()
  37742. return nil
  37743. case wxcardvisit.FieldUserID:
  37744. m.ResetUserID()
  37745. return nil
  37746. case wxcardvisit.FieldBotID:
  37747. m.ResetBotID()
  37748. return nil
  37749. case wxcardvisit.FieldBotType:
  37750. m.ResetBotType()
  37751. return nil
  37752. }
  37753. return fmt.Errorf("unknown WxCardVisit field %s", name)
  37754. }
  37755. // AddedEdges returns all edge names that were set/added in this mutation.
  37756. func (m *WxCardVisitMutation) AddedEdges() []string {
  37757. edges := make([]string, 0, 0)
  37758. return edges
  37759. }
  37760. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37761. // name in this mutation.
  37762. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  37763. return nil
  37764. }
  37765. // RemovedEdges returns all edge names that were removed in this mutation.
  37766. func (m *WxCardVisitMutation) RemovedEdges() []string {
  37767. edges := make([]string, 0, 0)
  37768. return edges
  37769. }
  37770. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37771. // the given name in this mutation.
  37772. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  37773. return nil
  37774. }
  37775. // ClearedEdges returns all edge names that were cleared in this mutation.
  37776. func (m *WxCardVisitMutation) ClearedEdges() []string {
  37777. edges := make([]string, 0, 0)
  37778. return edges
  37779. }
  37780. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37781. // was cleared in this mutation.
  37782. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  37783. return false
  37784. }
  37785. // ClearEdge clears the value of the edge with the given name. It returns an error
  37786. // if that edge is not defined in the schema.
  37787. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  37788. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  37789. }
  37790. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37791. // It returns an error if the edge is not defined in the schema.
  37792. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  37793. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  37794. }